summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java
diff options
context:
space:
mode:
authorElliott Baron <ebaron@fedoraproject.org>2010-06-26 22:27:34 -0400
committerElliott Baron <ebaron@fedoraproject.org>2010-06-26 22:27:34 -0400
commit4e112eca7750a4f530c986be55c178c43c16d3ea (patch)
treedb140c4fe4db9945502398e4869707ca0346353e /org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java
parentaa73b3f2503808e4b4029a73368a75b258d6f0dc (diff)
downloadcodan-4e112eca7750a4f530c986be55c178c43c16d3ea.tar.gz
codan-4e112eca7750a4f530c986be55c178c43c16d3ea.tar.xz
codan-4e112eca7750a4f530c986be55c178c43c16d3ea.zip
Update codan plugins to CDT 7.0.HEADmaster
* org.eclipse.cdt.codan.checkers.ui: Updated. * org.eclipse.cdt.codan.checkers: Updated. * org.eclipse.cdt.codan.core: Updated. * org.eclipse.cdt.codan.ui: Updated. * org.eclipse.cdt.codan.core.cxx: Added. * org.eclipse.cdt.codan.extension/META-INF/MANIFEST.MF: Import org.eclipse.cdt.codan.core.cxx.model. * org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/checkers/AbstractPropSimChecker.java: Superclass moved.
Diffstat (limited to 'org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java')
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java118
1 files changed, 118 insertions, 0 deletions
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java
new file mode 100644
index 0000000..188be3c
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alena Laskavaia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.codan.internal.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.core.Messages;
+import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Application to support headless build
+ *
+ * @noextend This class is not intended to be extended by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class CodanApplication implements IApplication {
+ private Collection<String> projects = new ArrayList<String>();
+ private boolean verbose = false;
+ private boolean all = false;
+
+ public Object start(IApplicationContext context) throws Exception {
+ String[] args = (String[]) context.getArguments().get(
+ "application.args"); //$NON-NLS-1$
+ if (args == null || args.length == 0) {
+ help();
+ return EXIT_OK;
+ }
+ extractArguments(args);
+ CodanBuilder codanBuilder = new CodanBuilder();
+ CodanRuntime runtime = CodanRuntime.getInstance();
+ runtime.setProblemReporter(new CodanMarkerProblemReporter() {
+ @Override
+ public void reportProblem(String id, String markerType,
+ int severity, IResource file, int lineNumber,
+ int startChar, int endChar, String message) {
+ System.out.println(file.getLocation() + ":" + lineNumber + ": " //$NON-NLS-1$ //$NON-NLS-2$
+ + message);
+ }
+ });
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ if (all) {
+ log(Messages.CodanApplication_LogRunWorkspace);
+ codanBuilder.processResource(root, new NullProgressMonitor());
+ } else {
+ for (String project : projects) {
+ log(Messages.CodanApplication_LogRunProject + project);
+ IProject wProject = root.getProject(project);
+ if (!wProject.exists()) {
+ System.err
+ .println( //
+ NLS.bind(
+ Messages.CodanApplication_Error_ProjectDoesNotExists,
+ project));
+ continue;
+ }
+ codanBuilder.processResource(wProject,
+ new NullProgressMonitor());
+ }
+ }
+ return EXIT_OK;
+ }
+
+ /**
+ * @param string
+ */
+ private void log(String string) {
+ if (verbose)
+ System.err.println(string);
+ }
+
+ /**
+ * @param args
+ */
+ private void extractArguments(String[] args) {
+ for (int i = 0; i < args.length; i++) {
+ String string = args[i];
+ if (string.equals("-verbose")) { //$NON-NLS-1$
+ verbose = true;
+ } else if (string.equals("-all")) { //$NON-NLS-1$
+ all = true;
+ } else {
+ projects.add(string);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private void help() {
+ System.out.println(Messages.CodanApplication_Usage);
+ System.out.println(Messages.CodanApplication_Options);
+ System.out.println(Messages.CodanApplication_all_option);
+ System.out.println(Messages.CodanApplication_verbose_option);
+ }
+
+ public void stop() {
+ // nothing
+ }
+}