mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 01:06:01 +02:00
fixed marker supertypes for codan marker and marker type generation
This commit is contained in:
parent
b07f185354
commit
bf3078242e
7 changed files with 65 additions and 22 deletions
|
@ -31,16 +31,24 @@
|
|||
id="codanProblem"
|
||||
name="Code Analysis Problem"
|
||||
point="org.eclipse.core.resources.markers">
|
||||
<!-- <super
|
||||
type="org.eclipse.core.resources.problemmarker">
|
||||
</super> -->
|
||||
|
||||
<super type="org.eclipse.core.resources.problemmarker"/>
|
||||
<super type="org.eclipse.core.resources.textmarker"/>
|
||||
|
||||
<super
|
||||
type="org.eclipse.cdt.core.problem">
|
||||
</super>
|
||||
<attribute
|
||||
name="category">
|
||||
</attribute>
|
||||
<attribute
|
||||
name="org.eclipse.core.resources.problemmarker">
|
||||
</attribute>
|
||||
<persistent
|
||||
value="true">
|
||||
</persistent>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.preferences">
|
||||
</extension>
|
||||
|
|
|
@ -171,6 +171,16 @@
|
|||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="markerType" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Marker type to use to generate problem, default is the generic codan marker
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.markers/@id"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ package org.eclipse.cdt.codan.core.model;
|
|||
* it will remain the same.
|
||||
* </p>
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IProblem extends IProblemElement {
|
||||
/**
|
||||
|
@ -78,4 +80,11 @@ public interface IProblem extends IProblemElement {
|
|||
* @return
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
* Return marker id for the problem
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getMarkerType();
|
||||
}
|
||||
|
|
|
@ -187,6 +187,8 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
String sev = getAtt(configurationElement, "defaultSeverity", false); //$NON-NLS-1$
|
||||
String patt = getAtt(configurationElement, "messagePattern", false); //$NON-NLS-1$
|
||||
String desc = getAtt(configurationElement, "description", false); //$NON-NLS-1$
|
||||
String markerType = getAtt(configurationElement,
|
||||
"markerType", false); //$NON-NLS-1$
|
||||
if (enab != null) {
|
||||
p.setEnabled(Boolean.valueOf(enab));
|
||||
}
|
||||
|
@ -198,6 +200,9 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
if (patt != null) {
|
||||
p.setMessagePattern(patt);
|
||||
}
|
||||
if (markerType != null) {
|
||||
p.setMarkerType(markerType);
|
||||
}
|
||||
p.setDescription(desc);
|
||||
addProblem(p, category);
|
||||
return p;
|
||||
|
@ -323,7 +328,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
wp = (IProblemProfile) getDefaultProfile().clone();
|
||||
// load default values
|
||||
CodanPreferencesLoader loader = new CodanPreferencesLoader(wp);
|
||||
loader.load(loader.getWorkspaceNode());
|
||||
loader.load(CodanPreferencesLoader.getWorkspaceNode());
|
||||
} catch (CloneNotSupportedException e) {
|
||||
wp = getDefaultProfile();
|
||||
}
|
||||
|
@ -357,7 +362,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
// load default values
|
||||
CodanPreferencesLoader loader = new CodanPreferencesLoader(
|
||||
prof);
|
||||
Preferences projectNode = loader
|
||||
Preferences projectNode = CodanPreferencesLoader
|
||||
.getProjectNode((IProject) element);
|
||||
boolean useWorkspace = projectNode.getBoolean(
|
||||
PreferenceConstants.P_USE_PARENT, false);
|
||||
|
|
|
@ -37,8 +37,9 @@ public class CodanApplication implements IApplication {
|
|||
CodanRuntime runtime = CodanRuntime.getInstance();
|
||||
runtime.setProblemReporter(new CodanMarkerProblemReporter() {
|
||||
@Override
|
||||
public void reportProblem(String id, int severity, IFile file,
|
||||
int lineNumber, int startChar, int endChar, String message) {
|
||||
public void reportProblem(String id, String markerType,
|
||||
int severity, IFile file, int lineNumber, int startChar,
|
||||
int endChar, String message) {
|
||||
System.out.println(file.getLocation() + ":" + lineNumber + ": "
|
||||
+ message);
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
|||
} else {
|
||||
message = MessageFormat.format(messagePattern, args);
|
||||
}
|
||||
reportProblem(id, severity, file, lineNumber, loc.getStartingChar(),
|
||||
loc.getEndingChar(), message);
|
||||
reportProblem(id, problem.getMarkerType(), severity, file, lineNumber,
|
||||
loc.getStartingChar(), loc.getEndingChar(), message);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -70,12 +70,13 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
|||
* org.eclipse.cdt.codan.core.model.IProblemReporter#reportProblem(java.
|
||||
* lang.String, org.eclipse.core.resources.IFile, int, java.lang.String)
|
||||
*/
|
||||
public void reportProblem(String id, int severity, IFile file,
|
||||
int lineNumber, int startChar, int endChar, String message) {
|
||||
public void reportProblem(String id, String markerType, int severity,
|
||||
IFile file, int lineNumber, int startChar, int endChar,
|
||||
String message) {
|
||||
try {
|
||||
// Do not put in duplicates
|
||||
IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE,
|
||||
false, IResource.DEPTH_ZERO);
|
||||
IMarker[] cur = file.findMarkers(markerType, false,
|
||||
IResource.DEPTH_ZERO);
|
||||
if (cur != null) {
|
||||
for (IMarker element : cur) {
|
||||
int line = ((Integer) element
|
||||
|
@ -90,8 +91,7 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
|||
}
|
||||
}
|
||||
}
|
||||
IMarker marker = file
|
||||
.createMarker(GENERIC_CODE_ANALYSIS_MARKER_TYPE);
|
||||
IMarker marker = file.createMarker(markerType);
|
||||
marker.setAttribute(IMarker.MESSAGE, message);
|
||||
marker.setAttribute(IMarker.SEVERITY, severity);
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
|
||||
|
|
|
@ -11,9 +11,10 @@
|
|||
package org.eclipse.cdt.codan.internal.core.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemCategory;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemReporter;
|
||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||
|
||||
public class CodanProblem implements IProblemWorkingCopy {
|
||||
|
@ -26,6 +27,7 @@ public class CodanProblem implements IProblemWorkingCopy {
|
|||
private IProblemParameterInfo parameterInfo;
|
||||
private boolean frozen;
|
||||
private String description;
|
||||
private String markerType = IProblemReporter.GENERIC_CODE_ANALYSIS_MARKER_TYPE;
|
||||
|
||||
public CodanSeverity getSeverity() {
|
||||
return severity;
|
||||
|
@ -45,11 +47,6 @@ public class CodanProblem implements IProblemWorkingCopy {
|
|||
return id;
|
||||
}
|
||||
|
||||
public IProblemCategory getCategory() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
|
@ -89,7 +86,7 @@ public class CodanProblem implements IProblemWorkingCopy {
|
|||
|
||||
public Object getParameter(Object key) {
|
||||
return parameters.get(key);
|
||||
};
|
||||
}
|
||||
|
||||
public IProblemParameterInfo getParameterInfo() {
|
||||
return parameterInfo;
|
||||
|
@ -141,4 +138,17 @@ public class CodanProblem implements IProblemWorkingCopy {
|
|||
public void setDescription(String desc) {
|
||||
this.description = desc;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.codan.core.model.IProblem#getMarkerType()
|
||||
*/
|
||||
public String getMarkerType() {
|
||||
return markerType;
|
||||
}
|
||||
|
||||
public void setMarkerType(String type) {
|
||||
markerType = type;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue