List of usage examples for org.eclipse.jdt.internal.compiler.lookup TagBits HasNoMemberTypes
long HasNoMemberTypes
To view the source code for org.eclipse.jdt.internal.compiler.lookup TagBits HasNoMemberTypes.
Click Source Link
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public ReferenceBinding findDirectMemberType(char[] typeName, ReferenceBinding enclosingType) { if ((enclosingType.tagBits & TagBits.HasNoMemberTypes) != 0) return null; // know it has no member types (nor inherited member types) ReferenceBinding enclosingReceiverType = enclosingReceiverType(); CompilationUnitScope unitScope = compilationUnitScope(); unitScope.recordReference(enclosingType, typeName); ReferenceBinding memberType = enclosingType.getMemberType(typeName); if (memberType != null) { unitScope.recordTypeReference(memberType); if (enclosingReceiverType == null) { if (memberType.canBeSeenBy(getCurrentPackage())) { return memberType; }/*from w w w . j av a2 s.c o m*/ // maybe some type in the compilation unit is extending some class in some package // and the selection is for some protected inner class of that superclass // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235658 if (this instanceof CompilationUnitScope) { TypeDeclaration[] types = ((CompilationUnitScope) this).referenceContext.types; if (types != null) { for (int i = 0, max = types.length; i < max; i++) { if (memberType.canBeSeenBy(enclosingType, types[i].binding)) { return memberType; } } } } } else if (memberType.canBeSeenBy(enclosingType, enclosingReceiverType)) { return memberType; } return new ProblemReferenceBinding(new char[][] { typeName }, memberType, ProblemReasons.NotVisible); } return null; }
From source file:org.eclipse.jdt.internal.compiler.lookup.Scope.java
License:Open Source License
public ReferenceBinding findMemberType(char[] typeName, ReferenceBinding enclosingType) { if ((enclosingType.tagBits & TagBits.HasNoMemberTypes) != 0) return null; // know it has no member types (nor inherited member types) ReferenceBinding enclosingSourceType = enclosingSourceType(); PackageBinding currentPackage = getCurrentPackage(); CompilationUnitScope unitScope = compilationUnitScope(); unitScope.recordReference(enclosingType, typeName); ReferenceBinding memberType = enclosingType.getMemberType(typeName); if (memberType != null) { unitScope.recordTypeReference(memberType); if (enclosingSourceType == null || (this.parent == unitScope && (enclosingSourceType.tagBits & TagBits.TypeVariablesAreConnected) == 0) ? memberType.canBeSeenBy(currentPackage) : memberType.canBeSeenBy(enclosingType, enclosingSourceType)) return memberType; return new ProblemReferenceBinding(new char[][] { typeName }, memberType, ProblemReasons.NotVisible); }//from w w w .j a v a 2 s .co m // collect all superinterfaces of receiverType until the memberType is found in a supertype ReferenceBinding currentType = enclosingType; ReferenceBinding[] interfacesToVisit = null; int nextPosition = 0; ReferenceBinding visibleMemberType = null; boolean keepLooking = true; ReferenceBinding notVisible = null; // we could hold onto the not visible field for extra error reporting while (keepLooking) { ReferenceBinding[] itsInterfaces = currentType.superInterfaces(); if (itsInterfaces == null) { // needed for statically imported types which don't know their hierarchy yet ReferenceBinding sourceType = currentType.isParameterizedType() ? ((ParameterizedTypeBinding) currentType).genericType() : currentType; if (sourceType.isHierarchyBeingConnected()) return null; // looking for an undefined member type in its own superclass ref ((SourceTypeBinding) sourceType).scope.connectTypeHierarchy(); itsInterfaces = currentType.superInterfaces(); } if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) { if (interfacesToVisit == null) { interfacesToVisit = itsInterfaces; nextPosition = interfacesToVisit.length; } else { int itsLength = itsInterfaces.length; if (nextPosition + itsLength >= interfacesToVisit.length) System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); nextInterface: for (int a = 0; a < itsLength; a++) { ReferenceBinding next = itsInterfaces[a]; for (int b = 0; b < nextPosition; b++) if (next == interfacesToVisit[b]) continue nextInterface; interfacesToVisit[nextPosition++] = next; } } } if ((currentType = currentType.superclass()) == null) break; unitScope.recordReference(currentType, typeName); if ((memberType = currentType.getMemberType(typeName)) != null) { unitScope.recordTypeReference(memberType); keepLooking = false; if (enclosingSourceType == null ? memberType.canBeSeenBy(currentPackage) : memberType.canBeSeenBy(enclosingType, enclosingSourceType)) { if (visibleMemberType == null) visibleMemberType = memberType; else return new ProblemReferenceBinding(new char[][] { typeName }, visibleMemberType, ProblemReasons.Ambiguous); } else { notVisible = memberType; } } } // walk all visible interfaces to find ambiguous references if (interfacesToVisit != null) { ProblemReferenceBinding ambiguous = null; done: for (int i = 0; i < nextPosition; i++) { ReferenceBinding anInterface = interfacesToVisit[i]; unitScope.recordReference(anInterface, typeName); if ((memberType = anInterface.getMemberType(typeName)) != null) { unitScope.recordTypeReference(memberType); if (visibleMemberType == null) { visibleMemberType = memberType; } else { ambiguous = new ProblemReferenceBinding(new char[][] { typeName }, visibleMemberType, ProblemReasons.Ambiguous); break done; } } else { ReferenceBinding[] itsInterfaces = anInterface.superInterfaces(); if (itsInterfaces != null && itsInterfaces != Binding.NO_SUPERINTERFACES) { int itsLength = itsInterfaces.length; if (nextPosition + itsLength >= interfacesToVisit.length) System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition); nextInterface: for (int a = 0; a < itsLength; a++) { ReferenceBinding next = itsInterfaces[a]; for (int b = 0; b < nextPosition; b++) if (next == interfacesToVisit[b]) continue nextInterface; interfacesToVisit[nextPosition++] = next; } } } } if (ambiguous != null) return ambiguous; } if (visibleMemberType != null) return visibleMemberType; if (notVisible != null) return new ProblemReferenceBinding(new char[][] { typeName }, notVisible, ProblemReasons.NotVisible); return null; }