mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
refactored error reported
This commit is contained in:
parent
86a922370c
commit
5407d0d337
5 changed files with 37 additions and 8 deletions
|
@ -14,7 +14,7 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||
import org.eclipse.cdt.codan.core.model.CheckersRegisry;
|
||||
import org.eclipse.cdt.codan.core.model.ErrorReporter;
|
||||
import org.eclipse.cdt.codan.core.model.CodanRuntime;
|
||||
import org.eclipse.cdt.codan.core.model.IChecker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -90,7 +90,7 @@ public class CodanBuilder extends IncrementalProjectBuilder {
|
|||
// CodanCorePlugin.PLUGIN_ID, "problems", "", null);
|
||||
// System.err.println("set = " + string);
|
||||
// delete general markers
|
||||
ErrorReporter.deleteMarkers(resource);
|
||||
CodanRuntime.getInstance().getProblemReporter().deleteMarkers(resource);
|
||||
for (IChecker checker : CheckersRegisry.getInstance()) {
|
||||
try {
|
||||
boolean run = false;
|
||||
|
|
|
@ -25,6 +25,7 @@ public abstract class AbstractChecker implements IChecker {
|
|||
|
||||
public void reportProblem(String id, IFile file, int lineNumber,
|
||||
String message) {
|
||||
ErrorReporter.reportProblem(id, file, lineNumber, message);
|
||||
CodanRuntime.getInstance().getProblemReporter().reportProblem(id, file,
|
||||
lineNumber, message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class ErrorReporter {
|
||||
public class CodanProblemReporter {
|
||||
public static final String GENERIC_CODE_ANALYSIS_MARKER_TYPE = "org.eclipse.cdt.codan.core.codanProblem";
|
||||
|
||||
public static void reportProblem(String id, IFile file, int lineNumber,
|
||||
public void reportProblem(String id, IFile file, int lineNumber,
|
||||
String message) {
|
||||
try {
|
||||
if (file == null)
|
||||
|
@ -46,7 +46,7 @@ public class ErrorReporter {
|
|||
}
|
||||
}
|
||||
|
||||
public static void deleteMarkers(IResource file) {
|
||||
public void deleteMarkers(IResource file) {
|
||||
try {
|
||||
file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false,
|
||||
IResource.DEPTH_ZERO);
|
||||
|
@ -54,7 +54,7 @@ public class ErrorReporter {
|
|||
}
|
||||
}
|
||||
|
||||
public static void deleteAllMarkers() {
|
||||
public void deleteAllMarkers() {
|
||||
try {
|
||||
// TODO delete contributed markers too
|
||||
ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(
|
|
@ -0,0 +1,28 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Alena Laskavaia
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.model;
|
||||
|
||||
/**
|
||||
* Runtime singleton class to get access to Codan framework parts
|
||||
*
|
||||
*/
|
||||
public class CodanRuntime {
|
||||
private static CodanRuntime instance = new CodanRuntime();
|
||||
private CodanProblemReporter problemReporter = new CodanProblemReporter();
|
||||
|
||||
public CodanProblemReporter getProblemReporter() {
|
||||
return problemReporter;
|
||||
}
|
||||
|
||||
public static CodanRuntime getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
|
|||
// "Confirmation",
|
||||
// "Do you want to remove existing problems? If build is disabled they won't be updated anymore.");
|
||||
// if (openQuestion == true) {
|
||||
// ErrorReporter.deleteAllMarkers();
|
||||
// CodanProblemReporter.deleteAllMarkers();
|
||||
// }
|
||||
// }
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue