Package de.tobject.findbugs.builder

Examples of de.tobject.findbugs.builder.WorkItem


    }

    public final void run(final IAction action) {
        if (currentEditor != null) {
            IFile file = ((FileEditorInput) (currentEditor.getEditorInput())).getFile();
            Job job = new ClearMarkersJob(file, Arrays.asList(new WorkItem[] { new WorkItem(file) }));
            job.setUser(true);
            job.setPriority(Job.INTERACTIVE);
            IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) currentEditor.getEditorSite().getService(
                    IWorkbenchSiteProgressService.class);
            service.schedule(job);
View Full Code Here


        return bugParameters;
    }

    private static MarkerParameter createMarkerParameter(IJavaProject project, BugInstance bug) {
        IJavaElement type = null;
        WorkItem resource = null;
        try {
            type = getJavaElement(bug, project);
            if (type != null) {
                resource = new WorkItem(type);
            }
        } catch (JavaModelException e1) {
            FindbugsPlugin.getDefault().logException(e1, "Could not find Java type for FindBugs warning");
        }
        if (resource == null) {
            if (Reporter.DEBUG) {
                reportNoResourceFound(bug);
            }
            return null;
        }

        // default - first class line
        int primaryLine = bug.getPrimarySourceLineAnnotation().getStartLine();

        // FindBugs needs originally generated primary line in order to find the
        // bug again.
        // Sometimes this primary line is <= 0, which causes Eclipse editor to
        // ignore it
        // So we check if we can replace the "wrong" primary line with a
        // "better" start line
        // If not, we just provide two values - one for Eclipse, another for
        // FindBugs itself.

        int startLine = -1;
        if (primaryLine <= 0) {
            FieldAnnotation primaryField = bug.getPrimaryField();
            if (primaryField != null && primaryField.getSourceLines() != null) {
                startLine = primaryField.getSourceLines().getStartLine();
                if (startLine < 0) {
                    // We have to provide line number, otherwise editor wouldn't
                    // show it
                    startLine = 1;
                }
            } else {
                // We have to provide line number, otherwise editor wouldn't
                // show it
                startLine = 1;
            }
        }

        MarkerParameter parameter;
        if (startLine > 0) {
            parameter = new MarkerParameter(bug, resource, startLine, primaryLine);
        } else {
            parameter = new MarkerParameter(bug, resource, primaryLine, primaryLine);
        }
        if (Reporter.DEBUG) {
            System.out
            .println("Creating marker for " + resource.getPath() + ": line " + parameter.primaryLine + bug.getMessage());
        }
        return parameter;
    }
View Full Code Here

            IMarker[] markers2 = MarkerUtil.getAllMarkers(res);
            for (IMarker marker : markers2) {
                markers.add(marker);
            }
        } else if (obj instanceof IJavaElement) {
            markers.addAll(new WorkItem((IJavaElement) obj).getMarkers(true));
        } else if (obj instanceof IAdaptable) {
            IAdaptable adapter = (IAdaptable) obj;
            IMarker marker = (IMarker) adapter.getAdapter(IMarker.class);
            if (marker == null) {
                IResource resource = (IResource) adapter.getAdapter(IResource.class);
View Full Code Here

    @Override
    public final void run(final IAction action) {
        if (currentEditor != null) {
            IFile file = ((FileEditorInput) (currentEditor.getEditorInput())).getFile();
            List<WorkItem> list = new ArrayList<WorkItem>();
            list.add(new WorkItem(file));
            work(currentEditor, file, list);
        }
    }
View Full Code Here

    public Image decorateImage(Image image, Object element) {
        return null;
    }

    public String decorateText(String text, Object element) {
        WorkItem item = ResourceUtils.getWorkItem(element);
        if (item == null) {
            IWorkingSet workingSet = Util.getAdapter(IWorkingSet.class, element);
            if (workingSet != null) {
                return decorateText(text, workingSet);
            }
            return text;
        }
        return decorateText(text, item.getMarkerCount(false));
    }
View Full Code Here

TOP

Related Classes of de.tobject.findbugs.builder.WorkItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.