List of usage examples for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding isAnnotationType
@Override public boolean isAnnotationType()
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);// w w w . j a va 2s. c o 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; }
From source file:com.google.gwt.dev.jjs.impl.BuildTypeMap.java
License:Apache License
private JDeclaredType createType(String name, SourceInfo info, ReferenceBinding binding) { JDeclaredType newType;/* ww w . j av a 2s .c o m*/ if (binding.isClass()) { newType = program.createClass(info, name, binding.isAbstract(), binding.isFinal()); } else if (binding.isInterface() || binding.isAnnotationType()) { newType = program.createInterface(info, name); } else if (binding.isEnum()) { if (binding.isAnonymousType()) { // Don't model an enum subclass as a JEnumType. newType = program.createClass(info, name, false, true); } else { newType = program.createEnum(info, name, binding.isAbstract()); } } else { throw new InternalCompilerException("ReferenceBinding is not a class, interface, or enum."); } info.addCorrelation(info.getCorrelator().by(newType)); /** * We emulate static initializers and instance initializers as methods. As * in other cases, this gives us: simpler AST, easier to optimize, more like * output JavaScript. Clinit is always in slot 0, init (if it exists) is * always in slot 1. */ SourceInfo child = info.makeChild(); JMethod clinit = program.createMethod(child, "$clinit", newType, program.getTypeVoid(), false, true, true, AccessModifier.PRIVATE, false); clinit.freezeParamTypes(); clinit.setSynthetic(); child.addCorrelation(info.getCorrelator().by(clinit)); if (newType instanceof JClassType) { child = info.makeChild(); JMethod init = program.createMethod(child, "$init", newType, program.getTypeVoid(), false, false, true, AccessModifier.PRIVATE, false); init.freezeParamTypes(); init.setSynthetic(); child.addCorrelation(info.getCorrelator().by(init)); } newType.setExternal(linker.isExternalType(newType.getName())); return newType; }
From source file:com.google.gwt.dev.jjs.impl.ReferenceMapper.java
License:Apache License
private JDeclaredType createType(ReferenceBinding binding) { String name = JdtUtil.asDottedString(binding.compoundName); SourceInfo info = SourceOrigin.UNKNOWN; if (binding.isClass()) { return new JClassType(info, name, binding.isAbstract(), binding.isFinal()); } else if (binding.isInterface() || binding.isAnnotationType()) { return new JInterfaceType(info, name); } else if (binding.isEnum()) { if (binding.isAnonymousType()) { // Don't model an enum subclass as a JEnumType. return new JClassType(info, name, false, true); } else {// ww w. ja va 2s . c o m return new JEnumType(info, name, binding.isAbstract()); } } else { throw new InternalCompilerException("ReferenceBinding is not a class, interface, or enum."); } }
From source file:com.redhat.ceylon.eclipse.core.model.mirror.UnknownClassMirror.java
License:Open Source License
public JDTClass(ReferenceBinding klass, IType type) { this.type = type; bindingRef = new WeakReference<ReferenceBinding>(klass); pkg = new JDTPackage(klass.getPackage()); simpleName = new String(klass.sourceName()); qualifiedName = JDTUtils.getFullyQualifiedName(klass); isPublic = klass.isPublic();// w w w.ja va 2s . c o m isInterface = klass.isInterface(); isAbstract = klass.isAbstract(); isProtected = klass.isProtected(); isDefaultAccess = klass.isDefault(); isLocalType = klass.isLocalType(); isStatic = (klass.modifiers & ClassFileConstants.AccStatic) != 0; isFinal = klass.isFinal(); isEnum = klass.isEnum(); isBinary = klass.isBinaryBinding(); isAnonymous = klass.isAnonymousType(); isJavaSource = (klass instanceof SourceTypeBinding) && new String(((SourceTypeBinding) klass).getFileName()).endsWith(".java"); isAnnotationType = klass.isAnnotationType(); bindingKey = klass.computeUniqueKey(); char[] bindingFileName = klass.getFileName(); int start = CharOperation.lastIndexOf('/', bindingFileName) + 1; if (start == 0 || start < CharOperation.lastIndexOf('\\', bindingFileName)) start = CharOperation.lastIndexOf('\\', bindingFileName) + 1; fileName = new String(CharOperation.subarray(bindingFileName, start, -1)); int jarFileEntrySeparatorIndex = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, bindingFileName); if (jarFileEntrySeparatorIndex > 0) { char[] jarPart = CharOperation.subarray(bindingFileName, 0, jarFileEntrySeparatorIndex); IJavaElement jarPackageFragmentRoot = JavaCore.create(new String(jarPart)); String jarPath = jarPackageFragmentRoot.getPath().toOSString(); char[] entryPart = CharOperation.subarray(bindingFileName, jarFileEntrySeparatorIndex + 1, bindingFileName.length); fullPath = new StringBuilder(jarPath).append("!/").append(entryPart).toString(); } else { fullPath = new String(bindingFileName); } ReferenceBinding sourceOrClass = klass; if (!klass.isBinaryBinding()) { sourceOrClass = klass.outermostEnclosingType(); } char[] classFullName = new char[0]; for (char[] part : sourceOrClass.compoundName) { classFullName = CharOperation.concat(classFullName, part, '/'); } char[][] temp = CharOperation.splitOn('.', sourceOrClass.getFileName()); String extension = temp.length > 1 ? "." + new String(temp[temp.length - 1]) : ""; javaModelPath = new String(classFullName) + extension; if (type == null) { annotations = new HashMap<>(); methods = Collections.emptyList(); interfaces = Collections.emptyList(); typeParams = Collections.emptyList(); fields = Collections.emptyList(); innerClasses = Collections.emptyList(); } }
From source file:org.eclipse.che.jdt.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 ww w. ja va 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, false, 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.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);/*from ww w .j a va2s . 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; }