org.eclipse.core.resources.IMarker Java Examples

The following examples show how to use org.eclipse.core.resources.IMarker. 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: FilterPatternAction.java    From spotbugs with GNU Lesser General Public License v2.1 7 votes vote down vote up
private String getPatternOrPatternType() {
    if (data instanceof IMarker) {
        BugInstance bug = MarkerUtil.findBugInstanceForMarker((IMarker) data);
        if (bug == null) {
            return null;
        }
        if (useSpecificPattern) {
            // uses specific pattern kind, the naming "Type" is misleading
            return bug.getType();
        }
        // uses pattern type, the naming "Abbrev" is misleading
        return bug.getAbbrev();
    } else if (data instanceof BugPattern) {
        BugPattern pattern = (BugPattern) data;
        if (useSpecificPattern) {
            // uses specific pattern kind, the naming "Type" is misleading
            return pattern.getType();
        }
        // uses pattern type, the naming "Abbrev" is misleading
        return pattern.getAbbrev();
    } else if (data instanceof BugCode) {
        // same as pattern.getAbbrev(): it's pattern type
        return ((BugCode) data).getAbbrev();
    }
    return null;
}
 
Example #2
Source File: OrganizeImportsFixesUnused.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void findAndDeleteUnusedImports(PySelection ps, PyEdit edit, IDocumentExtension4 doc, IFile f)
        throws Exception {
    Iterator<MarkerAnnotationAndPosition> it;
    if (edit != null) {
        it = edit.getPySourceViewer().getMarkerIterator();
    } else {

        IMarker markers[] = f.findMarkers(IMiscConstants.PYDEV_ANALYSIS_PROBLEM_MARKER, true, IResource.DEPTH_ZERO);
        MarkerAnnotationAndPosition maap[] = new MarkerAnnotationAndPosition[markers.length];
        int ix = 0;
        for (IMarker m : markers) {
            int start = (Integer) m.getAttribute(IMarker.CHAR_START);
            int end = (Integer) m.getAttribute(IMarker.CHAR_END);
            maap[ix++] =
                    new MarkerAnnotationAndPosition(new MarkerAnnotation(m), new Position(start, end - start));
        }
        it = Arrays.asList(maap).iterator();
    }
    ArrayList<MarkerAnnotationAndPosition> unusedImportsMarkers = getUnusedImports(it);
    sortInReverseDocumentOrder(unusedImportsMarkers);
    deleteImports(doc, ps, unusedImportsMarkers);

}
 
Example #3
Source File: WorkspaceDiagnosticsHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static Diagnostic toDiagnostic(IDocument document, IMarker marker, boolean isDiagnosticTagSupported) {
	if (marker == null || !marker.exists()) {
		return null;
	}
	Diagnostic d = new Diagnostic();
	d.setSource(JavaLanguageServerPlugin.SERVER_SOURCE_ID);
	d.setMessage(marker.getAttribute(IMarker.MESSAGE, ""));
	int problemId = marker.getAttribute(IJavaModelMarker.ID, 0);
	d.setCode(String.valueOf(problemId));
	d.setSeverity(convertSeverity(marker.getAttribute(IMarker.SEVERITY, -1)));
	d.setRange(convertRange(document, marker));
	if (isDiagnosticTagSupported) {
		d.setTags(DiagnosticsHandler.getDiagnosticTag(problemId));
	}
	return d;
}
 
Example #4
Source File: EclipseBuildSupportTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testUpdateJar() throws Exception {
	importProjects("eclipse/updatejar");
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("updatejar");
	assertIsJavaProject(project);
	List<IMarker> errors = ResourceUtils.getErrorMarkers(project);
	assertEquals("Unexpected errors " + ResourceUtils.toString(errors), 2, errors.size());
	File projectFile = project.getLocation().toFile();
	File validFooJar = new File(projectFile, "foo.jar");
	File destLib = new File(projectFile, "lib");
	FileUtils.copyFileToDirectory(validFooJar, destLib);
	File newJar = new File(destLib, "foo.jar");
	projectsManager.fileChanged(newJar.toPath().toUri().toString(), CHANGE_TYPE.CREATED);
	waitForBackgroundJobs();
	errors = ResourceUtils.getErrorMarkers(project);
	assertEquals("Unexpected errors " + ResourceUtils.toString(errors), 0, errors.size());

}
 
