mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed interface to return resource instead of file because in general problem can be on directory too not only file
This commit is contained in:
parent
3a426fb5fc
commit
dab37d2d92
3 changed files with 16 additions and 14 deletions
|
@ -10,7 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.model;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
/**
|
||||
* Interface to describe problem location. Usually contains file and linenumber,
|
||||
|
@ -24,7 +24,7 @@ public interface IProblemLocation {
|
|||
*
|
||||
* @return File for the problem - absolute full paths
|
||||
*/
|
||||
IFile getFile();
|
||||
IResource getFile();
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.Collection;
|
|||
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||
import org.eclipse.cdt.codan.core.Messages;
|
||||
import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
@ -40,8 +40,8 @@ public class CodanApplication implements IApplication {
|
|||
runtime.setProblemReporter(new CodanMarkerProblemReporter() {
|
||||
@Override
|
||||
public void reportProblem(String id, String markerType,
|
||||
int severity, IFile file, int lineNumber, int startChar,
|
||||
int endChar, String message) {
|
||||
int severity, IResource file, int lineNumber,
|
||||
int startChar, int endChar, String message) {
|
||||
System.out.println(file.getLocation() + ":" + lineNumber + ": " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ message);
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ public class CodanApplication implements IApplication {
|
|||
log(Messages.CodanApplication_LogRunProject + project);
|
||||
IProject wProject = root.getProject(project);
|
||||
if (!wProject.exists()) {
|
||||
System.err.println( //
|
||||
System.err
|
||||
.println( //
|
||||
NLS.bind(
|
||||
Messages.CodanApplication_Error_ProjectDoesNotExists,
|
||||
project));
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.cdt.codan.core.model.IProblem;
|
|||
import org.eclipse.cdt.codan.core.model.IProblemLocation;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemReporterPersistent;
|
||||
import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -38,14 +37,14 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
|||
* java.lang.Object[])
|
||||
*/
|
||||
public void reportProblem(String id, IProblemLocation loc, Object... args) {
|
||||
IFile file = loc.getFile();
|
||||
IResource file = loc.getFile();
|
||||
int lineNumber = loc.getLineNumber();
|
||||
if (file == null)
|
||||
throw new NullPointerException("file"); //$NON-NLS-1$
|
||||
if (id == null)
|
||||
throw new NullPointerException("id"); //$NON-NLS-1$
|
||||
IProblem problem = CheckersRegistry.getInstance().getResourceProfile(
|
||||
file).findProblem(id);
|
||||
IProblem problem = CheckersRegistry.getInstance()
|
||||
.getResourceProfile(file).findProblem(id);
|
||||
if (problem == null)
|
||||
throw new IllegalArgumentException("Id is not registered:" + id); //$NON-NLS-1$
|
||||
if (problem.isEnabled() == false)
|
||||
|
@ -71,7 +70,7 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
|||
* lang.String, org.eclipse.core.resources.IFile, int, java.lang.String)
|
||||
*/
|
||||
public void reportProblem(String id, String markerType, int severity,
|
||||
IFile file, int lineNumber, int startChar, int endChar,
|
||||
IResource file, int lineNumber, int startChar, int endChar,
|
||||
String message) {
|
||||
try {
|
||||
// Do not put in duplicates
|
||||
|
@ -115,9 +114,11 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
|||
|
||||
public void deleteAllProblems() {
|
||||
try {
|
||||
ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(
|
||||
GENERIC_CODE_ANALYSIS_MARKER_TYPE, true,
|
||||
IResource.DEPTH_INFINITE);
|
||||
ResourcesPlugin
|
||||
.getWorkspace()
|
||||
.getRoot()
|
||||
.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true,
|
||||
IResource.DEPTH_INFINITE);
|
||||
} catch (CoreException e) {
|
||||
CodanCorePlugin.log(e);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue