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