use of com.android.tools.klint.detector.api.Location.SearchHints in project kotlin by JetBrains.
the class ClassContext method getLocation.
/**
* Returns a location for the given {@link AbstractInsnNode}.
*
* @param instruction the instruction to look up the location for
* @return a location pointing to the instruction, or as close to it
* as possible
*/
@NonNull
public Location getLocation(@NonNull AbstractInsnNode instruction) {
SearchHints hints = SearchHints.create(FORWARD).matchJavaSymbol();
String pattern = null;
if (instruction instanceof MethodInsnNode) {
MethodInsnNode call = (MethodInsnNode) instruction;
if (call.name.equals(CONSTRUCTOR_NAME)) {
pattern = call.owner;
hints = hints.matchConstructor();
} else {
pattern = call.name;
}
int index = pattern.lastIndexOf('$');
if (index != -1) {
pattern = pattern.substring(index + 1);
}
index = pattern.lastIndexOf('/');
if (index != -1) {
pattern = pattern.substring(index + 1);
}
}
int line = findLineNumber(instruction);
return getLocationForLine(line, pattern, null, hints);
}
Aggregations