Example usage for org.eclipse.jdt.core.dom QualifiedName toString

List of usage examples for org.eclipse.jdt.core.dom QualifiedName toString

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom QualifiedName toString.

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this node suitable for debugging purposes only.

Usage

From source file:com.windowtester.eclipse.ui.convert.WTConvertAPIContext.java

License:Open Source License

/**
 * Construct a new simple or qualified name
 * //from   w  ww  .ja  v  a  2 s .  c  om
 * @param text the simple or qualified name as text (not <code>null</code>, not empty)
 * @param startPosition the starting position relative to the new AST nodes being
 *            created. For example, when instantiating a new name node to replace an
 *            existing name node, pass zero. When instantiation a new name node to be
 *            used as part of a new import declaration, pass the offset of the name
 *            node within the new import declaration.
 * @return a new name (not <code>null</code>)
 */
public Name newName(String text, final int startPosition) {
    Name newName = compUnit.getAST().newName(text);
    newName.accept(new ASTVisitor() {
        int index = startPosition;

        public boolean visit(QualifiedName node) {
            node.setSourceRange(startPosition, node.toString().length());
            return true;
        }

        public boolean visit(SimpleName node) {
            int length = node.getIdentifier().length();
            node.setSourceRange(index, length);
            index += length + 1;
            return true;
        }
    });
    return newName;
}

From source file:nz.ac.massey.cs.barrio.srcgraphbuilder.ExtractTypeInfoVisitor.java

License:Apache License

private void analyzeMemberAccess(Expression x) {

    if (x instanceof QualifiedName) {
        QualifiedName qn = (QualifiedName) x;
        // System.out.println("encountered qualified name " + qn);
        // check whether the first token is this, super or a known field
        // otherwise, we assume that this is the invocation of a static method
        // otherwise, we have to try (to resolve to type names) all combinations of substrings 
        // because we don't now whether tokens are fields or part of qualified type names
        String name = null;// w  ww.  j  av  a2  s. co  m
        StringTokenizer tokenizer = new StringTokenizer(qn.toString(), ".");
        while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken();
            if (name == null) {
                if (this.varTracker.isDefined(token)) { // there is a variable defined with this name
                    break;
                }
                name = token;
                this.add2used(name);
                //System.out.println("add type ref " + name);
            } else {
                name = name + '.' + token;
                this.add2used(name);
                //System.out.println("add type ref " + name);
            }
        }
    } else if (x instanceof SimpleName) {
        SimpleName s = (SimpleName) x;
        if (!this.varTracker.isDefined(s.toString())) {
            this.add2used(s.toString());
            //System.out.println("add type ref " + s);
        }
    } else {
        System.out.println("encountered unknown element in member access node " + x);
    }

}

From source file:nz.ac.massey.cs.barrio.srcgraphbuilder.ExtractTypeInfoVisitor.java

License:Apache License

public boolean visit(QualifiedName qn) {
    //System.out.println("encountered qualified name " + qn);
    // check whether the first token is this, super or a known field
    // otherwise, we assume that this is the invocation of a static method
    // otherwise, we have to try (to resolve to type names) all combinations of substrings 
    // because we don't now whether tokens are fields or part of qualified type names
    String name = null;/*  w  w w  .  j  a  va2  s  .  c  o m*/
    StringTokenizer tokenizer = new StringTokenizer(qn.toString(), ".");
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();
        if (name == null) {
            if (this.varTracker.isDefined(token)) { // there is a variable defined with this name
                break;
            }
            name = token;
            this.add2used(name);
            //System.out.println("add type ref " + name);
        } else {
            name = name + '.' + token;
            this.add2used(name);
            //System.out.println("add type ref " + name);
        }
    }

    return true;
}

From source file:sharpen.core.CSharpBuilder.java

License:Open Source License

private String qualifiedName(QualifiedName node) {
    IVariableBinding binding = variableBinding(node);
    if (binding == null)
        return node.toString();
    return BindingUtils.qualifiedName(binding);
}