Search in sources :

Example 1 with SetLocation

use of aQute.service.reporter.Reporter.SetLocation in project bnd by bndtools.

the class PropertiesParser method error.

private void error(String msg, Object... args) {
    if (reporter != null) {
        int line = this.line;
        String context = context();
        SetLocation loc = reporter.error("%s: <<%s>>", Strings.format(msg, args), context);
        loc.line(line);
        loc.context(context);
        if (file != null)
            loc.file(file);
        loc.length(context.length());
    }
}
Also used : SetLocation(aQute.service.reporter.Reporter.SetLocation)

Example 2 with SetLocation

use of aQute.service.reporter.Reporter.SetLocation in project bnd by bndtools.

the class Macro method _warning.

public String _warning(String[] args) throws Exception {
    for (int i = 1; i < args.length; i++) {
        SetLocation warning = domain.warning("%s", process(args[i]));
        FileLine header = domain.getHeader(Pattern.compile(".*"), Pattern.compile("\\$\\{warning;"));
        if (header != null)
            header.set(warning);
    }
    return "";
}
Also used : SetLocation(aQute.service.reporter.Reporter.SetLocation) FileLine(aQute.bnd.osgi.Processor.FileLine)

Example 3 with SetLocation

use of aQute.service.reporter.Reporter.SetLocation in project bnd by bndtools.

the class Macro method _error.

public String _error(String[] args) throws Exception {
    for (int i = 1; i < args.length; i++) {
        SetLocation error = domain.error("%s", process(args[i]));
        FileLine header = domain.getHeader(Pattern.compile(".*"), Pattern.compile("\\$\\{error;"));
        if (header != null)
            header.set(error);
    }
    return "";
}
Also used : SetLocation(aQute.service.reporter.Reporter.SetLocation) FileLine(aQute.bnd.osgi.Processor.FileLine)

Example 4 with SetLocation

use of aQute.service.reporter.Reporter.SetLocation in project bndtools by bndtools.

the class MarkerSupport method report.

private void report(Processor reporter, IStatus status) {
    if (status == null || status.isOK())
        return;
    if (status.isMultiStatus()) {
        for (IStatus s : status.getChildren()) report(reporter, s);
    } else {
        SetLocation location;
        Throwable exception = status.getException();
        if (exception != null)
            if (status.getSeverity() == IStatus.ERROR)
                location = reporter.exception(exception, status.getMessage());
            else
                location = reporter.warning(status.getMessage() + ": " + exception);
        else {
            if (status.getSeverity() == IStatus.ERROR) {
                location = reporter.error(status.getMessage());
            } else {
                location = reporter.warning(status.getMessage());
            }
        }
        location.file(reporter.getPropertiesFile().getAbsolutePath());
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) SetLocation(aQute.service.reporter.Reporter.SetLocation)

Example 5 with SetLocation

use of aQute.service.reporter.Reporter.SetLocation in project bndtools by bndtools.

the class WorkingSetTracker method doWorkingSets.

static void doWorkingSets(final Project model, final IProject targetProject) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkingSetManager workingSetManager = workbench.getWorkingSetManager();
    String mergeProperties = model.mergeProperties("-workingset");
    if (mergeProperties == null)
        return;
    Parameters memberShips = new Parameters(mergeProperties);
    IWorkingSet[] allWorkingSets = workingSetManager.getAllWorkingSets();
    for (IWorkingSet currentWorkingSet : allWorkingSets) {
        Attrs attrs = memberShips.remove(currentWorkingSet.getName());
        boolean shouldBeMember = attrs != null && Processor.isTrue(attrs.get("member", "true"));
        IAdaptable[] elements = currentWorkingSet.getElements();
        List<IAdaptable> members = new ExtList<>(elements);
        boolean foundProjectInCurrentWorkingSet = false;
        for (Iterator<IAdaptable> it = members.iterator(); it.hasNext(); ) {
            IAdaptable member = it.next();
            if (member.getAdapter(IProject.class) == targetProject) {
                foundProjectInCurrentWorkingSet = true;
                if (!shouldBeMember) {
                    it.remove();
                }
            }
        }
        if (!foundProjectInCurrentWorkingSet && shouldBeMember) {
            members.add(targetProject);
        }
        if (elements.length != members.size()) {
            updateWorkingSet(currentWorkingSet, members);
        }
    }
    for (final Entry<String, Attrs> e : memberShips.entrySet()) {
        String name = e.getKey();
        boolean isMember = Processor.isTrue(e.getValue().get("member", "true"));
        if (!isMember)
            continue;
        if (!JAVAID_P.matcher(name).matches()) {
            SetLocation error = model.warning("Invalid working set name '%s'. Must use pattern of Java identifier", name);
            error.file(model.getPropertiesFile().getAbsolutePath());
            error.header("-workingset");
            continue;
        }
        IAdaptable[] members = new IAdaptable[1];
        members[0] = targetProject;
        IWorkingSet newWorkingSet = workingSetManager.createWorkingSet(name, members);
        newWorkingSet.setId("org.eclipse.jdt.ui.JavaWorkingSetPage");
        newWorkingSet.setLabel(null);
        workingSetManager.addWorkingSet(newWorkingSet);
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) Parameters(aQute.bnd.header.Parameters) ExtList(aQute.lib.collections.ExtList) Attrs(aQute.bnd.header.Attrs) IProject(org.eclipse.core.resources.IProject) IWorkbench(org.eclipse.ui.IWorkbench) IWorkingSetManager(org.eclipse.ui.IWorkingSetManager) SetLocation(aQute.service.reporter.Reporter.SetLocation) IWorkingSet(org.eclipse.ui.IWorkingSet)

Aggregations

SetLocation (aQute.service.reporter.Reporter.SetLocation)6 FileLine (aQute.bnd.osgi.Processor.FileLine)2 Attrs (aQute.bnd.header.Attrs)1 Parameters (aQute.bnd.header.Parameters)1 ExtList (aQute.lib.collections.ExtList)1 IProject (org.eclipse.core.resources.IProject)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IStatus (org.eclipse.core.runtime.IStatus)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkingSet (org.eclipse.ui.IWorkingSet)1 IWorkingSetManager (org.eclipse.ui.IWorkingSetManager)1