Added special highlighting for invalid string escape.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user