@Override protected IMarkerResolution[] getAdaptedResolutions(List<IssueResolution> resolutions) { // choose valid resolutions final List<IssueResolution> validResolutions = new ArrayList<>(resolutions.size()); if (isMultiApplyAttempt()) { // only those that support multi-apply are valid for (IssueResolution currResolution : resolutions) { if (supportsMultiApply(currResolution)) validResolutions.add(currResolution); } if (validResolutions.size() < resolutions.size()) showError_MultiApplyNotSupported(); } else { // all are valid validResolutions.addAll(resolutions); } // perform wrapping IMarkerResolution[] result = new IMarkerResolution[validResolutions.size()]; for (int i = 0; i < validResolutions.size(); i++) result[i] = new MultiResolutionAdapter(validResolutions.get(i)); return result; }
@Override public IMarker[] findOtherMarkers(IMarker[] markers) { List<IMarker> similars = new ArrayList<IMarker>(); MarkerResolutionGenerator mrg = new MarkerResolutionGenerator(); for (int i = 0; i < markers.length; i++) { IMarker marker = markers[i]; IMarkerResolution[] resolutions = mrg.getResolutions(marker); if (resolutions==null) continue; for (int j = 0; j < resolutions.length; j++) { if (resolutions[j].getClass().getName().equals(this.getClass().getName())){ similars.add(marker); } } } IMarker[] ret = new IMarker[similars.size()]; similars.toArray(ret); return ret; }
public IMarkerResolution[] getResolutions(IMarker marker) { List conflictResolutions = new ArrayList(); try { if (marker.getAttribute("textConflict") != null && marker.getAttribute("textConflict").toString().equals("true")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ conflictResolutions.add(new EditConflictsResolution()); conflictResolutions.add(new AcceptMineResolution()); conflictResolutions.add(new AcceptTheirsResolution()); } } catch (Exception e) { SVNUIPlugin.log(e.getMessage()); } conflictResolutions.add(new MarkAsResolvedResolution()); IMarkerResolution[] resolutionArray = new IMarkerResolution[conflictResolutions.size()]; conflictResolutions.toArray(resolutionArray); return resolutionArray; }
/** * Generate resolutions for the given error marker. * Marker type must be SpellChecker.SPELLING_ERROR_MARKER_TYPE. * * @param marker marker for the error * @return an array of resolutions for the given marker * or null if an error occurs or the marker is of wrong type */ public IMarkerResolution[] getResolutions(IMarker marker) { try { if (!SpellChecker.SPELLING_ERROR_MARKER_TYPE.equals(marker.getType())) { return null; } } catch (CoreException e) { return null; } String[] proposals = SpellChecker.getProposals(marker); if (proposals == null || proposals.length == 0) { return null; } IDocument doc = getProviderDocument(); IMarkerResolution[] res = new IMarkerResolution[proposals.length]; for (int i = 0; i < res.length; i++) { res[i] = new SpellingMarkerResolution(proposals[i], doc); } return res; }
private ArrayList<IMarkerResolution> referErrorReference(Message message, NCLSourceDocument nclDoc, String tagname, int offset) { ArrayList<IMarkerResolution> fixes = new ArrayList<IMarkerResolution>(); ArrayList<String> elementsIds = nclDoc.getAllElementsOfType(tagname); for (String id : elementsIds) { int elementOffset = nclDoc.getOffsetByID(id); String refer = nclDoc.getAttributeValueFromCurrentTagName( elementOffset, "refer"); if (refer == null) fixes.add(changeAttributeResolution(message, nclDoc, "refer", id, offset)); } fixes.add(removeAttributeResolution(message, nclDoc, "refer", offset)); fixes.add(removeElementResolution(message, nclDoc, offset)); return fixes; }
private IMarkerResolution addElementResolution(Message message, NCLSourceDocument nclDoc, String element, int offset) { String newElement = element; String tagname = nclDoc.getCurrentTagname(offset); if (element.equals("causalConnector")) newElement = "xconnector"; if ((tagname.equals("bind") && !element.equals("descriptor")) || tagname.equals("port")) newElement = "component"; if (tagname.equals("bindRule")) newElement = "constituent"; String idNewElement = message.getElement().getAttribute(newElement); String label = "Add a <" + element + "> with identifier \"" + idNewElement + "\""; return new QuickFix(label, message, nclDoc, FixType.ADD_ELEMENT, offset, new String[] { element, idNewElement }); }
/** * {@inheritDoc} * * @see org.eclipse.ui.IMarkerResolutionGenerator#getResolutions(org.eclipse.core.resources.IMarker) */ public IMarkerResolution[] getResolutions(IMarker marker) { final List<IMarkerResolution> res = new ArrayList<IMarkerResolution>(); final ILocationDescriptor sourceDescriptor = IdeMappingUtils.adapt(marker, ILocationDescriptor.class); if (sourceDescriptor != null) { try { final Object concept = marker.getAttribute( ISemanticAnnotationMarker.SEMANTIC_CONCEPT_ATTRIBUTE); final IFile file = IdeMappingUtils.adapt(concept, IFile.class); if (file != null) { final ILocationDescriptor targetDescriptor = IdeMappingUtils.adapt(concept, ILocationDescriptor.class); if (MappingUtils.canCreateLink(sourceDescriptor, targetDescriptor)) { res.add(new SemanticLinkMarkerResolution(sourceDescriptor, targetDescriptor)); } } } catch (CoreException e) { Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, UNABLE_TO_GET_THE_CONCEPT_ATTRIBUTE_ON_THE_MARKER, e)); } } return res.toArray(new IMarkerResolution[res.size()]); }
public IMarkerResolution[] getResolutions(IMarker marker) { final IMarkerResolution[] emptyResult = new IMarkerResolution[0]; try { if(!marker.isSubtypeOf(MarkerTypes.ANY_VALIDATION)) return emptyResult; } catch (CoreException e) { return emptyResult; } if(!languageResourceHelper.isLanguageResource(marker.getResource())) { return emptyResult; } XtextEditor editor = getEditor(marker.getResource()); if(editor == null) return emptyResult; IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); if(annotationModel != null && !isMarkerStillValid(marker, annotationModel)) return emptyResult; final Iterable<IssueResolution> resolutions = getResolutions(getIssueUtil().createIssue(marker), editor.getDocument()); return getAdaptedResolutions(Lists.newArrayList(resolutions)); }
@Override public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) { List<IMarker> markers; try { markers = getMarkersFor(invocationContext.getSourceViewer(), invocationContext.getOffset()); } catch (BadLocationException e) { errorMessage = e.getMessage(); return new ICompletionProposal[0]; } List<ICompletionProposal> result = Lists.newArrayList(); for (IMarker marker : markers) { for (IMarkerResolution markerResolution : quickFixer.getResolutions(marker)) { result.add(new MarkerResolutionProposal(marker, markerResolution, invocationContext.getSourceViewer())); } } return result.toArray(new ICompletionProposal[0]); }
@Override public Set<Suggestion> getSuggestions() { Set<Suggestion> suggestions = new LinkedHashSet<Suggestion>(); IMarkerHelpRegistry registry = IDE.getMarkerHelpRegistry(); IMarker marker = getMarker(); EPlan plan = ((MarkerPlanAdvisor)getAdvisor()).getPlan(); if (registry.hasResolutions(marker)) { IMarkerResolution[] resolutions = registry.getResolutions(marker); for (IMarkerResolution resolution : resolutions) { String description = resolution.getLabel() + " for " + getDescription() + " at " + getPrintString(ViolationKey.TIME); IUndoableOperation operation = new MarkerResolutionOperation(this, resolution, plan); Suggestion suggestion = new Suggestion(null, description, operation); suggestions.add(suggestion); } } return suggestions; }
private void fixMarkerViolation(IMarkerHelpRegistry registry, final MarkerViolation markerViolation, boolean reportNoFix) { IMarker marker = markerViolation.getMarker(); if (registry.hasResolutions(marker)) { IMarkerResolution[] resolutions = registry.getResolutions(marker); switch (resolutions.length) { case 0: if (reportNoFix) { reportNoFix(markerViolation); } break; case 1: IMarkerResolution resolution = resolutions[0]; if (resolution instanceof IPlanMarkerResolution) { ((IPlanMarkerResolution)resolution).run(marker, plan); } else { resolution.run(marker); } break; default: chooseResolution(marker, resolutions); } } else if (reportNoFix) { reportNoFix(markerViolation); } }
private void chooseResolution(IMarker marker, IMarkerResolution[] resolutions) { final MarkerResolutionSelectionDialog dialog = new MarkerResolutionSelectionDialog(WidgetUtils.getShell(), resolutions); Display display = WidgetUtils.getDisplay(); final int[] returnCode = new int[1]; display.syncExec(new Runnable() { @Override public void run() { returnCode[0] = dialog.open(); } }); if (returnCode[0] != Window.OK) { return; } Object[] result = dialog.getResult(); if (result != null && result.length > 0) { ((IMarkerResolution) result[0]).run(marker); } }
@Override public IMarkerResolution[] getResolutions(IMarker marker) { ICompletionProposal[] quickfixes = AnalysisQuickfixProcessor.getQuickfixes(marker); IEditorPart editor= findEditor(null, false); if ( ! (editor instanceof AtlEditor ) ) return new IMarkerResolution[0]; AtlEditor atlEditor = (AtlEditor) editor; IDocument document = atlEditor.getDocumentProvider().getDocument(atlEditor.getEditorInput()); IMarkerResolution[] result = new IMarkerResolution[quickfixes.length]; int i = 0; for (ICompletionProposal proposal : quickfixes) { CompletionProposalToMarkerResolutionWrapper wrapper = new CompletionProposalToMarkerResolutionWrapper(proposal, document); result[i++] = wrapper; } return result; // return new IMarkerResolution[] { // new QuickFixTestReplacement() // }; }
@Override public IMarkerResolution[] getResolutions(IMarker marker) { try { Object variantKey = marker.getAttribute(JavaEditorConnector.LOCATION_MARKER_ATTRIBUTE_VARIANT); if (variantKey instanceof String) { Variant variant = VariantRegistry.get((String) variantKey); if (variant != null) { return buildAlternativeVariantLinks(variant); } else { logger.warn(String.format("No variant registered for variant attribure: %s", variantKey)); } } } catch (CoreException e) { logger.warn("Error accessing marker attribute", e); } return new IMarkerResolution[0]; }
protected boolean deregisterBugResolutions(String bugType, Set<Class<? extends IMarkerResolution>> resolutionClasses) { Assert.isNotNull(bugType); Assert.isNotNull(resolutionClasses); if (resolutionClasses.isEmpty()) { return false; } Set<Class<? extends IMarkerResolution>> classes = this.resolutionClasses.get(bugType); if (classes == null) { return false; } classes.removeAll(resolutionClasses); if (classes.isEmpty()) { this.resolutionClasses.remove(bugType); } return true; }
protected boolean addBugResolutions(String bugType, Set<IMarkerResolution> resolutions) { Assert.isNotNull(bugType); Assert.isNotNull(resolutions); if (resolutions.isEmpty()) { return false; } Set<Class<? extends IMarkerResolution>> resolutionClasses = new HashSet<Class<? extends IMarkerResolution>>(); for (IMarkerResolution bugFix : resolutions) { resolutionClasses.add(bugFix.getClass()); } registerBugResolutions(bugType, resolutionClasses); Set<IMarkerResolution> fixes = this.resolutions.get(bugType); if (fixes != null) { return fixes.addAll(resolutions); } this.resolutions.put(bugType, resolutions); return true; }
protected boolean removeBugResolutions(String bugType, Set<IMarkerResolution> resolutions) { Assert.isNotNull(bugType); Assert.isNotNull(resolutions); if (resolutions.isEmpty()) { return false; } Set<Class<? extends IMarkerResolution>> resolutionClasses = new HashSet<Class<? extends IMarkerResolution>>(); for (IMarkerResolution resolution : resolutions) { resolutionClasses.add(resolution.getClass()); } Set<IMarkerResolution> resolutionSet = this.resolutions.get(bugType); if (resolutionSet == null) { return false; } resolutionSet.removeAll(resolutions); if (resolutionSet.isEmpty()) { this.resolutions.remove(bugType); } return deregisterBugResolutions(bugType, resolutionClasses); }
@Override public String toString() { StringBuffer sb = new StringBuffer(); for (Entry<String, Set<Class<? extends IMarkerResolution>>> entry : resolutionClasses.entrySet()) { final String bugType = entry.getKey(); sb.append(bugType); sb.append(" { "); for (Class<? extends IMarkerResolution> resolutionClass : entry.getValue()) { sb.append(resolutionClass.getName()); sb.append(", "); } sb.replace(sb.length() - 2, sb.length(), " }\n"); } // sb.trimToSize(); return sb.toString(); }
@CheckForNull private Class<? extends IMarkerResolution> parseBugResolutionClass(Element resolutionElement) { String className = resolutionElement.getAttribute(RESOLUTION_CLASS); if (className == null) { FindbugsPlugin.getDefault().logWarning("Missing a classname in the resolution element."); return null; } try { Class<?> resolutionClass = Class.forName(className); if (IMarkerResolution.class.isAssignableFrom(resolutionClass)) { return resolutionClass.asSubclass(IMarkerResolution.class); } FindbugsPlugin.getDefault().logError("BugResolution '" + className + "' not a IMarkerResolution"); } catch (ClassNotFoundException e) { FindbugsPlugin.getDefault().logException(e, "BugResolution '" + className + "' not found."); } return null; }
public static void assertLabelsAndDescriptionsMatch(List<QuickFixTestPackage> packages, IMarker[] markers, BugResolutionSource resolutionSource) { Map<String, String> expectedLabelsAndDescriptions = new HashMap<>(); for (int i = 0; i < packages.size(); i++) { IMarker marker = markers[i]; QuickFixTestPackage p = packages.get(i); expectedLabelsAndDescriptions.clear(); for (int j = 0; j < p.expectedLabels.size(); j++) expectedLabelsAndDescriptions.put(p.expectedLabels.get(j), p.expectedDescriptions.get(j)); IMarkerResolution[] resolutions = resolutionSource.getResolutions(marker); assertEquals("The expected number of resolutions available was wrong " + p, expectedLabelsAndDescriptions.size(), resolutions.length); for (int j = 0; j < resolutions.length; j++) { BugResolution resolution = (BugResolution) resolutions[j]; String label = resolution.getLabel(); assertTrue("Should not have seen label: " + label + " in " + expectedLabelsAndDescriptions, expectedLabelsAndDescriptions.containsKey(label)); assertEquals("Description should have matched", expectedLabelsAndDescriptions.get(label), resolution.getDescription()); expectedLabelsAndDescriptions.remove(label); } } }
public void setup() { detectorsToReenable.clear(); final BugResolutionGenerator resolutionGenerator = new BugResolutionGenerator(); // we wrap this in case the underlying generator interface changes. resolutionSource = new BugResolutionSource() { @Override public IMarkerResolution[] getResolutions(IMarker marker) { return resolutionGenerator.getResolutions(marker); } @Override public boolean hasResolutions(IMarker marker) { return resolutionGenerator.hasResolutions(marker); } }; }
private boolean performResolution(QuickFixTestPackage qfPackage, IMarker marker) { if (qfPackage.resolutionToExecute < 0) { return false; // false means the marker should be ignored. } // This doesn't actually click on the bug marker, but it programmatically // gets the same resolutions. IMarkerResolution[] resolutions = resolutionSource.getResolutions(marker); assertTrue("I wanted to execute resolution #" + qfPackage.resolutionToExecute + " of " + qfPackage + " but there were only " + resolutions.length + " to choose from." , resolutions.length > qfPackage.resolutionToExecute); // the order isn't guaranteed, so we have to check the labels. @SuppressFBWarnings("NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD") String resolutionToDo = qfPackage.expectedLabels.get(qfPackage.resolutionToExecute); for (IMarkerResolution resolution : resolutions) { if (resolution.getLabel().equals(resolutionToDo)) { resolution.run(marker); } } return true; // a resolution was performed and we expect the bug marker to disappear. }
@Override public IMarkerResolution[] getResolutions(IMarker marker) { if (existsDirtyEditorFor(marker)) { showError_UnsavedChanges(); return new IMarkerResolution[0]; } return super.getResolutions(marker); }
public static IMarkerResolution [] getResolvers () { String label = MessageUtil.getString("update_severity_to"); List<IMarkerResolution> resolvers = new ArrayList<IMarkerResolution>(); resolvers.add(new InvalidSeverityMarkerResolution(label + " Information","I")); resolvers.add(new InvalidSeverityMarkerResolution(label + " Warning","W")); resolvers.add(new InvalidSeverityMarkerResolution(label + " Error","E")); IMarkerResolution [] ret = new IMarkerResolution [resolvers.size()]; resolvers.toArray(ret); return ret; }
public static IMarkerResolution [] getResolvers () { List<IMarkerResolution> resolvers = new ArrayList<IMarkerResolution>(); List<ResolutionMarkerDescription> resolutionMarkerDescriptions = PathGeneratorDescription.getDescriptions(); Iterator<ResolutionMarkerDescription> iter = resolutionMarkerDescriptions.iterator(); while (iter.hasNext()) { ResolutionMarkerDescription resolutionMarkerDescription = (ResolutionMarkerDescription) iter.next(); resolvers.add(new InvalidPathGeneratorMarkerResolution(resolutionMarkerDescription)); } IMarkerResolution [] ret = new IMarkerResolution [resolvers.size()]; resolvers.toArray(ret); return ret; }
/** * @return */ public static IMarkerResolution [] getResolvers () { List<IMarkerResolution> resolvers = new ArrayList<IMarkerResolution>(); List<ResolutionMarkerDescription> resolutionMarkerDescriptions = PathGeneratorDescription.getDescriptions(); Iterator<ResolutionMarkerDescription> iter = resolutionMarkerDescriptions.iterator(); while (iter.hasNext()) { ResolutionMarkerDescription resolutionMarkerDescription = iter.next(); resolvers.add(new InvalidAnnotationPathGeneratorMarkerResolution(resolutionMarkerDescription)); } IMarkerResolution [] ret = new IMarkerResolution [resolvers.size()]; resolvers.toArray(ret); return ret; }
@Override public IMarkerResolution[] getResolutions(IMarker marker) { Object attr; try { attr = marker.getAttribute(IJavaModelMarker.ID); IMarkerResolution[] resolutions = resolvers.get(attr); return resolutions; } catch (CoreException e) { ResourceManager.logException(e); } return new IMarkerResolution[0]; }
@Test public void testInvalidGenerator () throws CoreException, IOException, InterruptedException { System.out.println("XXXXXXXXXXXXXXXXXXXX testInvalidGenerator"); String wrongPathGenerator = "xxx"; GW4EProject project = new GW4EProject(bot, gwproject); project.createProjectWithoutError( TEST_RESOURCE_FOLDER, PACKAGE_NAME, graphMLFilename); String policiesFileName = PreferenceManager.getBuildPoliciesFileName(gwproject); IPath path = new Path (gwproject).append(TEST_RESOURCE_FOLDER).append(PACKAGE_NAME).append(policiesFileName); IFile buildPolicyFile = (IFile) ResourceManager.getResource(path.toString()); project.setPathGenerator (buildPolicyFile , graphMLFilename, wrongPathGenerator); project.cleanBuild(); String expectedErrorMessageInProblemView = "Missing severity flag for '" + wrongPathGenerator + "'"; ProblemView pv = ProblemView.open(bot); IMarkerResolution [] markers = InvalidSeverityMarkerResolution.getResolvers(); String error1 = MessageUtil.getString("invalidpathgeneratoroudinbuildpolicies") + wrongPathGenerator; pv.executeQuickFixForErrorMessage( expectedErrorMessageInProblemView, markers[0].getLabel(), new ICondition [] {new ErrorIsInProblemView(pv,error1)} ); pv.close();//Mandatory pv.open(bot); ResolutionMarkerDescription description = PathGeneratorDescription.getDescriptions().get(9); pv.executeQuickFixForErrorMessage( error1, description.toString(), new ICondition [] {new NoErrorInProblemView(pv)} ); String updatedValue = project.getPathGenerator (buildPolicyFile , graphMLFilename); String expectedValue = description.getGenerator() + ";" + PreferenceManager.getDefaultSeverity(gwproject); assertEquals("Wrong policies found in the build policies file", expectedValue, updatedValue); }
@Test public void testInvalidSeverity () throws CoreException, IOException, InterruptedException { System.out.println("XXXXXXXXXXXXXXXXXXXX testInvalidSeverity"); String wrongSeverity = "Z"; String pathGeneratorPrefix = "random(vertex_coverage(100));E;random(edge_coverage(100));"; GW4EProject project = new GW4EProject(bot, gwproject); project.createProjectWithoutError( TEST_RESOURCE_FOLDER, PACKAGE_NAME, graphMLFilename); String policiesFileName = PreferenceManager.getBuildPoliciesFileName(gwproject); IPath path = new Path (gwproject).append(TEST_RESOURCE_FOLDER).append(PACKAGE_NAME).append(policiesFileName); IFile buildPolicyFile = (IFile) ResourceManager.getResource(path.toString()); project.setPathGenerator (buildPolicyFile , graphMLFilename, pathGeneratorPrefix + wrongSeverity); project.cleanBuild(); String expectedErrorMessageInProblemView = "Invalid severity flag found '" + wrongSeverity + "' (Choose one of E,W,I)" ; ProblemView pv = ProblemView.open(bot); IMarkerResolution [] resolutions = InvalidSeverityMarkerResolution.getResolvers(); pv.executeQuickFixForErrorMessage( expectedErrorMessageInProblemView, resolutions [0].getLabel(), new ICondition [] {new NoErrorInProblemView(pv)} ); pv.close();//Mandatory String updatedValue = project.getPathGenerator (buildPolicyFile , graphMLFilename); String expectedValue = pathGeneratorPrefix + ((InvalidSeverityMarkerResolution)resolutions [0]).getSeverity(); assertEquals("Wrong severity found in the build policies file", expectedValue, updatedValue); }
@Override public IMarkerResolution[] getResolutions(IMarker marker) { List<IMarkerResolution> res = new ArrayList<>(1); try { if (MarkerUtils.isOptionType(marker, PropertyType.insert_final_newline.getName())) { res.add(InsertFinalNewLineMarkerResolution.INSTANCE); } else if (MarkerUtils.isOptionType(marker, PropertyType.trim_trailing_whitespace.getName())) { res.add(TrimTrailingWhitespaceMarkerResolution.INSTANCE); } } catch (CoreException e) { e.printStackTrace(); } return res.toArray(new IMarkerResolution[res.size()]); }
@Override public IMarkerResolution[] getResolutions(IMarker mk) { try { Object problem = mk.getAttribute(IMarker.MESSAGE); String diff = mk.getAttribute("diff", null); if (diff != null) { diff = DiffUtils.cleanDiff(diff); return new IMarkerResolution[] { new QuickFix("Apply patch for " + problem, diff) }; } return new IMarkerResolution[] {}; } catch (CoreException ex) { return new IMarkerResolution[0]; } }
@Test public void test() throws IOException, CoreException { QuickFixer qf = new QuickFixer(); IMarkerResolution[] mr = qf.getResolutions(marker); mr[0].run(marker); assertEquals("", IOUtils.toString(file.getContents())); }
@Test public void testGetResolutions_versionElement() throws CoreException { AppEngineWebMarkerResolutionGenerator resolution = new AppEngineWebMarkerResolutionGenerator(); IMarker marker = Mockito.mock(IMarker.class); Mockito.when(marker.getType()) .thenReturn("com.google.cloud.tools.eclipse.appengine.validation.versionMarker"); IMarkerResolution[] resolutions = resolution.getResolutions(marker); assertEquals(1, resolutions.length); assertEquals(VersionQuickFix.class, resolutions[0].getClass()); }
@Test public void testGetResolutions_applicationElement() throws CoreException { AppEngineWebMarkerResolutionGenerator resolution = new AppEngineWebMarkerResolutionGenerator(); IMarker marker = Mockito.mock(IMarker.class); Mockito.when(marker.getType()) .thenReturn("com.google.cloud.tools.eclipse.appengine.validation.applicationMarker"); IMarkerResolution[] resolutions = resolution.getResolutions(marker); assertEquals(1, resolutions.length); assertEquals(ApplicationQuickFix.class, resolutions[0].getClass()); }
@Test public void testGetResolutions() { ServletMarkerResolutionGenerator resolution = new ServletMarkerResolutionGenerator(); IMarker marker = Mockito.mock(IMarker.class); IMarkerResolution[] resolutions = resolution.getResolutions(marker); assertEquals(1, resolutions.length); assertNotNull(resolutions[0]); }
@Override public IMarkerResolution[] getResolutions(IMarker marker) { IMarkerResolution[] markerResolutions = new IMarkerResolution[1]; IMarkerResolution fix = new ToServlet25QuickFix(); markerResolutions[0] = fix; return markerResolutions; }
public void getMarkerResolutions(IMarker marker){ SootAttributeResolutionGenerator sarg = new SootAttributeResolutionGenerator(); if (sarg.hasResolutions(marker)){ IMarkerResolution [] res = sarg.getResolutions(marker); for (int i = 0; i < res.length; i++){ //System.out.println("res: "+res[i].getLabel()); } } }
/** * Converts the given marker resolutions to completion proposals. * * @param resolutions marker resolutions * @param marker marker that holds the given resolutions * @return completion proposals for the given marker */ private static ICompletionProposal[] convertAll(IMarkerResolution[] resolutions, IMarker marker) { ICompletionProposal[] array = new ICompletionProposal[resolutions.length]; for (int i = 0; i < resolutions.length; i++) { SpellingMarkerResolution smr = (SpellingMarkerResolution) resolutions[i]; array[i] = new SpellingCompletionProposal(smr.getSolution(), marker); } return array; }
private ArrayList<IMarkerResolution> interfaceReferenceError( Message message, NCLSourceDocument nclDoc, int offset) { ArrayList<IMarkerResolution> fixes = new ArrayList<IMarkerResolution>(); int componentOffset = nclDoc.getOffsetByID(nclDoc .getAttributeValueFromCurrentTagName(offset, "component")); if (componentOffset == -1) return fixes; String tag = nclDoc.getCurrentTagname(componentOffset); Vector<Integer> childrenOffsets = nclDoc .getChildrenOffsets(componentOffset); for (int Offset : childrenOffsets) { String id = ""; if ((tag.equals("media") && nclDoc.getCurrentTagname(Offset) .equals("area")) || tag.equals("context") && nclDoc.getCurrentTagname(Offset).equals("port") || tag.equals("switch") && nclDoc.getCurrentTagname(Offset).equals("switchPort")) { id = nclDoc.getAttributeValueFromCurrentTagName(Offset, "id"); if (id != null && !id.equals("")) fixes.add(changeAttributeResolution(message, nclDoc, "interface", id, offset)); } } fixes.add(removeAttributeResolution(message, nclDoc, "interface", offset)); return fixes; }