Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2012-04-28 20:59:34 -0400
committerSergey Prigogin2012-04-28 20:59:34 -0400
commitc554c4e7079e3ae47341e2907a1ed5423a6e78ea (patch)
tree7c8c61c964236e18622cf4415d594346d6db611d /codan/org.eclipse.cdt.codan.ui.cxx
parent5a643e5e57830c170edd1047d1a0232fab58dd98 (diff)
downloadorg.eclipse.cdt-c554c4e7079e3ae47341e2907a1ed5423a6e78ea.tar.gz
org.eclipse.cdt-c554c4e7079e3ae47341e2907a1ed5423a6e78ea.tar.xz
org.eclipse.cdt-c554c4e7079e3ae47341e2907a1ed5423a6e78ea.zip
Don't run checkers on UI thread.
Diffstat (limited to 'codan/org.eclipse.cdt.codan.ui.cxx')
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java2
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Messages.java26
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Messages.properties12
-rw-r--r--codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Startup.java42
4 files changed, 70 insertions, 12 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java
index c0c0030fe5..8ced0fda26 100644
--- a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Activator.java
@@ -66,7 +66,7 @@ public class Activator extends AbstractUIPlugin {
* @param e the exception to be logged
*/
public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, 1, "Internal Error", e)); //$NON-NLS-1$
+ log(new Status(IStatus.ERROR, PLUGIN_ID, 1, Messages.Activatior_Error, e));
}
/**
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Messages.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Messages.java
new file mode 100644
index 0000000000..d29000960b
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Messages.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Google, Inc 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.ui.cxx;
+
+import org.eclipse.osgi.util.NLS;
+
+class Messages extends NLS {
+ public static String Activatior_Error;
+ public static String Startup_AnalyzingFile;
+
+ static {
+ // Initialize resource bundle
+ NLS.initializeMessages(Messages.class.getName(), Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Messages.properties b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Messages.properties
new file mode 100644
index 0000000000..bb6a767564
--- /dev/null
+++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/internal/ui/cxx/Messages.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2012 Google, Inc 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
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Sergey Prigogin (Google) - initial API and implementation
+###############################################################################
+Activatior_InternalError=Error
+Startup_AnalyzingFile=Analizing ''{0}''
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 fa26b70967..237308dfd6 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
@@ -1,12 +1,14 @@
/*******************************************************************************
- * 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Alena Laskavaia - initial API and implementation
+ * Alena Laskavaia - initial API and implementation
+ * Alex Ruiz (Google)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.cxx;
@@ -16,7 +18,11 @@ 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.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IStartup;
@@ -33,11 +39,7 @@ import org.eclipse.ui.PlatformUI;
public class Startup implements IStartup {
private static final IProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor();
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IStartup#earlyStartup()
- */
+ @Override
public void earlyStartup() {
registerListeners();
}
@@ -48,18 +50,22 @@ public class Startup implements IStartup {
private void registerListeners() {
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
+ @Override
public void run() {
IWorkbenchWindow active = workbench.getActiveWorkbenchWindow();
final IWorkbenchPage page = active.getActivePage();
IPartListener2 partListener = new IPartListener2() {
CodanCReconciler reconciler = new CodanCReconciler();
+ @Override
public void partActivated(IWorkbenchPartReference partRef) {
}
+ @Override
public void partDeactivated(IWorkbenchPartReference partRef) {
}
+ @Override
public void partOpened(IWorkbenchPartReference partRef) {
IWorkbenchPart part = partRef.getPart(false);
if (part instanceof CEditor) {
@@ -72,17 +78,29 @@ public class Startup implements IStartup {
}
}
- private void processResource(IResource resource) {
- CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance().getBuilder();
- builder.processResource(resource, NULL_PROGRESS_MONITOR, CheckerLaunchMode.RUN_ON_FILE_OPEN);
+ private void processResource(final IResource resource) {
+ Job job = new Job(NLS.bind(Messages.Startup_AnalyzingFile, resource.getName())) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ CodanBuilder builder = (CodanBuilder) CodanRuntime.getInstance().getBuilder();
+ builder.processResource(resource, NULL_PROGRESS_MONITOR, CheckerLaunchMode.RUN_ON_FILE_OPEN);
+ return Status.OK_STATUS;
+ }
+ };
+ job.setRule(resource);
+ job.setSystem(true);
+ job.schedule();
}
+ @Override
public void partHidden(IWorkbenchPartReference partRef) {
}
+ @Override
public void partVisible(IWorkbenchPartReference partRef) {
}
+ @Override
public void partClosed(IWorkbenchPartReference partRef) {
IWorkbenchPart part = partRef.getPart(false);
if (part instanceof CEditor) {
@@ -90,14 +108,16 @@ public class Startup implements IStartup {
}
}
+ @Override
public void partBroughtToTop(IWorkbenchPartReference partRef) {
}
+ @Override
public void partInputChanged(IWorkbenchPartReference partRef) {
}
};
page.addPartListener(partListener);
- // check current open editors
+ // Check current open editors.
IEditorReference[] editorReferences = page.getEditorReferences();
for (int i = 0; i < editorReferences.length; i++) {
IEditorReference ref = editorReferences[i];

Back to the top