int startLine = 1; if (bug.getPrimarySourceLineAnnotation() != null) { startLine = bug.getPrimarySourceLineAnnotation().getStartLine(); }
int startLine = 1; if (bug.getPrimarySourceLineAnnotation() != null) startLine = bug.getPrimarySourceLineAnnotation().getStartLine();
	protected void doReportBug(BugInstance bug) {		getBugList().add(bug);		String className = null;		String packageName = null;		if (bug.getPrimaryClass() != null) {			className = bug.getPrimaryClass().getClassName();			packageName = bug.getPrimaryClass().getPackageName();		}		if (DEBUG) {			System.out.println("BUG in class: " //$NON-NLS-1$			+ packageName + "." //$NON-NLS-1$			+ className + ": \n\t" //$NON-NLS-1$			+ bug.getMessage() + " / Annotation: " //$NON-NLS-1$			+ bug.getAnnotationText() + " / Source Line: " //$NON-NLS-1$			+ bug.getPrimarySourceLineAnnotation());		}				IResource resource = null;		try {			resource = getUnderlyingResource(bug);		}		catch (JavaModelException e1) {			// TODO Auto-generated catch block			e1.printStackTrace();		}		if (resource != null) {			// default - first class line			int startLine = 1;			if (bug.getPrimarySourceLineAnnotation() != null) {				startLine = bug.getPrimarySourceLineAnnotation().getStartLine();			}			// TODO: DHH - Eclipse can help us find the line number for fields.			// Need a way to distinguish bugs where the field is the			// primary item of interest.			if (DEBUG) {				System.out.println("Creating marker for " //$NON-NLS-1$				+ resource.getLocation() + ": line " //$NON-NLS-1$				+ startLine);			}			try {				IMarker marker = resource.createMarker(FindBugsMarker.NAME);				marker.setAttribute(IMarker.LINE_NUMBER, startLine);				marker.setAttribute(FindBugsMarker.BUG_TYPE, bug.getType());				marker.setAttribute(IMarker.MESSAGE, bug.getMessage());				marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);			}			catch (CoreException e) {				e.printStackTrace();			}		}	}