Java Code Examples for com.puppycrawl.tools.checkstyle.api.TokenTypes#COMMA

The following examples show how to use com.puppycrawl.tools.checkstyle.api.TokenTypes#COMMA . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Resolver.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Resolves the types found in a method call. Any references found
 * in the process are created.  Returns a <code>MethodSignature</code> for
 * the types of the parameters.
 *
 * @param elist The <code>SymTabAST</code> for the list of parameters
 * @return the signature of the parameters
 */
private MethodSignature resolveParameters(
    SymTabAST elist,
    Scope location,
    IClass context,
    boolean referencePhase) {
    Vector parameters = new Vector();

    SymTabAST expr = (SymTabAST) (elist.getFirstChild());
    while (expr != null) {
        if (expr.getType() != TokenTypes.COMMA) {
            IClass parameter =
                resolveExpression((SymTabAST) (expr
    .getFirstChild()),
    location,
    context,
    referencePhase);
            parameters.add(parameter);
        }

        expr = (SymTabAST) (expr.getNextSibling());
    }

    return new MethodSignature(parameters);
}
 
Example 2
Source File: Resolver.java    From contribution with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Resolves the types found in a method call. Any references found
 * in the process are created.  Returns a <code>MethodSignature</code> for
 * the types of the parameters.
 *
 * @param elist The <code>SymTabAST</code> for the list of parameters
 * @return the signature of the parameters
 */
private MethodSignature resolveParameters(
    SymTabAST elist,
    Scope location,
    IClass context,
    boolean referencePhase) {
    Vector parameters = new Vector();

    SymTabAST expr = (SymTabAST) (elist.getFirstChild());
    while (expr != null) {
        if (expr.getType() != TokenTypes.COMMA) {
            IClass parameter =
                resolveExpression((SymTabAST) (expr
    .getFirstChild()),
    location,
    context,
    referencePhase);
            parameters.add(parameter);
        }

        expr = (SymTabAST) (expr.getNextSibling());
    }

    return new MethodSignature(parameters);
}
 
Example 3
Source File: Resolver.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * processes a <code>MethodDef</code> and resolves references in it
 *
 * @param method the <code>MethodDef</code> to process
 */
protected void handleMethod(MethodDef method) {
    SymTabAST node = method.getTreeNode();

    SymTabAST nameNode = node.findFirstToken(TokenTypes.IDENT);
    nameNode.setDefinition(method, method, true);

    // references to classes in return type
    SymTabAST returnTypeNode = node.findFirstToken(TokenTypes.TYPE);

    if (returnTypeNode != null) {
        // this is not a constructor
        resolveExpression(returnTypeNode, method, null, true);
    }

    SymTabAST throwsNode =
        node.findFirstToken(TokenTypes.LITERAL_THROWS);
    if (throwsNode != null) {
        SymTabAST exception = (SymTabAST) throwsNode.getFirstChild();
        while (exception != null) {
            // handle Checkstyle grammar
            if (exception.getType() != TokenTypes.COMMA) {
                resolveClass(exception, method, null, true);
            }
            exception = (SymTabAST) exception.getNextSibling();
        }
    }

    // references to classes in parameters

    // the body -- this would be better its own function
    SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);

    if (slist != null) {
        handleSList(slist, method);
    }
}
 
Example 4
Source File: Resolver.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Resolves a constructor call.
 *
 * @param tree the root node of the constructor call
 * @return the <code>ClassDef</code> for the class instantiated by the
 *         constructor
 */
private void resolveArrayInitializer(
    SymTabAST initializerNode,
    Scope location,
    IClass context,
    boolean referencePhase) {
    SymTabAST child = (SymTabAST) (initializerNode.getFirstChild());
    while (child != null) {
        if (child.getType() != TokenTypes.COMMA) {
            resolveExpression(child, location, context, referencePhase);
        }
        child = (SymTabAST) (child.getNextSibling());
    }
}
 
Example 5
Source File: Resolver.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * processes a <code>MethodDef</code> and resolves references in it
 *
 * @param method the <code>MethodDef</code> to process
 */
protected void handleMethod(MethodDef method) {
    SymTabAST node = method.getTreeNode();

    SymTabAST nameNode = node.findFirstToken(TokenTypes.IDENT);
    nameNode.setDefinition(method, method, true);

    // references to classes in return type
    SymTabAST returnTypeNode = node.findFirstToken(TokenTypes.TYPE);

    if (returnTypeNode != null) {
        // this is not a constructor
        resolveExpression(returnTypeNode, method, null, true);
    }

    SymTabAST throwsNode =
        node.findFirstToken(TokenTypes.LITERAL_THROWS);
    if (throwsNode != null) {
        SymTabAST exception = (SymTabAST) throwsNode.getFirstChild();
        while (exception != null) {
            // handle Checkstyle grammar
            if (exception.getType() != TokenTypes.COMMA) {
                resolveClass(exception, method, null, true);
            }
            exception = (SymTabAST) exception.getNextSibling();
        }
    }

    // references to classes in parameters

    // the body -- this would be better its own function
    SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);

    if (slist != null) {
        handleSList(slist, method);
    }
}
 
Example 6
Source File: Resolver.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Resolves a constructor call.
 *
 * @param tree the root node of the constructor call
 * @return the <code>ClassDef</code> for the class instantiated by the
 *         constructor
 */
private void resolveArrayInitializer(
    SymTabAST initializerNode,
    Scope location,
    IClass context,
    boolean referencePhase) {
    SymTabAST child = (SymTabAST) (initializerNode.getFirstChild());
    while (child != null) {
        if (child.getType() != TokenTypes.COMMA) {
            resolveExpression(child, location, context, referencePhase);
        }
        child = (SymTabAST) (child.getNextSibling());
    }
}
 
Example 7
Source File: Resolver.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Resolves any dotted reference, returning the <code>Scope</code>
 * identified by the reference.
 *
 * @param tree the root node of the dotted reference
 * @param location the <code>Scope</code> in which the expression occours.
 * @param context the <code>Scope</code> in which the search for the
 *                definition will start
 * @return the <code>Scope</code> indentified by the reference
 */
private IClass resolveDottedName(
    SymTabAST tree,
    Scope location,
    IClass context,
    boolean referencePhase) {
    IClass result = null;

    IClass localContext = context;
    String name = null;

    DotIterator it = new DotIterator(tree);
    while (it.hasNext()) {
        SymTabAST node = it.nextNode();
        if (node.getType() != TokenTypes.COMMA) {
            localContext =
                resolveExpression(
                    node,
                    location,
                    localContext,
                    referencePhase);
            if (localContext == null) {
                node.setMeaningfulness(false);
                name = node.getText();
                while (localContext == null && it.hasNext()) {
                    SymTabAST next = it.nextNode();
                    name = name + "." + next.getText();
                    localContext = location.getClassDefinition(name);
                    if (localContext != null && referencePhase) {
                        next.setDefinition(
                            localContext,
                            location,
                            referencePhase);
                    }
                    else {
                        next.setMeaningfulness(false);
                    }
                }
            }
        }
    }

    if (localContext != null) {
        result = localContext;
    }
    else {
        result = new UnknownClass(name, tree);
    }

    return result;
}
 
Example 8
Source File: Resolver.java    From contribution with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Resolves any dotted reference, returning the <code>Scope</code>
 * identified by the reference.
 *
 * @param tree the root node of the dotted reference
 * @param location the <code>Scope</code> in which the expression occours.
 * @param context the <code>Scope</code> in which the search for the
 *                definition will start
 * @return the <code>Scope</code> indentified by the reference
 */
private IClass resolveDottedName(
    SymTabAST tree,
    Scope location,
    IClass context,
    boolean referencePhase) {
    IClass result = null;

    IClass localContext = context;
    String name = null;

    DotIterator it = new DotIterator(tree);
    while (it.hasNext()) {
        SymTabAST node = it.nextNode();
        if (node.getType() != TokenTypes.COMMA) {
            localContext =
                resolveExpression(
                    node,
                    location,
                    localContext,
                    referencePhase);
            if (localContext == null) {
                node.setMeaningfulness(false);
                name = node.getText();
                while (localContext == null && it.hasNext()) {
                    SymTabAST next = it.nextNode();
                    name = name + "." + next.getText();
                    localContext = location.getClassDefinition(name);
                    if (localContext != null && referencePhase) {
                        next.setDefinition(
                            localContext,
                            location,
                            referencePhase);
                    }
                    else {
                        next.setMeaningfulness(false);
                    }
                }
            }
        }
    }

    if (localContext != null) {
        result = localContext;
    }
    else {
        result = new UnknownClass(name, tree);
    }

    return result;
}