Example #5
Source File: AbstractProgramRunner.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
    * Create a layout warning marker to the given resource.
    *
    * @param resource the file where the problem occurred
    * @param message error message
    * @param lineNumber line number
    * @param markerType
    * @param severity Severity of the error
    */
   @SuppressWarnings("unchecked")
protected static void createMarker(IResource resource, 
   		Integer lineNumber, String message, String markerType, int severity) {
   	int lineNr = -1;
   	if (lineNumber != null) {
   		lineNr = lineNumber;
   	}
   	IMarker marker = AbstractProgramRunner.findMarker(resource, lineNr, message, markerType);
   	if (marker == null) {
   		try {
   			HashMap map = new HashMap();
   			map.put(IMarker.MESSAGE, message);
   			map.put(IMarker.SEVERITY, new Integer (severity));

   			if (lineNumber != null)
   				map.put(IMarker.LINE_NUMBER, lineNumber);

   			MarkerUtilities.createMarker(resource, map, markerType);
   		} catch (CoreException e) {
   			throw new RuntimeException(e);
   		}
   	}
   }
 
Example #6
Source File: PropertyPageAdapterFactory.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
@SuppressWarnings("rawtypes")
public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (adapterType == IPropertySheetPage.class) {
        if (adaptableObject instanceof BugExplorerView || adaptableObject instanceof AbstractFindbugsView) {
            return new BugPropertySheetPage();
        }
    }
    if (adapterType == IPropertySource.class) {
        if (adaptableObject instanceof BugPattern || adaptableObject instanceof BugInstance
                || adaptableObject instanceof DetectorFactory || adaptableObject instanceof Plugin
                || adaptableObject instanceof BugGroup
                || adaptableObject instanceof BugAnnotation) {
            return new PropertySource(adaptableObject);
        }
        IMarker marker = Util.getAdapter(IMarker.class, adaptableObject);
        if (!MarkerUtil.isFindBugsMarker(marker)) {
            return null;
        }
        return new MarkerPropertySource(marker);
    }
    return null;
}
 
Example #7
Source File: Auditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void handleCheckstyleFailure(IProject project, CheckstyleException e)
        throws CheckstylePluginException {
  try {

    CheckstyleLog.log(e);

    // remove pre-existing project level marker
    project.deleteMarkers(CheckstyleMarker.MARKER_ID, false, IResource.DEPTH_ZERO);

    Map<String, Object> attrs = new HashMap<>();
    attrs.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_NORMAL));
    attrs.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
    attrs.put(IMarker.MESSAGE, NLS.bind(Messages.Auditor_msgMsgCheckstyleInternalError, null));

    IMarker projectMarker = project.createMarker(CheckstyleMarker.MARKER_ID);
    projectMarker.setAttributes(attrs);
  } catch (CoreException ce) {
    CheckstylePluginException.rethrow(e);
  }
}
 
Example #8
Source File: BuildInstruction.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private boolean shouldGenerate(Resource resource, IProject aProject) {
	try {
		Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(resource.getURI());
		for (Pair<IStorage, IProject> pair : storages) {
			if (pair.getFirst() instanceof IFile && pair.getSecond().equals(aProject)) {
				IFile file = (IFile) pair.getFirst();
				int findMaxProblemSeverity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
				// If the generator itself placed an error marker on the resource, we have to ignore that error.
				// Easiest way here is to remove that error marker-type and look for other severe errors once more:
				if (findMaxProblemSeverity == IMarker.SEVERITY_ERROR) {
					// clean
					GeneratorMarkerSupport generatorMarkerSupport = injector
							.getInstance(GeneratorMarkerSupport.class);
					generatorMarkerSupport.deleteMarker(resource);
					// and recompute:
					findMaxProblemSeverity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
				}
				// the final decision to build:
				return findMaxProblemSeverity != IMarker.SEVERITY_ERROR;
			}
		}
		return false;
	} catch (CoreException exc) {
		throw new WrappedException(exc);
	}
}
 
