/** * 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 element the node to create a location for * @return a location for the given node */ @NonNull public Location getNameLocation(@NonNull JavaContext context, @NonNull PsiElement element) { PsiElement nameNode = JavaContext.findNameElement(element); if (nameNode != null) { element = nameNode; } return getLocation(context, element); } /**
PsiElement locationNode = JavaContext.findNameElement(declaration); if (locationNode == null) { locationNode = declaration;
String message = "Fragments should be static such that they can be re-instantiated by " + "the system, and anonymous classes are not static"; PsiElement locationNode = JavaContext.findNameElement(node); if (locationNode == null) { locationNode = node;