Search in sources :

Example 1 with For

use of lombok.ast.For 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);
}
Also used : Return(lombok.ast.Return) Switch(lombok.ast.Switch) Position(com.android.tools.klint.detector.api.Position) DefaultPosition(com.android.tools.klint.detector.api.DefaultPosition) Throw(lombok.ast.Throw) Node(lombok.ast.Node) DefaultPosition(com.android.tools.klint.detector.api.DefaultPosition) For(lombok.ast.For) While(lombok.ast.While) If(lombok.ast.If) Location(com.android.tools.klint.detector.api.Location) NonNull(com.android.annotations.NonNull)

Aggregations

NonNull (com.android.annotations.NonNull)1 DefaultPosition (com.android.tools.klint.detector.api.DefaultPosition)1 Location (com.android.tools.klint.detector.api.Location)1 Position (com.android.tools.klint.detector.api.Position)1 For (lombok.ast.For)1 If (lombok.ast.If)1 Node (lombok.ast.Node)1 Return (lombok.ast.Return)1 Switch (lombok.ast.Switch)1 Throw (lombok.ast.Throw)1 While (lombok.ast.While)1