Added special highlighting for invalid string escape.

This commit is contained in:
Evgeny Gerashchenko
2012-03-29 20:00:45 +04:00
parent c65425edac
commit cd18094929
3 changed files with 13 additions and 0 deletions
@@ -103,6 +103,7 @@ public class JetColorSettingsPage implements ColorSettingsPage {
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.string"), JetHighlightingColors.STRING),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.valid.escape.in.string"), JetHighlightingColors.VALID_STRING_ESCAPE),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.invalid.escape.in.string"), JetHighlightingColors.INVALID_STRING_ESCAPE),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.line.comment"), JetHighlightingColors.LINE_COMMENT),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.block.comment"), JetHighlightingColors.BLOCK_COMMENT),
@@ -51,6 +51,11 @@ public class JetHighlightingColors {
SyntaxHighlighterColors.VALID_STRING_ESCAPE.getDefaultAttributes()
);
public static final TextAttributesKey INVALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey(
"KOTLIN_INVALID_STRING_ESCAPE",
SyntaxHighlighterColors.INVALID_STRING_ESCAPE.getDefaultAttributes()
);
public static final TextAttributesKey LINE_COMMENT = TextAttributesKey.createTextAttributesKey(
"KOTLIN_LINE_COMMENT",
SyntaxHighlighterColors.LINE_COMMENT.getDefaultAttributes()
@@ -147,6 +147,13 @@ public class JetPsiChecker implements Annotator {
return;
}
if (diagnostic.getFactory() == Errors.ILLEGAL_ESCAPE_SEQUENCE) {
for (TextRange textRange : diagnostic.getTextRanges()) {
Annotation annotation = holder.createErrorAnnotation(textRange, diagnostic.getMessage());
annotation.setTextAttributes(JetHighlightingColors.INVALID_STRING_ESCAPE);
}
}
if (diagnostic instanceof RedeclarationDiagnostic) {
RedeclarationDiagnostic redeclarationDiagnostic = (RedeclarationDiagnostic)diagnostic;
registerQuickFix(markRedeclaration(redeclarations, redeclarationDiagnostic, holder), diagnostic);