/** * Returns a location for the given node * * @param node the AST node to get a location for * @return a location for the given node */ @NonNull public Location getLocation(@NonNull Node node) { return parser.getLocation(this, node); }
@NonNull public Location getLocation(@NonNull PsiElement node) { return parser.getLocation(this, node); }
/** * 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); } /**
Location location = getLocation(context, node); Position start = location.getStart(); if (start != null) { return getLocation(context, node);