Example #9
Source File: BIRTGotoMarker.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void gotoXMLSourcePage( final IMarker marker )
{
	if ( activatePage( MultiPageReportEditor.XMLSourcePage_ID ) == false )
	{
		return;
	}

	final IReportEditorPage reportXMLSourcePage = (IReportEditorPage) editorPart.getActivePageInstance( );
	Display.getCurrent( ).asyncExec( new Runnable( ) {

		public void run( )
		{
			gotoXMLSourceMarker( reportXMLSourcePage, marker );
		}
	} );
}
 
Example #10
Source File: QuickFix.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
public void run(IMarker marker) {
	try {
		String[] path = ((String) marker.getAttribute("PATH")).split("/");
		switch (fixType) {
			case ADD_TO_TAXONOMY:
				addToTaxonomy(path);
				break;
			case DELETE_FROM_FILE:
				deleteFromFile(path, marker.getAttribute(IMarker.LOCATION).toString());
				break;
			case MATCH_TAXONOMY:
				moveTermInFile(path, ((String) marker.getAttribute("PATH2")).split("/"), marker.getAttribute(IMarker.LOCATION).toString());
				break;
		}
		
		marker.delete();
	} catch (CoreException e) {
		e.printStackTrace();
	}
}
 
Example #11
Source File: TddTestWorkbench.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Callback that'll check if there are error markers in the mod1.py resource
 */
private ICallback<Boolean, Object> getHasBothErrorMarkersCondition(final IFile file) {
    return new ICallback<Boolean, Object>() {

        @Override
        public Boolean call(Object arg) {
            try {
                //must have both problems: syntax and analysis error!!
                IMarker[] markers = file.findMarkers(AnalysisRunner.PYDEV_ANALYSIS_PROBLEM_MARKER, false,
                        IResource.DEPTH_ZERO);
                return markers.length > 0;
            } catch (CoreException e) {
                throw new RuntimeException(e);
            }
        }
    };
}
 
Example #12
Source File: BuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.4
 */
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject,
		Collection<OutputConfiguration> outputConfigurations) throws CoreException {
	Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
	for (OutputConfiguration config : outputConfigurations) {
		if (config.isCleanUpDerivedResources()) {
			List<IMarker> markers = Lists.newArrayList();
			for (IContainer container : getOutputs(builtProject, config)) {
				Iterables.addAll(
						markers,
						derivedResourceMarkers.findDerivedResourceMarkers(container,
								generatorIdProvider.getGeneratorIdentifier()));
			}
			generatorMarkers.put(config, markers);
		}
	}
	return buildGeneratorMarkersReverseLookupMap(generatorMarkers);
}
 
