提交 abdf3441 编写于 作者: E Evgeny Gerashchenko

Got rid of returning empty range list in position strategies (in places where...

Got rid of returning empty range list in position strategies (in places where they don't depend on syntax errors).
上级 0fd34a45
......@@ -247,12 +247,12 @@ public interface Errors {
public List<TextRange> mark(@NotNull JetDeclarationWithBody element) {
JetExpression bodyExpression = element.getBodyExpression();
if (!(bodyExpression instanceof JetBlockExpression)) {
return Collections.emptyList();
return markElement(element);
}
JetBlockExpression blockExpression = (JetBlockExpression)bodyExpression;
TextRange lastBracketRange = blockExpression.getLastBracketRange();
if (lastBracketRange == null) {
return Collections.emptyList();
return markElement(element);
}
return markRange(lastBracketRange);
}
......@@ -403,7 +403,7 @@ public interface Errors {
JetClass klass = (JetClass)jetDeclaration;
PsiElement nameAsDeclaration = klass.getNameIdentifier();
if (nameAsDeclaration == null) {
return markRange(klass.getTextRange());
return markElement(klass);
}
PsiElement primaryConstructorParameterList = klass.getPrimaryConstructorParameterList();
if (primaryConstructorParameterList == null) {
......@@ -416,7 +416,7 @@ public interface Errors {
}
else {
// safe way
return markRange(jetDeclaration.getTextRange());
return markElement(jetDeclaration);
}
}
});
......
......@@ -59,10 +59,9 @@ public class PositioningStrategies {
returnTypeRef = accessor.getReturnTypeReference();
nameNode = accessor.getNamePlaceholder().getNode();
}
if (returnTypeRef != null) return Collections.singletonList(returnTypeRef.getTextRange());
if (nameNode != null) return Collections.singletonList(nameNode.getTextRange());
return super.mark(declaration);
if (returnTypeRef != null) return markElement(returnTypeRef);
if (nameNode != null) return markNode(nameNode);
return markElement(declaration);
}
private ASTNode getNameNode(JetNamedDeclaration function) {
......@@ -100,9 +99,9 @@ public class PositioningStrategies {
assert modifierList != null;
ASTNode node = modifierList.getModifierNode(token);
assert node != null;
return Collections.singletonList(node.getTextRange());
return markNode(node);
}
return Collections.emptyList();
return markElement(modifierListOwner);
}
};
}
......
......@@ -34,7 +34,10 @@ public class UnresolvedReferenceDiagnosticFactory extends DiagnosticFactory1<Jet
@Override
public List<TextRange> mark(@NotNull JetReferenceExpression element) {
if (element instanceof JetArrayAccessExpression) {
return ((JetArrayAccessExpression) element).getBracketRanges();
List<TextRange> ranges = ((JetArrayAccessExpression) element).getBracketRanges();
if (!ranges.isEmpty()) {
return ranges;
}
}
return Collections.singletonList(element.getTextRange());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册