public static void getAccessRulesProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { IBinding referencedElement= null; ASTNode node= problem.getCoveredNode(context.getASTRoot()); if (node instanceof Type) { referencedElement= ((Type) node).resolveBinding(); } else if (node instanceof Name) { referencedElement= ((Name) node).resolveBinding(); } if (referencedElement != null && canModifyAccessRules(referencedElement)) { IProject project= context.getCompilationUnit().getJavaProject().getProject(); String label= CorrectionMessages.ReorgCorrectionsSubProcessor_accessrules_description; OpenBuildPathCorrectionProposal proposal= new OpenBuildPathCorrectionProposal(project, label, IProposalRelevance.CONFIGURE_ACCESS_RULES, referencedElement); proposals.add(proposal); } }
case IProblem.CannotImportPackage: case IProblem.ConflictingImport: ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.ImportNotFound: ReorgCorrectionsSubProcessor.importNotFoundProposals(context, problem, proposals); ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.UndefinedMethod: break; case IProblem.PublicClassMustMatchFileName: ReorgCorrectionsSubProcessor.getWrongTypeNameProposals(context, problem, proposals); break; case IProblem.PackageIsNotExpectedPackage: ReorgCorrectionsSubProcessor.getWrongPackageDeclNameProposals(context, problem, proposals); break; case IProblem.UndefinedType: case IProblem.InvalidUsageOfAnnotations: case IProblem.InvalidUsageOfAnnotationDeclarations: ReorgCorrectionsSubProcessor.getNeed50ComplianceProposals(context, problem, proposals); break; case IProblem.NonGenericType: break; case IProblem.IsClassPathCorrect: ReorgCorrectionsSubProcessor.getIncorrectBuildPathProposals(context, problem, proposals); break;
case IProblem.CannotImportPackage: case IProblem.ConflictingImport: ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.ImportNotFound: ReorgCorrectionsSubProcessor.importNotFoundProposals(context, problem, proposals); ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.UndefinedMethod: break; case IProblem.PublicClassMustMatchFileName: ReorgCorrectionsSubProcessor.getWrongTypeNameProposals(context, problem, proposals); break; case IProblem.PackageIsNotExpectedPackage: ReorgCorrectionsSubProcessor.getWrongPackageDeclNameProposals(context, problem, proposals); break; case IProblem.UndefinedType: case IProblem.InvalidUsageOfAnnotations: case IProblem.InvalidUsageOfAnnotationDeclarations: ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_1_5); break; case IProblem.DiamondNotBelow17: case IProblem.UnderscoresInLiteralsNotBelow17: case IProblem.SwitchOnStringsNotBelow17: ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_1_7); break;
ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_11); } else { ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_10); ReorgCorrectionsSubProcessor.addProjectSetupFixProposal(context, problem, node.getFullyQualifiedName(), proposals);
public static void importNotFoundProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException { ICompilationUnit cu= context.getCompilationUnit(); ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot()); if (selectedNode == null) { return; } ImportDeclaration importDeclaration= (ImportDeclaration) ASTNodes.getParent(selectedNode, ASTNode.IMPORT_DECLARATION); if (importDeclaration == null) { return; } if (!importDeclaration.isOnDemand()) { Name name= importDeclaration.getName(); if (importDeclaration.isStatic() && name.isQualifiedName()) { name= ((QualifiedName) name).getQualifier(); } int kind= JavaModelUtil.is50OrHigher(cu.getJavaProject()) ? SimilarElementsRequestor.REF_TYPES : SimilarElementsRequestor.CLASSES | SimilarElementsRequestor.INTERFACES; UnresolvedElementsSubProcessor.addNewTypeProposals(cu, name, kind, IProposalRelevance.IMPORT_NOT_FOUND_NEW_TYPE, proposals); } String name= ASTNodes.asString(importDeclaration.getName()); if (importDeclaration.isOnDemand()) { name= JavaModelUtil.concatenateName(name, "*"); //$NON-NLS-1$ } addProjectSetupFixProposal(context, problem, name, proposals); }
case IProblem.CannotImportPackage: case IProblem.ConflictingImport: ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.ImportNotFound: ReorgCorrectionsSubProcessor.importNotFoundProposals(context, problem, proposals); ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.UndefinedMethod: break; case IProblem.PublicClassMustMatchFileName: ReorgCorrectionsSubProcessor.getWrongTypeNameProposals(context, problem, proposals); break; case IProblem.PackageIsNotExpectedPackage: ReorgCorrectionsSubProcessor.getWrongPackageDeclNameProposals(context, problem, proposals); break; case IProblem.UndefinedType: case IProblem.InvalidUsageOfAnnotations: case IProblem.InvalidUsageOfAnnotationDeclarations: ReorgCorrectionsSubProcessor.getNeed50ComplianceProposals(context, problem, proposals); break; case IProblem.NonGenericType: break; case IProblem.IsClassPathCorrect: ReorgCorrectionsSubProcessor.getIncorrectBuildPathProposals(context, problem, proposals); break;
case IProblem.CannotImportPackage: case IProblem.ConflictingImport: ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.ImportNotFound: ReorgCorrectionsSubProcessor.importNotFoundProposals(context, problem, proposals); ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.UndefinedMethod: break; case IProblem.PublicClassMustMatchFileName: ReorgCorrectionsSubProcessor.getWrongTypeNameProposals(context, problem, proposals); break; case IProblem.PackageIsNotExpectedPackage: ReorgCorrectionsSubProcessor.getWrongPackageDeclNameProposals(context, problem, proposals); break; case IProblem.UndefinedType: case IProblem.InvalidUsageOfAnnotations: case IProblem.InvalidUsageOfAnnotationDeclarations: ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_1_5); break; case IProblem.DiamondNotBelow17: case IProblem.UnderscoresInLiteralsNotBelow17: case IProblem.SwitchOnStringsNotBelow17: ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context, problem, proposals, JavaCore.VERSION_1_7); break;
public static void importNotFoundProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws CoreException { ICompilationUnit cu= context.getCompilationUnit(); ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot()); if (selectedNode == null) { return; } ImportDeclaration importDeclaration= (ImportDeclaration) ASTNodes.getParent(selectedNode, ASTNode.IMPORT_DECLARATION); if (importDeclaration == null) { return; } if (!importDeclaration.isOnDemand()) { Name name= importDeclaration.getName(); if (importDeclaration.isStatic() && name.isQualifiedName()) { name= ((QualifiedName) name).getQualifier(); } int kind= JavaModelUtil.is50OrHigher(cu.getJavaProject()) ? TypeKinds.REF_TYPES : TypeKinds.CLASSES | TypeKinds.INTERFACES; UnresolvedElementsSubProcessor.addRequiresModuleProposals(cu, name, IProposalRelevance.IMPORT_NOT_FOUND_ADD_REQUIRES_MODULE, proposals, false); UnresolvedElementsSubProcessor.addNewTypeProposals(cu, name, kind, IProposalRelevance.IMPORT_NOT_FOUND_NEW_TYPE, proposals); } else { Name name= importDeclaration.getName(); UnresolvedElementsSubProcessor.addRequiresModuleProposals(cu, name, IProposalRelevance.IMPORT_NOT_FOUND_ADD_REQUIRES_MODULE, proposals, true); } String name= ASTNodes.asString(importDeclaration.getName()); if (importDeclaration.isOnDemand()) { name= JavaModelUtil.concatenateName(name, "*"); //$NON-NLS-1$ } addProjectSetupFixProposal(context, problem, name, proposals); }
ReorgCorrectionsSubProcessor.addProjectSetupFixProposal(context, problem, node.getFullyQualifiedName(), proposals);
public static void getAccessRulesProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { IBinding referencedElement= null; ASTNode node= problem.getCoveredNode(context.getASTRoot()); if (node instanceof Type) { referencedElement= ((Type) node).resolveBinding(); } else if (node instanceof Name) { referencedElement= ((Name) node).resolveBinding(); } if (referencedElement != null && canModifyAccessRules(referencedElement)) { IProject project= context.getCompilationUnit().getJavaProject().getProject(); String label= CorrectionMessages.ReorgCorrectionsSubProcessor_accessrules_description; OpenBuildPathCorrectionProposal proposal= new OpenBuildPathCorrectionProposal(project, label, IProposalRelevance.CONFIGURE_ACCESS_RULES, referencedElement); proposals.add(proposal); } }
addNewTypeProposals(cu, node, typeKind, relevance, proposals); ReorgCorrectionsSubProcessor.addProjectSetupFixProposal(context, problem, node.getFullyQualifiedName(), proposals);
addNewTypeProposals(cu, node, typeKind, relevance, proposals); ReorgCorrectionsSubProcessor.addProjectSetupFixProposal(context, problem, node.getFullyQualifiedName(), proposals);