Example #13
Source File: RebuildAffectedResourcesTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
public void assertHasErrors(final IFile file, final String msgPart) {
  try {
    final IMarker[] findMarkers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    for (final IMarker iMarker : findMarkers) {
      if (((MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) && MarkerUtilities.getMessage(iMarker).contains(msgPart))) {
        return;
      }
    }
    IPath _fullPath = file.getFullPath();
    String _plus = ((("Expected an error marker containing \'" + msgPart) + "\' on ") + _fullPath);
    String _plus_1 = (_plus + " but found ");
    final Function1<IMarker, String> _function = (IMarker it) -> {
      return MarkerUtilities.getMessage(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<IMarker, String>map(((List<IMarker>)Conversions.doWrapArray(findMarkers)), _function), ",");
    String _plus_2 = (_plus_1 + _join);
    Assert.fail(_plus_2);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #14
Source File: IssueReportFix.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void run(IMarker curMarker) {
	marker = curMarker;

	Reporter dialog = new Reporter(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), marker.getResource().getName());
	dialog.create();

	if (dialog.open() == Window.OK) {
		try {
			createIssue(dialog.getIssueTitle(), dialog.getIssueText(), dialog.getAttachmentIndex(), getAttachment(dialog.getAttachmentIndex()));
		}
		catch (CoreException e) {
			Activator.getDefault().logError(e);
		}
	}
}
 
Example #15
Source File: ProfilerAbstractBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testFullBuildBigProjectWithLinkingErrors() throws Exception {
	IJavaProject project =  workspace.createJavaProject("foo");
	workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IFolder folder = project.getProject().getFolder("src");
	int NUM_FILES = 200;
	IFile[] files = new IFile[NUM_FILES];
	StopWatch timer = new StopWatch();
	for (int i = 0; i < NUM_FILES; i++) {
		IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
		files[i] = file;
		String contents = "object Foo" + i + " references Foo" + (i * 1000);
		if (i == NUM_FILES)
			contents = "object Foo" + i;
		file.create(new StringInputStream(contents), true, workspace.monitor());
	}
	logAndReset("Creating files", timer);
	workspace.build();
	logAndReset("Auto build", timer);
	IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE);
	assertEquals(NUM_FILES-1,iMarkers.length);
}
 
Example #16
Source File: SuppressResolution.java    From cppcheclipse with Apache License 2.0 6 votes vote down vote up
public void run(IMarker marker) {
	try {
		IResource resource = (IResource)marker.getResource();
		IProject project = resource.getProject();
		String problemId = marker.getAttribute(ProblemReporter.ATTRIBUTE_ID, ""); //$NON-NLS-1$
		int line = marker.getAttribute(ProblemReporter.ATTRIBUTE_ORIGINAL_LINE_NUMBER, 0);
		File file = new File(marker.getAttribute(ProblemReporter.ATTRIBUTE_FILE, "")); //$NON-NLS-1$
		marker.delete();
		SuppressionProfile profile = new SuppressionProfile(CppcheclipsePlugin.getProjectPreferenceStore(project), project);
		suppress(profile, resource, file, problemId, line);
		profile.save();
	} 
	catch (Exception e) {
		CppcheclipsePlugin.logError("Could not save suppression", e);
	}
}
 
Example #17
Source File: EclipseBasedShouldGenerate.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean shouldGenerate(Resource resource, CancelIndicator cancelIndicator) {
	URI uri = resource.getURI();
	if (uri == null || !uri.isPlatformResource()) {
		return false;
	}

	IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(uri.toPlatformString(true)));
	if (member != null && member.getType() == IResource.FILE) {
		ProjectConfigAdapter projectConfigAdapter = ProjectConfigAdapter.findInEmfObject(resource.getResourceSet());
		if (projectConfigAdapter != null) {
			IProjectConfig projectConfig = projectConfigAdapter.getProjectConfig();
			if (projectConfig != null && Objects.equals(member.getProject().getName(), projectConfig.getName())) {
				try {
					return member.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE) != IMarker.SEVERITY_ERROR;
				} catch (CoreException e) {
					LOG.error("The resource " + member.getName() + " does not exist", e);
					return false;
				}
			}
		}
	}
	return false;
}
 
Example #18
Source File: MarkerCreator.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.0
 */
protected void setMarkerAttributes(Issue issue, IResource resource, IMarker marker) throws CoreException {
	String lineNR = "";
	if (issue.getLineNumber() != null) {
		lineNR = "line: " + issue.getLineNumber() + " ";
	}
	marker.setAttribute(IMarker.LOCATION, lineNR + resource.getFullPath().toString());
	marker.setAttribute(Issue.CODE_KEY, issue.getCode());		
	marker.setAttribute(IMarker.SEVERITY, getSeverity(issue));
	marker.setAttribute(IMarker.CHAR_START, issue.getOffset());
	if(issue.getOffset() != null && issue.getLength() != null)
		marker.setAttribute(IMarker.CHAR_END, issue.getOffset()+issue.getLength());
	marker.setAttribute(IMarker.LINE_NUMBER, issue.getLineNumber());
	marker.setAttribute(Issue.COLUMN_KEY, issue.getColumn());
	marker.setAttribute(IMarker.MESSAGE, issue.getMessage());

	if (issue.getUriToProblem()!=null) 
		marker.setAttribute(Issue.URI_KEY, issue.getUriToProblem().toString());
	if(issue.getData() != null && issue.getData().length > 0) {
		marker.setAttribute(Issue.DATA_KEY, Strings.pack(issue.getData()));
	}
	if (resolutionProvider != null && resolutionProvider.hasResolutionFor(issue.getCode())) {
		marker.setAttribute(FIXABLE_KEY, true);
	}
}
 
