当前位置: 首页>>代码示例>>Java>>正文


Java IResource.findMarkers方法代码示例

本文整理汇总了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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:ProjectUtils.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:32,代码来源:ProjectUtils.java

示例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;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:26,代码来源:AbstractMarkerHelper.java

示例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;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:23,代码来源:AbstractMarkerHelper.java

示例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);
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:20,代码来源:PgDecorator.java

示例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;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:22,代码来源:SQLEditor.java

示例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<>();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:25,代码来源:MarkerFactory.java

示例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;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:13,代码来源:ProblemView.java

示例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();
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:13,代码来源:ProblemView.java

示例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();
	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:30,代码来源:JimpleBreakpointManager.java

示例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;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:75,代码来源:JavaHotCodeReplaceProvider.java


注:本文中的org.eclipse.core.resources.IResource.findMarkers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。