List of usage examples for org.eclipse.jdt.internal.compiler.lookup ProblemReasons InternalNameProvided
int InternalNameProvided
To view the source code for org.eclipse.jdt.internal.compiler.lookup ProblemReasons InternalNameProvided.
Click Source Link
From source file:com.redhat.ceylon.eclipse.core.model.JDTModelLoader.java
License:Open Source License
private static ReferenceBinding toBinding(IType type, LookupEnvironment theLookupEnvironment, char[][] compoundName) throws JavaModelException { ITypeRoot typeRoot = type.getTypeRoot(); if (typeRoot instanceof IClassFile) { ClassFile classFile = (ClassFile) typeRoot; IFile classFileRsrc = (IFile) classFile.getCorrespondingResource(); if (classFileRsrc != null && !classFileRsrc.exists()) { //the .class file has been deleted return null; }//from ww w . jav a2s . co m BinaryTypeBinding binaryTypeBinding = null; try { IBinaryType binaryType = classFile.getBinaryTypeInfo(classFileRsrc, true); binaryTypeBinding = theLookupEnvironment.cacheBinaryType(binaryType, null); } catch (JavaModelException e) { if (!e.isDoesNotExist()) { throw e; } } if (binaryTypeBinding == null) { ReferenceBinding existingType = theLookupEnvironment.getCachedType(compoundName); if (existingType == null || !(existingType instanceof BinaryTypeBinding)) { return null; } binaryTypeBinding = (BinaryTypeBinding) existingType; } return binaryTypeBinding; } else { ReferenceBinding referenceBinding = theLookupEnvironment.getType(compoundName); if (referenceBinding != null && !(referenceBinding instanceof BinaryTypeBinding)) { if (referenceBinding instanceof ProblemReferenceBinding) { ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) referenceBinding; if (problemReferenceBinding.problemId() == ProblemReasons.InternalNameProvided) { referenceBinding = problemReferenceBinding.closestReferenceMatch(); } else { System.out.println( ProblemReferenceBinding.problemReasonString(problemReferenceBinding.problemId())); return null; } } return referenceBinding; } return null; } }
From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTModelLoader.java
License:Open Source License
private ClassMirror buildClassMirror(String name) { try {/*from ww w. j a va 2s. c o m*/ IType type = javaProject.findType(name); if (type == null) { return null; } LookupEnvironment theLookupEnvironment = getLookupEnvironment(); if (type.isBinary()) { ClassFile classFile = (ClassFile) type.getClassFile(); if (classFile != null) { IPackageFragmentRoot fragmentRoot = classFile.getPackageFragmentRoot(); if (fragmentRoot != null) { if (isInCeylonClassesOutputFolder(fragmentRoot.getPath())) { return null; } } IFile classFileRsrc = (IFile) classFile.getCorrespondingResource(); IBinaryType binaryType = classFile.getBinaryTypeInfo(classFileRsrc, true); if (classFileRsrc != null && !classFileRsrc.exists()) { //the .class file has been deleted return null; } BinaryTypeBinding binaryTypeBinding = theLookupEnvironment.cacheBinaryType(binaryType, null); if (binaryTypeBinding == null) { char[][] compoundName = CharOperation.splitOn('/', binaryType.getName()); ReferenceBinding existingType = theLookupEnvironment.getCachedType(compoundName); if (existingType == null || !(existingType instanceof BinaryTypeBinding)) { return null; } binaryTypeBinding = (BinaryTypeBinding) existingType; } return new JDTClass(binaryTypeBinding, theLookupEnvironment); } } else { char[][] compoundName = CharOperation.splitOn('.', type.getFullyQualifiedName().toCharArray()); ReferenceBinding referenceBinding = theLookupEnvironment.getType(compoundName); if (referenceBinding != null) { if (referenceBinding instanceof ProblemReferenceBinding) { ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) referenceBinding; if (problemReferenceBinding.problemId() == ProblemReasons.InternalNameProvided) { referenceBinding = problemReferenceBinding.closestReferenceMatch(); } else { System.out.println(ProblemReferenceBinding .problemReasonString(problemReferenceBinding.problemId())); return null; } } return new JDTClass(referenceBinding, theLookupEnvironment); } } } catch (JavaModelException e) { e.printStackTrace(); } return null; }
From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitScope.java
License:Open Source License
/** * Look in the local cache, if we don't find it then ask JDT. If JDT responds with a SourceTypeBinding then it has been found. * If JDT responds with some other kind of binding, we consider that 'not found as source' and return null. * // w ww .jav a 2 s. com * Not quite the right name for this method, because on an incremental build it will find BinaryTypeBindings for types that were * SourceTypeBindings during the full build * */ // FIXASC (optimization) cache any non SourceTypeBinding found and use that information in the lookupClassNodeForBinary public ClassNode lookupClassNodeForSource(String typename, JDTResolver jdtResolver) { ClassNode node = typenameToClassNodeCache.get(typename); if (node != null) { return node; } char[][] compoundName = CharOperation.splitOn('.', typename.toCharArray()); TypeBinding jdtBinding = null; try { jdtBinding = getType(compoundName, compoundName.length); } catch (AbortCompilation t) { if (t.silentException instanceof AbortIncrementalBuildException) { jdtBinding = null; } else { throw t; } } if (jdtBinding != null) { if (jdtBinding instanceof SourceTypeBinding) { ClassNode classNode = jdtResolver.convertToClassNode(jdtBinding); if (classNode != null) { typenameToClassNodeCache.put(typename, classNode); } return classNode; } else if (jdtBinding instanceof BinaryTypeBinding) { ClassNode newNode = jdtResolver.convertToClassNode(jdtBinding); if (newNode != null) { typenameToClassNodeCache.put(typename, newNode); } return newNode; } } // FIXASC better to look it up properly as a member type rather than catch the problem and unwrap! if (jdtBinding != null && (jdtBinding instanceof ProblemReferenceBinding)) { ProblemReferenceBinding prBinding = (ProblemReferenceBinding) jdtBinding; if (prBinding.problemId() == ProblemReasons.InternalNameProvided) { jdtBinding = prBinding.closestMatch(); // FIXASC caching for this too? if (jdtBinding != null && (jdtBinding instanceof SourceTypeBinding)) { return jdtResolver.convertToClassNode(jdtBinding); } if (jdtBinding != null && (jdtBinding instanceof BinaryTypeBinding)) { return jdtResolver.convertToClassNode(jdtBinding); } } } return null; }
From source file:org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitScope.java
License:Open Source License
public ClassNode lookupClassNodeForBinary(String typename, JDTResolver jdtResolver) { char[][] compoundName = CharOperation.splitOn('.', typename.toCharArray()); TypeBinding jdtBinding = getType(compoundName, compoundName.length); if (jdtBinding != null && (jdtBinding instanceof BinaryTypeBinding)) { // log("GCUScope.lookupClassNodeForBinary(): JDTBinding for '" + typename + "' found to be " // + jdtBinding.getClass().getSimpleName()); ClassNode classNode = jdtResolver.convertToClassNode(jdtBinding); return classNode; }/* w w w . j ava 2 s.c o m*/ if (jdtBinding != null && (jdtBinding instanceof ProblemReferenceBinding)) { ProblemReferenceBinding prBinding = (ProblemReferenceBinding) jdtBinding; if (prBinding.problemId() == ProblemReasons.InternalNameProvided) { jdtBinding = prBinding.closestMatch(); if (jdtBinding != null && (jdtBinding instanceof BinaryTypeBinding)) { return jdtResolver.convertToClassNode(jdtBinding); } } } return null; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.RoleFileHelper.java
License:Open Source License
private static ReferenceBinding myGetType(LookupEnvironment env, TypeDeclaration roleType, char[][] firstTypeName, char[] nestedTypeName) { ReferenceBinding firstType;//from ww w.ja v a2 s . c o m if (nestedTypeName == null) firstType = env.getTeamForRoFi(firstTypeName, roleType); else firstType = env.getType(firstTypeName); if (firstType == null && firstTypeName.length > 1) { char[][] parentTypeName = new char[firstTypeName.length - 1][]; System.arraycopy(firstTypeName, 0, parentTypeName, 0, parentTypeName.length); firstType = myGetType(env, roleType, parentTypeName, firstTypeName[firstTypeName.length - 1]); } if (firstType == null) return null; // the case of deeply nested role: env didn't like to fetch it, but by unwrapping we are actually fine: if (firstType.problemId() == ProblemReasons.InternalNameProvided) firstType = ((ProblemReferenceBinding) firstType).closestReferenceMatch(); if (nestedTypeName == null) return firstType; if (firstType.isSynthInterface()) firstType = firstType.getRealClass(); return firstType.getMemberType(nestedTypeName); }