Search in sources :

Example 1 with CheckType

use of org.eclipse.xtext.validation.CheckType in project xtext-eclipse by eclipse.

the class MarkerEraser method deleteMarkers.

/**
 * Deletes {@link IFile}'s markers which type matches the given {@link CheckType}s represented by the
 * {@link CheckMode}.
 *
 * @see CheckType
 * @see CheckMode#shouldCheck(CheckType)
 * @see MarkerTypes#forCheckType(CheckType)
 */
public void deleteMarkers(final IFile file, final CheckMode checkMode, final IProgressMonitor monitor) throws CoreException {
    for (CheckType chkType : CheckType.values()) {
        if (checkMode.shouldCheck(chkType)) {
            String markerType = MarkerTypes.forCheckType(chkType);
            file.deleteMarkers(markerType, true, IResource.DEPTH_ZERO);
        }
    }
}
Also used : CheckType(org.eclipse.xtext.validation.CheckType)

Example 2 with CheckType

use of org.eclipse.xtext.validation.CheckType in project statecharts by Yakindu.

the class DefaultValidationIssueStore method processIssues.

@Override
public synchronized void processIssues(List<Issue> issues, IProgressMonitor monitor) {
    final Multimap<String, SCTIssue> newVisibleIssues = ArrayListMultimap.create();
    for (Issue issue : issues) {
        if (issue instanceof SCTIssue) {
            String semanticURI = ((SCTIssue) issue).getSemanticURI();
            newVisibleIssues.put(semanticURI, (SCTIssue) issue);
        }
    }
    final Multimap<String, SCTIssue> oldVisibleIssues = ArrayListMultimap.create();
    synchronized (visibleIssues) {
        oldVisibleIssues.putAll(visibleIssues);
        // normal and expensive checks will not be executed by the live
        // validation, so persistent markers have to be copied
        Iterable<SCTIssue> persistentIssues = Iterables.filter(visibleIssues.values(), new Predicate<SCTIssue>() {

            public boolean apply(SCTIssue input) {
                CheckType type = input.getType();
                Severity severity = input.getSeverity();
                return CheckType.NORMAL == type || CheckType.EXPENSIVE == type || Severity.INFO == severity;
            }
        });
        for (SCTIssue sctIssue : persistentIssues) {
            newVisibleIssues.put(sctIssue.getSemanticURI(), sctIssue);
        }
        visibleIssues.clear();
        visibleIssues.putAll(newVisibleIssues);
    }
    SetView<String> changes = Sets.symmetricDifference(oldVisibleIssues.keySet(), newVisibleIssues.keySet());
    for (String string : changes) {
        notifyListeners(string);
    }
    SetView<String> intersection = Sets.intersection(oldVisibleIssues.keySet(), newVisibleIssues.keySet());
    for (String string : intersection) {
        if (changedSeverity(string, oldVisibleIssues, newVisibleIssues) || changedErrorCount(string, oldVisibleIssues, newVisibleIssues)) {
            notifyListeners(string);
        }
    }
}
Also used : SCTIssue(org.yakindu.sct.model.sgraph.ui.validation.SCTIssue) Issue(org.eclipse.xtext.validation.Issue) SCTIssue(org.yakindu.sct.model.sgraph.ui.validation.SCTIssue) CheckType(org.eclipse.xtext.validation.CheckType) Severity(org.eclipse.xtext.diagnostics.Severity)

Aggregations

CheckType (org.eclipse.xtext.validation.CheckType)2 Severity (org.eclipse.xtext.diagnostics.Severity)1 Issue (org.eclipse.xtext.validation.Issue)1 SCTIssue (org.yakindu.sct.model.sgraph.ui.validation.SCTIssue)1