mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
Fix text ranges
This commit is contained in:
parent
2471ecc98e
commit
ceb5bb3507
@ -16,23 +16,22 @@ public class SimpleAnnotator implements Annotator {
|
||||
if (element instanceof PsiLiteralExpression) {
|
||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
||||
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
||||
|
||||
|
||||
if (value != null && value.startsWith("simple" + ":")) {
|
||||
Project project = element.getProject();
|
||||
String key = value.substring(7);
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
|
||||
if (properties.size() == 1) {
|
||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 7,
|
||||
element.getTextRange().getStartOffset() + 7);
|
||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
|
||||
element.getTextRange().getEndOffset() - 1);
|
||||
Annotation annotation = holder.createInfoAnnotation(range, null);
|
||||
annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT);
|
||||
} else if (properties.size() == 0) {
|
||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
|
||||
element.getTextRange().getEndOffset());
|
||||
holder.createErrorAnnotation(range, "Unresolved property").
|
||||
registerFix(new CreatePropertyQuickFix(key));
|
||||
element.getTextRange().getEndOffset() - 1);
|
||||
holder.createErrorAnnotation(range, "Unresolved property");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user