1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

- added description field for problem interface

This commit is contained in:
Alena Laskavaia 2010-03-23 03:07:14 +00:00
parent 61da6659ce
commit 21fa408633
5 changed files with 90 additions and 29 deletions

View file

@ -161,6 +161,16 @@
</appinfo>
</annotation>
</attribute>
<attribute name="description" type="string">
<annotation>
<documentation>
Short description of the problem
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

View file

@ -11,18 +11,19 @@
package org.eclipse.cdt.codan.core.model;
/**
* Interface representing code analysis problem type. For example "Null Pointer Dereference"
* is a problem. It has user visible Name and Message (translatable), as well as some other
* parameters, changeable by user such as enablement, severity and so on. Same problem
* cannot have two severities determined by runtime. If it is the case - two Problem should
* be created (i.e. one for error and one for warning).
*
* Interface representing code analysis problem type. For example
* "Null Pointer Dereference" is a problem. It has user visible Name and Message
* (translatable), as well as some other parameters, changeable by user such as
* enablement, severity and so on. Same problem cannot have two severities
* 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.
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same.
* </p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
* of a work in progress. There is no guarantee that this API will work or that
* it will remain the same.
* </p>
*
*/
public interface IProblem extends IProblemElement {
@ -70,4 +71,11 @@ public interface IProblem extends IProblemElement {
* @return
*/
public IProblemParameterInfo getParameterInfo();
/**
* Get short description of a problem
*
* @return
*/
public String getDescription();
}

View file

@ -15,43 +15,63 @@ package org.eclipse.cdt.codan.core.model;
*
* Clients may extend and implement this interface
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will
* work or that it will remain the same.
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
* of a work in progress. There is no guarantee that this API will work or that
* it will remain the same.
* </p>
*/
public interface IProblemWorkingCopy extends IProblem {
/**
* Set severity for this this problem instance. Severity can only be changed in profile
* not by checker when printing problems.
* @param sev - codan severity
* Set severity for this this problem instance. Severity can only be changed
* in profile not by checker when printing problems.
*
* @param sev
* - codan severity
*/
void setSeverity(CodanSeverity sev);
/**
* 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);
/**
* Set default message pattern. UI would call this method if user does not like default
* settings, checker should not use method, default message pattern should be set in
* checker extension
* @param messagePattern - java style message patter i.e. "Variable {0} is never used"
* Set default message pattern. UI would call this method if user does not
* like default settings, checker should not use method, default message
* pattern should be set in checker extension
*
* @param messagePattern
* - java style message patter i.e. "Variable {0} is never used"
*/
void setMessagePattern(String messagePattern);
/**
* Set value for the checker parameter, checker may set value during initialization only
* @param key - key of the parameter
* @param value - parameter value
* Set value for the checker parameter, checker may set value during
* initialization only
*
* @param key
* - key of the parameter
* @param value
* - parameter 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
*/
public void setParameterInfo(IProblemParameterInfo info);
/**
* Set problem description
*
* @param desc
* - problem description - short version, but longer than name
*/
public void setDescription(String desc);
}

View file

@ -14,7 +14,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.PreferenceConstants;
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 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$
if (enab != null) {
p.setEnabled(Boolean.valueOf(enab));
}
@ -198,6 +198,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
if (patt != null) {
p.setMessagePattern(patt);
}
p.setDescription(desc);
addProblem(p, category);
return p;
}

View file

@ -11,7 +11,6 @@
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;
@ -26,6 +25,7 @@ public class CodanProblem implements IProblemWorkingCopy {
private HashMap<Object, Object> parameters = new HashMap<Object, Object>(0);
private IProblemParameterInfo parameterInfo;
private boolean frozen;
private String description;
public CodanSeverity getSeverity() {
return severity;
@ -60,7 +60,8 @@ public class CodanProblem implements IProblemWorkingCopy {
}
public void setSeverity(CodanSeverity sev) {
if (sev == null) throw new NullPointerException();
if (sev == null)
throw new NullPointerException();
this.severity = sev;
}
@ -117,6 +118,27 @@ public class CodanProblem implements IProblemWorkingCopy {
}
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;
}
}