Example usage for org.eclipse.jdt.internal.core.util Util getAllTypeArguments

List of usage examples for org.eclipse.jdt.internal.core.util Util getAllTypeArguments

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util Util getAllTypeArguments.

Prototype

public final static char[][][] getAllTypeArguments(char[][] typeSignatures) 

Source Link

Document

Get all type arguments from an array of signatures.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.ConstructorPattern.java

License:Open Source License

public ConstructorPattern(char[] declaringSimpleName, char[] declaringQualification,
        char[][] parameterQualifications, char[][] parameterSimpleNames, String[] parameterSignatures,
        IMethod method, int limitTo, int matchRule) {

    this(declaringSimpleName, declaringQualification, parameterQualifications, parameterSimpleNames, limitTo,
            matchRule);//ww  w .  ja va  2 s .  co  m

    // Set flags
    try {
        this.varargs = (method.getFlags() & Flags.AccVarargs) != 0;
    } catch (JavaModelException e) {
        // do nothing
    }

    // Get unique key for parameterized constructors
    String genericDeclaringTypeSignature = null;
    if (method.isResolved()) {
        String key = method.getKey();
        BindingKey bindingKey = new BindingKey(key);
        if (bindingKey.isParameterizedType()) {
            genericDeclaringTypeSignature = Util.getDeclaringTypeSignature(key);
            // Store type signature and arguments for declaring type
            if (genericDeclaringTypeSignature != null) {
                this.typeSignatures = Util.splitTypeLevelsSignature(genericDeclaringTypeSignature);
                setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
            }
        }
    } else {
        this.constructorParameters = true;
        storeTypeSignaturesAndArguments(method.getDeclaringType());
    }

    // store type signatures and arguments for method parameters type
    if (parameterSignatures != null) {
        int length = parameterSignatures.length;
        if (length > 0) {
            this.parametersTypeSignatures = new char[length][][];
            this.parametersTypeArguments = new char[length][][][];
            for (int i = 0; i < length; i++) {
                this.parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
                this.parametersTypeArguments[i] = Util.getAllTypeArguments(this.parametersTypeSignatures[i]);
            }
        }
    }

    // Store type signatures and arguments for method
    this.constructorArguments = extractMethodArguments(method);
    if (hasConstructorArguments())
        this.mustResolve = true;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.ConstructorPattern.java

License:Open Source License

public ConstructorPattern(char[] declaringSimpleName, char[] declaringQualification, String declaringSignature,
        char[][] parameterQualifications, char[][] parameterSimpleNames, String[] parameterSignatures,
        char[][] arguments, int limitTo, int matchRule) {

    this(declaringSimpleName, declaringQualification, parameterQualifications, parameterSimpleNames, limitTo,
            matchRule);/*from ww w.  ja v  a2s.c  o m*/

    // Store type signature and arguments for declaring type
    if (declaringSignature != null) {
        this.typeSignatures = Util.splitTypeLevelsSignature(declaringSignature);
        setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
    }

    // Store type signatures and arguments for method parameters type
    if (parameterSignatures != null) {
        int length = parameterSignatures.length;
        if (length > 0) {
            this.parametersTypeSignatures = new char[length][][];
            this.parametersTypeArguments = new char[length][][][];
            for (int i = 0; i < length; i++) {
                this.parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
                this.parametersTypeArguments[i] = Util.getAllTypeArguments(this.parametersTypeSignatures[i]);
            }
        }
    }

    // Store type signatures and arguments for method
    this.constructorArguments = arguments;
    if (arguments == null || arguments.length == 0) {
        if (getTypeArguments() != null && getTypeArguments().length > 0) {
            this.constructorArguments = getTypeArguments()[0];
        }
    }
    if (hasConstructorArguments())
        this.mustResolve = true;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.FieldPattern.java

License:Open Source License

public FieldPattern(char[] name, char[] declaringQualification, char[] declaringSimpleName,
        char[] typeQualification, char[] typeSimpleName, String typeSignature, int limitTo, int matchRule) {

    this(name, declaringQualification, declaringSimpleName, typeQualification, typeSimpleName, limitTo,
            matchRule);//from  w w w .  j  a  v a  2s.c om

    // store type signatures and arguments
    if (typeSignature != null) {
        this.typeSignatures = Util.splitTypeLevelsSignature(typeSignature);
        setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.JavaSearchPattern.java

License:Open Source License

void storeTypeSignaturesAndArguments(IType type) {
    if (type.isResolved()) {
        BindingKey bindingKey = new BindingKey(type.getKey());
        if (bindingKey.isParameterizedType() || bindingKey.isRawType()) {
            String signature = bindingKey.toSignature();
            this.typeSignatures = Util.splitTypeLevelsSignature(signature);
            setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
        }//w ww.j a v  a2 s .c  o  m
        return;
    }

    // Scan hierarchy to store type arguments at each level
    char[][][] typeParameters = new char[10][][];
    int ptr = -1;
    boolean hasParameters = false;
    try {
        IJavaElement parent = type;
        ITypeParameter[] parameters = null;
        while (parent != null && parent.getElementType() == IJavaElement.TYPE) {
            if (++ptr > typeParameters.length) {
                System.arraycopy(typeParameters, 0, typeParameters = new char[typeParameters.length + 10][][],
                        0, ptr);
            }
            IType parentType = (IType) parent;
            parameters = parentType.getTypeParameters();
            if (parameters != null) {
                int length = parameters.length;
                if (length > 0) {
                    hasParameters = true;
                    typeParameters[ptr] = new char[length][];
                    for (int i = 0; i < length; i++)
                        typeParameters[ptr][i] = Signature
                                .createTypeSignature(parameters[i].getElementName(), false).toCharArray();
                }
            }
            parent = parent.getParent();
        }
    } catch (JavaModelException jme) {
        return;
    }

    // Store type arguments if any
    if (hasParameters) {
        if (++ptr < typeParameters.length)
            System.arraycopy(typeParameters, 0, typeParameters = new char[ptr][][], 0, ptr);
        setTypeArguments(typeParameters);
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MethodPattern.java

License:Open Source License

public MethodPattern(char[] selector, char[] declaringQualification, char[] declaringSimpleName,
        char[] returnQualification, char[] returnSimpleName, String returnSignature,
        char[][] parameterQualifications, char[][] parameterSimpleNames, String[] parameterSignatures,
        IMethod method, int limitTo, int matchRule) {

    this(selector, declaringQualification, declaringSimpleName, returnQualification, returnSimpleName,
            parameterQualifications, parameterSimpleNames, method.getDeclaringType(), limitTo, matchRule);

    // Set flags//from w w  w  .j  ava 2  s  .  c om
    try {
        this.varargs = (method.getFlags() & Flags.AccVarargs) != 0;
    } catch (JavaModelException e) {
        // do nothing
    }

    // Get unique key for parameterized constructors
    String genericDeclaringTypeSignature = null;
    if (method.isResolved()) {
        String key = method.getKey();
        BindingKey bindingKey = new BindingKey(key);
        if (bindingKey.isParameterizedType()) {
            genericDeclaringTypeSignature = Util.getDeclaringTypeSignature(key);
            // Store type signature and arguments for declaring type
            if (genericDeclaringTypeSignature != null) {
                this.typeSignatures = Util.splitTypeLevelsSignature(genericDeclaringTypeSignature);
                setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
            }
        }
    } else {
        this.methodParameters = true;
        storeTypeSignaturesAndArguments(this.declaringType);
    }

    // Store type signatures and arguments for return type
    if (returnSignature != null) {
        this.returnTypeSignatures = Util.splitTypeLevelsSignature(returnSignature);
    }

    // Store type signatures and arguments for method parameters type
    if (parameterSignatures != null) {
        int length = parameterSignatures.length;
        if (length > 0) {
            this.parametersTypeSignatures = new char[length][][];
            this.parametersTypeArguments = new char[length][][][];
            for (int i = 0; i < length; i++) {
                this.parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
                this.parametersTypeArguments[i] = Util.getAllTypeArguments(this.parametersTypeSignatures[i]);
            }
        }
    }

    // Store type signatures and arguments for method
    this.methodArguments = extractMethodArguments(method);
    if (hasMethodArguments())
        this.mustResolve = true;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MethodPattern.java

License:Open Source License

public MethodPattern(char[] selector, char[] declaringQualification, char[] declaringSimpleName,
        String declaringSignature, char[] returnQualification, char[] returnSimpleName, String returnSignature,
        char[][] parameterQualifications, char[][] parameterSimpleNames, String[] parameterSignatures,
        char[][] arguments, int limitTo, int matchRule) {

    this(selector, declaringQualification, declaringSimpleName, returnQualification, returnSimpleName,
            parameterQualifications, parameterSimpleNames, null, limitTo, matchRule);

    // Store type signature and arguments for declaring type
    if (declaringSignature != null) {
        this.typeSignatures = Util.splitTypeLevelsSignature(declaringSignature);
        setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
    }//w w  w .ja  va 2 s  .  co  m

    // Store type signatures and arguments for return type
    if (returnSignature != null) {
        this.returnTypeSignatures = Util.splitTypeLevelsSignature(returnSignature);
    }

    // Store type signatures and arguments for method parameters type
    if (parameterSignatures != null) {
        int length = parameterSignatures.length;
        if (length > 0) {
            this.parametersTypeSignatures = new char[length][][];
            this.parametersTypeArguments = new char[length][][][];
            for (int i = 0; i < length; i++) {
                this.parametersTypeSignatures[i] = Util.splitTypeLevelsSignature(parameterSignatures[i]);
                this.parametersTypeArguments[i] = Util.getAllTypeArguments(this.parametersTypeSignatures[i]);
            }
        }
    }

    // Store type signatures and arguments for method
    this.methodArguments = arguments;
    if (hasMethodArguments())
        this.mustResolve = true;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.TypeReferencePattern.java

License:Open Source License

public TypeReferencePattern(char[] qualification, char[] simpleName, String typeSignature, int limitTo,
        char typeSuffix, int matchRule) {
    this(qualification, simpleName, matchRule);
    this.typeSuffix = typeSuffix;
    if (typeSignature != null) {
        // store type signatures and arguments
        this.typeSignatures = Util.splitTypeLevelsSignature(typeSignature);
        setTypeArguments(Util.getAllTypeArguments(this.typeSignatures));
        if (hasTypeArguments()) {
            this.segmentsSize = getTypeArguments().length
                    + CharOperation.occurencesOf('/', this.typeSignatures[0]) - 1;
        }/*  ww w.jav  a  2s  .  c om*/
    }
    this.fineGrain = limitTo & 0xFFFFFFF0;
    if (this.fineGrain == IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE) {
        this.categories = CATEGORIES_ANNOT_REF;
    }
}