mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Refactored ProblemParameterInfo
This commit is contained in:
parent
eb382a9bee
commit
208b649f76
13 changed files with 296 additions and 40 deletions
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.cxx.model;
|
package org.eclipse.cdt.codan.core.cxx.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.model.ICheckerWithParameters;
|
||||||
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
@ -22,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
* Abstract class for checkers that do all the work on function definition level
|
* Abstract class for checkers that do all the work on function definition level
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractAstFunctionChecker extends
|
public abstract class AbstractAstFunctionChecker extends
|
||||||
AbstractIndexAstChecker {
|
AbstractIndexAstChecker implements ICheckerWithParameters{
|
||||||
public void processAst(IASTTranslationUnit ast) {
|
public void processAst(IASTTranslationUnit ast) {
|
||||||
// traverse the ast using the visitor pattern.
|
// traverse the ast using the visitor pattern.
|
||||||
ast.accept(new ASTVisitor() {
|
ast.accept(new ASTVisitor() {
|
||||||
|
@ -55,4 +57,8 @@ public abstract class AbstractAstFunctionChecker extends
|
||||||
* - ast node representing function definition
|
* - ast node representing function definition
|
||||||
*/
|
*/
|
||||||
protected abstract void processFunction(IASTFunctionDefinition func);
|
protected abstract void processFunction(IASTFunctionDefinition func);
|
||||||
|
|
||||||
|
public void initParameters(IProblemWorkingCopy problem) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
Export-Package: org.eclipse.cdt.codan.core,
|
Export-Package: org.eclipse.cdt.codan.core,
|
||||||
org.eclipse.cdt.codan.core.model,
|
org.eclipse.cdt.codan.core.model,
|
||||||
org.eclipse.cdt.codan.core.model.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.checkers",
|
org.eclipse.cdt.codan.core.model.cfg;x-friends:="org.eclipse.cdt.codan.core.cxx,org.eclipse.cdt.codan.checkers",
|
||||||
|
org.eclipse.cdt.codan.core.param;x-friends:="org.eclipse.cdt.codan.checkers,org.eclipse.cdt.codan.checkers.ui,org.eclipse.cdt.codan.ui",
|
||||||
org.eclipse.cdt.codan.internal.core;
|
org.eclipse.cdt.codan.internal.core;
|
||||||
x-friends:="org.eclipse.cdt.codan.core,
|
x-friends:="org.eclipse.cdt.codan.core,
|
||||||
org.eclipse.cdt.codan.core.cxx,
|
org.eclipse.cdt.codan.core.cxx,
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.model;
|
package org.eclipse.cdt.codan.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing code analysis problem type. For example
|
* Interface representing code analysis problem type. For example
|
||||||
* "Null Pointer Dereference" is a problem. It has user visible Name and Message
|
* "Null Pointer Dereference" is a problem. It has user visible Name and Message
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.model;
|
package org.eclipse.cdt.codan.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifiable problem.
|
* Modifiable problem.
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Alena Laskavaia - initial API and implementation
|
* Alena Laskavaia - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.model;
|
package org.eclipse.cdt.codan.core.param;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ public abstract class AbstractProblemParameterInfo implements
|
||||||
*
|
*
|
||||||
* @see org.eclipse.cdt.codan.core.model.IProblemParameterInfo#getType()
|
* @see org.eclipse.cdt.codan.core.model.IProblemParameterInfo#getType()
|
||||||
*/
|
*/
|
||||||
public ParameterTypes getType() {
|
public ParameterType getType() {
|
||||||
return ParameterTypes.TYPE_STRING;
|
return ParameterType.TYPE_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.param;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HashParamterInfo - for checker that needs more than one parameter and they
|
||||||
|
* all different "named".
|
||||||
|
* For example checker has 2 optional boolean parameters. For example checker
|
||||||
|
* for parameter names
|
||||||
|
* shadowing would have two boolean options: "check contructors" and
|
||||||
|
* "check setters". In this case you use this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HashParameterInfo extends SingleParameterInfo {
|
||||||
|
protected HashMap<String, IProblemParameterInfo> hash = new HashMap<String, IProblemParameterInfo>();
|
||||||
|
|
||||||
|
public HashParameterInfo() {
|
||||||
|
super(""); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param label
|
||||||
|
* - label for this group of parameters
|
||||||
|
*/
|
||||||
|
public HashParameterInfo(String label) {
|
||||||
|
super(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key
|
||||||
|
* - key for itself
|
||||||
|
* @param label
|
||||||
|
* - label for this group of parameters
|
||||||
|
*/
|
||||||
|
public HashParameterInfo(String key, String label) {
|
||||||
|
super(key, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParameterType getType() {
|
||||||
|
return ParameterType.TYPE_HASH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setType(ParameterType type) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get parameter into for element by key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IProblemParameterInfo getElement(String key) {
|
||||||
|
return hash.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set parameter info for element with the key equals to info.getKey()
|
||||||
|
*
|
||||||
|
* @param i
|
||||||
|
* @param info
|
||||||
|
*/
|
||||||
|
public void setElement(IProblemParameterInfo info) {
|
||||||
|
hash.put(info.getKey(), info);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<IProblemParameterInfo> getIterator() {
|
||||||
|
return hash.values().iterator();
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Alena Laskavaia - initial API and implementation
|
* Alena Laskavaia - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.model;
|
package org.eclipse.cdt.codan.core.param;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
@ -19,13 +19,15 @@ import java.util.Iterator;
|
||||||
* ProblemParameterInfo represent parameter meta-info for the ui. If more that
|
* ProblemParameterInfo represent parameter meta-info for the ui. If more that
|
||||||
* one parameter required ParameterInfo should describe hash or array of
|
* one parameter required ParameterInfo should describe hash or array of
|
||||||
* parameters. This is only needed for auto-generated ui for parameter editing.
|
* parameters. This is only needed for auto-generated ui for parameter editing.
|
||||||
* For complex case custom ui control should be used
|
* For complex case custom ui control should be used. Extend
|
||||||
|
* AbstractProblemParamterInfo class
|
||||||
|
* to implement this interface.
|
||||||
*
|
*
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IProblemParameterInfo {
|
public interface IProblemParameterInfo {
|
||||||
enum ParameterTypes {
|
public enum ParameterType {
|
||||||
TYPE_STRING("string"), //$NON-NLS-1$
|
TYPE_STRING("string"), //$NON-NLS-1$
|
||||||
TYPE_INTEGER("integer"), //$NON-NLS-1$
|
TYPE_INTEGER("integer"), //$NON-NLS-1$
|
||||||
TYPE_BOOLEAN("boolean"), //$NON-NLS-1$
|
TYPE_BOOLEAN("boolean"), //$NON-NLS-1$
|
||||||
|
@ -34,14 +36,14 @@ public interface IProblemParameterInfo {
|
||||||
TYPE_HASH("hash"); //$NON-NLS-1$
|
TYPE_HASH("hash"); //$NON-NLS-1$
|
||||||
private String literal;
|
private String literal;
|
||||||
|
|
||||||
private ParameterTypes(String literal) {
|
private ParameterType(String literal) {
|
||||||
this.literal = literal;
|
this.literal = literal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ParameterTypes valueOfLiteral(String name) {
|
public static ParameterType valueOfLiteral(String name) {
|
||||||
ParameterTypes[] values = values();
|
ParameterType[] values = values();
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
ParameterTypes e = values[i];
|
ParameterType e = values[i];
|
||||||
if (e.literal.equals(name))
|
if (e.literal.equals(name))
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +66,7 @@ public interface IProblemParameterInfo {
|
||||||
*
|
*
|
||||||
* @return string value of the type
|
* @return string value of the type
|
||||||
*/
|
*/
|
||||||
ParameterTypes getType();
|
ParameterType getType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional info on how it is represented in the ui, for example boolean
|
* Additional info on how it is represented in the ui, for example boolean
|
||||||
|
@ -84,7 +86,7 @@ public interface IProblemParameterInfo {
|
||||||
/**
|
/**
|
||||||
* Detailed explanation of parameter
|
* Detailed explanation of parameter
|
||||||
*
|
*
|
||||||
* @return the tooltip text
|
* @return the toolTip text
|
||||||
*/
|
*/
|
||||||
String getToolTip();
|
String getToolTip();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Alena Laskavaia - initial API and implementation
|
* Alena Laskavaia - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.model;
|
package org.eclipse.cdt.codan.core.param;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -17,20 +17,26 @@ import java.util.Iterator;
|
||||||
* @author Alena
|
* @author Alena
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractListParameterInfo extends
|
public class ListParameterInfo extends SingleParameterInfo {
|
||||||
AbstractProblemParameterInfo {
|
|
||||||
protected ArrayList<IProblemParameterInfo> list = new ArrayList<IProblemParameterInfo>(
|
protected ArrayList<IProblemParameterInfo> list = new ArrayList<IProblemParameterInfo>(
|
||||||
1);
|
1);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
* @param key
|
||||||
*
|
* @param label
|
||||||
* @see
|
|
||||||
* org.eclipse.cdt.codan.core.model.AbstractProblemParameterInfo#getType()
|
|
||||||
*/
|
*/
|
||||||
|
public ListParameterInfo(String key, String label) {
|
||||||
|
super(key, label);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParameterTypes getType() {
|
public ParameterType getType() {
|
||||||
return ParameterTypes.TYPE_LIST;
|
return ParameterType.TYPE_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setType(ParameterType type) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,14 +69,14 @@ public abstract class AbstractListParameterInfo extends
|
||||||
* @param i
|
* @param i
|
||||||
* @param info
|
* @param info
|
||||||
*/
|
*/
|
||||||
protected void setElement(int i, IProblemParameterInfo info) {
|
public void setElement(int i, IProblemParameterInfo info) {
|
||||||
while (i >= list.size()) {
|
while (i >= list.size()) {
|
||||||
list.add(null);
|
list.add(null);
|
||||||
}
|
}
|
||||||
list.set(i, info);
|
list.set(i, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IProblemParameterInfo getElement(int i) {
|
public IProblemParameterInfo getElement(int i) {
|
||||||
return list.get(i);
|
return list.get(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ParameterInfo representing a single checker parameter
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SingleParameterInfo extends AbstractProblemParameterInfo {
|
||||||
|
protected String key = PARAM;
|
||||||
|
protected String label;
|
||||||
|
protected String toolTip = null;
|
||||||
|
protected ParameterType type = ParameterType.TYPE_STRING;
|
||||||
|
protected String uiInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate an info with given key and label
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* - property id (use in actual property hash of a checker)
|
||||||
|
* @param label
|
||||||
|
* - label to be shown to user
|
||||||
|
* @param type
|
||||||
|
* - parameter type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SingleParameterInfo(String key, String label, ParameterType type) {
|
||||||
|
if (key == null)
|
||||||
|
throw new NullPointerException("key"); //$NON-NLS-1$
|
||||||
|
if (type == null)
|
||||||
|
throw new NullPointerException("type"); //$NON-NLS-1$
|
||||||
|
setKey(key);
|
||||||
|
setLabel(label);
|
||||||
|
setType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate an info with given key and label
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* - property id (use in actual property hash of a checker)
|
||||||
|
* @param label
|
||||||
|
* - label to be shown to user
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SingleParameterInfo(String key, String label) {
|
||||||
|
setKey(key);
|
||||||
|
setLabel(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate an info with given label, default key PARAM would be as a key
|
||||||
|
*
|
||||||
|
* @param label
|
||||||
|
* - label to be shown to user
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SingleParameterInfo(String label) {
|
||||||
|
setLabel(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParameterType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getToolTip() {
|
||||||
|
return toolTip;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUiInfo() {
|
||||||
|
return uiInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToolTip(String tooltip) {
|
||||||
|
this.toolTip = tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(ParameterType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUiInfo(String uiinfo) {
|
||||||
|
this.uiInfo = uiinfo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,9 +13,9 @@ 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.IProblemParameterInfo;
|
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemReporter;
|
import org.eclipse.cdt.codan.core.model.IProblemReporter;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo;
|
||||||
|
|
||||||
public class CodanProblem implements IProblemWorkingCopy {
|
public class CodanProblem implements IProblemWorkingCopy {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
|
@ -12,11 +12,11 @@ package org.eclipse.cdt.codan.examples.checkers;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.eclipse.cdt.codan.core.cxx.model.AbstractCIndexChecker;
|
import org.eclipse.cdt.codan.core.cxx.model.AbstractCIndexChecker;
|
||||||
import org.eclipse.cdt.codan.core.model.AbstractProblemParameterInfo;
|
|
||||||
import org.eclipse.cdt.codan.core.model.ICheckerWithParameters;
|
import org.eclipse.cdt.codan.core.model.ICheckerWithParameters;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
|
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
|
import org.eclipse.cdt.codan.core.param.AbstractProblemParameterInfo;
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementVisitor;
|
import org.eclipse.cdt.core.model.ICElementVisitor;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
|
|
@ -10,10 +10,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.ui.dialogs;
|
package org.eclipse.cdt.codan.internal.ui.dialogs;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
|
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo;
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo.ParameterType;
|
||||||
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
|
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
|
||||||
|
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||||
import org.eclipse.jface.preference.PreferenceStore;
|
import org.eclipse.jface.preference.PreferenceStore;
|
||||||
import org.eclipse.jface.preference.StringFieldEditor;
|
import org.eclipse.jface.preference.StringFieldEditor;
|
||||||
|
@ -61,14 +65,32 @@ public class ParametersComposite extends Composite {
|
||||||
if (info == null)
|
if (info == null)
|
||||||
return;
|
return;
|
||||||
switch (info.getType()) {
|
switch (info.getType()) {
|
||||||
case TYPE_STRING:
|
case TYPE_STRING: {
|
||||||
StringFieldEditor fe = new StringFieldEditor(info.getKey(),
|
StringFieldEditor fe = new StringFieldEditor(
|
||||||
info.getLabel(), getFieldEditorParent());
|
info.getKey(), info.getLabel(),
|
||||||
addField(fe);
|
getFieldEditorParent());
|
||||||
break;
|
addField(fe);
|
||||||
default:
|
break;
|
||||||
throw new UnsupportedOperationException(info.getType()
|
}
|
||||||
.toString());
|
case TYPE_BOOLEAN: {
|
||||||
|
BooleanFieldEditor fe = new BooleanFieldEditor(
|
||||||
|
info.getKey(), info.getLabel(),
|
||||||
|
getFieldEditorParent());
|
||||||
|
addField(fe);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TYPE_HASH: {
|
||||||
|
Iterator<IProblemParameterInfo> iterator = info
|
||||||
|
.getIterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
IProblemParameterInfo info1 = iterator.next();
|
||||||
|
createFieldEditorsForParameters(info1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
throw new UnsupportedOperationException(info.getType()
|
||||||
|
.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -99,9 +121,18 @@ public class ParametersComposite extends Composite {
|
||||||
return;
|
return;
|
||||||
String key = info.getKey();
|
String key = info.getKey();
|
||||||
Object parameter = problem.getParameter(key);
|
Object parameter = problem.getParameter(key);
|
||||||
if (parameter instanceof String) {
|
if (info.getType() == ParameterType.TYPE_HASH && parameter == null) {
|
||||||
|
Iterator<IProblemParameterInfo> iterator = info.getIterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
IProblemParameterInfo info1 = iterator.next();
|
||||||
|
savePrefStore(info1, problemwc);
|
||||||
|
}
|
||||||
|
} else if (parameter instanceof String) {
|
||||||
String newValue = pref.getString(key);
|
String newValue = pref.getString(key);
|
||||||
problemwc.setParameter(key, newValue);
|
problemwc.setParameter(key, newValue);
|
||||||
|
} else if (parameter instanceof Boolean) {
|
||||||
|
boolean newValue = pref.getBoolean(key);
|
||||||
|
problemwc.setParameter(key, newValue);
|
||||||
} else
|
} else
|
||||||
throw new UnsupportedOperationException(info.getType().toString());
|
throw new UnsupportedOperationException(info.getType().toString());
|
||||||
}
|
}
|
||||||
|
@ -114,9 +145,18 @@ public class ParametersComposite extends Composite {
|
||||||
return;
|
return;
|
||||||
String key = info.getKey();
|
String key = info.getKey();
|
||||||
Object parameter = problem.getParameter(key);
|
Object parameter = problem.getParameter(key);
|
||||||
if (parameter instanceof String) {
|
if (info.getType() == ParameterType.TYPE_HASH && parameter == null) {
|
||||||
|
Iterator<IProblemParameterInfo> iterator = info.getIterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
IProblemParameterInfo info1 = iterator.next();
|
||||||
|
initPrefStore(info1);
|
||||||
|
}
|
||||||
|
} else if (parameter instanceof String) {
|
||||||
pref.setDefault(key, (String) parameter);
|
pref.setDefault(key, (String) parameter);
|
||||||
pref.setValue(key, (String) parameter);
|
pref.setValue(key, (String) parameter);
|
||||||
|
} else if (parameter instanceof Boolean) {
|
||||||
|
pref.setDefault(key, (Boolean) parameter);
|
||||||
|
pref.setValue(key, (Boolean) parameter);
|
||||||
} else
|
} else
|
||||||
throw new UnsupportedOperationException(info.getType().toString());
|
throw new UnsupportedOperationException(info.getType().toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||||
import org.eclipse.cdt.codan.core.CodanRuntime;
|
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||||
import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
|
import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
|
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo;
|
||||||
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
|
||||||
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
|
import org.eclipse.cdt.codan.internal.ui.CodanUIMessages;
|
||||||
import org.eclipse.cdt.codan.internal.ui.dialogs.CustomizeProblemDialog;
|
import org.eclipse.cdt.codan.internal.ui.dialogs.CustomizeProblemDialog;
|
||||||
|
|
Loading…
Add table
Reference in a new issue