Got rid of returning empty range list in position strategies (in places where they don't depend on syntax errors).

This commit is contained in:
Evgeny Gerashchenko
2012-04-29 13:43:18 +04:00
parent 0fd34a455f
commit abdf34418a
3 changed files with 13 additions and 11 deletions
@@ -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());
}