Example usage for org.eclipse.jdt.internal.core NameLookup ACCEPT_ENUMS

List of usage examples for org.eclipse.jdt.internal.core NameLookup ACCEPT_ENUMS

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core NameLookup ACCEPT_ENUMS.

Prototype

int ACCEPT_ENUMS

To view the source code for org.eclipse.jdt.internal.core NameLookup ACCEPT_ENUMS.

Click Source Link

Document

Accept flag for specifying enums.

Usage

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

License:Open Source License

private static int convertSearchFilterToModelFilter(int searchFilter) {
    switch (searchFilter) {
    case org.eclipse.jdt.core.search.IJavaSearchConstants.CLASS:
        return NameLookup.ACCEPT_CLASSES;
    case org.eclipse.jdt.core.search.IJavaSearchConstants.INTERFACE:
        return NameLookup.ACCEPT_INTERFACES;
    case org.eclipse.jdt.core.search.IJavaSearchConstants.ENUM:
        return NameLookup.ACCEPT_ENUMS;
    case org.eclipse.jdt.core.search.IJavaSearchConstants.ANNOTATION_TYPE:
        return NameLookup.ACCEPT_ANNOTATIONS;
    case org.eclipse.jdt.core.search.IJavaSearchConstants.CLASS_AND_ENUM:
        return NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_ENUMS;
    case org.eclipse.jdt.core.search.IJavaSearchConstants.CLASS_AND_INTERFACE:
        return NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES;
    default:/*from w  w w.j  a va 2s.c o m*/
        return NameLookup.ACCEPT_ALL;
    }
}

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

License:Open Source License

protected IType lookupType(ReferenceBinding typeBinding) {
    if (typeBinding == null || !typeBinding.isValidBinding())
        return null;

    char[] packageName = typeBinding.qualifiedPackageName();
    IPackageFragment[] pkgs = this.nameLookup.findPackageFragments(
            (packageName == null || packageName.length == 0) ? IPackageFragment.DEFAULT_PACKAGE_NAME
                    : new String(packageName),
            false);//from  www  .  j ava  2  s.  c  om

    // iterate type lookup in each package fragment
    char[] sourceName = typeBinding.qualifiedSourceName();
    String typeName = new String(sourceName);
    int acceptFlag = 0;
    if (typeBinding.isAnnotationType()) {
        acceptFlag = NameLookup.ACCEPT_ANNOTATIONS;
    } else if (typeBinding.isEnum()) {
        acceptFlag = NameLookup.ACCEPT_ENUMS;
    } else if (typeBinding.isInterface()) {
        acceptFlag = NameLookup.ACCEPT_INTERFACES;
    } else if (typeBinding.isClass()) {
        acceptFlag = NameLookup.ACCEPT_CLASSES;
    }
    if (pkgs != null) {
        for (int i = 0, length = pkgs.length; i < length; i++) {
            IType type = this.nameLookup.findType(typeName, pkgs[i], false, acceptFlag,
                    true/*consider secondary types*/);
            if (type != null)
                return type;
        }
    }

    // search inside enclosing element
    char[][] qualifiedName = CharOperation.splitOn('.', sourceName);
    int length = qualifiedName.length;
    if (length == 0)
        return null;

    IType type = createTypeHandle(new String(qualifiedName[0])); // find the top-level type
    if (type == null)
        return null;

    for (int i = 1; i < length; i++) {
        type = type.getType(new String(qualifiedName[i]));
        if (type == null)
            return null;
    }
    if (type.exists())
        return type;
    return null;
}

From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.java

License:Open Source License

/**
 * Looks up and returns a handle for the given binary info.
 *///from  w w  w  .j  a va 2 s  .c o  m
protected IType lookupBinaryHandle(IBinaryType typeInfo) {
    int flag;
    String qualifiedName;
    switch (TypeDeclaration.kind(typeInfo.getModifiers())) {
    case TypeDeclaration.CLASS_DECL:
        flag = NameLookup.ACCEPT_CLASSES;
        break;
    case TypeDeclaration.INTERFACE_DECL:
        flag = NameLookup.ACCEPT_INTERFACES;
        break;
    case TypeDeclaration.ENUM_DECL:
        flag = NameLookup.ACCEPT_ENUMS;
        break;
    default:
        //case IGenericType.ANNOTATION :
        flag = NameLookup.ACCEPT_ANNOTATIONS;
        break;
    }
    char[] bName = typeInfo.getName();
    qualifiedName = new String(ClassFile.translatedName(bName));
    if (qualifiedName.equals(this.focusQualifiedName))
        return getType();
    NameLookup.Answer answer = this.nameLookup.findType(qualifiedName, false, flag,
            true/* consider secondary types */, false/* do NOT wait for indexes */,
            false/*don't check restrictions*/, null);
    return answer == null || answer.type == null || !answer.type.isBinary() ? null : answer.type;

}

From source file:org.eclipse.jdt.internal.core.search.matching.MatchLocator.java

License:Open Source License

protected IType lookupType(ReferenceBinding typeBinding) {
    if (typeBinding == null)
        return null;

    char[] packageName = typeBinding.qualifiedPackageName();
    IPackageFragment[] pkgs = this.nameLookup.findPackageFragments(
            (packageName == null || packageName.length == 0) ? IPackageFragment.DEFAULT_PACKAGE_NAME
                    : new String(packageName),
            false);/*w  ww. ja va  2  s.  co  m*/

    // iterate type lookup in each package fragment
    char[] sourceName = typeBinding.qualifiedSourceName();
    String typeName = new String(sourceName);
    int acceptFlag = 0;
    if (typeBinding.isAnnotationType()) {
        acceptFlag = NameLookup.ACCEPT_ANNOTATIONS;
    } else if (typeBinding.isEnum()) {
        acceptFlag = NameLookup.ACCEPT_ENUMS;
    } else if (typeBinding.isInterface()) {
        acceptFlag = NameLookup.ACCEPT_INTERFACES;
    } else if (typeBinding.isClass()) {
        acceptFlag = NameLookup.ACCEPT_CLASSES;
    }
    if (pkgs != null) {
        for (int i = 0, length = pkgs.length; i < length; i++) {
            IType type = this.nameLookup.findType(typeName, pkgs[i], false, acceptFlag,
                    true/*consider secondary types*/);
            if (type != null)
                return type;
        }
    }

    // search inside enclosing element
    char[][] qualifiedName = CharOperation.splitOn('.', sourceName);
    int length = qualifiedName.length;
    if (length == 0)
        return null;

    IType type = createTypeHandle(new String(qualifiedName[0])); // find the top-level type
    if (type == null)
        return null;

    for (int i = 1; i < length; i++) {
        type = type.getType(new String(qualifiedName[i]));
        if (type == null)
            return null;
    }
    if (type.exists())
        return type;
    return null;
}