List of usage examples for org.eclipse.jdt.internal.compiler.ast TypeDeclaration tagAsHavingErrors
@Override
public void tagAsHavingErrors()
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies.java
License:Open Source License
/** * After copying remember how many fields/methods have been copied, * in order to add copies of generated features later. * * Note: Local types will be copied for STATE_LATE_ELEMENTS_COPIED * * BinaryTypes and marker interfaces: nothing to do. *///from ww w. j a v a 2 s . c o m private static boolean establishRoleFeaturesCopied(RoleModel role) { TypeDeclaration roleType = role.getAst(); if (roleType != null && needMethodBodies(roleType)) { if (OTNameUtils.isTSuperMarkerInterface(roleType.name)) { role.setState(STATE_ROLE_FEATURES_COPIED); return true; } ReferenceBinding superRole = roleType.binding.superclass; if (superRole != null && superRole.id != TypeIds.T_JavaLangObject) { // for signature weakening, as performed by copyMethod, // we must first process the super role (extends): if (superRole.isRole()) { if (!ensureRoleState(superRole.roleModel, STATE_ROLE_FEATURES_COPIED)) { role.setState(STATE_ROLE_FEATURES_COPIED); return false; } } } ReferenceBinding[] tsupers = role.getTSuperRoleBindings(); for (int i = 0; i < tsupers.length; i++) { ReferenceBinding tsuperRoleBinding = tsupers[i]; if ((tsuperRoleBinding != null) && (!tsuperRoleBinding.isInterface())) { // prepare for transitive copying: // (later added features are copied via RoleModel.setState()->CopyInheritance.copyGeneratedFeatures()) if (!ensureTeamState(tsuperRoleBinding.roleModel.getTeamModel(), STATE_ROLE_FEATURES_COPIED)) { role.setState(STATE_ROLE_FEATURES_COPIED); roleType.tagAsHavingErrors(); // missing methods from tsuper. return false; } // to use transitive copyInheritanceSrc tsuper must have that attribute evaluated. ModelElement.evaluateLateAttributes(tsuperRoleBinding, STATE_ROLE_FEATURES_COPIED); if (role.getState() < STATE_ROLE_FEATURES_COPIED) CopyInheritance.copyFeatures(role, tsuperRoleBinding); } } } role.setState(STATE_ROLE_FEATURES_COPIED); return true; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies.java
License:Open Source License
/** * Signature weakening and adjustments for declared lifting in team ctors. * Type wrapping in methods.// w w w.j a va2s . c om * * Recurse: NONE. */ private static boolean establishTypesAdjusted(TeamModel teamModel) { TypeDeclaration teamDecl = teamModel.getAst(); if (teamDecl != null) { if (needMethodBodies(teamDecl)) DeclaredLifting.prepareArgLifting(teamDecl); if (teamDecl.isRole()) { ensureRoleState(teamDecl.getRoleModel(), STATE_TYPES_ADJUSTED); } TeamModel superTeam = teamModel.getSuperTeam(); if (superTeam != null) { if (!ensureTeamState(superTeam, STATE_TYPES_ADJUSTED)) { teamDecl.tagAsHavingErrors(); teamModel.setState(STATE_TYPES_ADJUSTED); return false; } } CopyInheritance.weakenTeamMethodSignatures(teamDecl); } teamModel.setState(STATE_TYPES_ADJUSTED); return true; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.RoleFileHelper.java
License:Open Source License
/** * Given a role file find and link the enclosing team type. * * @param roleUnit the compilation unit containing the role * @param roleType the role type//from w ww . j a va 2s . c o m * @param environment for lookup of the team type. */ public static void getTeamOfRoleFile(CompilationUnitDeclaration roleUnit, TypeDeclaration roleType, LookupEnvironment environment) { // restore what might have been forgotton e.g., by SourceTypeConverter if (roleType.compilationUnit == null) roleType.compilationUnit = roleUnit; if (roleUnit.currentPackage == null) { if (!roleUnit.ignoreFurtherInvestigation) { // double protection for https://bugs.eclipse.org/407223 ProblemReporter problemReporter = environment.problemReporter; problemReporter.referenceContext = roleType; try { problemReporter.roleFileMissingTeamDeclaration(roleUnit); } finally { problemReporter.referenceContext = null; } } return; // silently, error (assumably severe) has been reported } boolean sourceTypeReqSave = Config.getSourceTypeRequired(); Config.setSourceTypeRequired(true); char[][] tokens = roleUnit.currentPackage.tokens; ReferenceBinding teamBinding = myGetType(environment, roleType, tokens, null); if (teamBinding != null && teamBinding.isRole()) teamBinding = teamBinding.roleModel.getClassPartBinding(); Config.setSourceTypeRequired(sourceTypeReqSave); // TODO (SH): ROFI: still need to deal with team for which a // binary type already exists, which needs to be cancelled/converted. if (teamBinding != null) { if (!teamBinding.isTeam()) { environment.problemReporter.missingTeamForRoleWithMembers((SourceTypeBinding) teamBinding, roleType); // remove the role mark from the type and transfer the state to the TypeModel: if (roleType.binding != null) roleType.binding.unrolify(roleType); } else if (teamBinding instanceof SourceTypeBinding) { SourceTypeBinding teamSource = (SourceTypeBinding) teamBinding; TypeDeclaration teamDecl = (teamSource.scope != null) ? teamSource.scope.referenceContext : teamSource.getTeamModel().getAst(); char[][] packageName = roleUnit.currentPackage.tokens; if (!CharOperation.equals(packageName[packageName.length - 1], teamBinding.sourceName())) environment.problemReporter.mismatchingPackageForRole(packageName, teamDecl.name, roleUnit.getFileName(), roleUnit.currentPackage.sourceStart, roleUnit.currentPackage.sourceEnd); if (roleType.enclosingType == null) // otherwise already connected in LookupEnvironment#checkConnectTeamToRoFi AstEdit.addMemberTypeDeclaration(teamDecl, roleType); int teamState = teamBinding.getTeamModel().getState(); if (teamState > ITranslationStates.STATE_ROLE_FILES_LINKED) roleType.getRoleModel()._state.requestState(roleType, teamState); } else { environment.problemReporter.roleFileInBinaryTeam(roleType, teamBinding); // TODO (SH): Several problems with recompiling a role file whose team is already compiled: if (teamBinding.getMemberType(roleType.name) != null) throw new InternalCompilerError("Binary team " + new String(teamBinding.readableName()) //$NON-NLS-1$ + " already contains this role, yet compilation can't proceed"); //$NON-NLS-1$ else throw new InternalCompilerError( "Source Role in Binary Team not yet implemented, please delete the classfile of " //$NON-NLS-1$ + new String(teamBinding.readableName())); } } else { // FIXME(SH): team not found _could_ mean that the team is something like a phantom role // (see 1.5.16-otjld-1). Therefor, we might want to postpone the roleUnit and hope // that a new type has been entered via env.getType() and processing will proceed that way. // Should this be done by the compiler.adaptor? How then would we determine fatal error? environment.problemReporter.noEnclosingTeamForRoleFile(roleUnit, roleType); // reset flags because we can't process it as a role without a team: roleUnit.currentPackage.modifiers &= ~ClassFileConstants.AccTeam; roleType.modifiers &= ~ExtraCompilerModifiers.AccRole; roleType.tagAsHavingErrors(); // CUD is already marked, nor can the type be translated successfully } }