summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Ruiz2012-04-26 14:23:00 (EDT)
committer Sergey Prigogin2012-04-26 23:02:11 (EDT)
commit181907f2fd9fab50a6753ac1f495ec1486d3d25f (patch)
tree7c5c17e3cbf4f4305ca6959f56745cead0271f7c
parent73f53173ecee33b2b6df44216075a001ff9338ce (diff)
downloadorg.eclipse.cdt-181907f2fd9fab50a6753ac1f495ec1486d3d25f.zip
org.eclipse.cdt-181907f2fd9fab50a6753ac1f495ec1486d3d25f.tar.gz
org.eclipse.cdt-181907f2fd9fab50a6753ac1f495ec1486d3d25f.tar.bz2
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>
-rw-r--r--codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/externaltool/AbstractExternalToolBasedChecker.java1
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckerLaunchMode.java9
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java17
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java32
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java2
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties4
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java1
-rw-r--r--core/org.eclipse.cdt.core/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF4
9 files changed, 48 insertions, 24 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/externaltool/AbstractExternalToolBasedChecker.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/externaltool/AbstractExternalToolBasedChecker.java
index 20b7b29..41b38c1 100644
--- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/externaltool/AbstractExternalToolBasedChecker.java
+++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/externaltool/AbstractExternalToolBasedChecker.java
@@ -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());
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckerLaunchMode.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckerLaunchMode.java
index 677bb75..660cceb 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckerLaunchMode.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckerLaunchMode.java
@@ -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,
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java
index 687898f..18b491f 100644
--- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/CodanCReconciler.java
@@ -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) {
- initialize();
- ((CEditor) editor).addReconcileListener(this);
- }
+ void install(CEditor editor) {
+ initialize();
+ editor.addReconcileListener(this);
}
- void uninstall(ITextEditor editor) {
- if (editor instanceof CEditor) {
- initialize();
- ((CEditor) editor).removeReconcileListener(this);
- }
+ void uninstall(CEditor editor) {
+ initialize();
+ editor.removeReconcileListener(this);
}
/**
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java
index 0075bce..fa26b70 100644
--- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java
@@ -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);
}
}
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java
index cc8c553..821c5c4 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.java
@@ -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);
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties
index 414ab1e..b00af0a 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIMessages.properties
@@ -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
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java
index 733f7c1..2c3e929 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/LaunchModesPropertyPage.java
@@ -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()));
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index 908a38a..cc0667b 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -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,
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index cb5ca91..ed8dab4 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -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,