use of com.android.tools.klint.detector.api.DefaultPosition in project kotlin by JetBrains.
the class JavaParser method getNameLocation.
/**
* Returns a {@link Location} for the given node. This attempts to pick a shorter
* location range than the entire node; for a class or method for example, it picks
* the name node (if found). For statement constructs such as a {@code switch} statement
* it will highlight the keyword, etc.
*
* @param context information about the file being parsed
* @param node the node to create a location for
* @return a location for the given node
* @deprecated Use {@link #getNameLocation(JavaContext, PsiElement)} instead
*/
@Deprecated
@NonNull
public Location getNameLocation(@NonNull JavaContext context, @NonNull Node node) {
Node nameNode = JavaContext.findNameNode(node);
if (nameNode != null) {
node = nameNode;
} else {
if (node instanceof Switch || node instanceof For || node instanceof If || node instanceof While || node instanceof Throw || node instanceof Return) {
// Lint doesn't want to highlight the entire statement/block associated
// with this node, it wants to just highlight the keyword.
Location location = getLocation(context, node);
Position start = location.getStart();
if (start != null) {
// The Lombok classes happen to have the same length as the target keyword
int length = node.getClass().getSimpleName().length();
return Location.create(location.getFile(), start, new DefaultPosition(start.getLine(), start.getColumn() + length, start.getOffset() + length));
}
}
}
return getLocation(context, node);
}
use of com.android.tools.klint.detector.api.DefaultPosition in project kotlin by JetBrains.
the class DomPsiParser method getLocation.
@NonNull
@Override
public Location getLocation(@NonNull XmlContext context, @NonNull Node node, int startDelta, int endDelta) {
TextRange textRange = DomPsiConverter.getTextRange(node);
Position start = new DefaultPosition(-1, -1, textRange.getStartOffset() + startDelta);
Position end = new DefaultPosition(-1, -1, textRange.getStartOffset() + endDelta);
return Location.create(context.file, start, end);
}
use of com.android.tools.klint.detector.api.DefaultPosition in project kotlin by JetBrains.
the class DomPsiParser method getValueLocation.
@NonNull
@Override
public Location getValueLocation(@NonNull XmlContext context, @NonNull Attr node) {
TextRange textRange = DomPsiConverter.getTextValueRange(node);
Position start = new DefaultPosition(-1, -1, textRange.getStartOffset());
Position end = new DefaultPosition(-1, -1, textRange.getEndOffset());
return Location.create(context.file, start, end);
}
use of com.android.tools.klint.detector.api.DefaultPosition in project kotlin by JetBrains.
the class DomPsiParser method getLocation.
@NonNull
@Override
public Location getLocation(@NonNull XmlContext context, @NonNull Node node) {
TextRange textRange = DomPsiConverter.getTextRange(node);
Position start = new DefaultPosition(-1, -1, textRange.getStartOffset());
Position end = new DefaultPosition(-1, -1, textRange.getEndOffset());
return Location.create(context.file, start, end);
}
use of com.android.tools.klint.detector.api.DefaultPosition in project kotlin by JetBrains.
the class DomPsiParser method getNameLocation.
@NonNull
@Override
public Location getNameLocation(@NonNull XmlContext context, @NonNull Node node) {
TextRange textRange = DomPsiConverter.getTextNameRange(node);
Position start = new DefaultPosition(-1, -1, textRange.getStartOffset());
Position end = new DefaultPosition(-1, -1, textRange.getEndOffset());
return Location.create(context.file, start, end);
}
Aggregations