mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
- added description field for problem interface
This commit is contained in:
parent
61da6659ce
commit
21fa408633
5 changed files with 90 additions and 29 deletions
|
@ -161,6 +161,16 @@
|
||||||
</appinfo>
|
</appinfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="description" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Short description of the problem
|
||||||
|
</documentation>
|
||||||
|
<appinfo>
|
||||||
|
<meta.attribute translatable="true"/>
|
||||||
|
</appinfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
|
|
@ -11,18 +11,19 @@
|
||||||
package org.eclipse.cdt.codan.core.model;
|
package org.eclipse.cdt.codan.core.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing code analysis problem type. For example "Null Pointer Dereference"
|
* Interface representing code analysis problem type. For example
|
||||||
* is a problem. It has user visible Name and Message (translatable), as well as some other
|
* "Null Pointer Dereference" is a problem. It has user visible Name and Message
|
||||||
* parameters, changeable by user such as enablement, severity and so on. Same problem
|
* (translatable), as well as some other parameters, changeable by user such as
|
||||||
* cannot have two severities determined by runtime. If it is the case - two Problem should
|
* enablement, severity and so on. Same problem cannot have two severities
|
||||||
* be created (i.e. one for error and one for warning).
|
* determined by runtime. If it is the case - two Problem should be created
|
||||||
|
* (i.e. one for error and one for warning).
|
||||||
*
|
*
|
||||||
* Clients may implement and extend this interface.
|
* Clients may implement and extend this interface.
|
||||||
* <p>
|
* <p>
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
|
||||||
* part of a work in progress. There is no guarantee that this API will
|
* of a work in progress. There is no guarantee that this API will work or that
|
||||||
* work or that it will remain the same.
|
* it will remain the same.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IProblem extends IProblemElement {
|
public interface IProblem extends IProblemElement {
|
||||||
|
@ -70,4 +71,11 @@ public interface IProblem extends IProblemElement {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IProblemParameterInfo getParameterInfo();
|
public IProblemParameterInfo getParameterInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get short description of a problem
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getDescription();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,43 +15,63 @@ package org.eclipse.cdt.codan.core.model;
|
||||||
*
|
*
|
||||||
* Clients may extend and implement this interface
|
* Clients may extend and implement this interface
|
||||||
* <p>
|
* <p>
|
||||||
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
|
||||||
* part of a work in progress. There is no guarantee that this API will
|
* of a work in progress. There is no guarantee that this API will work or that
|
||||||
* work or that it will remain the same.
|
* it will remain the same.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public interface IProblemWorkingCopy extends IProblem {
|
public interface IProblemWorkingCopy extends IProblem {
|
||||||
/**
|
/**
|
||||||
* Set severity for this this problem instance. Severity can only be changed in profile
|
* Set severity for this this problem instance. Severity can only be changed
|
||||||
* not by checker when printing problems.
|
* in profile not by checker when printing problems.
|
||||||
* @param sev - codan severity
|
*
|
||||||
|
* @param sev
|
||||||
|
* - codan severity
|
||||||
*/
|
*/
|
||||||
void setSeverity(CodanSeverity sev);
|
void setSeverity(CodanSeverity sev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set checker enablement.
|
* Set checker enablement.
|
||||||
* @param enabled - true if problem is enabled in profile
|
*
|
||||||
|
* @param enabled
|
||||||
|
* - true if problem is enabled in profile
|
||||||
*/
|
*/
|
||||||
void setEnabled(boolean enabled);
|
void setEnabled(boolean enabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default message pattern. UI would call this method if user does not like default
|
* Set default message pattern. UI would call this method if user does not
|
||||||
* settings, checker should not use method, default message pattern should be set in
|
* like default settings, checker should not use method, default message
|
||||||
* checker extension
|
* pattern should be set in checker extension
|
||||||
* @param messagePattern - java style message patter i.e. "Variable {0} is never used"
|
*
|
||||||
|
* @param messagePattern
|
||||||
|
* - java style message patter i.e. "Variable {0} is never used"
|
||||||
*/
|
*/
|
||||||
void setMessagePattern(String messagePattern);
|
void setMessagePattern(String messagePattern);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set value for the checker parameter, checker may set value during initialization only
|
* Set value for the checker parameter, checker may set value during
|
||||||
* @param key - key of the parameter
|
* initialization only
|
||||||
* @param value - parameter value
|
*
|
||||||
|
* @param key
|
||||||
|
* - key of the parameter
|
||||||
|
* @param value
|
||||||
|
* - parameter value
|
||||||
*/
|
*/
|
||||||
public void setParameter(Object key, Object value);
|
public void setParameter(Object key, Object value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set parameter info object for the given problem, see {@link IProblemParameterInfo}
|
* Set parameter info object for the given problem, see
|
||||||
|
* {@link IProblemParameterInfo}
|
||||||
|
*
|
||||||
* @param info
|
* @param info
|
||||||
*/
|
*/
|
||||||
public void setParameterInfo(IProblemParameterInfo info);
|
public void setParameterInfo(IProblemParameterInfo info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set problem description
|
||||||
|
*
|
||||||
|
* @param desc
|
||||||
|
* - problem description - short version, but longer than name
|
||||||
|
*/
|
||||||
|
public void setDescription(String desc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||||
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
||||||
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
||||||
|
@ -187,6 +186,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
String enab = getAtt(configurationElement, "defaultEnabled", false); //$NON-NLS-1$
|
String enab = getAtt(configurationElement, "defaultEnabled", false); //$NON-NLS-1$
|
||||||
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$
|
||||||
if (enab != null) {
|
if (enab != null) {
|
||||||
p.setEnabled(Boolean.valueOf(enab));
|
p.setEnabled(Boolean.valueOf(enab));
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
if (patt != null) {
|
if (patt != null) {
|
||||||
p.setMessagePattern(patt);
|
p.setMessagePattern(patt);
|
||||||
}
|
}
|
||||||
|
p.setDescription(desc);
|
||||||
addProblem(p, category);
|
addProblem(p, category);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
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.IProblemCategory;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
|
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
|
||||||
|
@ -26,6 +25,7 @@ public class CodanProblem implements IProblemWorkingCopy {
|
||||||
private HashMap<Object, Object> parameters = new HashMap<Object, Object>(0);
|
private HashMap<Object, Object> parameters = new HashMap<Object, Object>(0);
|
||||||
private IProblemParameterInfo parameterInfo;
|
private IProblemParameterInfo parameterInfo;
|
||||||
private boolean frozen;
|
private boolean frozen;
|
||||||
|
private String description;
|
||||||
|
|
||||||
public CodanSeverity getSeverity() {
|
public CodanSeverity getSeverity() {
|
||||||
return severity;
|
return severity;
|
||||||
|
@ -60,7 +60,8 @@ public class CodanProblem implements IProblemWorkingCopy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSeverity(CodanSeverity sev) {
|
public void setSeverity(CodanSeverity sev) {
|
||||||
if (sev == null) throw new NullPointerException();
|
if (sev == null)
|
||||||
|
throw new NullPointerException();
|
||||||
this.severity = sev;
|
this.severity = sev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +118,27 @@ public class CodanProblem implements IProblemWorkingCopy {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkSet() {
|
protected void checkSet() {
|
||||||
if (frozen) throw new IllegalStateException("Object is unmodifieble"); //$NON-NLS-1$
|
if (frozen)
|
||||||
|
throw new IllegalStateException("Object is unmodifieble"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.codan.core.model.IProblem#getDescription()
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.eclipse.cdt.codan.core.model.IProblemWorkingCopy#setDescription(java
|
||||||
|
* .lang.String)
|
||||||
|
*/
|
||||||
|
public void setDescription(String desc) {
|
||||||
|
this.description = desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue