本文整理匯總了Java中org.eclipse.core.resources.IResource.findMarkers方法的典型用法代碼示例。如果您正苦於以下問題:Java IResource.findMarkers方法的具體用法?Java IResource.findMarkers怎麽用?Java IResource.findMarkers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IResource
的用法示例。
在下文中一共展示了IResource.findMarkers方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: assertMarkers
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
/***/
public static IMarker[] assertMarkers(String assertMessage, final IResource resource, String markerType, int count,
final Predicate<IMarker> markerPredicate) throws CoreException {
IMarker[] markers = resource.findMarkers(markerType, true, IResource.DEPTH_INFINITE);
List<IMarker> markerList = from(Arrays.asList(markers)).filter(markerPredicate).toList();
if (markerList.size() != count) {
StringBuilder message = new StringBuilder(assertMessage);
message.append("\nbut was:");
for (IMarker marker : markerList) {
message.append("\n");
message.append("line " + MarkerUtilities.getLineNumber(marker) + ": ");
message.append(marker.getAttribute(IMarker.MESSAGE, "<no message>"));
}
Assert.assertEquals(message.toString(), count, markers.length);
}
return markers;
}
示例2: assertIssues
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
/**
* Asserts that the given resource (usually an N4JS file) contains issues with the given messages and no other
* issues. Each message given should be prefixed with the line numer where the issues occurs, e.g.:
*
* <pre>
* line 5: Couldn't resolve reference to identifiable element 'unknown'.
* </pre>
*
* Column information is not provided, so this method is not intended for several issues within a single line.
*/
public static void assertIssues(final IResource resource, String... expectedMessages) throws CoreException {
final IMarker[] markers = resource.findMarkers(MarkerTypes.ANY_VALIDATION, true, IResource.DEPTH_INFINITE);
final String[] actualMessages = new String[markers.length];
for (int i = 0; i < markers.length; i++) {
final IMarker m = markers[i];
actualMessages[i] = "line " + MarkerUtilities.getLineNumber(m) + ": " + m.getAttribute(IMarker.MESSAGE);
}
if (!Objects.equals(
new HashSet<>(Arrays.asList(actualMessages)),
new HashSet<>(Arrays.asList(expectedMessages)))) {
final Joiner joiner = Joiner.on("\n ");
final String msg = "expected these issues:\n"
+ " " + joiner.join(expectedMessages) + "\n"
+ "but got these:\n"
+ " " + joiner.join(actualMessages);
System.out.println("*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*");
System.out.println(msg);
System.out.println("*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*");
Assert.fail(msg);
}
}
示例3: findMarker
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
private IMarker findMarker(IResource resource, String message, int lineNumber, String type) throws CoreException {
IMarker[] marker = resource.findMarkers(type, true, IResource.DEPTH_ZERO);
for (int i = 0; i < marker.length; i++) {
IMarker currentMarker = marker[i];
if (currentMarker == null) {
continue;
}
Object lineNrAttribute = currentMarker.getAttribute(IMarker.LINE_NUMBER);
String markerLineNumber = null;
if (lineNrAttribute != null) {
markerLineNumber = lineNrAttribute.toString();
}
Object messageAttribute = currentMarker.getAttribute(IMarker.MESSAGE);
String markerMessage = null;
if (messageAttribute != null) {
markerMessage = messageAttribute.toString();
}
boolean sameMessageAndLineNr = SimpleStringUtils.equals(markerLineNumber, String.valueOf(lineNumber))
&& SimpleStringUtils.equals(markerMessage, message);
if (sameMessageAndLineNr) {
return currentMarker;
}
}
return null;
}
示例4: removeMarkers
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
private IMarker[] removeMarkers(IResource resource, String markerType) {
if (resource == null) {
/* maybe sync problem - guard close */
return new IMarker[] {};
}
IMarker[] tasks = null;
if (resource != null) {
try {
tasks = resource.findMarkers(markerType, true, IResource.DEPTH_ZERO);
for (int i = 0; i < tasks.length; i++) {
tasks[i].delete();
}
} catch (CoreException e) {
EclipseUtil.logError("Was not able to delete markers", e);
}
}
if (tasks == null) {
tasks = new IMarker[] {};
}
return tasks;
}
示例5: decorate
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
@Override
public void decorate(Object element, IDecoration decoration) {
if (element instanceof IResource) {
IResource res = (IResource) element;
IProject proj = res.getProject();
try {
if (proj != null && proj.isAccessible() && proj.hasNature(NATURE.ID)) {
IMarker[] markers = res.findMarkers(MARKER.ERROR, false,
IResource.DEPTH_INFINITE);
if (markers.length > 0) {
decoration.addOverlay(PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR));
}
}
} catch (CoreException e) {
Log.log(e);
}
}
}
示例6: getTitleImage
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
@Override
public Image getTitleImage() {
Image image = super.getTitleImage();
try {
IEditorInput input = getEditorInput();
IResource file = ResourceUtil.getResource(input);
if (input.exists() && file != null
&& file.findMarkers(MARKER.ERROR, false, IResource.DEPTH_ZERO).length > 0) {
if (errorTitleImage == null) {
errorTitleImage = new DecorationOverlayIcon(image,
PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
ISharedImages.IMG_DEC_FIELD_ERROR), IDecoration.BOTTOM_LEFT)
.createImage();
}
return errorTitleImage;
}
} catch (CoreException e) {
Log.log(e);
}
return image;
}
示例7: findMarkersAsArrayList
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
/**
* Returns a list of a resources markers
*
* @param resource
* @return
*/
public static ArrayList<IMarker> findMarkersAsArrayList(final IResource resource) {
try {
if (resource == null) {
return new ArrayList<>();
}
final ArrayList<IMarker> myMarkerList = new ArrayList<>();
IMarker[] list;
list = resource.findMarkers(MarkerFactory.MARKER_MARKING, true, IResource.DEPTH_INFINITE);
for (final IMarker iMarker : list) {
myMarkerList.add(iMarker);
}
return myMarkerList;
} catch (final CoreException e) {
e.printStackTrace();
}
return new ArrayList<>();
}
示例8: errorIsInProblemView
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
public boolean errorIsInProblemView (String expected) throws CoreException {
System.out.println("XXXXXXXXX errorIsInProblemView >"+expected+"<");
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResource resource = workspace.getRoot();
IMarker[] markers = resource.findMarkers(null, true, IResource.DEPTH_INFINITE);
for (IMarker m : markers) {
String msg = (String)m.getAttribute(IMarker.MESSAGE);
System.out.println(">"+msg+"<");
if (expected.equalsIgnoreCase(msg.trim())) return true;
}
return false;
}
示例9: print
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
public void print() {
try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResource resource = workspace.getRoot();
IMarker[] markers = resource.findMarkers(IMarker.MARKER, true, IResource.DEPTH_INFINITE);
for (IMarker m : markers) {
System.out.println("Message: " + m.getAttribute(IMarker.MESSAGE));
}
} catch (CoreException e) {
e.printStackTrace();
}
}
示例10: loadBreakpoints
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
private void loadBreakpoints(IResource project) {
try {
IMarker[] markers = project.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE);
List<IMarker> methodBreakpoints = filterJavaMethodBreakpoints(markers);
List<IMarker> jimpleChildBreakpoints = filterJimpleChildBreakpoints(methodBreakpoints);
for (IMarker marker : jimpleChildBreakpoints) {
String unitFqn = (String) marker.getAttribute("Jimple.unit.fqn");
WorkspaceJob createBreakpoint = new WorkspaceJob("Create Jimple breakpoint") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
JimpleBreakpoint jimpleBreakpoint = getJimpleBreakpoint(unitFqn);
if(jimpleBreakpoint == null) {
IMarker jimpleMarker = createJimpleMarker(marker);
jimpleBreakpoint = createBreakpointWithoutJavaBreakpoints(jimpleMarker);
addBreakpoint(jimpleBreakpoint);
}
IBreakpoint javaBreakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker);
jimpleBreakpoint.addJavaBreakpoint(javaBreakpoint);
return Status.OK_STATUS;
}
};
createBreakpoint.schedule();
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例11: visit
import org.eclipse.core.resources.IResource; //導入方法依賴的package包/類
/**
* Answers whether children should be visited.
* <p>
* If the associated resource is a class file which has been changed, record it.
* </p>
*/
@Override
public boolean visit(IResourceDelta delta) {
if (delta == null || 0 == (delta.getKind() & IResourceDelta.CHANGED)) {
return false;
}
IResource resource = delta.getResource();
if (resource != null) {
switch (resource.getType()) {
case IResource.FILE:
if (0 == (delta.getFlags() & IResourceDelta.CONTENT)) {
return false;
}
if (CLASS_FILE_EXTENSION.equals(resource.getFullPath().getFileExtension())) {
IPath localLocation = resource.getLocation();
if (localLocation != null) {
String path = localLocation.toOSString();
IClassFileReader reader = ToolFactory.createDefaultClassFileReader(path,
IClassFileReader.CLASSFILE_ATTRIBUTES);
if (reader != null) {
// this name is slash-delimited
String qualifiedName = new String(reader.getClassName());
boolean hasBlockingErrors = false;
try {
// If the user doesn't want to replace
// classfiles containing
// compilation errors, get the source
// file associated with
// the class file and query it for
// compilation errors
IJavaProject pro = JavaCore.create(resource.getProject());
ISourceAttribute sourceAttribute = reader.getSourceFileAttribute();
String sourceName = null;
if (sourceAttribute != null) {
sourceName = new String(sourceAttribute.getSourceFileName());
}
IResource sourceFile = getSourceFile(pro, qualifiedName, sourceName);
if (sourceFile != null) {
IMarker[] problemMarkers = null;
problemMarkers = sourceFile.findMarkers(
IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true,
IResource.DEPTH_INFINITE);
for (IMarker problemMarker : problemMarkers) {
if (problemMarker.getAttribute(IMarker.SEVERITY,
-1) == IMarker.SEVERITY_ERROR) {
hasBlockingErrors = true;
break;
}
}
}
} catch (CoreException e) {
logger.log(Level.SEVERE, "Failed to visit classes: " + e.getMessage(), e);
}
if (!hasBlockingErrors) {
changedFiles.add(resource);
// dot-delimit the name
fullyQualifiedNames.add(qualifiedName.replace('/', '.'));
}
}
}
}
return false;
default:
return true;
}
}
return true;
}