本文整理汇总了Java中org.eclipse.core.resources.IMarker类的典型用法代码示例。如果您正苦于以下问题:Java IMarker类的具体用法?Java IMarker怎么用?Java IMarker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IMarker类属于org.eclipse.core.resources包,在下文中一共展示了IMarker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fix
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
private void fix(IMarker marker, IProgressMonitor monitor) {
MarkerResolutionGenerator.printAttributes (marker);
try {
String filepath = (String) marker.getAttribute(BuildPolicyConfigurationException.JAVAFILENAME);
int start = (int) marker.getAttribute(IMarker.CHAR_START);
int end = (int) marker.getAttribute(IMarker.CHAR_END);
IFile ifile = (IFile) ResourceManager.toResource(new Path(filepath));
ICompilationUnit cu = JavaCore.createCompilationUnitFrom(ifile);
String source = cu.getBuffer().getContents();
String part1 = source.substring(0,start);
String part2 = source.substring(end);
source = part1 + "value=\"" + resolutionMarkerDescription.getGenerator() + "\"" + part2;
final Document document = new Document(source);
cu.getBuffer().setContents(document.get());
cu.save(monitor, false);
} catch (Exception e) {
ResourceManager.logException(e);
}
}
示例2: findMarkerByID
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
public static IMarker findMarkerByID(final String markerId) {
final ItemType itemType = AlloyUtilities.getItemById(markerId);
if (itemType == null) {
return null;
}
final String path = AlloyUtilities.getValueOfEntry(itemType, AlloyUtilities.RESOURCE);
if (path == null) {
return null;
}
final IMarker marker = MarkUtilities.getiMarker(markerId, path);
return marker;
}
示例3: assertIssues
import org.eclipse.core.resources.IMarker; //导入依赖的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);
}
}
示例4: updateMarker
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
private void updateMarker(IResource resource, String message, int start, int end, int severity,
IMarker marker) {
try {
marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, severity);
if (resource.getType() != IResource.FILE) {
return;
}
IFile file = (IFile) resource;
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
ITextFileBuffer textFileBuffer = manager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
if (textFileBuffer == null) {
manager.connect(file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor());
textFileBuffer = manager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
}
IDocument document = textFileBuffer.getDocument();
marker.setAttribute(IMarker.CHAR_START, start);
marker.setAttribute(IMarker.CHAR_END, end);
marker.setAttribute(IMarker.LINE_NUMBER, document.getLineOfOffset(start) + 1);
} catch (CoreException | BadLocationException e) {
e.printStackTrace();
}
}
示例5: removeRelationActionListener
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
public static ActionListener removeRelationActionListener() {
return new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final IMarker startMarker =
Visualization.getMarker(((AlloyTuple) Visualization.rightClickedAnnotation).getStart());
final IMarker endMarker =
Visualization.getMarker(((AlloyTuple) Visualization.rightClickedAnnotation).getEnd());
final String relation = Visualization.relation;
Display.getDefault().syncExec(new RemoveRelationCommand(startMarker, endMarker, relation));
Visualization.showViz();
AlloyOtherSolutionReasoning.getInstance().finish();
for (final VisualizationChangeListener listener : VisualizationActionListenerFactory.listeners) {
listener.onRelationRemoved(startMarker, endMarker, relation);
}
}
};
}
示例6: addMapping2RelationType
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
public static void addMapping2RelationType(IMarker fromMarker, IMarker toMarker) {
fromMarker = MarkUtilities.getLeaderOfMarker(fromMarker);
toMarker = MarkUtilities.getLeaderOfMarker(toMarker);
final DocumentRoot documentRoot = AlloyUtilities.getDocumentRoot();
final RelationType relationType = documentRoot.getAlloy().getRelation();
final TupleType tupleType = persistenceFactory.eINSTANCE.createTupleType();
relationType.getTuple().add(tupleType);
final AtomType fromAtom = persistenceFactory.eINSTANCE.createAtomType();
tupleType.getAtom().add(fromAtom);
fromAtom.setLabel(MarkUtilities.getSourceId(fromMarker));
final AtomType toAtom = persistenceFactory.eINSTANCE.createAtomType();
tupleType.getAtom().add(toAtom);
toAtom.setLabel(MarkUtilities.getSourceId(toMarker));
AlloyUtilities.writeDocumentRoot(documentRoot);
}
示例7: removeTypesFromMarkers
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
private static void removeTypesFromMarkers() {
for (final IResource iResource : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
boolean isClosed = false;
try {
if (!((IProject) iResource).isOpen()) {
isClosed = true;
((IProject) iResource).open(new NullProgressMonitor());
}
for (IMarker iMarker : MarkerFactory.findMarkersAsArrayList(iResource)) {
if (MarkUtilities.getType(iMarker) != null) {
if (AlloyUtilities.getTotalTargetCount(iMarker) != 0) {
iMarker = AnnotationFactory.convertAnnotationType(iMarker, false, true,
AlloyUtilities.getTotalTargetCount(iMarker));
}
MarkUtilities.setType(iMarker, null);
AlloyUtilities.removeTypeFromMarker(iMarker);
}
}
if (isClosed == true) {
((IProject) iResource).close(new NullProgressMonitor());
}
} catch (final CoreException e) {
e.printStackTrace();
}
}
}
示例8: removeRelationOfMarker
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
/**
* Removes relation of given marker
*
* @param marker which will be deleted relation of
*/
public static void removeRelationOfMarker(IMarker marker) {
marker = MarkUtilities.getLeaderOfMarker(marker);
final DocumentRoot documentRoot = AlloyUtilities.getDocumentRoot();
final String id = MarkUtilities.getSourceId(marker);
final EList<TupleType> tupleTypes = AlloyUtilities.getRelationType(documentRoot).getTuple();
final Iterator<TupleType> iter = tupleTypes.iterator();
while (iter.hasNext()) {
final TupleType tupleType = iter.next();
final AtomType firstSideAtom = tupleType.getAtom().get(0);
final AtomType secondSideAtom = tupleType.getAtom().get(1);
if (firstSideAtom.getLabel().equals(id) || secondSideAtom.getLabel().equals(id)) {
iter.remove();
}
}
AlloyUtilities.writeDocumentRoot(documentRoot);
}
示例9: refreshTree
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
protected void refreshTree() {
if (this.treeViewer == null) {
return;
}
if (!this.treeViewer.getTree().isDisposed()) {
ArrayList<IMarker> allMarkers = new ArrayList<>();
allMarkers.addAll(MarkerFactory.findMarkers(ResourcesPlugin.getWorkspace().getRoot()));
final Iterator<IMarker> iter = allMarkers.iterator();
while (iter.hasNext()) {
final Object marker = iter.next();
if (MarkUtilities.getLeaderId((IMarker) marker) == null
&& MarkUtilities.getGroupId((IMarker) marker) != null) {
iter.remove();
}
}
this.treeViewer.setInput(allMarkers.toArray());
}
}
示例10: findItemTypeInRepository
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
public static int findItemTypeInRepository(final IMarker marker) {
final String markerId = MarkUtilities.getSourceId(marker);
final EList<ItemType> itemTypes = AlloyUtilities.getItemtypes();
int itemTypeIndex = 0;
for (final ItemType itemType : itemTypes) {
if (markerId.equals(itemType.getId())) {
return itemTypeIndex;
}
itemTypeIndex++;
}
return -1;
}
示例11: createReference
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
public void createReference(IMarker fromMarker, IMarker toMarker, String relationName)
throws TraceException {
EObject source = findEObject(fromMarker);
EObject target = findEObject(toMarker);
EReference ref = null;
for (EReference eReference : source.eClass().getEAllReferences()) {
RelationTrace relationTrace =
getRelationTrace(((EClass) eReference.eContainer()).getName(), eReference.getName());
if (relationTrace != null && relationTrace.getRelationName().equals(relationName)) {
ref = eReference;
break;
}
}
if (ref != null) {
EcoreUtilities.eSetReferenceByName(source, ref.getName(), target);
EcoreUtilities.saveResource(source);
}
}
示例12: setImpactAndChanged
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
public static void setImpactAndChanged(final IMarker marker) {
final DocumentRoot documentRoot = AlloyUtilities.getDocumentRoot();
final AlloyType alloyType = documentRoot.getAlloy();
if (MarkUtilities.getType(marker) != null) {
final EList<SigType> listOfSigs = alloyType.getInstance().getSig();
for (final SigType sigType : listOfSigs) {
final EList<AtomType> atoms = sigType.getAtom();
for (final AtomType atomType : atoms) {
if (atomType.getLabel().equals(MarkUtilities.getSourceId(marker))) {
atomType.setChanged(true);
}
}
}
final EList<FieldType> listOfField = alloyType.getInstance().getField();
for (final FieldType fieldType : listOfField) {
final EList<TupleType> tuples = fieldType.getTuple();
for (final TupleType tupleType : tuples) {
if (tupleType.getAtom().get(0).getLabel().equals(MarkUtilities.getSourceId(marker))) {
tupleType.getAtom().get(1).setImpact(true);
}
}
}
AlloyUtilities.writeDocumentRoot(documentRoot);
}
}
示例13: createMarker
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
private void createMarker(IResource resource, String message, int lineNumber, String markerType, int severity,
int charStart, int charEnd) throws CoreException {
if (lineNumber <= 0)
lineNumber = 1;
IMarker marker = findMarker(resource, message, lineNumber, markerType);
if (marker == null) {
HashMap<String, Object> map = new HashMap<>();
map.put(IMarker.SEVERITY, new Integer(severity));
map.put(IMarker.LOCATION, resource.getFullPath().toOSString());
map.put(IMarker.MESSAGE, message);
MarkerUtilities.setLineNumber(map, lineNumber);
MarkerUtilities.setMessage(map, message);
if (charStart != -1) {
MarkerUtilities.setCharStart(map, charStart);
MarkerUtilities.setCharEnd(map, charEnd);
}
internalCreateMarker(resource, map, markerType);
}
}
示例14: removeMarkers
import org.eclipse.core.resources.IMarker; //导入依赖的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;
}
示例15: getSourcesOfMarkerAtRelations
import org.eclipse.core.resources.IMarker; //导入依赖的package包/类
/**
* This method is used to get source marker list of iMarker. Also iMarker doesn't contain any
* marker type.
*
* @param iMarker
* @return
*/
public static ArrayList<IMarker> getSourcesOfMarkerAtRelations(IMarker iMarker) {
iMarker = MarkUtilities.getLeaderOfMarker(iMarker);
final ArrayList<IMarker> sources = new ArrayList<>();
final DocumentRoot documentRoot = AlloyUtilities.getDocumentRoot();
final RelationType relationType = AlloyUtilities.getRelationType(documentRoot);
final String selectedMarkerId = MarkUtilities.getSourceId(iMarker);
final EList<TupleType> tupleTypes = relationType.getTuple();
for (final TupleType tupleType : tupleTypes) {
final EList<AtomType> atoms = tupleType.getAtom();
final AtomType firstAtomType = atoms.get(0);
final AtomType secondAtomType = atoms.get(1);
if (secondAtomType.getLabel().equals(selectedMarkerId)) {
final ItemType itemTypeOfAtom = AlloyUtilities.getItemById(firstAtomType.getLabel());
final IMarker toMarker = MarkUtilities.getiMarker(firstAtomType.getLabel(),
AlloyUtilities.getValueOfEntry(itemTypeOfAtom, AlloyUtilities.RESOURCE));
sources.add(toMarker);
}
}
return sources;
}