Java 类org.eclipse.core.resources.IMarker 实例源码

项目:gw4e.project    文件:InvalidAnnotationPathGeneratorMarkerResolution.java   
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);
    }
}
项目:Tarski    文件:AlloyUtilities.java   
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;
}
项目:n4js    文件:ProjectUtils.java   
/**
 * 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);
    }
}
项目:ec4e    文件:ValidateEditorConfigStrategy.java   
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();
    }
}
项目:Tarski    文件:VisualizationActionListenerFactory.java   
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);
      }
    }
  };
}
项目:Tarski    文件:AlloyUtilities.java   
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);
}
项目:Tarski    文件:AlloyParseUtil.java   
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();
    }
  }
}
项目:Tarski    文件:AlloyUtilities.java   
/**
 * 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);
}
项目:Tarski    文件:MasterView.java   
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());
    }
}
项目:Tarski    文件:AlloyUtilities.java   
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;
}
项目:Tarski    文件:TraceManager.java   
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);
  }
}
项目:Tarski    文件:AlloyUtilities.java   
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);
  }
}
项目:eclipse-batch-editor    文件:AbstractMarkerHelper.java   
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);
    }
}
项目:eclipse-batch-editor    文件:AbstractMarkerHelper.java   
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;
}
项目:Tarski    文件:AlloyUtilities.java   
/**
 * 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;
}
项目:Tarski    文件:Startup.java   
private void initContextualView(IEditorPart editor) {
  if (editor == null) {
    return;
  }
  IFile file = editor.getEditorInput().getAdapter(IFile.class);
  TreeViewer treeViewer = ContextualView.getTreeViewer();
  if (treeViewer != null) {
    // Finding all markers in given file.
    ArrayList<IMarker> allMarkers;
    allMarkers = MarkerFactory.findMarkersAsArrayList(file);
    if (allMarkers == null) {
      return;
    }
    Iterator<IMarker> iter = allMarkers.iterator();
    while (iter.hasNext()) {
      IMarker marker = iter.next();
      if (MarkUtilities.getLeaderId(marker) == null && MarkUtilities.getGroupId(marker) != null) {
        iter.remove();
      }
    }
    if (!treeViewer.getTree().isDisposed()) {
      treeViewer.setInput(allMarkers.toArray());
    }
    treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
  }
}
项目:eclipse-bash-editor    文件:AbstractMarkerHelper.java   
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;
}
项目:eclipse-bash-editor    文件:AbstractMarkerHelper.java   
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);
    }
}
项目:gemoc-studio    文件:EclipseMessagingSystem.java   
@Override
public void logProblem(Kind kind, String msg, String msgGroup, Reference ref) {
    //Kind log_kind = kind;
    switch (kind) {
    case UserWARNING:
        eclipseReporter.addMarker( IMarker.SEVERITY_WARNING, ref, msg,msgGroup);
        // since the message is in the problem view, downgrade log_kind to dev so it can be filtered
        //log_kind = Kind.DevWARNING;
        break;
    case UserERROR:
        eclipseReporter.addMarker( IMarker.SEVERITY_ERROR, ref, msg,msgGroup);
        // downgrade log_kind to dev
        //log_kind = Kind.DevERROR;
        break;
    default:
        eclipseReporter.addMarker( IMarker.SEVERITY_INFO, ref, msg,msgGroup);
        // downgrade log_kind to dev
        //log_kind = Kind.DevERROR;
        break;
    }
    // forward all message to usual log too
    //log(log_kind, msg + " "+ref, msgGroup);
}
项目:time4sys    文件:ConstraintsEditor.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void gotoMarker(IMarker marker) {
    List<?> targetObjects = markerHelper.getTargetObjects(editingDomain, marker);
    if (!targetObjects.isEmpty()) {
        setSelectionToViewer(targetObjects);
    }
}
项目:Tarski    文件:MarkUtilities.java   
private static void setMessage(final IMarker iMarker, final String type) {
  try {
    iMarker.setAttribute(IMarker.MESSAGE,
        type == null ? "Marker Type : non-type" : "Marker Type : " + type);
  } catch (final CoreException e) {
    e.printStackTrace();
  }
}
项目:Equella    文件:JPFManifestBuilder.java   
private void reportError(IResource resource, String message)
{
    try
    {
        IMarker marker = resource.createMarker(JPFClasspathPlugin.MARKER_ID);
        marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
        marker.setAttribute(IMarker.MESSAGE, message);
        marker.setAttribute(IMarker.LINE_NUMBER, 1);
    }
    catch( CoreException e )
    {
        // nothing
    }
}
项目:Tarski    文件:MarkUtilities.java   
public static String getXpath(final IMarker iMarker) {
  try {
    return (String) iMarker.getAttribute("xpath");
  } catch (final CoreException e) {
    e.printStackTrace();
  }
  return null;
}
项目:visuflow-plugin    文件:JimpleBreakpointManager.java   
private List<IMarker> filterJavaMethodBreakpoints(IMarker[] markers) throws CoreException {
    List<IMarker> filteredList = new ArrayList<>();
    for (IMarker marker : markers) {
        if(marker.getType().equals("org.eclipse.jdt.debug.javaMethodBreakpointMarker")) {
            filteredList.add(marker);
        }
    }
    return filteredList;
}
项目:gw4e.project    文件:ProjectHelper.java   
public static IMarker getMarker(IJavaProject project, int problemID) throws CoreException {
    IMarker[] markers = project.getProject().findMarkers(GW4EBuilder.MARKER_TYPE, true, IResource.DEPTH_INFINITE);
    for (IMarker iMarker : markers) {
        Object attr = iMarker.getAttribute(IJavaModelMarker.ID);
        Integer pbid = (Integer) attr;
        if (pbid == null)
            continue;
        if (pbid.equals(problemID)) {
            return iMarker;
        }
    }
    return null;
}
项目:Tarski    文件:MarkUtilities.java   
public static int getEnd(final IMarker iMarker) {
  try {
    return (int) iMarker.getAttribute(IMarker.CHAR_END);
  } catch (final CoreException e) {
    e.printStackTrace();
  }
  return -1;
}
项目:Tarski    文件:ContextualView.java   
private void deleteFromAlloyXML(final IMarker beDeleted) {
  if (AlloyUtilities.isExists()) {
    AlloyUtilities.removeMarkerFromRepository(beDeleted);
    if (MarkUtilities.getGroupId(beDeleted) == null
        || MarkUtilities.getLeaderId(beDeleted) != null) {
      AlloyUtilities.removeTypeFromMarker(beDeleted);
      AlloyUtilities.removeRelationOfMarker(beDeleted);
    }
  }
}
项目:Tarski    文件:MasterViewDeleteHandler.java   
private void deleteSelections() {
    for (final IMarker iMarker : this.delCandidates) {
        this.deleteFromAlloyXML(iMarker);
        AnnotationFactory.removeAnnotation(iMarker);
        try {
            iMarker.delete();
        } catch (final CoreException e) {
            e.printStackTrace();
        }
    }
}
项目:visuflow-plugin    文件:JavaBreakpointListener.java   
private void addNewInstructionPointer(String project, String path, int line, int charStart, int charEnd) throws CoreException {
    IFile file = getFile(project, path);
    IMarker marker = file.createMarker("visuflow.debug.instructionPointer.marker");
    marker.setAttribute(IMarker.MESSAGE, "");
    marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
    marker.setAttribute(IMarker.LINE_NUMBER, line);
    marker.setAttribute(IMarker.CHAR_START, charStart);
    marker.setAttribute(IMarker.CHAR_END, charEnd);
}
项目:Tarski    文件:AutomatedTraceCreator.java   
private void createMarkers(List<EObject> allEObjects) throws TraceException {
  for (EObject eObject : allEObjects) {
    final String className = eObject.eClass().getName();
    final SigTrace sigTrace = TraceManager.get().getSigTraceByClassName(className);
    if (sigTrace != null) {
      LoadItem load = TraceManager.get().getLoadByAlias(sigTrace.getAlias());
      IMarker marker = createMarker(eObject, load.getInstanceFile(), sigTrace.getSigType());
      if (marker != null) {
        eObject2Marker.put(eObject, marker);
      }
    } else {
      throw new TraceException("There is no sig trace for EClass " + className);
    }
  }
}
项目:Tarski    文件:TraceObserver.java   
private void createRelations(IMarker marker, final Map<Object, String> secondSides)
    throws TraceException {
  for (final Entry<Object, String> entry : secondSides.entrySet()) {
    if (entry.getKey() instanceof IMarker) {
      createRelation(marker, (IMarker) entry.getKey(), entry.getValue());
    } else {
      // Atom has no marker, need to create one
      interpretAtom((String) entry.getKey(), true);
    }
  }
}
项目:Tarski    文件:CreateInstanceElementWizard.java   
@Override
public boolean performFinish() {
  final String sigTypeName = typeSelectionPage.getSelectedType();
  IMarker containerMarker = null;
  if (containerSelectionPage.isPageComplete())
    containerMarker = containerSelectionPage.getSelectedMarker();

  try {
    EObject eObject = TraceManager.get().createEObject(sigTypeName, "", containerMarker);
    IMarker marker = TraceManager.get().createMarkerForEObject(eObject);
    if (marker == null) {
      return false;
    }
    AlloyUtilities.addTypeToMarker(marker);
    AlloyUtilities.addMarkerToRepository(marker);
    String atomName = AlloyUtilities.getAtomNameById(MarkUtilities.getSourceId(marker));
    EcoreUtilities.eSetAttributeByName(eObject, "name", atomName);
    EcoreUtilities.saveResource(eObject);
    MarkUtilities.setText(marker, MarkerFactory.instanceToString(eObject));
    int index = Integer.parseInt(atomName.toString().substring(sigTypeName.length() + 1));
    AlloyUtilities.bindAtomToMarker(sigTypeName, index, marker);
    if (containerMarker != null) {
      String relation = TraceManager.get().getContainmentRelation(containerMarker, marker);
      AlloyUtilities.addRelation2Markers(containerMarker, marker, relation);
      AnnotationFactory.convertAnnotationType(containerMarker, false, false,
          AlloyUtilities.getTotalTargetCount(containerMarker));
    }
  } catch (TraceException e) {
    e.printStackTrace();
    return false;
  } finally {
    Visualization.showViz();
  }
  return true;
}
项目:ec4e    文件:MarkerUtils.java   
public static boolean isEditorConfigMarker(IMarker marker) {
    try {
        return EC_PROBLEM_MARKER_TYPE.equals(marker.getType());
    } catch (CoreException e) {
        return false;
    }
}
项目:n4js    文件:N4JSMarkerResolutionGenerator.java   
private boolean isSameProblem(IMarker marker) {
    URI myUriToProblem = issue.getUriToProblem();

    String code = issueUtil.getCode(marker);
    if (code != null && code.equals(org.eclipse.n4js.validation.IssueCodes.NON_EXISTING_PROJECT)) {
        myUriToProblem = myUriToProblem.appendFragment(Integer.toString(marker.hashCode()));
    }

    return myUriToProblem != null && myUriToProblem.equals(issueUtil.getUriToProblem(marker));
}
项目:Tarski    文件:MasterViewContentProvider.java   
@Override
public Object[] getChildren(final Object parentElement) {
  if (parentElement instanceof IMarker) {
    final IMarker iMarker = (IMarker) parentElement;
    final List<IMarker> groupElements = MarkerFactory.findMarkersByGroupId(iMarker.getResource(),
        MarkUtilities.getGroupId(iMarker));
    groupElements.remove(iMarker);

    return groupElements.toArray();
  } else {
    return null;
  }
}
项目:n4js    文件:N4JSMarkerResolutionGenerator.java   
/**
 * Same as {@link #isMarkerStillValid(IMarker, IAnnotationModel)}, but obtains the annotation model from the
 * marker's editor.
 */