Example #19
Source File: BugResolutionAssociations.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public IMarkerResolution[] createBugResolutions(String bugType, IMarker marker) {
    Assert.isNotNull(bugType);
    Assert.isNotNull(marker);
    List<QuickFixContribution> classes = quickFixes.get(bugType);
    if (classes == null) {
        return new IMarkerResolution[0];
    }

    Set<BugResolution> fixes = instantiateBugResolutions(classes);
    for (Iterator<BugResolution> iterator = fixes.iterator(); iterator.hasNext();) {
        BugResolution fix = iterator.next();
        if (fix.isApplicable(marker)) {
            fix.setMarker(marker);
        } else {
            iterator.remove();
        }
    }
    return fixes.toArray(new IMarkerResolution[fixes.size()]);
}
 
Example #20
Source File: CrossflowMarkerNavigationProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
public static IMarker addMarker(IFile file, String elementId, String location, String message, int statusSeverity) {
	IMarker marker = null;
	try {
		marker = file.createMarker(MARKER_TYPE);
		marker.setAttribute(IMarker.MESSAGE, message);
		marker.setAttribute(IMarker.LOCATION, location);
		marker.setAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, elementId);
		int markerSeverity = IMarker.SEVERITY_INFO;
		if (statusSeverity == IStatus.WARNING) {
			markerSeverity = IMarker.SEVERITY_WARNING;
		} else if (statusSeverity == IStatus.ERROR || statusSeverity == IStatus.CANCEL) {
			markerSeverity = IMarker.SEVERITY_ERROR;
		}
		marker.setAttribute(IMarker.SEVERITY, markerSeverity);
	} catch (CoreException e) {
		CrossflowDiagramEditorPlugin.getInstance().logError("Failed to create validation marker", e); //$NON-NLS-1$
	}
	return marker;
}
 
Example #21
Source File: CheckstyleMarkerFilter.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Selects marker by matching the message against regular expressions.
 *
 * @param item
 *          the marker
 * @return <code>true</code> if the marker is selected
 */
private boolean selectByRegex(IMarker item) {

  if (mFilterByRegex) {

    int size = mFilterRegex != null ? mFilterRegex.size() : 0;
    for (int i = 0; i < size; i++) {

      String regex = mFilterRegex.get(i);

      String message = item.getAttribute(IMarker.MESSAGE, null);

      if (message != null && message.matches(regex)) {
        return false;
      }
    }
  }
  return true;

}
 
Example #22
Source File: BuildInstruction.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void recordDerivedResources(final String uri) {
	for (OutputConfiguration config : outputConfigurations.values()) {
		if (config.isCleanUpDerivedResources()) {
			Iterable<IMarker> markers = generatorMarkers.get(config);
			if (null != markers) {
				for (IMarker marker : markers) {
					String source = derivedResourceMarkers.getSource(marker);
					if (source != null && source.equals(uri)) {
						derivedResources.add((IFile) marker.getResource());
					}
				}
			}
		}
	}
}
 
Example #23
Source File: MarkerUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * createMarker
 * 
 * @param resource
 * @param attributes
 * @param markerType
 * @return IMarker
 * @throws CoreException
 */
public static IMarker createMarker(IUniformResource resource, Map attributes, String markerType)
		throws CoreException
{
	MarkerInfo info = new MarkerInfo();
	info.setType(markerType);
	info.setCreationTime(System.currentTimeMillis());
	if (attributes != null)
	{
		info.setAttributes(attributes, getMarkerManager().isPersistent(info));
	}
	getMarkerManager().add(resource, info);
	return new UniformResourceMarker(resource, info.getId());
}
 
Example #24
Source File: MarkerUtilTest.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testIsFiltered_EmptyFilters() throws CoreException {
    // Load bugs from a file
    loadXml(createFindBugsWorker(), getBugsFileLocation());

    IMarker marker = getAnyMarker();
    assertFalse(MarkerUtil.isFiltered(marker, Collections.<String>emptySet()));
}
 
Example #25
Source File: ExternalFileAnnotationModel.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void deleteMarkers(final IMarker[] markers) throws CoreException
{
	ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable()
	{
		public void run(IProgressMonitor monitor) throws CoreException
		{
			for (int i = 0; i < markers.length; ++i)
			{
				markers[i].delete();
			}
		}
	}, null, IWorkspace.AVOID_UPDATE, null);
}
 
Example #26
Source File: MarkerRulerAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void update() {
    if (markers.size() > 0) {
        IMarker marker = markers.get(0);
        if (action.getId().endsWith("showBugInfo")) {
            FindbugsPlugin.showMarker(marker, FindbugsPlugin.DETAILS_VIEW_ID, editor);
        } else {
            // TODO show all
            FindbugsPlugin.showMarker(marker, FindbugsPlugin.TREE_VIEW_ID, editor);
        }
        markers.clear();
    }
}
 
Example #27
Source File: EntryRetriever.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
private void inBibtexEntry(TIdentifier tid) {
    currEntry = new ReferenceEntry(tid.getText());
    currEntry.startLine = tid.getLine();
    currEntryInfo = new StringBuffer();
    
    Integer x=allDefinedKeys.put(currEntry.key, currEntry.startLine);
    if (x != null) {
        warnings.add(new ParseErrorMessage(currEntry.startLine,
                tid.getPos() - 1, currEntry.key.length(),
                "BibTex key " + currEntry.key + " is not unique: also defined in line "+x,
                IMarker.SEVERITY_WARNING));
    }
}
 
Example #28
Source File: UndefinedVariableFixParticipant.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see IAnalysisMarkersParticipant#addProps(MarkerAnnotation, IAnalysisPreferences, String, PySelection, int, IPythonNature,
 * PyEdit, List)
 *
 */
@Override
public void addProps(MarkerAnnotationAndPosition markerAnnotation, IAnalysisPreferences analysisPreferences,
        String line, PySelection ps, int offset, IPythonNature initialNature, PyEdit edit,
        List<ICompletionProposalHandle> props)
        throws BadLocationException, CoreException {
    IMarker marker = markerAnnotation.markerAnnotation.getMarker();
    Integer id = (Integer) marker.getAttribute(AnalysisRunner.PYDEV_ANALYSIS_TYPE);
    if (id != IAnalysisPreferences.TYPE_UNDEFINED_VARIABLE) {
        return;
    }
    if (initialNature == null) {
        return;
    }
    ICodeCompletionASTManager astManager = initialNature.getAstManager();
    if (astManager == null) {
        return;
    }

    if (markerAnnotation.position == null) {
        return;
    }
    int start = markerAnnotation.position.offset;
    int end = start + markerAnnotation.position.length;
    UndefinedVariableQuickFixCreator.createImportQuickProposalsFromMarkerSelectedText(ps, offset, initialNature,
            props, astManager, start, end, forceReparseOnApply);
}
 
Example #29
Source File: WorkbenchResolutionAdaptorRunTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
private void mockMarkerResource(final URI uri) throws CoreException {
  // Resource is a file and so gets processed
  when(mockMarker.getResource()).thenReturn(mockFile);
  when(mockFile.getName()).thenReturn(uri.lastSegment());
  when(mockFile.findMarkers(anyString(), anyBoolean(), anyInt())).thenReturn(new IMarker[] {});
  when(mockMarker.getAttribute(eq(Issue.URI_KEY), anyString())).thenReturn(uri.toString());
  when(mockMarker.isSubtypeOf(eq(MarkerTypes.ANY_VALIDATION))).thenReturn(true);
  when(mockStorage2UriMapper.getUri(eq(mockFile))).thenReturn(uri);
  @SuppressWarnings("unchecked")
  Iterable<Pair<IStorage, IProject>> storages = Lists.newArrayList(Tuples.create((IStorage) mockFile, mock(IProject.class)));
  when(mockStorage2UriMapper.getStorages(eq(uri))).thenReturn(storages);
  when(mockLanguageResourceHelper.isLanguageResource(eq(mockFile))).thenReturn(true);
}
 
Example #30
Source File: MarkerUtil.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static @CheckForNull BugCode findBugCodeForMarker(IMarker marker) {
    try {
        Object bugCode = marker.getAttribute(FindBugsMarker.PATTERN_TYPE);
        if (bugCode instanceof String) {
            return DetectorFactoryCollection.instance().getBugCode((String) bugCode);
        }
    } catch (CoreException e) {
        FindbugsPlugin.getDefault().logException(e, "Marker does not contain bug code");
        return null;
    }
    return null;
}