mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
semantic errors problem would not run on build by default
This commit is contained in:
parent
117fd4a222
commit
1db363d94c
4 changed files with 50 additions and 12 deletions
|
@ -14,6 +14,8 @@ package org.eclipse.cdt.codan.internal.checkers;
|
||||||
import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
|
import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
|
||||||
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
|
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
|
||||||
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
||||||
|
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
|
||||||
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
@ -58,6 +60,16 @@ public class ProblemBindingChecker extends AbstractIndexAstChecker {
|
||||||
public boolean runInEditor() {
|
public boolean runInEditor() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.codan.core.model.AbstractCheckerWithProblemPreferences#initPreferences(org.eclipse.cdt.codan.core.model.IProblemWorkingCopy)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void initPreferences(IProblemWorkingCopy problem) {
|
||||||
|
super.initPreferences(problem);
|
||||||
|
// these checkers should not run on full or incremental build
|
||||||
|
getLaunchModePreference(problem).enableInLaunchModes(CheckerLaunchMode.RUN_AS_YOU_TYPE, CheckerLaunchMode.RUN_ON_DEMAND);
|
||||||
|
}
|
||||||
|
|
||||||
public void processAst(IASTTranslationUnit ast) {
|
public void processAst(IASTTranslationUnit ast) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.codan.core.param.BasicProblemPreference;
|
||||||
import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
|
import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
|
||||||
import org.eclipse.cdt.codan.core.param.IProblemPreference;
|
import org.eclipse.cdt.codan.core.param.IProblemPreference;
|
||||||
import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor.PreferenceType;
|
import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor.PreferenceType;
|
||||||
|
import org.eclipse.cdt.codan.core.param.LaunchModeProblemPreference;
|
||||||
import org.eclipse.cdt.codan.core.param.ListProblemPreference;
|
import org.eclipse.cdt.codan.core.param.ListProblemPreference;
|
||||||
import org.eclipse.cdt.codan.core.param.MapProblemPreference;
|
import org.eclipse.cdt.codan.core.param.MapProblemPreference;
|
||||||
import org.eclipse.cdt.codan.core.param.RootProblemPreference;
|
import org.eclipse.cdt.codan.core.param.RootProblemPreference;
|
||||||
|
@ -49,6 +50,17 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param problem - problem for which preference is extracted
|
||||||
|
* @return launch mode preference
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public LaunchModeProblemPreference getLaunchModePreference(IProblem problem) {
|
||||||
|
LaunchModeProblemPreference launchModes = getTopLevelPreference(problem).getLaunchModePreference();
|
||||||
|
return launchModes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User can scope out some resources for this checker. Checker can use this
|
* User can scope out some resources for this checker. Checker can use this
|
||||||
* call to test if it should run on this resource at all or not. Test should
|
* call to test if it should run on this resource at all or not. Test should
|
||||||
|
|
|
@ -35,18 +35,18 @@ public class LaunchModeProblemPreference extends MapProblemPreference {
|
||||||
* constructor
|
* constructor
|
||||||
*/
|
*/
|
||||||
public LaunchModeProblemPreference() {
|
public LaunchModeProblemPreference() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if values has not been set
|
* @return true if values has not been set
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isDefault(){
|
public boolean isDefault() {
|
||||||
CheckerLaunchMode[] values = CheckerLaunchMode.values();
|
CheckerLaunchMode[] values = CheckerLaunchMode.values();
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
CheckerLaunchMode checkerLaunchMode = values[i];
|
CheckerLaunchMode checkerLaunchMode = values[i];
|
||||||
if (getChildDescriptor(checkerLaunchMode.name())!=null) return false;
|
if (getChildDescriptor(checkerLaunchMode.name()) != null)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class LaunchModeProblemPreference extends MapProblemPreference {
|
||||||
* @return true if this mode enabled for this preference
|
* @return true if this mode enabled for this preference
|
||||||
*/
|
*/
|
||||||
public boolean isRunningInMode(CheckerLaunchMode mode) {
|
public boolean isRunningInMode(CheckerLaunchMode mode) {
|
||||||
if (getChildDescriptor(mode.name())==null) {
|
if (getChildDescriptor(mode.name()) == null) {
|
||||||
if (mode == CheckerLaunchMode.RUN_ON_INC_BUILD)
|
if (mode == CheckerLaunchMode.RUN_ON_INC_BUILD)
|
||||||
return isRunningInMode(CheckerLaunchMode.RUN_ON_FULL_BUILD);
|
return isRunningInMode(CheckerLaunchMode.RUN_ON_FULL_BUILD);
|
||||||
return true; // default is true
|
return true; // default is true
|
||||||
|
@ -82,6 +82,7 @@ public class LaunchModeProblemPreference extends MapProblemPreference {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Set a single running mode to a value (if mode is not defined it value assumed to be true!)
|
||||||
* @param mode
|
* @param mode
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
|
@ -93,6 +94,24 @@ public class LaunchModeProblemPreference extends MapProblemPreference {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set modes in the argument list to true, and the rest to false
|
||||||
|
* @param modes
|
||||||
|
*/
|
||||||
|
public void enableInLaunchModes(CheckerLaunchMode... modes) {
|
||||||
|
CheckerLaunchMode[] all = CheckerLaunchMode.values();
|
||||||
|
for (int i = 0; i < all.length; i++) {
|
||||||
|
CheckerLaunchMode mode = all[i];
|
||||||
|
if (getChildDescriptor(mode.name()) == null) {
|
||||||
|
addLaunchMode(mode, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < modes.length; i++) {
|
||||||
|
CheckerLaunchMode mode = modes[i];
|
||||||
|
setChildValue(mode.name(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if all modes are enabled (or this is parent mode)
|
* @return true if all modes are enabled (or this is parent mode)
|
||||||
*/
|
*/
|
||||||
|
@ -112,9 +131,9 @@ public class LaunchModeProblemPreference extends MapProblemPreference {
|
||||||
@Override
|
@Override
|
||||||
protected IProblemPreference importChildValue(String key, StreamTokenizer tokenizer) throws IOException {
|
protected IProblemPreference importChildValue(String key, StreamTokenizer tokenizer) throws IOException {
|
||||||
IProblemPreference desc = getChildDescriptor(key);
|
IProblemPreference desc = getChildDescriptor(key);
|
||||||
if (desc==null) {
|
if (desc == null) {
|
||||||
CheckerLaunchMode mode = CheckerLaunchMode.valueOf(key);
|
CheckerLaunchMode mode = CheckerLaunchMode.valueOf(key);
|
||||||
if (mode==null)
|
if (mode == null)
|
||||||
throw new IllegalArgumentException(key);
|
throw new IllegalArgumentException(key);
|
||||||
desc = addLaunchMode(mode, true);
|
desc = addLaunchMode(mode, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.eclipse.cdt.codan.core.model.IProblemCategory;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
import org.eclipse.cdt.codan.core.model.IProblemProfile;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
import org.eclipse.cdt.codan.core.param.LaunchModeProblemPreference;
|
import org.eclipse.cdt.codan.core.param.LaunchModeProblemPreference;
|
||||||
import org.eclipse.cdt.codan.core.param.RootProblemPreference;
|
|
||||||
import org.eclipse.cdt.codan.internal.core.model.CodanProblem;
|
import org.eclipse.cdt.codan.internal.core.model.CodanProblem;
|
||||||
import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory;
|
import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory;
|
||||||
import org.eclipse.cdt.codan.internal.core.model.ProblemProfile;
|
import org.eclipse.cdt.codan.internal.core.model.ProblemProfile;
|
||||||
|
@ -442,11 +441,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
if (problem == null)
|
if (problem == null)
|
||||||
throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
|
throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
|
||||||
if (checker instanceof AbstractCheckerWithProblemPreferences) {
|
if (checker instanceof AbstractCheckerWithProblemPreferences) {
|
||||||
RootProblemPreference root = ((AbstractCheckerWithProblemPreferences)checker).getTopLevelPreference(problem);
|
LaunchModeProblemPreference pref = ((AbstractCheckerWithProblemPreferences) checker).getLaunchModePreference(problem);
|
||||||
|
|
||||||
LaunchModeProblemPreference pref = root.getLaunchModePreference();
|
|
||||||
// XXX: how to set defaults
|
|
||||||
|
|
||||||
if (pref.isRunningInMode(mode)) {
|
if (pref.isRunningInMode(mode)) {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue