List of usage examples for org.eclipse.jdt.internal.compiler.lookup ReferenceBinding isFinal
public final boolean isFinal()
From source file:com.google.gwt.dev.javac.Shared.java
License:Open Source License
public static int bindingToModifierBits(ReferenceBinding binding) { int bits = 0; bits |= (binding.isPublic() ? MOD_PUBLIC : 0); bits |= (binding.isPrivate() ? MOD_PRIVATE : 0); bits |= (binding.isProtected() ? MOD_PROTECTED : 0); bits |= (binding.isStatic() ? MOD_STATIC : 0); bits |= (binding.isFinal() ? MOD_FINAL : 0); bits |= (binding.isAbstract() ? MOD_ABSTRACT : 0); return bits;//from w w w.ja va 2 s . c om }
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;//from w ww . j a va 2 s . c om 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 {//from w ww .j av a 2 s. 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();//from ww w . jav a 2s. c om 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.objectteams.otdt.internal.core.compiler.statemachine.copyinheritance.CopyInheritance.java
License:Open Source License
/** * If a tsuper role is not overriden in the current team, * create a fresh new role type declaration. * Always copy all inheritance information to the tsub role * (extends, implements, playedBy).// www . j a v a2 s . c o m * No difference, whether we are looking at a role class or interface. * * @param superRole * @param subTeamDecl this declaration is being edited. * @return the new or modified type declaration */ private static TypeDeclaration copyRole(ReferenceBinding superRole, boolean isNestedType, TypeDeclaration subTeamDecl, boolean isTsuperTeam) { subTeamDecl.getTeamModel()._isCopyingLateRole = true; try { if (superRole instanceof MissingTypeBinding) return null; // don't copy missing type! if (superRole.sourceName == null) return null; // local types have null name String name = new String(superRole.sourceName); if ((name.startsWith(TSUPER_OT) || CharOperation.equals(superRole.sourceName, ROFI_CACHE))) return null; // don't copy these special roles if (subTeamDecl.isRole() && superRole.roleModel.equals(subTeamDecl.getRoleModel())) return null; // can happen in case of a role extending its enclosing TypeDeclaration subRoleDecl = findMemberType(subTeamDecl, superRole.sourceName); ReferenceBinding subRoleBinding = subTeamDecl.binding.getMemberType(superRole.internalName()); if (subRoleBinding != null) { // don't copy binary tsuper, if a binary exists already here. if (shouldPreserveBinaryRole(subRoleBinding, subTeamDecl.compilationResult)) { if (isNestedType) subRoleBinding.roleModel.maybeAddLocalToEnclosing(); // no further processing needed except for connecting tsuper and copyInheritanceSrc: connectBinaryNested(superRole, subTeamDecl, subRoleBinding); return null; } // try again, memberType lookup might have introduced a role file to subTeamDecl: if (subRoleDecl == null) subRoleDecl = findMemberType(subTeamDecl, superRole.sourceName); if (subRoleDecl != null && (subRoleDecl.binding.tagBits & TagBits.BeginHierarchyCheck) == 0) subRoleDecl.scope.connectTypeHierarchyWithoutMembers(); if (subRoleDecl == null) // still? return null; // assume recompile has been scheduled } // If type doesn't exist, create now if (subRoleDecl == null) { char[] superRoleName = superRole.internalName(); if (superRole.isLocalType()) { if (!superRole.isBinaryBinding()) ((LocalTypeBinding) superRole).computeConstantPoolName(); int lastDollar = CharOperation.lastIndexOf('$', superRole.sourceName); if (lastDollar >= 0) { superRoleName = CharOperation.subarray(superRole.sourceName, lastDollar + 1, -1); } else { char[] superConstantPoolName = superRole.constantPoolName(); lastDollar = CharOperation.lastIndexOf('$', superConstantPoolName); if (lastDollar >= 0) superRoleName = CharOperation.subarray(superConstantPoolName, lastDollar + 1, -1); } } subRoleDecl = AstConverter.createNestedType(superRoleName, superRole.modifiers, isNestedType, true, // purely copied subTeamDecl, superRole); if (subRoleDecl.isInterface()) { // purely copied interface now copies superinterfaces (not handled in connectRolesFromTeam()): ReferenceBinding[] tsuperSupers = superRole.superInterfaces(); subRoleDecl.binding.superInterfaces = new ReferenceBinding[tsuperSupers.length]; int j = 0; for (int i = 0; i < tsuperSupers.length; i++) { char[] tsuperSuperName = tsuperSupers[i].internalName(); if (!CharOperation.equals(tsuperSuperName, superRoleName)) { ReferenceBinding tsubRole = subTeamDecl.binding.getMemberType(tsuperSuperName); if (tsubRole != null) subRoleDecl.binding.superInterfaces[j++] = tsubRole; } } if (j < tsuperSupers.length) System.arraycopy(subRoleDecl.binding.superInterfaces, 0, subRoleDecl.binding.superInterfaces = new ReferenceBinding[j], 0, j); } } else { if (subRoleDecl.isRegularInterface() != superRole.isRegularInterface()) { subRoleDecl.scope.problemReporter().roleClassIfcConflict(subRoleDecl); // overwrite existing type with tsuper copy: subRoleDecl.isGenerated = true; subRoleDecl.isPurelyCopied = true; subRoleDecl.modifiers = superRole.modifiers; subRoleDecl.fields = null; subRoleDecl.methods = null; subRoleDecl.superclass = null; subRoleDecl.superInterfaces = null; SourceTypeBinding roleBinding = subRoleDecl.binding; roleBinding.modifiers = superRole.modifiers; roleBinding.setFields(Binding.NO_FIELDS); roleBinding.setMethods(Binding.NO_METHODS); roleBinding.baseclass = null; roleBinding.superclass = subTeamDecl.scope.getJavaLangObject(); roleBinding.superInterfaces = Binding.NO_SUPERINTERFACES; return subRoleDecl; } if (superRole.isTeam() && !subRoleDecl.isTeam()) { if (!Protections.hasClassKindProblem(subRoleDecl.binding)) subRoleDecl.scope.problemReporter().regularOverridesTeam(subRoleDecl, superRole); subRoleDecl.modifiers |= ClassFileConstants.AccTeam; if (subRoleBinding != null) subRoleBinding.modifiers |= ClassFileConstants.AccTeam; } if (!isTsuperTeam) { if (CharOperation.equals(subRoleDecl.name, OTCONFINED)) { subRoleDecl.scope.problemReporter().overridingConfined(subRoleDecl, "Confined"); //$NON-NLS-1$ return null; } if (CharOperation.equals(subRoleDecl.name, ICONFINED)) { subRoleDecl.scope.problemReporter().overridingConfined(subRoleDecl, "IConfined"); //$NON-NLS-1$ return null; } if (superRole.isFinal()) { subRoleDecl.scope.problemReporter().overridingFinalRole(subRoleDecl, superRole); return null; } } } superRole.roleModel.hasBaseclassProblem(); // just trigger propagation from super-role to current // if (subRoleBinding != null && subRoleBinding.isBinaryBinding()) // subRoleDecl.scope.problemReporter().mismatchingRoleParts(subRoleBinding, subRoleDecl); return subRoleDecl; } finally { subTeamDecl.getTeamModel()._isCopyingLateRole = false; } }