private boolean isMarkerStillValid(IMarker marker) {
    if (marker == null)
        return false;
    final XtextEditor editor = getEditor(marker.getResource());
    if (editor == null)
        return false;
    final IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(
            editor.getEditorInput());
    if (annotationModel == null)
        return false;
    return isMarkerStillValid(marker, annotationModel);
}
项目:time4sys    文件:NfpEditor.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void gotoMarker(IMarker marker) {
    List<?> targetObjects = markerHelper.getTargetObjects(editingDomain, marker);
    if (!targetObjects.isEmpty()) {
        setSelectionToViewer(targetObjects);
    }
}
项目:n4js    文件:N4JSMarkerResolutionGenerator.java   
/**
 * Returns true iff for at least one of the given markers the corresponding editor is open and is dirty. Does not
 * open any editors if they aren't open already.
 */
private boolean existsDirtyEditorFor(IMarker[] markers) {
    // look for an editor containing one of the given markers that is already open and dirty
    for (IMarker marker : markers) {
        final XtextEditor editorForMarker = findEditor(marker.getResource()); // returns null if not open already
        if (editorForMarker != null && editorForMarker.isDirty())
            return true;
    }
    return false;
}
项目:Tarski    文件:TraceManager.java   
public EObject createEObject(String sigTypeName, String atomName, IMarker source)
    throws TraceException {
  SigTrace trace = getSigTraceByType(sigTypeName);
  EClass eClass = trace.getEClass();
  EObject eObject = EcoreUtil.create(eClass);
  EcoreUtilities.eSetAttributeByName(eObject, "name", atomName);
  EcoreUtilities.putIntoContainer(
      source == null ? trace.getLoad().getInstanceRoot() : findEObject(source), eObject);
  EcoreUtilities.saveResource(trace.getLoad().getInstanceRoot());
  return eObject;
}
项目:SimQRI    文件:MetamodelEditor.java   
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void gotoMarker(IMarker marker) {
    List<?> targetObjects = markerHelper.getTargetObjects(editingDomain, marker);
    if (!targetObjects.isEmpty()) {
        setSelectionToViewer(targetObjects);
    }
}