mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Eliminated redundant checker runs.
This commit is contained in:
parent
07924ceeeb
commit
c8e3a663f0
8 changed files with 33 additions and 112 deletions
|
@ -160,11 +160,9 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
|
|||
public void initPreferences(IProblemWorkingCopy problem) {
|
||||
super.initPreferences(problem);
|
||||
getLaunchModePreference(problem).enableInLaunchModes(
|
||||
CheckerLaunchMode.RUN_ON_FULL_BUILD,
|
||||
CheckerLaunchMode.RUN_ON_INC_BUILD,
|
||||
CheckerLaunchMode.RUN_ON_DEMAND,
|
||||
CheckerLaunchMode.RUN_ON_FILE_OPEN,
|
||||
CheckerLaunchMode.RUN_ON_FILE_SAVE,
|
||||
CheckerLaunchMode.RUN_ON_DEMAND);
|
||||
CheckerLaunchMode.RUN_ON_FILE_SAVE);
|
||||
addPreference(problem, settings.getPath());
|
||||
addPreference(problem, settings.getArgs());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Alena Laskavaia
|
||||
* Copyright (c) 2009, 2012 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.model;
|
||||
|
||||
|
@ -25,8 +26,7 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* AbstractChecker that has extra methods to simplify adding problem
|
||||
* preferences.
|
||||
* AbstractChecker that has extra methods to simplify adding problem preferences.
|
||||
* Checker can produce several problems, but preferences are per problem.
|
||||
* Sharing preferences between problems is not supported now.
|
||||
*/
|
||||
|
@ -38,6 +38,11 @@ public abstract class AbstractCheckerWithProblemPreferences extends AbstractChec
|
|||
@Override
|
||||
public void initPreferences(IProblemWorkingCopy problem) {
|
||||
getTopLevelPreference(problem); // initialize
|
||||
getLaunchModePreference(problem).enableInLaunchModes(
|
||||
CheckerLaunchMode.RUN_AS_YOU_TYPE,
|
||||
CheckerLaunchMode.RUN_ON_DEMAND,
|
||||
CheckerLaunchMode.RUN_ON_FULL_BUILD,
|
||||
CheckerLaunchMode.RUN_ON_INC_BUILD);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,7 +69,7 @@ public interface IChecker {
|
|||
* @param resource the resource to run on.
|
||||
* @return true if checker should be run on this resource.
|
||||
* @deprecated Ignored since 2.0. Replaced by
|
||||
* {@code CheckersRegistry.isCheckerEnabled((IChecker, IResource, CheckerLaunchMode)}
|
||||
* {@link org.eclipse.cdt.codan.internal.core.CheckersRegistry#isCheckerEnabled(IChecker, IResource, CheckerLaunchMode)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean enabledInContext(IResource resource);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class LaunchModeProblemPreference extends MapProblemPreference {
|
|||
if (getChildDescriptor(mode.name()) == null) {
|
||||
if (mode == CheckerLaunchMode.RUN_ON_INC_BUILD)
|
||||
return isRunningInMode(CheckerLaunchMode.RUN_ON_FULL_BUILD);
|
||||
return true; // default is true
|
||||
return false; // default is false
|
||||
}
|
||||
Object value = getChildValue(mode.name());
|
||||
if (value instanceof Boolean) {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009,2010 QNX Software Systems
|
||||
* Copyright (c) 2009, 2010 QNX Software Systems
|
||||
* 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:
|
||||
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
||||
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.param;
|
||||
|
||||
|
@ -58,8 +58,7 @@ public class MapProblemPreference extends AbstractProblemPreference implements I
|
|||
}
|
||||
|
||||
/**
|
||||
* Get parameter preference for element by key
|
||||
*
|
||||
* Returns parameter preference for element by key
|
||||
*/
|
||||
@Override
|
||||
public IProblemPreference getChildDescriptor(String key) {
|
||||
|
|
|
@ -257,11 +257,6 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
return Platform.getExtensionRegistry().getExtensionPoint(CodanCorePlugin.PLUGIN_ID, extensionPointName);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.codan.core.model.ICheckersRegistry#iterator()
|
||||
*/
|
||||
@Override
|
||||
public Iterator<IChecker> iterator() {
|
||||
return checkers.iterator();
|
||||
|
@ -278,25 +273,11 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
return instance;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.codan.core.model.ICheckersRegistry#addChecker(org.eclipse
|
||||
* .cdt.codan.core.model.IChecker)
|
||||
*/
|
||||
@Override
|
||||
public void addChecker(IChecker checker) {
|
||||
checkers.add(checker);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.codan.core.model.ICheckersRegistry#addProblem(org.eclipse
|
||||
* .cdt.codan.core.model.IProblem, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void addProblem(IProblem p, String category) {
|
||||
IProblemCategory cat = getDefaultProfile().findCategory(category);
|
||||
|
@ -305,13 +286,6 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
((ProblemProfile) getDefaultProfile()).addProblem(p, cat);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.codan.core.model.ICheckersRegistry#addCategory(org.eclipse
|
||||
* .cdt.codan.core.model.IProblemCategory, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void addCategory(IProblemCategory p, String category) {
|
||||
IProblemCategory cat = getDefaultProfile().findCategory(category);
|
||||
|
@ -320,14 +294,6 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
((ProblemProfile) getDefaultProfile()).addCategory(p, cat);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.codan.core.model.ICheckersRegistry#addRefProblem(org.
|
||||
* eclipse.cdt.codan.core.model.IChecker,
|
||||
* org.eclipse.cdt.codan.core.model.IProblem)
|
||||
*/
|
||||
@Override
|
||||
public void addRefProblem(IChecker c, IProblem p) {
|
||||
Collection<IProblem> plist = problemList.get(c);
|
||||
|
@ -358,23 +324,11 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
return problemList.get(checker);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.codan.core.model.ICheckersRegistry#getDefaultProfile()
|
||||
*/
|
||||
@Override
|
||||
public IProblemProfile getDefaultProfile() {
|
||||
return profiles.get(DEFAULT);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.codan.core.model.ICheckersRegistry#getWorkspaceProfile()
|
||||
*/
|
||||
@Override
|
||||
public IProblemProfile getWorkspaceProfile() {
|
||||
IProblemProfile wp = profiles.get(ResourcesPlugin.getWorkspace());
|
||||
|
@ -396,7 +350,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
|
||||
@Override
|
||||
public void updateProfile(IResource element, IProblemProfile profile) {
|
||||
// updating profile can invalidate all cached profiles
|
||||
// Updating profile can invalidate all cached profiles
|
||||
IProblemProfile defaultProfile = getDefaultProfile();
|
||||
profiles.clear();
|
||||
profiles.put(DEFAULT, defaultProfile);
|
||||
|
@ -404,13 +358,6 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
profiles.put(element, profile);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.cdt.codan.core.model.ICheckersRegistry#getResourceProfile
|
||||
* (org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public IProblemProfile getResourceProfile(IResource element) {
|
||||
IProblemProfile prof = profiles.get(element);
|
||||
|
@ -418,7 +365,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
if (element instanceof IProject) {
|
||||
prof = (IProblemProfile) getWorkspaceProfile().clone();
|
||||
((ProblemProfile) prof).setResource(element);
|
||||
// load default values
|
||||
// Load default values
|
||||
CodanPreferencesLoader loader = new CodanPreferencesLoader(prof);
|
||||
Preferences projectNode = CodanPreferencesLoader.getProjectNode((IProject) element);
|
||||
boolean useWorkspace = projectNode.getBoolean(PreferenceConstants.P_USE_PARENT, true);
|
||||
|
@ -435,12 +382,6 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
return prof;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.eclipse.cdt.codan.core.model.ICheckersRegistry#
|
||||
* getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public IProblemProfile getResourceProfileWorkingCopy(IResource element) {
|
||||
IProblemProfile prof = (IProblemProfile) getResourceProfile(element).clone();
|
||||
|
@ -471,8 +412,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
|
||||
IProblemProfile resourceProfile = getResourceProfile(resource);
|
||||
Collection<IProblem> refProblems = getRefProblems(checker);
|
||||
for (Iterator<IProblem> iterator = refProblems.iterator(); iterator.hasNext();) {
|
||||
IProblem p = iterator.next();
|
||||
for (IProblem p : refProblems) {
|
||||
// We need to check problem enablement in a particular profile.
|
||||
IProblem problem = resourceProfile.findProblem(p.getId());
|
||||
if (problem == null)
|
||||
|
@ -525,7 +465,7 @@ public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
|
|||
int num = 0;
|
||||
try {
|
||||
num = Integer.parseInt(x.getId().substring(prefix.length()));
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
// well...
|
||||
}
|
||||
if (max < num)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2010, 2011 Alena Laskavaia and others.
|
||||
# Copyright (c) 2010, 2012 Alena Laskavaia and others.
|
||||
# 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
|
||||
|
@ -74,13 +74,13 @@ ExclusionInclusionEntryDialog_exclude_add_title=Add Exclusion Pattern
|
|||
ExclusionInclusionEntryDialog_exclude_edit_title=Edit Exclusion Pattern
|
||||
ExclusionInclusionEntryDialog_exclude_description=Enter a pattern for excluding files from the source folder. Allowed wildcards are '*', '?' and '**'. Examples: 'src/util/a*.c', 'src/util/', '**/Test*'.
|
||||
|
||||
ExclusionInclusionEntryDialog_exclude_pattern_label=E&xclusion pattern (Path relative to ''{0}''):
|
||||
ExclusionInclusionEntryDialog_exclude_pattern_label=E&xclusion pattern (path relative to ''{0}''):
|
||||
|
||||
ExclusionInclusionEntryDialog_include_add_title=Add Inclusion Pattern
|
||||
ExclusionInclusionEntryDialog_include_edit_title=Edit Inclusion Pattern
|
||||
ExclusionInclusionEntryDialog_include_description=Enter a pattern for including files to the source folder. Allowed wildcards are '*', '?' and '**'. Examples: 'src/util/a*.c', 'src/util/', '**/Test*'.
|
||||
|
||||
ExclusionInclusionEntryDialog_include_pattern_label=I&nclusion pattern (Path relative to ''{0}''):
|
||||
ExclusionInclusionEntryDialog_include_pattern_label=I&nclusion pattern (path relative to ''{0}''):
|
||||
|
||||
ExclusionInclusionEntryDialog_pattern_button=Bro&wse...
|
||||
|
||||
|
@ -93,9 +93,9 @@ ExclusionInclusionEntryDialog_ChooseExclusionPattern_description=&Choose a folde
|
|||
|
||||
ExclusionInclusionEntryDialog_ChooseInclusionPattern_title=Inclusion Pattern Selection
|
||||
ExclusionInclusionEntryDialog_ChooseInclusionPattern_description=&Choose a folder or file to include:
|
||||
LaunchModesPropertyPage_RunAsYouType=Run as you type
|
||||
LaunchModesPropertyPage_RunOnDemand=Run on demand
|
||||
LaunchModesPropertyPage_RunOnFullBuild=Run on full build
|
||||
LaunchModesPropertyPage_RunOnIncrementalBuild=Run on incremental build
|
||||
LaunchModesPropertyPage_RunOnFileSave=Run on file save
|
||||
LaunchModesPropertyPage_RunOnFileOpen=Run on file open
|
||||
LaunchModesPropertyPage_RunAsYouType=Run as you &type
|
||||
LaunchModesPropertyPage_RunOnFileOpen=Run on file &open
|
||||
LaunchModesPropertyPage_RunOnFileSave=Run on file &save
|
||||
LaunchModesPropertyPage_RunOnIncrementalBuild=Run on i&ncremental build
|
||||
LaunchModesPropertyPage_RunOnFullBuild=Run on &full build
|
||||
LaunchModesPropertyPage_RunOnDemand=Run on &demand
|
||||
|
|
|
@ -51,45 +51,24 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
|
|||
super.noDefaultAndApplyButton();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
protected void createFieldEditors() {
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FULL_BUILD.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnFullBuild, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_INC_BUILD.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnIncrementalBuild, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_DEMAND.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnDemand, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FILE_OPEN.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnFileOpen, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FILE_SAVE.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnFileSave, getFieldEditorParent()));
|
||||
if (runInEditor) {
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_AS_YOU_TYPE.name(), CodanUIMessages.LaunchModesPropertyPage_RunAsYouType, getFieldEditorParent()));
|
||||
}
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FILE_OPEN.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnFileOpen, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FILE_SAVE.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnFileSave, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_INC_BUILD.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnIncrementalBuild, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_FULL_BUILD.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnFullBuild, getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(CheckerLaunchMode.RUN_ON_DEMAND.name(), CodanUIMessages.LaunchModesPropertyPage_RunOnDemand, getFieldEditorParent()));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.jface.preference.FieldEditorPreferencePage#addField(org.eclipse
|
||||
* .jface.preference.FieldEditor)
|
||||
*/
|
||||
@Override
|
||||
protected void addField(FieldEditor editor) {
|
||||
editors.add(editor);
|
||||
super.addField(editor);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void configureProjectSettings() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
boolean result = super.performOk();
|
||||
|
|
Loading…
Add table
Reference in a new issue