mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 372551. Fixed running checkers on file open. Split "On file save"
launch mode into "On file save" and "On file open". Removed warnings in project org.eclipse.cdt.codan.ui.cxx. Change-Id: I7f0bc16731ba36e8048904f19836da9ae47514de Reviewed-on: https://git.eclipse.org/r/5665 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
73f53173ec
commit
181907f2fd
9 changed files with 48 additions and 24 deletions
|
@ -162,6 +162,7 @@ public abstract class AbstractExternalToolBasedChecker extends AbstractCheckerWi
|
|||
getLaunchModePreference(problem).enableInLaunchModes(
|
||||
CheckerLaunchMode.RUN_ON_FULL_BUILD,
|
||||
CheckerLaunchMode.RUN_ON_INC_BUILD,
|
||||
CheckerLaunchMode.RUN_ON_FILE_OPEN,
|
||||
CheckerLaunchMode.RUN_ON_FILE_SAVE,
|
||||
CheckerLaunchMode.RUN_ON_DEMAND);
|
||||
addPreference(problem, settings.getPath());
|
||||
|
|
|
@ -31,8 +31,13 @@ public enum CheckerLaunchMode {
|
|||
*/
|
||||
RUN_ON_INC_BUILD,
|
||||
/**
|
||||
* Checker runs when a file is saved or opened. Checker will not run if the file is an editor
|
||||
* with unsaved changes.
|
||||
* Checker runs when a file is opened.
|
||||
* @since 2.1
|
||||
*/
|
||||
RUN_ON_FILE_OPEN,
|
||||
/**
|
||||
* Checker runs when a file is saved. Checker will not run if the file is an editor with unsaved
|
||||
* changes.
|
||||
* @since 2.1
|
||||
*/
|
||||
RUN_ON_FILE_SAVE,
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
/**
|
||||
* @author Alena
|
||||
|
@ -29,18 +28,14 @@ import org.eclipse.ui.texteditor.ITextEditor;
|
|||
public class CodanCReconciler implements ICReconcilingListener {
|
||||
private CxxCodanReconciler reconsiler = new CxxCodanReconciler();
|
||||
|
||||
void install(ITextEditor editor) {
|
||||
if (editor instanceof CEditor) {
|
||||
void install(CEditor editor) {
|
||||
initialize();
|
||||
((CEditor) editor).addReconcileListener(this);
|
||||
}
|
||||
editor.addReconcileListener(this);
|
||||
}
|
||||
|
||||
void uninstall(ITextEditor editor) {
|
||||
if (editor instanceof CEditor) {
|
||||
void uninstall(CEditor editor) {
|
||||
initialize();
|
||||
((CEditor) editor).removeReconcileListener(this);
|
||||
}
|
||||
editor.removeReconcileListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,13 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.ui.cxx;
|
||||
|
||||
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||
import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
|
||||
import org.eclipse.cdt.codan.internal.core.CodanBuilder;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.IPartListener2;
|
||||
import org.eclipse.ui.IStartup;
|
||||
|
@ -19,12 +26,13 @@ import org.eclipse.ui.IWorkbenchPart;
|
|||
import org.eclipse.ui.IWorkbenchPartReference;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
/**
|
||||
* @author Alena Laskavaia
|
||||
*/
|
||||
public class Startup implements IStartup {
|
||||
private static final IProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -44,7 +52,7 @@ public class Startup implements IStartup {
|
|||
IWorkbenchWindow active = workbench.getActiveWorkbenchWindow();
|
||||
final IWorkbenchPage page = active.getActivePage();
|
||||
IPartListener2 partListener = new IPartListener2() {
|
||||
CodanCReconciler reconsiler = new CodanCReconciler();
|
||||
CodanCReconciler reconciler = new CodanCReconciler();
|
||||
|
||||
public void partActivated(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
|
@ -53,11 +61,21 @@ public class Startup implements IStartup {
|
|||
}
|
||||
|
||||
public void partOpened(IWorkbenchPartReference partRef) {
|
||||
IWorkbenchPart editor = partRef.getPart(false);
|
||||
if (editor instanceof ITextEditor) {
|
||||
reconsiler.install((ITextEditor) editor);
|
||||
IWorkbenchPart part = partRef.getPart(false);
|
||||
if (part instanceof CEditor) {
|
||||
CEditor editor = (CEditor) part;
|
||||
reconciler.install(editor);
|
||||
IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
|
||||
if (resource != null) {
|
||||
processResource(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processResource(IResource resource) {
|
||||
CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance().getBuilder();
|
||||
builder.processResource(resource, NULL_PROGRESS_MONITOR, CheckerLaunchMode.RUN_ON_FILE_OPEN);
|
||||
}
|
||||
|
||||
public void partHidden(IWorkbenchPartReference partRef) {
|
||||
}
|
||||
|
@ -67,8 +85,8 @@ public class Startup implements IStartup {
|
|||
|
||||
public void partClosed(IWorkbenchPartReference partRef) {
|
||||
IWorkbenchPart part = partRef.getPart(false);
|
||||
if (part instanceof ITextEditor) {
|
||||
reconsiler.uninstall((ITextEditor) part);
|
||||
if (part instanceof CEditor) {
|
||||
reconciler.uninstall((CEditor) part);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* Alena Laskavaia - initial API and implementation
|
||||
* IBM Corporation
|
||||
* Sergey Prigogin (Google)
|
||||
* Alex Ruiz (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.ui;
|
||||
|
||||
|
@ -88,6 +89,7 @@ public class CodanUIMessages extends NLS {
|
|||
public static String LaunchModesPropertyPage_RunOnFullBuild;
|
||||
public static String LaunchModesPropertyPage_RunOnIncrementalBuild;
|
||||
public static String LaunchModesPropertyPage_RunOnFileSave;
|
||||
public static String LaunchModesPropertyPage_RunOnFileOpen;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(CodanUIMessages.class.getName(), CodanUIMessages.class);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# Alena Laskavaia - initial API and implementation
|
||||
# IBM Corporation
|
||||
# Sergey Prigogin (Google)
|
||||
# Alex Ruiz (Google)
|
||||
###############################################################################
|
||||
BuildPropertyPage_Description=Set launch method for checkers, you can override this by editing individual problem settings
|
||||
BuildPropertyPage_RunAsYouType=Run as you &type (selected checkers)
|
||||
|
@ -96,4 +97,5 @@ 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 or open
|
||||
LaunchModesPropertyPage_RunOnFileSave=Run on file save
|
||||
LaunchModesPropertyPage_RunOnFileOpen=Run on file open
|
||||
|
|
|
@ -63,6 +63,7 @@ public class LaunchModesPropertyPage extends FieldEditorPreferencePage {
|
|||
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()));
|
||||
|
|
|
@ -84,7 +84,7 @@ Export-Package: org.eclipse.cdt.core,
|
|||
org.eclipse.cdt.internal.core.pdom.dom.cpp;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.pdom.export;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.pdom.indexer;x-friends:="org.eclipse.cdt.ui",
|
||||
org.eclipse.cdt.internal.core.resources;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.make.core",
|
||||
org.eclipse.cdt.internal.core.resources;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.make.core,org.eclipse.cdt.codan.ui.cxx",
|
||||
org.eclipse.cdt.internal.core.settings.model;x-internal:=true,
|
||||
org.eclipse.cdt.internal.core.util;x-internal:=true,
|
||||
org.eclipse.cdt.internal.errorparsers;x-internal:=true,
|
||||
|
|
|
@ -22,7 +22,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
|
|||
org.eclipse.cdt.internal.ui.dialogs;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.dialogs.cpaths;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.dnd;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.editor;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.editor;x-friends:="org.eclipse.cdt.codan.ui.cxx",
|
||||
org.eclipse.cdt.internal.ui.editor.asm;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.filters;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.help;x-internal:=true,
|
||||
|
@ -47,7 +47,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
|
|||
org.eclipse.cdt.internal.ui.resources,
|
||||
org.eclipse.cdt.internal.ui.search;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.search.actions;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.text;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.text;x-friends:="org.eclipse.cdt.codan.ui.cxx",
|
||||
org.eclipse.cdt.internal.ui.text.asm;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.text.c.hover;x-internal:=true,
|
||||
org.eclipse.cdt.internal.ui.text.contentassist;x-internal:=true,
|
||||
|
|
Loading…
Add table
Reference in a new issue