mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-29 09:47:50 +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) {
|
if (element instanceof PsiLiteralExpression) {
|
||||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
||||||
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
||||||
|
|
||||||
if (value != null && value.startsWith("simple" + ":")) {
|
if (value != null && value.startsWith("simple" + ":")) {
|
||||||
Project project = element.getProject();
|
Project project = element.getProject();
|
||||||
String key = value.substring(7);
|
String key = value.substring(7);
|
||||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
|
List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
|
||||||
if (properties.size() == 1) {
|
if (properties.size() == 1) {
|
||||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 7,
|
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
|
||||||
element.getTextRange().getStartOffset() + 7);
|
element.getTextRange().getEndOffset() - 1);
|
||||||
Annotation annotation = holder.createInfoAnnotation(range, null);
|
Annotation annotation = holder.createInfoAnnotation(range, null);
|
||||||
annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT);
|
annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT);
|
||||||
} else if (properties.size() == 0) {
|
} else if (properties.size() == 0) {
|
||||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
|
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
|
||||||
element.getTextRange().getEndOffset());
|
element.getTextRange().getEndOffset() - 1);
|
||||||
holder.createErrorAnnotation(range, "Unresolved property").
|
holder.createErrorAnnotation(range, "Unresolved property");
|
||||||
registerFix(new CreatePropertyQuickFix(key));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user