Java Code Examples for org.eclipse.jdt.ui.text.java.IProblemLocation#getProblemArguments()
The following examples show how to use
org.eclipse.jdt.ui.text.java.IProblemLocation#getProblemArguments() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteServiceProblemMarkerResolutionGenerator.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException { List<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>(); for (IProblemLocation problem : locations) { RemoteServiceProblemType problemType = RemoteServiceProblemType.getProblemType(problem.getProblemId()); if (problemType == null) { continue; } switch (problemType) { case MISSING_ASYNC_TYPE: proposals.addAll(CreateAsyncInterfaceProposal.createProposals( context, problem)); break; case MISSING_ASYNC_METHOD: // Provide different resolutions depending on which type error is on if (problem.getProblemArguments()[0].equals("async")) { String syncMethodBindingKey = problem.getProblemArguments()[1]; proposals.addAll(CreateAsyncMethodProposal.createProposalsForProblemOnAsyncType( context.getCompilationUnit(), context.getCoveringNode(), syncMethodBindingKey)); proposals.addAll(DeleteMethodProposal.createProposalsForProblemOnAsyncType( context.getCoveringNode(), syncMethodBindingKey)); proposals.addAll(UpdateAsyncSignatureProposal.createProposalsForProblemsOnAsyncType( context.getCoveringNode(), syncMethodBindingKey)); } else { // on sync type proposals.addAll(CreateAsyncMethodProposal.createProposalsForProblemOnSyncMethod(context.getCoveringNode())); proposals.addAll(DeleteMethodProposal.createProposalsForProblemOnExtraMethod(context.getCoveringNode())); proposals.addAll(UpdateAsyncSignatureProposal.createProposalsForProblemsOnSyncMethod(context.getCoveringNode())); } break; case MISSING_SYNC_METHOD: if (problem.getProblemArguments()[0].equals("sync")) { String asyncMethodBindingKey = problem.getProblemArguments()[1]; proposals.addAll(CreateSyncMethodProposal.createProposalsForProblemOnSyncType( context.getCompilationUnit(), context.getCoveringNode(), asyncMethodBindingKey)); proposals.addAll(DeleteMethodProposal.createProposalsForProblemOnSyncType( context.getCoveringNode(), asyncMethodBindingKey)); proposals.addAll(UpdateSyncSignatureProposal.createProposalsForProblemsOnSyncType( context.getCoveringNode(), asyncMethodBindingKey)); } else { // on async type proposals.addAll(CreateSyncMethodProposal.createProposalsForProblemOnAsyncMethod(context.getCoveringNode())); proposals.addAll(DeleteMethodProposal.createProposalsForProblemOnExtraMethod(context.getCoveringNode())); proposals.addAll(UpdateSyncSignatureProposal.createProposalsForProblemsOnAsyncMethod(context.getCoveringNode())); } break; case INVALID_ASYNC_RETURN_TYPE: proposals.addAll(ChangeAsyncMethodReturnTypeProposal.createProposals(context.getCoveringNode())); break; case ASYNCCALLBACK_TYPE_ARGUMENT_MISMATCH: if (problem.getProblemArguments()[0].equals("sync")) { proposals.addAll(UpdateAsyncSignatureProposal.createProposalsForProblemsOnSyncMethod(context.getCoveringNode())); } else { proposals.addAll(UpdateSyncSignatureProposal.createProposalsForProblemsOnAsyncMethod(context.getCoveringNode())); } break; default: break; } } return proposals.toArray(new IJavaCompletionProposal[0]); }
Example 2
Source File: CreateAsyncInterfaceProposal.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public static List<IJavaCompletionProposal> createProposals(IInvocationContext context, IProblemLocation problem) throws JavaModelException { String syncTypeName = problem.getProblemArguments()[0]; IJavaProject javaProject = context.getCompilationUnit().getJavaProject(); IType syncType = JavaModelSearch.findType(javaProject, syncTypeName); if (syncType == null || !syncType.isInterface()) { return Collections.emptyList(); } CompilationUnit cu = context.getASTRoot(); ASTNode coveredNode = problem.getCoveredNode(cu); TypeDeclaration syncTypeDecl = (TypeDeclaration) coveredNode.getParent(); assert (cu.getAST().hasResolvedBindings()); ITypeBinding syncTypeBinding = syncTypeDecl.resolveBinding(); assert (syncTypeBinding != null); String asyncName = RemoteServiceUtilities.computeAsyncTypeName(problem.getProblemArguments()[0]); AST ast = context.getASTRoot().getAST(); Name name = ast.newName(asyncName); /* * HACK: NewCUUsingWizardProposal wants a name that has a parent expression so we create an * assignment so that the name has a valid parent */ ast.newAssignment().setLeftHandSide(name); IJavaElement typeContainer = syncType.getParent(); if (typeContainer.getElementType() == IJavaElement.COMPILATION_UNIT) { typeContainer = syncType.getPackageFragment(); } // Add a create async interface proposal CreateAsyncInterfaceProposal createAsyncInterfaceProposal = new CreateAsyncInterfaceProposal( context.getCompilationUnit(), name, K_INTERFACE, typeContainer, 2, syncTypeBinding); // Add the stock create interface proposal NewCompilationUnitUsingWizardProposal fallbackProposal = new NewCompilationUnitUsingWizardProposal( context.getCompilationUnit(), name, K_INTERFACE, context.getCompilationUnit().getParent(), 1); return Arrays.<IJavaCompletionProposal>asList(createAsyncInterfaceProposal, fallbackProposal); }
Example 3
Source File: WordQuickFixProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public IJavaCompletionProposal[] getCorrections(IInvocationContext invocationContext, IProblemLocation[] locations) throws CoreException { final int threshold= PreferenceConstants.getPreferenceStore().getInt(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD); int size= 0; List<RankedWordProposal> proposals= null; String[] arguments= null; IProblemLocation location= null; RankedWordProposal proposal= null; IJavaCompletionProposal[] result= null; boolean fixed= false; boolean match= false; boolean sentence= false; final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker != null) { for (int index= 0; index < locations.length; index++) { location= locations[index]; ISourceViewer sourceViewer= null; if (invocationContext instanceof IQuickAssistInvocationContext) sourceViewer= ((IQuickAssistInvocationContext)invocationContext).getSourceViewer(); IQuickAssistInvocationContext context= new TextInvocationContext(sourceViewer, location.getOffset(), location.getLength()); if (location.getProblemId() == JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID) { arguments= location.getProblemArguments(); if (arguments != null && arguments.length > 4) { sentence= Boolean.valueOf(arguments[3]).booleanValue(); match= Boolean.valueOf(arguments[4]).booleanValue(); fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX || arguments[0].charAt(0) == IJavaDocTagConstants.JAVADOC_TAG_PREFIX; if ((sentence && match) && !fixed) result= new IJavaCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())}; else { proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence)); size= proposals.size(); if (threshold > 0 && size > threshold) { Collections.sort(proposals); proposals= proposals.subList(size - threshold - 1, size - 1); size= proposals.size(); } boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false; result= new IJavaCompletionProposal[size + (extendable ? 3 : 2)]; for (index= 0; index < size; index++) { proposal= proposals.get(index); result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank()); } if (extendable) result[index++]= new AddWordProposal(arguments[0], context); result[index++]= new WordIgnoreProposal(arguments[0], context); result[index++]= new DisableSpellCheckingProposal(context); } break; } } } } return result; }