diff --git a/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF
index cbeb1d1cd0d..00becff334b 100644
--- a/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.make.core.tests/META-INF/MANIFEST.MF
@@ -12,7 +12,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.junit,
org.eclipse.cdt.make.core,
org.eclipse.cdt.core,
- org.eclipse.core.resources,
- org.eclipse.cdt.managedbuilder.core
+ org.eclipse.core.resources
Eclipse-AutoStart: true
Bundle-Vendor: Eclipse.org
diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java
index e823b3fc270..b16afb8de44 100644
--- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java
+++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/ScannerConfigDiscoveryTests.java
@@ -11,13 +11,21 @@
package org.eclipse.cdt.make.builder.tests;
import java.io.ByteArrayInputStream;
+import java.util.Map;
import junit.framework.TestCase;
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.MakeProjectNature;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
import org.eclipse.cdt.make.core.tests.StandardBuildTestHelper;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -53,33 +61,33 @@ public class ScannerConfigDiscoveryTests extends TestCase {
StandardBuildTestHelper.removeProject("SCDC");
}
-// public void testGetCCompilerBuiltins() throws CoreException {
-// MakeProjectNature.addNature(fCProject, fMonitor);
-// ScannerConfigNature.addScannerConfigNature(fCProject);
-//
-// PerProjectSICollector.calculateCompilerBuiltins(fCProject);
-// IScannerInfo scInfo = CCorePlugin.getDefault().getScannerInfoProvider(fCProject).
-// getScannerInformation(fCFile);
-// assertNotNull(scInfo);
-// String[] includes = scInfo.getIncludePaths();
-// assertTrue(includes.length > 0);
-// Map symbols = scInfo.getDefinedSymbols();
-// assertFalse(symbols.isEmpty());
-// }
+ public void testGetCCompilerBuiltins() throws CoreException {
+ MakeProjectNature.addNature(fCProject, fMonitor);
+ ScannerConfigNature.addScannerConfigNature(fCProject);
+
+ PerProjectSICollector.calculateCompilerBuiltins(fCProject);
+ IScannerInfo scInfo = CCorePlugin.getDefault().getScannerInfoProvider(fCProject).
+ getScannerInformation(fCFile);
+ assertNotNull(scInfo);
+ String[] includes = scInfo.getIncludePaths();
+ assertTrue(includes.length > 0);
+ Map symbols = scInfo.getDefinedSymbols();
+ assertFalse(symbols.isEmpty());
+ }
-// public void testGetCCCompilerBuiltins() throws CoreException {
-// CCProjectNature.addCCNature(fCProject, fMonitor);
-// MakeProjectNature.addNature(fCProject, fMonitor);
-// ScannerConfigNature.addScannerConfigNature(fCProject);
-//
-// PerProjectSICollector.calculateCompilerBuiltins(fCProject);
-// IScannerInfo scInfo = CCorePlugin.getDefault().getScannerInfoProvider(fCProject).
-// getScannerInformation(fCFile);
-// assertNotNull(scInfo);
-// String[] includes = scInfo.getIncludePaths();
-// assertTrue(includes.length > 0);
-// Map symbols = scInfo.getDefinedSymbols();
-// assertFalse(symbols.isEmpty());
-// }
+ public void testGetCCCompilerBuiltins() throws CoreException {
+ CCProjectNature.addCCNature(fCProject, fMonitor);
+ MakeProjectNature.addNature(fCProject, fMonitor);
+ ScannerConfigNature.addScannerConfigNature(fCProject);
+
+ PerProjectSICollector.calculateCompilerBuiltins(fCProject);
+ IScannerInfo scInfo = CCorePlugin.getDefault().getScannerInfoProvider(fCProject).
+ getScannerInformation(fCFile);
+ assertNotNull(scInfo);
+ String[] includes = scInfo.getIncludePaths();
+ assertTrue(includes.length > 0);
+ Map symbols = scInfo.getDefinedSymbols();
+ assertFalse(symbols.isEmpty());
+ }
}
diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java
index fe40525e64e..367d5b1b73a 100644
--- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java
+++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/StandardBuildTests.java
@@ -17,9 +17,10 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.make.core.IMakeBuilderInfo;
+import org.eclipse.cdt.make.core.MakeBuilder;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
-import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -45,217 +46,216 @@ public class StandardBuildTests extends TestCase {
super(name);
}
- //TODO: migrate tests to the new functionality
public static Test suite() {
TestSuite suite = new TestSuite(StandardBuildTests.class.getName());
// Add the relevant tests to the suite
-// suite.addTest(new StandardBuildTests("testProjectCreation"));
-// suite.addTest(new StandardBuildTests("testProjectSettings"));
-// suite.addTest(new StandardBuildTests("testProjectConversion"));
-// suite.addTest(new StandardBuildTests("testProjectCleanup"));
-//
-// suite.addTestSuite(ScannerConfigConsoleParserTests.class);
-// suite.addTestSuite(ScannerConfigDiscoveryTests.class);
+ suite.addTest(new StandardBuildTests("testProjectCreation"));
+ suite.addTest(new StandardBuildTests("testProjectSettings"));
+ suite.addTest(new StandardBuildTests("testProjectConversion"));
+ suite.addTest(new StandardBuildTests("testProjectCleanup"));
+
+ suite.addTestSuite(ScannerConfigConsoleParserTests.class);
+ suite.addTestSuite(ScannerConfigDiscoveryTests.class);
return suite;
}
-// private void checkDefaultProjectSettings(IProject project) throws Exception {
-// assertNotNull(project);
-//
-// IMakeBuilderInfo defaultInfo = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true);
-//
-// IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
-// // Check the rest of the project information
-// assertEquals(defaultInfo.isDefaultBuildCmd(), builderInfo.isDefaultBuildCmd());
-// assertEquals(defaultInfo.isStopOnError(), builderInfo.isStopOnError());
-// assertEquals(defaultInfo.getBuildCommand(), builderInfo.getBuildCommand());
-// assertEquals(defaultInfo.getBuildArguments(), builderInfo.getBuildArguments());
-// assertEquals(defaultInfo.getBuildLocation(), builderInfo.getBuildLocation());
-//
-// assertEquals(defaultInfo.isAutoBuildEnable(), builderInfo.isAutoBuildEnable());
-// assertEquals(defaultInfo.getAutoBuildTarget(), builderInfo.getAutoBuildTarget());
-// assertEquals(defaultInfo.isIncrementalBuildEnabled(), builderInfo.isIncrementalBuildEnabled());
-// assertEquals(defaultInfo.getIncrementalBuildTarget(), builderInfo.getIncrementalBuildTarget());
-// assertEquals(defaultInfo.isFullBuildEnabled(), builderInfo.isFullBuildEnabled());
-// assertEquals(defaultInfo.getFullBuildTarget(), builderInfo.getFullBuildTarget());
-// assertEquals(defaultInfo.isCleanBuildEnabled(), builderInfo.isCleanBuildEnabled());
-// assertEquals(defaultInfo.getCleanBuildTarget(), builderInfo.getCleanBuildTarget());
-//
-// }
-//
-// private void checkOverriddenProjectSettings(IProject project) throws Exception {
-// assertNotNull(project);
-//
-// // Check the rest of the project information
-// IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
-// assertEquals(OFF, builderInfo.isDefaultBuildCmd());
-// assertEquals(ON, builderInfo.isStopOnError());
-// assertEquals(new Path(OVR_BUILD_COMMAND), builderInfo.getBuildCommand());
-// assertEquals(OVR_BUILD_ARGS, builderInfo.getBuildArguments());
-// assertEquals(new Path(OVR_BUILD_LOCATION), builderInfo.getBuildLocation());
-// }
-//
-// /**
-// * Create a new project named name
or return the project in
-// * the workspace of the same name if it exists.
-// *
-// * @param name The name of the project to create or retrieve.
-// * @return
-// * @throws CoreException
-// */
-// private IProject createProject(final String name) throws CoreException {
-// final Object[] result = new Object[1];
-// ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
-//
-// public void run(IProgressMonitor monitor) throws CoreException {
-// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
-// IProject project = root.getProject(name);
-// if (!project.exists()) {
-// project.create(null);
-// } else {
-// project.refreshLocal(IResource.DEPTH_INFINITE, null);
-// }
-//
-// if (!project.isOpen()) {
-// project.open(null);
-// }
-// CCorePlugin.getDefault().convertProjectToC(project, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
-// result[0] = project;
-// }
-// }, null);
-// return (IProject)result[0];
-// }
-//
-// /**
-// * Remove the IProject
with the name specified in the argument from the
-// * receiver's workspace.
-// *
-// * @param name
-// */
-// private void removeProject(String name) {
-// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
-// IProject project = root.getProject(name);
-// if (project.exists()) {
-// try {
-// project.delete(true, false, null);
-// } catch (CoreException e) {
-// assertTrue(false);
-// }
-// }
-// }
-//
-// /**
-// * Remove all the project information associated with the project used during test.
-// */
-// public void testProjectCleanup() {
-// removeProject(PROJECT_NAME);
-// }
-//
-// public void testProjectConversion() throws Exception {
-// // Open the project
-// IProject project = null;
-// try {
-// project = createProject(PROJECT_NAME);
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectConversion failed opening project: " + e.getLocalizedMessage());
-// }
-// assertNotNull(project);
-//
-// // Check the settings (they should be the override values)
-// checkOverriddenProjectSettings(project);
-//
-// // Now convert the project
-// try {
-// CCorePlugin.getDefault().convertProjectFromCtoCC(project, new NullProgressMonitor());
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectConversion failed to convert project: " + e.getLocalizedMessage());
-// }
-//
-// // Close, and Reopen the project
-// try {
-// project.close(new NullProgressMonitor());
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectConversion failed to close project " + e.getLocalizedMessage());
-// }
-// try {
-// project.open(new NullProgressMonitor());
-// } catch (CoreException e) {
-// fail ("StandardBuildTest testProjectConversion failed to open project " + e.getLocalizedMessage());
-// }
-//
-// // Make sure it has a CCNature
-// try {
-// project.hasNature(CCProjectNature.CC_NATURE_ID);
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectConversion failed getting nature: " + e.getLocalizedMessage());
-// }
-//
-// // Nothing should have changed in the settings
-// checkOverriddenProjectSettings(project);
-// }
-//
-// /**
-// *
-// */
-// public void testProjectCreation() throws Exception {
-// // Create a new project
-// IProject project = null;
-// try {
-// project = createProject(PROJECT_NAME);
-// // Convert the new project to a standard make project
-// MakeProjectNature.addNature(project, null);
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectCreation failed creating project: " + e.getLocalizedMessage());
-// }
-// assertNotNull(project);
-//
-// // Make sure it has a CNature
-// try {
-// project.hasNature(CProjectNature.C_NATURE_ID);
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectCreation failed getting nature: " + e.getLocalizedMessage());
-// }
-// // Make sure it has a MakeNature
-// try {
-// project.hasNature(MakeProjectNature.NATURE_ID);
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectCreation failed getting nature: " + e.getLocalizedMessage());
-// }
-// // Check the default settings
-// checkDefaultProjectSettings(project);
-// }
-//
-// public void testProjectSettings() throws Exception {
-// // Get the project
-// IProject project = null;
-// try {
-// project = createProject(PROJECT_NAME);
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectSettings failed opening project: " + e.getLocalizedMessage());
-// }
-// assertNotNull(project);
-//
-// // Use the build info for the rest of the settings
-// IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
-// builderInfo.setStopOnError(ON);
-// builderInfo.setUseDefaultBuildCmd(OFF);
-// builderInfo.setBuildCommand(new Path(OVR_BUILD_COMMAND));
-// builderInfo.setBuildArguments(OVR_BUILD_ARGS);
-// builderInfo.setBuildLocation(new Path(OVR_BUILD_LOCATION));
-// try {
-// project.close(new NullProgressMonitor());
-// } catch (CoreException e) {
-// fail("StandardBuildTest testProjectSettings failed to close project " + e.getLocalizedMessage());
-// }
-// try {
-// project.open(new NullProgressMonitor());
-// } catch (CoreException e) {
-// fail ("StandardBuildTest testProjectSettings failed to open project " + e.getLocalizedMessage());
-// }
-//
-// // Retest
-// checkOverriddenProjectSettings(project);
-// }
+ private void checkDefaultProjectSettings(IProject project) throws Exception {
+ assertNotNull(project);
+
+ IMakeBuilderInfo defaultInfo = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true);
+
+ IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
+ // Check the rest of the project information
+ assertEquals(defaultInfo.isDefaultBuildCmd(), builderInfo.isDefaultBuildCmd());
+ assertEquals(defaultInfo.isStopOnError(), builderInfo.isStopOnError());
+ assertEquals(defaultInfo.getBuildCommand(), builderInfo.getBuildCommand());
+ assertEquals(defaultInfo.getBuildArguments(), builderInfo.getBuildArguments());
+ assertEquals(defaultInfo.getBuildLocation(), builderInfo.getBuildLocation());
+
+ assertEquals(defaultInfo.isAutoBuildEnable(), builderInfo.isAutoBuildEnable());
+ assertEquals(defaultInfo.getAutoBuildTarget(), builderInfo.getAutoBuildTarget());
+ assertEquals(defaultInfo.isIncrementalBuildEnabled(), builderInfo.isIncrementalBuildEnabled());
+ assertEquals(defaultInfo.getIncrementalBuildTarget(), builderInfo.getIncrementalBuildTarget());
+ assertEquals(defaultInfo.isFullBuildEnabled(), builderInfo.isFullBuildEnabled());
+ assertEquals(defaultInfo.getFullBuildTarget(), builderInfo.getFullBuildTarget());
+ assertEquals(defaultInfo.isCleanBuildEnabled(), builderInfo.isCleanBuildEnabled());
+ assertEquals(defaultInfo.getCleanBuildTarget(), builderInfo.getCleanBuildTarget());
+
+ }
+
+ private void checkOverriddenProjectSettings(IProject project) throws Exception {
+ assertNotNull(project);
+
+ // Check the rest of the project information
+ IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
+ assertEquals(OFF, builderInfo.isDefaultBuildCmd());
+ assertEquals(ON, builderInfo.isStopOnError());
+ assertEquals(new Path(OVR_BUILD_COMMAND), builderInfo.getBuildCommand());
+ assertEquals(OVR_BUILD_ARGS, builderInfo.getBuildArguments());
+ assertEquals(new Path(OVR_BUILD_LOCATION), builderInfo.getBuildLocation());
+ }
+
+ /**
+ * Create a new project named name
or return the project in
+ * the workspace of the same name if it exists.
+ *
+ * @param name The name of the project to create or retrieve.
+ * @return
+ * @throws CoreException
+ */
+ private IProject createProject(final String name) throws CoreException {
+ final Object[] result = new Object[1];
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(name);
+ if (!project.exists()) {
+ project.create(null);
+ } else {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ if (!project.isOpen()) {
+ project.open(null);
+ }
+ CCorePlugin.getDefault().convertProjectToC(project, new NullProgressMonitor(), MakeCorePlugin.MAKE_PROJECT_ID);
+ result[0] = project;
+ }
+ }, null);
+ return (IProject)result[0];
+ }
+
+ /**
+ * Remove the IProject
with the name specified in the argument from the
+ * receiver's workspace.
+ *
+ * @param name
+ */
+ private void removeProject(String name) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(name);
+ if (project.exists()) {
+ try {
+ project.delete(true, false, null);
+ } catch (CoreException e) {
+ assertTrue(false);
+ }
+ }
+ }
+
+ /**
+ * Remove all the project information associated with the project used during test.
+ */
+ public void testProjectCleanup() {
+ removeProject(PROJECT_NAME);
+ }
+
+ public void testProjectConversion() throws Exception {
+ // Open the project
+ IProject project = null;
+ try {
+ project = createProject(PROJECT_NAME);
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectConversion failed opening project: " + e.getLocalizedMessage());
+ }
+ assertNotNull(project);
+
+ // Check the settings (they should be the override values)
+ checkOverriddenProjectSettings(project);
+
+ // Now convert the project
+ try {
+ CCorePlugin.getDefault().convertProjectFromCtoCC(project, new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectConversion failed to convert project: " + e.getLocalizedMessage());
+ }
+
+ // Close, and Reopen the project
+ try {
+ project.close(new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectConversion failed to close project " + e.getLocalizedMessage());
+ }
+ try {
+ project.open(new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail ("StandardBuildTest testProjectConversion failed to open project " + e.getLocalizedMessage());
+ }
+
+ // Make sure it has a CCNature
+ try {
+ project.hasNature(CCProjectNature.CC_NATURE_ID);
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectConversion failed getting nature: " + e.getLocalizedMessage());
+ }
+
+ // Nothing should have changed in the settings
+ checkOverriddenProjectSettings(project);
+ }
+
+ /**
+ *
+ */
+ public void testProjectCreation() throws Exception {
+ // Create a new project
+ IProject project = null;
+ try {
+ project = createProject(PROJECT_NAME);
+ // Convert the new project to a standard make project
+ MakeProjectNature.addNature(project, null);
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectCreation failed creating project: " + e.getLocalizedMessage());
+ }
+ assertNotNull(project);
+
+ // Make sure it has a CNature
+ try {
+ project.hasNature(CProjectNature.C_NATURE_ID);
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectCreation failed getting nature: " + e.getLocalizedMessage());
+ }
+ // Make sure it has a MakeNature
+ try {
+ project.hasNature(MakeProjectNature.NATURE_ID);
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectCreation failed getting nature: " + e.getLocalizedMessage());
+ }
+ // Check the default settings
+ checkDefaultProjectSettings(project);
+ }
+
+ public void testProjectSettings() throws Exception {
+ // Get the project
+ IProject project = null;
+ try {
+ project = createProject(PROJECT_NAME);
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectSettings failed opening project: " + e.getLocalizedMessage());
+ }
+ assertNotNull(project);
+
+ // Use the build info for the rest of the settings
+ IMakeBuilderInfo builderInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
+ builderInfo.setStopOnError(ON);
+ builderInfo.setUseDefaultBuildCmd(OFF);
+ builderInfo.setBuildCommand(new Path(OVR_BUILD_COMMAND));
+ builderInfo.setBuildArguments(OVR_BUILD_ARGS);
+ builderInfo.setBuildLocation(new Path(OVR_BUILD_LOCATION));
+ try {
+ project.close(new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail("StandardBuildTest testProjectSettings failed to close project " + e.getLocalizedMessage());
+ }
+ try {
+ project.open(new NullProgressMonitor());
+ } catch (CoreException e) {
+ fail ("StandardBuildTest testProjectSettings failed to open project " + e.getLocalizedMessage());
+ }
+
+ // Retest
+ checkOverriddenProjectSettings(project);
+ }
}
diff --git a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
index ef230e9f5de..eab1be0f42e 100644
--- a/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.make.ui/META-INF/MANIFEST.MF
@@ -30,7 +30,6 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.cdt.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.cdt.ui;bundle-version="[4.0.0,5.0.0)",
org.eclipse.cdt.make.core;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.cdt.managedbuilder.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/ErrorParserBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/ErrorParserBlock.java
new file mode 100644
index 00000000000..f712cb0d05d
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/ErrorParserBlock.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems 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:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui;
+
+import org.eclipse.cdt.make.core.IMakeBuilderInfo;
+import org.eclipse.cdt.make.core.MakeBuilder;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.swt.widgets.Composite;
+
+public class ErrorParserBlock extends AbstractErrorParserBlock {
+
+ // make builder enabled
+ IMakeBuilderInfo fBuildInfo;
+ boolean useBuildInfo = false;
+ Preferences fPrefs;
+
+ public ErrorParserBlock(Preferences preferences) {
+ super();
+ fPrefs = preferences;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+
+ if (useBuildInfo == true && fBuildInfo == null) {
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ setControl(composite);
+ ControlFactory.createEmptySpace(composite);
+ ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString("ErrorParserBlock.label.missingBuilderInformation")); //$NON-NLS-1$
+ return;
+ }
+ super.createControl(parent);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.ui.dialogs.ErrorParserBlock#getErrorParserIDs(org.eclipse.core.resources.IProject)
+ */
+ protected String[] getErrorParserIDs(IProject project) {
+ if (getContainer().getProject() != null && fBuildInfo == null) {
+ try {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), MakeBuilder.BUILDER_ID);
+ } catch (CoreException e) {
+ }
+ }
+ if (fBuildInfo != null) {
+ return fBuildInfo.getErrorParsers();
+ }
+ return new String[0];
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.ui.dialogs.ErrorParserBlock#saveErrorParsers(org.eclipse.core.resources.IProject,
+ * java.lang.String[])
+ */
+ public void saveErrorParsers(IProject project, String[] parserIDs) throws CoreException {
+ if (getContainer().getProject() != null) {
+ try {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), MakeBuilder.BUILDER_ID);
+ } catch (CoreException e) {
+ }
+ }
+ if (fBuildInfo != null) {
+ fBuildInfo.setErrorParsers(parserIDs);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock#saveErrorParsers(java.lang.String[])
+ */
+ protected void saveErrorParsers(String[] parserIDs) throws CoreException {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, MakeBuilder.BUILDER_ID, false);
+ fBuildInfo.setErrorParsers(parserIDs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock#getErrorParserIDs(boolean)
+ */
+ protected String[] getErrorParserIDs(boolean defaults) {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, MakeBuilder.BUILDER_ID, defaults);
+ return fBuildInfo.getErrorParsers();
+ }
+
+ public void setContainer(ICOptionContainer container) {
+ super.setContainer(container);
+ if (getContainer().getProject() != null) {
+ try {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), MakeBuilder.BUILDER_ID);
+ } catch (CoreException e) {
+ }
+ useBuildInfo = true;
+ } else {
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java
new file mode 100644
index 00000000000..3754ff1e8d8
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeEnvironmentBlock.java
@@ -0,0 +1,810 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 QNX Software Systems 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:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui;
+
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.utils.spawner.EnvironmentReader;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+
+public class MakeEnvironmentBlock extends AbstractCOptionPage {
+
+ Preferences fPrefs;
+ String fBuilderID;
+ IMakeCommonBuildInfo fBuildInfo;
+ protected TableViewer environmentTable;
+ protected String[] envTableColumnHeaders = {MakeUIPlugin.getResourceString("MakeEnvironmentBlock.0"), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.1")}; //$NON-NLS-1$ //$NON-NLS-2$
+ protected ColumnLayoutData[] envTableColumnLayouts = {new ColumnPixelData(150), new ColumnPixelData(250)};
+
+ private static final String NAME_LABEL = MakeUIPlugin.getResourceString("MakeEnvironmentBlock.2"); //$NON-NLS-1$
+ private static final String VALUE_LABEL = MakeUIPlugin.getResourceString("MakeEnvironmentBlock.3"); //$NON-NLS-1$
+
+ protected static final String P_VARIABLE = "variable"; //$NON-NLS-1$
+ protected static final String P_VALUE = "value"; //$NON-NLS-1$
+ protected static String[] envTableColumnProperties = {P_VARIABLE, P_VALUE};
+ protected Button envAddButton;
+ protected Button envEditButton;
+ protected Button envRemoveButton;
+ protected Button appendEnvironment;
+ protected Button replaceEnvironment;
+ protected Button envSelectButton;
+
+ class EnvironmentVariable {
+
+ // The name of the environment variable
+ private String name;
+
+ // The value of the environment variable
+ private String value;
+
+ EnvironmentVariable(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Returns this variable's name, which serves as the key in the
+ * key/value pair this variable represents
+ *
+ * @return this variable's name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns this variables value.
+ *
+ * @return this variable's value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets this variable's value
+ *
+ * @param value
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ boolean equal = false;
+ if (obj instanceof EnvironmentVariable) {
+ EnvironmentVariable var = (EnvironmentVariable)obj;
+ equal = var.getName().equals(name);
+ }
+ return equal;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return name.hashCode();
+ }
+ }
+
+ /**
+ * Content provider for the environment table
+ */
+ protected class EnvironmentVariableContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ EnvironmentVariable[] elements = new EnvironmentVariable[0];
+ IMakeCommonBuildInfo info = (IMakeCommonBuildInfo)inputElement;
+ Map m = info.getEnvironment();
+ if (m != null && !m.isEmpty()) {
+ elements = new EnvironmentVariable[m.size()];
+ String[] varNames = new String[m.size()];
+ m.keySet().toArray(varNames);
+ for (int i = 0; i < m.size(); i++) {
+ elements[i] = new EnvironmentVariable(varNames[i], (String)m.get(varNames[i]));
+ }
+ }
+ return elements;
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (newInput == null) {
+ return;
+ }
+ if (viewer instanceof TableViewer) {
+ TableViewer tableViewer = (TableViewer)viewer;
+ if (tableViewer.getTable().isDisposed()) {
+ return;
+ }
+ tableViewer.setSorter(new ViewerSorter() {
+
+ public int compare(Viewer iviewer, Object e1, Object e2) {
+ if (e1 == null) {
+ return -1;
+ } else if (e2 == null) {
+ return 1;
+ } else {
+ return ((EnvironmentVariable)e1).getName().compareToIgnoreCase( ((EnvironmentVariable)e2).getName());
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Label provider for the environment table
+ */
+ public class EnvironmentVariableLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+ public String getColumnText(Object element, int columnIndex) {
+ String result = null;
+ if (element != null) {
+ EnvironmentVariable var = (EnvironmentVariable)element;
+ switch (columnIndex) {
+ case 0 : // variable
+ result = var.getName();
+ break;
+ case 1 : // value
+ result = var.getValue();
+ break;
+ }
+ }
+ return result;
+ }
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex == 0) {
+ return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ENV_VAR);
+ }
+ return null;
+ }
+ }
+
+ public MakeEnvironmentBlock(Preferences prefs, String builderID) {
+ super(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.4")); //$NON-NLS-1$
+ setDescription(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.5")); //$NON-NLS-1$
+ fPrefs = prefs;
+ fBuilderID = builderID;
+ }
+
+ public void setContainer(ICOptionContainer container) {
+ super.setContainer(container);
+ if (getContainer().getProject() != null) {
+ try {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
+ } catch (CoreException e) {
+ }
+ } else {
+ fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
+ }
+ }
+
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ // Missing builder info
+ if (fBuildInfo == null) {
+ return;
+ }
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ IWorkspace workspace = MakeUIPlugin.getWorkspace();
+ // To avoid multi-build
+ IWorkspaceRunnable operation = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(MakeUIPlugin.getResourceString("SettingsBlock.monitor.applyingSettings"), 1); //$NON-NLS-1$
+ IMakeCommonBuildInfo info = null;
+ if (getContainer().getProject() != null) {
+ try {
+ info = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
+ } catch (CoreException e) {
+ // disabled builder... just log it
+ MakeCorePlugin.log(e);
+ return;
+ }
+ } else {
+ info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
+ }
+ // Convert the table's items into a Map so that this can be saved in the
+ // configuration's attributes.
+ TableItem[] items = environmentTable.getTable().getItems();
+ Map map = new HashMap(items.length);
+ for (int i = 0; i < items.length; i++)
+ {
+ EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
+ map.put(var.getName(), var.getValue());
+ }
+ info.setEnvironment(map);
+ info.setAppendEnvironment(appendEnvironment.getSelection());
+ }
+ };
+ if (getContainer().getProject() != null) {
+ workspace.run(operation, monitor);
+ } else {
+ operation.run(monitor);
+ }
+ }
+
+ /**
+ * Updates the environment table for the given launch configuration
+ *
+ * @param configuration
+ */
+ protected void updateEnvironment(IMakeCommonBuildInfo info) {
+ environmentTable.setInput(info);
+ }
+
+ public void performDefaults() {
+ // Missing builder info
+ if (fBuildInfo == null) {
+ return;
+ }
+
+ IMakeCommonBuildInfo info;
+ if (getContainer().getProject() != null) {
+ info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
+ } else {
+ info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, true);
+ }
+ boolean append = info.appendEnvironment();
+ if (append) {
+ appendEnvironment.setSelection(true);
+ replaceEnvironment.setSelection(false);
+ } else {
+ replaceEnvironment.setSelection(true);
+ appendEnvironment.setSelection(false);
+ }
+ updateEnvironment(info);
+ updateAppendReplace();
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ setControl(composite);
+
+ MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.MAKE_BUILDER_SETTINGS);
+
+ if (fBuildInfo == null) {
+ ControlFactory.createEmptySpace(composite);
+ ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString("SettingsBlock.label.missingBuilderInformation")); //$NON-NLS-1$
+ return;
+ }
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ composite.setLayout(layout);
+ composite.setLayoutData(gridData);
+ composite.setFont(parent.getFont());
+
+ createBuildEnvironmentControls(composite);
+ createTableButtons(composite);
+ createAppendReplace(composite);
+
+ boolean append = fBuildInfo.appendEnvironment();
+ if (append) {
+ appendEnvironment.setSelection(true);
+ replaceEnvironment.setSelection(false);
+ } else {
+ replaceEnvironment.setSelection(true);
+ appendEnvironment.setSelection(false);
+ }
+ updateEnvironment(fBuildInfo);
+ updateAppendReplace();
+
+ }
+
+ private void createBuildEnvironmentControls(Composite parent) {
+ Font font = parent.getFont();
+ // Create table composite
+ Composite tableComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 1;
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.heightHint = 150;
+ tableComposite.setLayout(layout);
+ tableComposite.setLayoutData(gridData);
+ tableComposite.setFont(font);
+ // Create label
+ Label label = new Label(tableComposite, SWT.NONE);
+ label.setFont(font);
+ label.setText(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.6")); //$NON-NLS-1$
+ // Create table
+ environmentTable = new TableViewer(tableComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
+ | SWT.FULL_SELECTION);
+ Table table = environmentTable.getTable();
+ TableLayout tableLayout = new TableLayout();
+ table.setLayout(tableLayout);
+ table.setHeaderVisible(true);
+ table.setFont(font);
+ gridData = new GridData(GridData.FILL_BOTH);
+ environmentTable.getControl().setLayoutData(gridData);
+ environmentTable.setContentProvider(new EnvironmentVariableContentProvider());
+ environmentTable.setLabelProvider(new EnvironmentVariableLabelProvider());
+ environmentTable.setColumnProperties(envTableColumnProperties);
+ environmentTable.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTableSelectionChanged(event);
+ }
+ });
+ environmentTable.addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ if (!environmentTable.getSelection().isEmpty()) {
+ handleEnvEditButtonSelected();
+ }
+ }
+ });
+ // Create columns
+ for (int i = 0; i < envTableColumnHeaders.length; i++) {
+ tableLayout.addColumnData(envTableColumnLayouts[i]);
+ TableColumn tc = new TableColumn(table, SWT.NONE, i);
+ tc.setResizable(envTableColumnLayouts[i].resizable);
+ tc.setText(envTableColumnHeaders[i]);
+ }
+ }
+
+ /**
+ * Responds to a selection changed event in the environment table
+ *
+ * @param event
+ * the selection change event
+ */
+ protected void handleTableSelectionChanged(SelectionChangedEvent event) {
+ int size = ((IStructuredSelection)event.getSelection()).size();
+ envEditButton.setEnabled(size == 1);
+ envRemoveButton.setEnabled(size > 0);
+ }
+
+ /**
+ * Create some empty space.
+ */
+ protected void createVerticalSpacer(Composite comp, int colSpan) {
+ Label label = new Label(comp, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalSpan = colSpan;
+ label.setLayoutData(gd);
+ label.setFont(comp.getFont());
+ }
+
+ /**
+ * Creates the add/edit/remove buttons for the environment table
+ *
+ * @param parent
+ * the composite in which the buttons should be created
+ */
+ protected void createTableButtons(Composite parent) {
+ // Create button composite
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ GridLayout glayout = new GridLayout();
+ glayout.marginHeight = 0;
+ glayout.marginWidth = 0;
+ glayout.numColumns = 1;
+ GridData gdata = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
+ buttonComposite.setLayout(glayout);
+ buttonComposite.setLayoutData(gdata);
+ buttonComposite.setFont(parent.getFont());
+
+ createVerticalSpacer(buttonComposite, 1);
+ // Create buttons
+ envAddButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.7"), null); //$NON-NLS-1$
+ envAddButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvAddButtonSelected();
+ }
+ });
+ envSelectButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.8"), null); //$NON-NLS-1$
+ envSelectButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvSelectButtonSelected();
+ }
+ });
+ envEditButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.9"), null); //$NON-NLS-1$
+ envEditButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvEditButtonSelected();
+ }
+ });
+ envEditButton.setEnabled(false);
+ envRemoveButton = createPushButton(buttonComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.10"), null); //$NON-NLS-1$
+ envRemoveButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvRemoveButtonSelected();
+ }
+ });
+ envRemoveButton.setEnabled(false);
+ }
+
+ /**
+ * Adds a new environment variable to the table.
+ */
+ protected void handleEnvAddButtonSelected() {
+ MultipleInputDialog dialog = new MultipleInputDialog(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.11")); //$NON-NLS-1$
+ dialog.addTextField(NAME_LABEL, null, false);
+ dialog.addVariablesField(VALUE_LABEL, null, true);
+
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+
+ String name = dialog.getStringValue(NAME_LABEL);
+ String value = dialog.getStringValue(VALUE_LABEL);
+
+ if (name != null && value != null && name.length() > 0 && value.length() > 0) {
+ addVariable(new EnvironmentVariable(name.trim(), value.trim()));
+ updateAppendReplace();
+ }
+ }
+
+ /**
+ * Updates the enablement of the append/replace widgets. The widgets should
+ * disable when there are no environment variables specified.
+ */
+ protected void updateAppendReplace() {
+ boolean enable = environmentTable.getTable().getItemCount() > 0;
+ appendEnvironment.setEnabled(enable);
+ replaceEnvironment.setEnabled(enable);
+ }
+
+ /**
+ * Attempts to add the given variable. Returns whether the variable was
+ * added or not (as when the user answers not to overwrite an existing
+ * variable).
+ *
+ * @param variable
+ * the variable to add
+ * @return whether the variable was added
+ */
+ protected boolean addVariable(EnvironmentVariable variable) {
+ String name = variable.getName();
+ TableItem[] items = environmentTable.getTable().getItems();
+ for (int i = 0; i < items.length; i++) {
+ EnvironmentVariable existingVariable = (EnvironmentVariable)items[i].getData();
+ if (existingVariable.getName().equals(name)) {
+ boolean overWrite = MessageDialog.openQuestion(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.12"), MessageFormat.format( //$NON-NLS-1$
+ MakeUIPlugin.getResourceString("MakeEnvironmentBlock.13"), new String[]{name})); //$NON-NLS-1$
+ if (!overWrite) {
+ return false;
+ }
+ environmentTable.remove(existingVariable);
+ break;
+ }
+ }
+ environmentTable.add(variable);
+ getContainer().updateContainer();
+ return true;
+ }
+
+ /**
+ * Gets native environment variable. Creates EnvironmentVariable objects.
+ *
+ * @return Map of name - EnvironmentVariable pairs based on native
+ * environment.
+ */
+ private Map getNativeEnvironment() {
+ Map stringVars = EnvironmentReader.getEnvVars();
+ HashMap vars = new HashMap();
+ for (Iterator i = stringVars.keySet().iterator(); i.hasNext();) {
+ String key = (String)i.next();
+ String value = (String)stringVars.get(key);
+ vars.put(key, new EnvironmentVariable(key, value));
+ }
+ return vars;
+ }
+
+ /**
+ * Displays a dialog that allows user to select native environment variables
+ * to add to the table.
+ */
+ protected void handleEnvSelectButtonSelected() {
+ // get Environment Variables from the OS
+ Map envVariables = getNativeEnvironment();
+
+ // get Environment Variables from the table
+ TableItem[] items = environmentTable.getTable().getItems();
+ for (int i = 0; i < items.length; i++) {
+ EnvironmentVariable var = (EnvironmentVariable)items[i].getData();
+ envVariables.remove(var.getName());
+ }
+
+ ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(),
+ createSelectionDialogLabelProvider(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.14")); //$NON-NLS-1$
+ dialog.setTitle(MakeUIPlugin.getResourceString("MakeEnvironmentBlock.15")); //$NON-NLS-1$
+
+ int button = dialog.open();
+ if (button == Window.OK) {
+ Object[] selected = dialog.getResult();
+ for (int i = 0; i < selected.length; i++) {
+ environmentTable.add(selected[i]);
+ }
+ }
+
+ updateAppendReplace();
+ getContainer().updateContainer();
+ }
+
+ /**
+ * Creates a label provider for the native native environment variable
+ * selection dialog.
+ *
+ * @return A label provider for the native native environment variable
+ * selection dialog.
+ */
+ private ILabelProvider createSelectionDialogLabelProvider() {
+ return new ILabelProvider() {
+
+ public Image getImage(Object element) {
+ return MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ENVIRONMNET);
+ }
+ public String getText(Object element) {
+ EnvironmentVariable var = (EnvironmentVariable)element;
+ return var.getName() + " [" + var.getValue() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ public void addListener(ILabelProviderListener listener) {
+ }
+ public void dispose() {
+ }
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ };
+ }
+
+ /**
+ * Creates a content provider for the native native environment variable
+ * selection dialog.
+ *
+ * @return A content provider for the native native environment variable
+ * selection dialog.
+ */
+ private IStructuredContentProvider createSelectionDialogContentProvider() {
+ return new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ EnvironmentVariable[] elements = null;
+ if (inputElement instanceof Map) {
+ Comparator comparator = new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ String s1 = (String)o1;
+ String s2 = (String)o2;
+ return s1.compareTo(s2);
+ }
+
+ };
+ TreeMap envVars = new TreeMap(comparator);
+ envVars.putAll((Map)inputElement);
+ elements = new EnvironmentVariable[envVars.size()];
+ int index = 0;
+ for (Iterator iterator = envVars.keySet().iterator(); iterator.hasNext(); index++) {
+ Object key = iterator.next();
+ elements[index] = (EnvironmentVariable)envVars.get(key);
+ }
+ }
+ return elements;
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ };
+ }
+ /**
+ * Creates an editor for the value of the selected environment variable.
+ */
+ protected void handleEnvEditButtonSelected() {
+ IStructuredSelection sel = (IStructuredSelection)environmentTable.getSelection();
+ EnvironmentVariable var = (EnvironmentVariable)sel.getFirstElement();
+ if (var == null) {
+ return;
+ }
+ String originalName = var.getName();
+ String value = var.getValue();
+ MultipleInputDialog dialog = new MultipleInputDialog(getShell(), MakeUIPlugin.getResourceString("MakeEnvironmentBlock.16")); //$NON-NLS-1$
+ dialog.addTextField(NAME_LABEL, originalName, false);
+ dialog.addVariablesField(VALUE_LABEL, value, true);
+
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ String name = dialog.getStringValue(NAME_LABEL);
+ value = dialog.getStringValue(VALUE_LABEL);
+ if (!originalName.equals(name)) {
+ if (addVariable(new EnvironmentVariable(name, value))) {
+ environmentTable.remove(var);
+ }
+ } else {
+ var.setValue(value);
+ environmentTable.update(var, null);
+ getContainer().updateContainer();
+ }
+ }
+
+ /**
+ * Removes the selected environment variable from the table.
+ */
+ protected void handleEnvRemoveButtonSelected() {
+ IStructuredSelection sel = (IStructuredSelection)environmentTable.getSelection();
+ environmentTable.getControl().setRedraw(false);
+ for (Iterator i = sel.iterator(); i.hasNext();) {
+ EnvironmentVariable var = (EnvironmentVariable)i.next();
+ environmentTable.remove(var);
+ }
+ environmentTable.getControl().setRedraw(true);
+ updateAppendReplace();
+ getContainer().updateContainer();
+ }
+
+ private class NativeEnvironmentDialog extends ListSelectionDialog {
+
+ public NativeEnvironmentDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider,
+ ILabelProvider labelProvider, String message) {
+ super(parentShell, input, contentProvider, labelProvider, message);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ protected IDialogSettings getDialogSettings() {
+ IDialogSettings settings = MakeUIPlugin.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
+ if (section == null) {
+ section = settings.addNewSection(getDialogSettingsSectionName());
+ }
+ return section;
+ }
+
+ /**
+ * Returns the name of the section that this dialog stores its settings
+ * in
+ *
+ * @return String
+ */
+ protected String getDialogSettingsSectionName() {
+ return MakeUIPlugin.getPluginId() + ".ENVIRONMENT_TAB.NATIVE_ENVIROMENT_DIALOG"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
+ */
+ protected Point getInitialLocation(Point initialSize) {
+ Point initialLocation = DialogSettingsHelper.getInitialLocation(getDialogSettingsSectionName());
+ if (initialLocation != null) {
+ return initialLocation;
+ }
+ return super.getInitialLocation(initialSize);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#getInitialSize()
+ */
+ protected Point getInitialSize() {
+ Point size = super.getInitialSize();
+ return DialogSettingsHelper.getInitialSize(getDialogSettingsSectionName(), size);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#close()
+ */
+ public boolean close() {
+ DialogSettingsHelper.persistShellGeometry(getShell(), getDialogSettingsSectionName());
+ return super.close();
+ }
+ }
+
+ /**
+ * Creates and configures the widgets which allow the user to choose whether
+ * the specified environment should be appended to the native environment or
+ * if it should completely replace it.
+ *
+ * @param parent
+ * the composite in which the widgets should be created
+ */
+ protected void createAppendReplace(Composite parent) {
+ Composite appendReplaceComposite = new Composite(parent, SWT.NONE);
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ GridLayout layout = new GridLayout();
+ appendReplaceComposite.setLayoutData(gridData);
+ appendReplaceComposite.setLayout(layout);
+ appendReplaceComposite.setFont(parent.getFont());
+
+ appendEnvironment = createRadioButton(appendReplaceComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.17")); //$NON-NLS-1$
+ appendEnvironment.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ getContainer().updateContainer();
+ }
+ });
+ replaceEnvironment = createRadioButton(appendReplaceComposite, MakeUIPlugin.getResourceString("MakeEnvironmentBlock.18")); //$NON-NLS-1$
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
index abea9ee1da7..ea0305e527e 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeProjectOptionBlock.java
@@ -13,8 +13,13 @@ package org.eclipse.cdt.make.internal.ui;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.cdt.make.core.MakeBuilder;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.properties.MakePropertyPage;
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
+import org.eclipse.cdt.make.ui.dialogs.DiscoveryOptionsBlock;
+import org.eclipse.cdt.make.ui.dialogs.SettingsBlock;
+import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
@@ -34,12 +39,11 @@ public class MakeProjectOptionBlock extends TabFolderOptionBlock {
}
protected void addTabs() {
-
-// addTab(new SettingsBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
-// addTab(new MakeEnvironmentBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
-// addTab(new ErrorParserBlock(MakeCorePlugin.getDefault().getPluginPreferences()));
-// addTab(new BinaryParserBlock());
-// addTab(new DiscoveryOptionsBlock());
+ addTab(new SettingsBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
+ addTab(new MakeEnvironmentBlock(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID));
+ addTab(new ErrorParserBlock(MakeCorePlugin.getDefault().getPluginPreferences()));
+ addTab(new BinaryParserBlock());
+ addTab(new DiscoveryOptionsBlock());
}
public void setOptionContainer(ICOptionContainer parent) {
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
index 8df515c259c..19fb38ffdd3 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
@@ -19,10 +19,6 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.makefile.ITargetRule;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
@@ -121,17 +117,8 @@ public class AddBuildTargetAction extends Action {
IFile file = getFile();
if (file == null)
return false;
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(file);
- if(info == null)
+ if (!MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(file.getProject()))
return false;
- IConfiguration cfg = info.getDefaultConfiguration();
- if(cfg == null)
- return false;
- IBuilder builder = cfg.getBuilder();
- if(builder == null)
- return false;
-// if(!builder.isManagedBuildOn())
-// return false;
}
return true;
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java
index 9b71878e2c9..6217f750be0 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeLabelProvider.java
@@ -15,7 +15,6 @@ import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java
index 7061cca0904..b719b95bcd5 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/UpdateMakeProjectAction.java
@@ -16,13 +16,14 @@ import java.util.Vector;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
+import org.eclipse.cdt.make.core.MakeBuilder;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.wizards.UpdateMakeProjectWizard;
-import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -211,7 +212,7 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
MakeProjectNature.addNature(project[i], new SubProgressMonitor(monitor, 1));
// move existing build properties to new
- IMakeBuilderInfo newInfo = null; //TODO: MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
+ IMakeBuilderInfo newInfo = MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
final int LOCATION = 0, FULL_ARGS = 1, INC_ARGS = 2, STOP_ERORR = 3, USE_DEFAULT = 4;
QualifiedName[] qName = new QualifiedName[USE_DEFAULT + 1];
qName[LOCATION] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildLocation"); //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java
new file mode 100644
index 00000000000..772c926aa71
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryOptionsBlock.java
@@ -0,0 +1,383 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.ui.dialogs;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.make.internal.ui.preferences.TabFolderLayout;
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Fremework for loading profile option pages
+ *
+ * @author vhirsl
+ */
+public abstract class AbstractDiscoveryOptionsBlock extends AbstractCOptionPage {
+ protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
+ private static final String UNSAVEDCHANGES_TITLE = PREFIX + ".unsavedchanges.title"; //$NON-NLS-1$
+ private static final String UNSAVEDCHANGES_MESSAGE = PREFIX + ".unsavedchanges.message"; //$NON-NLS-1$
+ private static final String UNSAVEDCHANGES_BSAVE = PREFIX + ".unsavedchanges.button.save"; //$NON-NLS-1$
+ private static final String UNSAVEDCHANGES_BCANCEL = PREFIX + ".unsavedchanges.button.cancel"; //$NON-NLS-1$
+ private static final String ERROR_TITLE = PREFIX + ".error.title"; //$NON-NLS-1$
+ private static final String ERROR_MESSAGE = PREFIX + ".error.message"; //$NON-NLS-1$
+ private static final String PROFILE_PAGE = "profilePage"; //$NON-NLS-1$
+ private static final String PROFILE_ID = "profileId"; //$NON-NLS-1$
+
+ private Preferences fPrefs;
+ private IScannerConfigBuilderInfo2 fBuildInfo;
+ private boolean fInitialized = false;
+ private String fPersistedProfileId = null;
+
+ private Map fProfilePageMap = null;
+
+ // Composite parent provided by the block.
+ private Composite fCompositeParent;
+ private AbstractDiscoveryPage fCurrentPage;
+
+ /**
+ * @return Returns the project.
+ */
+ public IProject getProject() {
+ return getContainer().getProject();
+ }
+ /**
+ * @return Returns the fPrefs.
+ */
+ public Preferences getPrefs() {
+ return fPrefs;
+ }
+ /**
+ * @return Returns the fBuildInfo.
+ */
+ public IScannerConfigBuilderInfo2 getBuildInfo() {
+ return fBuildInfo;
+ }
+ /**
+ * @return Returns the fInitialized.
+ */
+ public boolean isInitialized() {
+ return fInitialized;
+ }
+ /**
+ * @param initialized The fInitialized to set.
+ */
+ public void setInitialized(boolean initialized) {
+ fInitialized = initialized;
+ }
+
+ /**
+ * @return true - OK to continue
+ */
+ public boolean checkDialogForChanges() {
+ boolean rc = true;
+ if (isProfileDifferentThenPersisted()) {
+ String title = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_TITLE);
+ String message = MakeUIPlugin.getResourceString(UNSAVEDCHANGES_MESSAGE);
+ String[] buttonLabels = new String[]{
+ MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BSAVE),
+ MakeUIPlugin.getResourceString(UNSAVEDCHANGES_BCANCEL),
+ };
+ MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
+ buttonLabels, 0);
+ int res = dialog.open();
+ if (res == 0) { // OK
+ callPerformApply();
+ rc = true;
+ } else if (res == 1) { // CANCEL
+ rc = false;
+ }
+ }
+ return rc;
+ }
+
+ public boolean isProfileDifferentThenPersisted() {
+ return (fPersistedProfileId != null &&
+ !fPersistedProfileId.equals(getBuildInfo().getSelectedProfileId()));
+ }
+
+ public void updatePersistedProfile() {
+ fPersistedProfileId = getBuildInfo().getSelectedProfileId();
+ }
+
+ /**
+ * Create a profile page only on request
+ *
+ * @author vhirsl
+ */
+ protected static class DiscoveryProfilePageConfiguration {
+
+ AbstractDiscoveryPage page;
+ IConfigurationElement fElement;
+
+ public DiscoveryProfilePageConfiguration(IConfigurationElement element) {
+ fElement = element;
+ }
+
+ public AbstractDiscoveryPage getPage() throws CoreException {
+ if (page == null) {
+ page = (AbstractDiscoveryPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ return page;
+ }
+ public String getName() {
+ return fElement.getAttribute("name"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @param title
+ */
+ public AbstractDiscoveryOptionsBlock(String title) {
+ super(title);
+ initializeProfilePageMap();
+ }
+
+ /**
+ * @param title
+ * @param image
+ */
+ public AbstractDiscoveryOptionsBlock(String title, ImageDescriptor image) {
+ super(title, image);
+ initializeProfilePageMap();
+ }
+
+ /**
+ *
+ */
+ private void initializeProfilePageMap() {
+ fProfilePageMap = new HashMap(5);
+
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(MakeUIPlugin.getPluginId(), "DiscoveryProfilePage"); //$NON-NLS-1$
+ IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
+ for (int i = 0; i < infos.length; i++) {
+ if (infos[i].getName().equals(PROFILE_PAGE)) { //$NON-NLS-1$
+ String id = infos[i].getAttribute(PROFILE_ID); //$NON-NLS-1$
+ fProfilePageMap.put(id, new DiscoveryProfilePageConfiguration(infos[i]));
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#setContainer(org.eclipse.cdt.ui.dialogs.ICOptionContainer)
+ */
+ public void setContainer(ICOptionContainer container) {
+ super.setContainer(container);
+
+ fPrefs = getContainer().getPreferences();
+ IProject project = getContainer().getProject();
+
+ fInitialized = true;
+ if (project != null) {
+ try {
+ fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
+ } catch (CoreException e) {
+ // missing builder information (builder disabled or legacy project)
+ fInitialized = false;
+ fBuildInfo = null;
+ }
+ } else {
+ fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
+ }
+ if (fBuildInfo != null) {
+ fPersistedProfileId = fBuildInfo.getSelectedProfileId();
+ }
+ }
+
+ public void updateContainer() {
+ getContainer().updateContainer();
+ }
+
+ /**
+ * @param project
+ */
+ protected void createBuildInfo() {
+ if (getProject() != null) {
+ try {
+ // get the project properties
+ fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(getProject());
+ }
+ catch (CoreException e) {
+ fBuildInfo = null;
+ }
+ }
+ else {
+ // get the preferences
+ fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
+ }
+ }
+
+ /**
+ * Create build info based on preferences
+ */
+ protected void createDefaultBuildInfo() {
+ // Populate with the default values
+ if (getProject() != null) {
+ // get the preferences
+ fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
+ } else {
+ // get the defaults
+ fBuildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, true);
+ }
+ }
+
+ protected Composite getCompositeParent() {
+ return fCompositeParent;
+ }
+
+ protected void setCompositeParent(Composite parent) {
+ fCompositeParent = parent;
+ fCompositeParent.setLayout(new TabFolderLayout());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ handleDiscoveryProfileChanged();
+ }
+ }
+
+ /**
+ * Notification that the user changed the selection of the SCD profile.
+ */
+ protected void handleDiscoveryProfileChanged() {
+ if (getCompositeParent() == null) {
+ return;
+ }
+ String profileId = getCurrentProfileId();
+ AbstractDiscoveryPage page = getDiscoveryProfilePage(profileId);
+ if (page != null) {
+ if (page.getControl() == null) {
+ Composite parent = getCompositeParent();
+ page.setContainer(this);
+ page.createControl(parent);
+ parent.layout(true);
+ }
+ if (fCurrentPage != null) {
+ fCurrentPage.setVisible(false);
+ }
+ page.setVisible(true);
+ }
+ setCurrentPage(page);
+ }
+
+ protected AbstractDiscoveryPage getCurrentPage() {
+ return fCurrentPage;
+ }
+
+ protected void setCurrentPage(AbstractDiscoveryPage page) {
+ fCurrentPage = page;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.AbstractDiscoveryPage#isValid()
+ */
+ public boolean isValid() {
+ return (getCurrentPage() == null) ? true : getCurrentPage().isValid();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ return getCurrentPage().getErrorMessage();
+ }
+
+ protected AbstractDiscoveryPage getDiscoveryProfilePage(String profileId) {
+ DiscoveryProfilePageConfiguration configElement =
+ (DiscoveryProfilePageConfiguration) fProfilePageMap.get(profileId);
+ if (configElement != null) {
+ try {
+ return configElement.getPage();
+ } catch (CoreException e) {
+ }
+ }
+ return null;
+ }
+
+ protected String getDiscoveryProfileName(String profileId) {
+ DiscoveryProfilePageConfiguration configElement =
+ (DiscoveryProfilePageConfiguration) fProfilePageMap.get(profileId);
+ if (configElement != null) {
+ return configElement.getName();
+ }
+ return null;
+ }
+
+ protected String getDiscoveryProfileId(String profileName) {
+ for (Iterator I = fProfilePageMap.keySet().iterator(); I.hasNext();) {
+ String profileId = (String) I.next();
+ String confProfileName = getDiscoveryProfileName(profileId);
+ if (profileName.equals(confProfileName)) {
+ return profileId;
+ }
+ }
+ return null;
+ }
+
+ protected List getDiscoveryProfileIdList() {
+ return new ArrayList(fProfilePageMap.keySet());
+ }
+
+ protected abstract String getCurrentProfileId();
+
+ /**
+ *
+ */
+ public void callPerformApply() {
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ performApply(monitor);
+ }
+ catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ });
+ } catch (InvocationTargetException e) {
+ String title = CPathEntryMessages.getString(ERROR_TITLE); //$NON-NLS-1$
+ String message = CPathEntryMessages.getString(ERROR_MESSAGE); //$NON-NLS-1$
+ ExceptionHandler.handle(e, getShell(), title, message);
+ } catch (InterruptedException e) {
+ // cancelled
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java
new file mode 100644
index 00000000000..22ad6e803f9
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/AbstractDiscoveryPage.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.ui.dialogs;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.debug.ui.StringVariableSelectionDialog;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Abstract SCD profile page
+ *
+ * @author vhirsl
+ */
+public abstract class AbstractDiscoveryPage extends DialogPage {
+ protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
+ protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
+ private static final String VARIABLES_BUTTON = PREFIX + ".common.variables.button"; //$NON-NLS-1$
+
+ protected AbstractDiscoveryOptionsBlock fContainer; // parent
+
+ /**
+ * @return Returns the fContainer.
+ */
+ protected AbstractDiscoveryOptionsBlock getContainer() {
+ return fContainer;
+ }
+ /**
+ * @param container The fContainer to set.
+ */
+ public void setContainer(AbstractDiscoveryOptionsBlock container) {
+ fContainer = container;
+ }
+ /**
+ *
+ */
+ public AbstractDiscoveryPage() {
+ super();
+ }
+
+ /**
+ * @param title
+ */
+ public AbstractDiscoveryPage(String title) {
+ super(title);
+ }
+
+ /**
+ * @param title
+ * @param image
+ */
+ public AbstractDiscoveryPage(String title, ImageDescriptor image) {
+ super(title, image);
+ }
+
+ protected Button addVariablesButton(Composite parent, final Text control) {
+ Button variablesButton = ControlFactory.createPushButton(parent,
+ MakeUIPlugin.getResourceString(VARIABLES_BUTTON));
+ ((GridData) variablesButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(variablesButton);
+
+ variablesButton.addSelectionListener(new SelectionAdapter() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent arg0) {
+ handleVariablesButtonSelected(control);
+ }
+ });
+ return variablesButton;
+ }
+
+ /**
+ * A variable entry button has been pressed for the given text field. Prompt
+ * the user for a variable and enter the result in the given field.
+ */
+ private void handleVariablesButtonSelected(Text textField) {
+ String variable = getVariable();
+ if (variable != null) {
+ textField.append(variable);
+ }
+ }
+
+ /**
+ * Prompts the user to choose and configure a variable and returns the
+ * resulting string, suitable to be used as an attribute.
+ */
+ private String getVariable() {
+ StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
+ dialog.open();
+ return dialog.getVariableExpression();
+ }
+
+ protected abstract boolean isValid();
+ protected abstract void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo);
+ protected abstract void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo);
+
+ public void performApply() {
+ IScannerConfigBuilderInfo2 buildInfo = getContainer().getBuildInfo();
+
+ populateBuildInfo(buildInfo);
+ }
+
+ public void performDefaults() {
+ IScannerConfigBuilderInfo2 buildInfo = getContainer().getBuildInfo();
+
+ restoreFromBuildinfo(buildInfo);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java
new file mode 100644
index 00000000000..8493ee417d0
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveredPathContainerPage.java
@@ -0,0 +1,846 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IPathEntryContainer;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.util.PixelConverter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
+import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
+import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
+import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElement;
+import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElementLabelProvider;
+import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElementSorter;
+import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ActionHandler;
+import org.eclipse.ui.commands.HandlerSubmission;
+import org.eclipse.ui.commands.IWorkbenchCommandSupport;
+import org.eclipse.ui.commands.Priority;
+import org.eclipse.ui.contexts.IWorkbenchContextSupport;
+
+/**
+ * A dialog page to manage discovered scanner configuration
+ *
+ * @author vhirsl
+ */
+public class DiscoveredPathContainerPage extends WizardPage implements IPathEntryContainerPage {
+ private static final String PREFIX = "DiscoveredScannerConfigurationContainerPage"; //$NON-NLS-1$
+
+ private static final String DISC_COMMON_PREFIX = "ManageScannerConfigDialogCommon"; //$NON-NLS-1$
+ private static final String UP = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.up.label"; //$NON-NLS-1$
+ private static final String DOWN = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.down.label"; //$NON-NLS-1$
+ private static final String DISABLE = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.disable.label"; //$NON-NLS-1$
+ private static final String ENABLE = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.enable.label"; //$NON-NLS-1$
+ private static final String DELETE = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.delete.label"; //$NON-NLS-1$
+
+ private static final String CONTAINER_LABEL = PREFIX + ".title"; //$NON-NLS-1$
+ private static final String CONTAINER_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
+ private static final String CONTAINER_LIST_LABEL = PREFIX + ".list.title"; //$NON-NLS-1$
+ private static final String CONTAINER_INITIALIZATION_ERROR = PREFIX +".initialization.error.message"; //$NON-NLS-1$
+
+ private final int IDX_UP = 0;
+ private final int IDX_DOWN = 1;
+ private final int IDX_ENABLE = 2;
+ private final int IDX_DISABLE = 3;
+
+ private final int IDX_DELETE = 5;
+
+ private static final int DISC_UP = 0;
+ private static final int DISC_DOWN = 1;
+
+ private static final int DO_DISABLE = 0;
+ private static final int DO_ENABLE = 1;
+
+ private ICProject fCProject;
+ private IContainerEntry fPathEntry;
+
+ private TreeListDialogField fDiscoveredContainerList;
+ private IDiscoveredPathInfo info = null;
+ private boolean dirty;
+ private List deletedEntries;
+
+ private CopyTextAction copyTextAction;
+ private HandlerSubmission submission;
+
+ public DiscoveredPathContainerPage() {
+ super("DiscoveredScannerConfigurationContainerPage"); //$NON-NLS-1$
+
+ setTitle(MakeUIPlugin.getResourceString(CONTAINER_LABEL));
+ setDescription(MakeUIPlugin.getResourceString(CONTAINER_DESCRIPTION));
+ setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
+
+ String[] buttonLabels = new String[]{
+ /* IDX_UP */ MakeUIPlugin.getResourceString(UP),
+ /* IDX_DOWN */ MakeUIPlugin.getResourceString(DOWN),
+ /* IDX_ENABLE */MakeUIPlugin.getResourceString(ENABLE),
+ /* IDX_DISABLE */MakeUIPlugin.getResourceString(DISABLE),
+ null,
+ /* IDX_DELETE */MakeUIPlugin.getResourceString(DELETE),
+ };
+
+ DiscoveredContainerAdapter adapter = new DiscoveredContainerAdapter();
+
+ fDiscoveredContainerList = new TreeListDialogField(adapter, buttonLabels, new DiscoveredElementLabelProvider());
+ fDiscoveredContainerList.setDialogFieldListener(adapter);
+ fDiscoveredContainerList.setLabelText(MakeUIPlugin.getResourceString(CONTAINER_LIST_LABEL)); //$NON-NLS-1$
+
+ fDiscoveredContainerList.setTreeExpansionLevel(2);
+ fDiscoveredContainerList.setViewerSorter(new DiscoveredElementSorter());
+ dirty = false;
+ deletedEntries = new ArrayList();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
+ */
+ public void dispose() {
+ deregisterActionHandlers();
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.ICPathContainerPage#initialize(org.eclipse.cdt.core.model.ICProject, org.eclipse.cdt.core.model.IPathEntry[])
+ */
+ public void initialize(ICProject project, IPathEntry[] currentEntries) {
+ fCProject = project;
+ try {
+ info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fCProject.getProject());
+ } catch (CoreException e) {
+ setErrorMessage(MakeUIPlugin.getResourceString(CONTAINER_INITIALIZATION_ERROR));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.ICPathContainerPage#finish()
+ */
+ public boolean finish() {
+ if (!dirty) {
+ return true;
+ }
+ // first process deletes
+ if (deletedEntries.size() > 0) {
+ IProject project = fCProject.getProject();
+ SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
+ getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID); // use selected profile for the project
+ IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
+ if (collector instanceof IScannerInfoCollectorCleaner) {
+ IScannerInfoCollectorCleaner collectorUtil = (IScannerInfoCollectorCleaner) collector;
+ boolean exitLoop = false;
+ for (Iterator i = deletedEntries.iterator(); i.hasNext() && !exitLoop; ) {
+ DiscoveredElement elem = (DiscoveredElement) i.next();
+ switch (elem.getEntryKind()) {
+ case DiscoveredElement.CONTAINER:
+ collectorUtil.deleteAll(project);
+ exitLoop = true;
+ break;
+ case DiscoveredElement.PATHS_GROUP:
+ collectorUtil.deleteAllPaths(project);
+ break;
+ case DiscoveredElement.SYMBOLS_GROUP:
+ collectorUtil.deleteAllSymbols(project);
+ break;
+ case DiscoveredElement.INCLUDE_PATH:
+ collectorUtil.deletePath(project, elem.getEntry());
+ break;
+ case DiscoveredElement.SYMBOL_DEFINITION:
+ collectorUtil.deleteSymbol(project, elem.getEntry());
+ break;
+ }
+ }
+ }
+ }
+
+ if (info instanceof IPerProjectDiscoveredPathInfo) {
+ IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) info;
+
+ LinkedHashMap includes = new LinkedHashMap();
+ LinkedHashMap symbols = new LinkedHashMap();
+
+ DiscoveredElement container = (DiscoveredElement) fDiscoveredContainerList.getElement(0);
+ if (container != null && container.getEntryKind() == DiscoveredElement.CONTAINER) {
+ Object[] cChildren = container.getChildren();
+ if (cChildren != null) {
+ for (int i = 0; i < cChildren.length; ++i) {
+ DiscoveredElement group = (DiscoveredElement) cChildren[i];
+ switch (group.getEntryKind()) {
+ case DiscoveredElement.PATHS_GROUP: {
+ // get the include paths
+ Object[] gChildren = group.getChildren();
+ if (gChildren != null) {
+ for (int j = 0; j < gChildren.length; ++j) {
+ DiscoveredElement include = (DiscoveredElement) gChildren[j];
+ includes.put(include.getEntry(), Boolean.valueOf(include.isRemoved()));
+ }
+ }
+ }
+ break;
+ case DiscoveredElement.SYMBOLS_GROUP: {
+ // get the symbol definitions
+ Object[] gChildren = group.getChildren();
+ if (gChildren != null) {
+ for (int j = 0; j < gChildren.length; ++j) {
+ DiscoveredElement symbol = (DiscoveredElement) gChildren[j];
+ ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol.getEntry(), !symbol.isRemoved());
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ projectPathInfo.setIncludeMap(includes);
+ projectPathInfo.setSymbolMap(symbols);
+ }
+
+ try {
+ // update scanner configuration
+ List resourceDelta = new ArrayList(1);
+ resourceDelta.add(fCProject.getProject());
+ MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(info, resourceDelta);
+ return true;
+ } catch (CoreException e) {
+ MakeCorePlugin.log(e);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.ICPathContainerPage#getContainerEntries()
+ */
+ public IContainerEntry[] getNewContainers() {
+ return new IContainerEntry[] { fPathEntry };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.ICPathContainerPage#setSelection(org.eclipse.cdt.core.model.IPathEntry)
+ */
+ public void setSelection(IContainerEntry containerEntry) {
+ if (containerEntry != null) {
+ fPathEntry = containerEntry;
+ }
+ else {
+ fPathEntry = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
+ }
+ if (fPathEntry != null) {
+ DiscoveredElement element = populateDiscoveredElements(fPathEntry);
+ ArrayList elements = new ArrayList();
+ elements.add(element);
+ fDiscoveredContainerList.addElements(elements);
+ }
+ }
+
+ /**
+ * @param pathEntry
+ * @return
+ */
+ private DiscoveredElement populateDiscoveredElements(IContainerEntry pathEntry) {
+ DiscoveredElement container = null;
+ try {
+ container = DiscoveredElement.createNew(null, fCProject.getProject(), null,
+ DiscoveredElement.CONTAINER, false, false);
+ IPathEntryContainer peContainer = CoreModel.getPathEntryContainer(pathEntry.getPath(), fCProject);
+ if (peContainer != null) {
+ container.setEntry(peContainer.getDescription());
+ }
+ if (info != null) {
+ if (info instanceof IPerProjectDiscoveredPathInfo) {
+ IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) info;
+ // get include paths
+ LinkedHashMap paths = projectPathInfo.getIncludeMap();
+ for (Iterator i = paths.keySet().iterator(); i.hasNext(); ) {
+ String include = (String) i.next();
+ Boolean removed = (Boolean) paths.get(include);
+ removed = (removed == null) ? Boolean.FALSE : removed;
+ DiscoveredElement.createNew(container, fCProject.getProject(), include,
+ DiscoveredElement.INCLUDE_PATH, removed.booleanValue(), false);
+ }
+ // get defined symbols
+ LinkedHashMap symbols = projectPathInfo.getSymbolMap();
+ for (Iterator i = symbols.keySet().iterator(); i.hasNext(); ) {
+ String symbol = (String) i.next();
+ SymbolEntry se = (SymbolEntry) symbols.get(symbol);
+ for (Iterator j = se.getActiveRaw().iterator(); j.hasNext();) {
+ String value = (String) j.next();
+ DiscoveredElement.createNew(container, fCProject.getProject(), value,
+ DiscoveredElement.SYMBOL_DEFINITION, false, false);
+ }
+ for (Iterator j = se.getRemovedRaw().iterator(); j.hasNext();) {
+ String value = (String) j.next();
+ DiscoveredElement.createNew(container, fCProject.getProject(), value,
+ DiscoveredElement.SYMBOL_DEFINITION, true, false);
+ }
+ }
+ }
+ else if (info instanceof IPerFileDiscoveredPathInfo) {
+ IPerFileDiscoveredPathInfo filePathInfo = (IPerFileDiscoveredPathInfo) info;
+ // get include paths
+ IPath[] includes = filePathInfo.getIncludePaths();
+ for (int i = 0; i < includes.length; i++) {
+ String include = includes[i].toPortableString();
+ DiscoveredElement.createNew(container, fCProject.getProject(), include,
+ DiscoveredElement.INCLUDE_PATH, false, false);
+ }
+ // get defined symbols
+ Map symbols = filePathInfo.getSymbols();
+ for (Iterator iter = symbols.keySet().iterator(); iter.hasNext();) {
+ String key = (String) iter.next();
+ String value = (String) symbols.get(key);
+ String symbol = (value != null && value.length() > 0) ? key + "=" + value : key; //$NON-NLS-1$
+ DiscoveredElement.createNew(container, fCProject.getProject(), symbol,
+ DiscoveredElement.SYMBOL_DEFINITION, false, false);
+ }
+ // get include files
+ IPath[] includeFiles = filePathInfo.getIncludeFiles(fCProject.getPath());
+ for (int i = 0; i < includeFiles.length; i++) {
+ String includeFile = includeFiles[i].toPortableString();
+ DiscoveredElement.createNew(container, fCProject.getProject(), includeFile,
+ DiscoveredElement.INCLUDE_FILE, false, false);
+ }
+ // get macros files
+ IPath[] macrosFiles = filePathInfo.getMacroFiles(fCProject.getPath());
+ for (int i = 0; i < macrosFiles.length; i++) {
+ String macrosFile = macrosFiles[i].toPortableString();
+ DiscoveredElement.createNew(container, fCProject.getProject(), macrosFile,
+ DiscoveredElement.MACROS_FILE, false, false);
+ }
+ }
+ }
+ } catch (CModelException e) {
+ MakeUIPlugin.log(e.getStatus());
+ }
+ return container;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ PixelConverter converter = new PixelConverter(parent);
+
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ LayoutUtil.doDefaultLayout(composite, new DialogField[]{fDiscoveredContainerList}, true);
+ LayoutUtil.setHorizontalGrabbing(fDiscoveredContainerList.getTreeControl(null));
+
+ int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+ fDiscoveredContainerList.setButtonsMinWidth(buttonBarWidth);
+
+ fDiscoveredContainerList.getTreeViewer().addFilter(new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof DiscoveredElement) {
+ DiscoveredElement elem = (DiscoveredElement) element;
+ switch (elem.getEntryKind()) {
+ case DiscoveredElement.PATHS_GROUP:
+ case DiscoveredElement.SYMBOLS_GROUP:
+ case DiscoveredElement.INCLUDE_FILE_GROUP:
+ case DiscoveredElement.MACROS_FILE_GROUP:
+ return elem.getChildren().length != 0;
+ }
+ }
+ return true;
+ }
+ });
+
+ setControl(composite);
+
+ fDiscoveredContainerList.selectFirstElement();
+
+ // Create copy text action
+ Shell shell = fDiscoveredContainerList.getTreeViewer().getControl().getShell();
+ copyTextAction = new CopyTextAction(shell);
+ hookContextMenu();
+ registerActionHandler(shell, copyTextAction);
+ }
+
+ private void hookContextMenu() {
+ MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+// if (copyTextAction.canBeApplied(fDiscoveredContainerList.getSelectedElements())) {
+ manager.add(copyTextAction);
+// }
+ }
+ });
+ Menu menu = menuMgr.createContextMenu(fDiscoveredContainerList.getTreeViewer().getControl());
+ fDiscoveredContainerList.getTreeViewer().getControl().setMenu(menu);
+ }
+
+ private void registerActionHandler(Shell shell, IAction action) {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+
+ IWorkbenchContextSupport contextSupport = workbench.getContextSupport();
+ IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
+
+ submission = new HandlerSubmission(null, shell, null,
+ CopyTextAction.ACTION_ID, new ActionHandler(action), Priority.MEDIUM);
+ commandSupport.addHandlerSubmission(submission);
+ contextSupport.registerShell(shell, IWorkbenchContextSupport.TYPE_DIALOG);
+ }
+
+ private void deregisterActionHandlers() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+
+ IWorkbenchContextSupport contextSupport = workbench.getContextSupport();
+ IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
+
+ commandSupport.removeHandlerSubmission(submission);
+ contextSupport.unregisterShell(fDiscoveredContainerList.getTreeViewer().getControl().getShell());
+ }
+
+ /**
+ * @author vhirsl
+ */
+ private class DiscoveredContainerAdapter implements IDialogFieldListener, ITreeListAdapter {
+ private final Object[] EMPTY_ARR = new Object[0];
+
+ // ---------- IDialogFieldListener --------
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField)
+ */
+ public void dialogFieldChanged(DialogField field) {
+ // TODO Auto-generated method stub
+
+ }
+
+ // -------- IListAdapter --------
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#customButtonPressed(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, int)
+ */
+ public void customButtonPressed(TreeListDialogField field, int index) {
+ containerPageCustomButtonPressed(field, index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#selectionChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField)
+ */
+ public void selectionChanged(TreeListDialogField field) {
+ if (copyTextAction != null) {
+ copyTextAction.canBeApplied(field.getSelectedElements());
+ }
+ containerPageSelectionChanged(field);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#doubleClicked(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField)
+ */
+ public void doubleClicked(TreeListDialogField field) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#keyPressed(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, org.eclipse.swt.events.KeyEvent)
+ */
+ public void keyPressed(TreeListDialogField field, KeyEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#getChildren(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, java.lang.Object)
+ */
+ public Object[] getChildren(TreeListDialogField field, Object element) {
+ if (element instanceof DiscoveredElement) {
+ DiscoveredElement elem = (DiscoveredElement) element;
+ return elem.getChildren();
+ }
+ return EMPTY_ARR;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#getParent(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, java.lang.Object)
+ */
+ public Object getParent(TreeListDialogField field, Object element) {
+ if (element instanceof DiscoveredElement) {
+ DiscoveredElement elem = (DiscoveredElement) element;
+ return elem.getParent();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter#hasChildren(org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField, java.lang.Object)
+ */
+ public boolean hasChildren(TreeListDialogField field, Object element) {
+ if (element instanceof DiscoveredElement) {
+ DiscoveredElement elem = (DiscoveredElement) element;
+ return elem.hasChildren();
+ }
+ return false;
+ }
+ }
+
+ /**
+ * @param field
+ * @param index
+ */
+ private void containerPageCustomButtonPressed(TreeListDialogField field, int index) {
+ switch (index) {
+ case IDX_UP:
+ /* move entry up */
+ dirty |= moveUp();
+ break;
+ case IDX_DOWN:
+ /* move entry down */
+ dirty |= moveDown();
+ break;
+ case IDX_DISABLE:
+ /* remove */
+ dirty |= enableDisableEntry(DO_DISABLE);
+ break;
+ case IDX_ENABLE:
+ /* restore */
+ dirty |= enableDisableEntry(DO_ENABLE);
+ break;
+ case IDX_DELETE:
+ /* delete */
+ dirty |= deleteEntry();
+ break;
+ }
+ if (dirty) {
+ fDiscoveredContainerList.refresh();
+ fDiscoveredContainerList.setFocus();
+ }
+ }
+
+ private boolean moveUp() {
+ boolean rc = false;
+ List selElements = fDiscoveredContainerList.getSelectedElements();
+ for (Iterator i = selElements.iterator(); i.hasNext(); ) {
+ DiscoveredElement elem = (DiscoveredElement) i.next();
+ DiscoveredElement parent = elem.getParent();
+ Object[] children = parent.getChildren();
+ for (int j = 0; j < children.length; ++j) {
+ DiscoveredElement child = (DiscoveredElement) children[j];
+ if (elem.equals(child)) {
+ int prevIndex = j - 1;
+ if (prevIndex >= 0) {
+ // swap the two
+ children[j] = children[prevIndex];
+ children[prevIndex] = elem;
+ rc = true;
+ break;
+ }
+ }
+ }
+ parent.setChildren(children);
+ }
+ fDiscoveredContainerList.postSetSelection(new StructuredSelection(selElements));
+ return rc;
+ }
+
+ private boolean moveDown() {
+ boolean rc = false;
+ List selElements = fDiscoveredContainerList.getSelectedElements();
+ List revSelElements = new ArrayList(selElements);
+ Collections.reverse(revSelElements);
+ for (Iterator i = revSelElements.iterator(); i.hasNext(); ) {
+ DiscoveredElement elem = (DiscoveredElement) i.next();
+ DiscoveredElement parent = elem.getParent();
+ Object[] children = parent.getChildren();
+ for (int j = children.length - 1; j >= 0; --j) {
+ DiscoveredElement child = (DiscoveredElement) children[j];
+ if (elem.equals(child)) {
+ int prevIndex = j + 1;
+ if (prevIndex < children.length) {
+ // swap the two
+ children[j] = children[prevIndex];
+ children[prevIndex] = elem;
+ rc = true;
+ break;
+ }
+ }
+ }
+ parent.setChildren(children);
+ }
+ fDiscoveredContainerList.postSetSelection(new StructuredSelection(selElements));
+ return rc;
+ }
+
+ /**
+ * @param action
+ * @return
+ */
+ private boolean enableDisableEntry(int action) {
+ boolean rc = false;
+ boolean remove = (action == DO_DISABLE);
+ List selElements = fDiscoveredContainerList.getSelectedElements();
+ for (int i = selElements.size() - 1; i >= 0; --i) {
+ DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
+ switch (elem.getEntryKind()) {
+ case DiscoveredElement.INCLUDE_PATH:
+ case DiscoveredElement.SYMBOL_DEFINITION:
+ elem.setRemoved(remove);
+ rc = true;
+ }
+ }
+ return rc;
+ }
+
+ private boolean deleteEntry() {
+ boolean rc = false;
+ List newSelection = new ArrayList();
+ List selElements = fDiscoveredContainerList.getSelectedElements();
+ boolean skipIncludes = false, skipSymbols = false;
+ for (int i = 0; i < selElements.size(); ++i) {
+ DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
+ if (elem.getEntryKind() == DiscoveredElement.CONTAINER) {
+ deletedEntries.add(elem);
+
+ Object[] children = elem.getChildren();
+ for (int j = 0; j < children.length; j++) {
+ if (children[j] instanceof DiscoveredElement) {
+ DiscoveredElement child = (DiscoveredElement) children[j];
+ child.delete();
+ }
+ }
+ newSelection.add(elem);
+ rc = true;
+ break;
+ }
+ DiscoveredElement parent = elem.getParent();
+ if (parent != null) {
+ Object[] children = parent.getChildren();
+ if (elem.delete()) {
+ switch (elem.getEntryKind()) {
+ case DiscoveredElement.PATHS_GROUP:
+ deletedEntries.add(elem);
+ skipIncludes = true;
+ break;
+ case DiscoveredElement.SYMBOLS_GROUP:
+ deletedEntries.add(elem);
+ skipSymbols = true;
+ break;
+ case DiscoveredElement.INCLUDE_PATH:
+ if (!skipIncludes) {
+ deletedEntries.add(elem);
+ }
+ break;
+ case DiscoveredElement.SYMBOL_DEFINITION:
+ if (!skipSymbols) {
+ deletedEntries.add(elem);
+ }
+ break;
+ }
+
+ rc = true;
+ // set new selection
+ for (int j = 0; j < children.length; ++j) {
+ DiscoveredElement child = (DiscoveredElement) children[j];
+ if (elem.equals(child)) {
+ newSelection.clear();
+ if (j + 1 < children.length) {
+ newSelection.add(children[j + 1]);
+ }
+ else if (j - 1 >= 0) {
+ newSelection.add(children[j - 1]);
+ }
+ else {
+ newSelection.add(parent);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ fDiscoveredContainerList.postSetSelection(new StructuredSelection(newSelection));
+ return rc;
+ }
+
+ /**
+ * @param field
+ */
+ private void containerPageSelectionChanged(TreeListDialogField field) {
+ List selElements = field.getSelectedElements();
+ fDiscoveredContainerList.enableButton(IDX_UP, canMoveUpDown(selElements, DISC_UP));
+ fDiscoveredContainerList.enableButton(IDX_DOWN, canMoveUpDown(selElements, DISC_DOWN));
+ fDiscoveredContainerList.enableButton(IDX_DISABLE, canRemoveRestore(selElements));
+ fDiscoveredContainerList.enableButton(IDX_ENABLE, canRemoveRestore(selElements));
+ fDiscoveredContainerList.enableButton(IDX_DELETE, canDelete(selElements));
+ }
+
+ /**
+ * @param selElements
+ * @param direction
+ * @return
+ */
+ private boolean canMoveUpDown(List selElements, int direction) {
+ if (info instanceof IPerFileDiscoveredPathInfo) {
+ return false;
+ }
+ if (selElements.size() == 0) {
+ return false;
+ }
+ for (int i = 0; i < selElements.size(); i++) {
+ DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
+ switch (elem.getEntryKind()) {
+ case DiscoveredElement.CONTAINER:
+ case DiscoveredElement.PATHS_GROUP:
+ case DiscoveredElement.SYMBOLS_GROUP:
+ case DiscoveredElement.SYMBOL_DEFINITION:
+ return false;
+ }
+ DiscoveredElement parent = elem.getParent();
+ DiscoveredElement borderElem = null;
+ int borderElementIndex = (direction == DISC_UP) ? 0 : parent.getChildren().length - 1;
+ if (parent.getEntryKind() == DiscoveredElement.PATHS_GROUP) {
+ borderElem = (DiscoveredElement)(parent.getChildren())[borderElementIndex];
+ }
+ if (borderElem != null) {
+ if (borderElem.equals(elem)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @param selElements
+ * @return
+ */
+ private boolean canRemoveRestore(List selElements) {
+ if (info instanceof IPerFileDiscoveredPathInfo) {
+ return false;
+ }
+ if (selElements.size() == 0) {
+ return false;
+ }
+ for (int i = 0; i < selElements.size(); i++) {
+ DiscoveredElement elem = (DiscoveredElement) selElements.get(i);
+ switch (elem.getEntryKind()) {
+ case DiscoveredElement.CONTAINER:
+ case DiscoveredElement.PATHS_GROUP:
+ case DiscoveredElement.SYMBOLS_GROUP:
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @param selElements
+ * @return
+ */
+ private boolean canDelete(List selElements) {
+ if (info instanceof IPerFileDiscoveredPathInfo) {
+ if (selElements.size() > 0 &&
+ ((DiscoveredElement) selElements.get(0)).getEntryKind() == DiscoveredElement.CONTAINER) {
+ return true;
+ }
+ return false;
+ }
+ if (selElements.size() == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Support for text copy/paste
+ *
+ * @author vhirsl
+ */
+ public class CopyTextAction extends Action {
+ static final String ACTION_ID = "org.eclipse.ui.edit.copy"; //$NON-NLS-1$
+ private Clipboard clipboard;
+ private String discoveredEntry = null;
+
+ public CopyTextAction(Shell shell) {
+ super(MakeUIPlugin.getResourceString("CopyDiscoveredPathAction.title")); //$NON-NLS-1$
+ setDescription(MakeUIPlugin.getResourceString("CopyDiscoveredPathAction.description")); //$NON-NLS-1$
+ setToolTipText(MakeUIPlugin.getResourceString("CopyDiscoveredPathAction.tooltip")); //$NON-NLS-1$
+ setActionDefinitionId(ACTION_ID);
+ clipboard = new Clipboard(shell.getDisplay());
+ }
+
+ /**
+ * @param selectedElements
+ * @return
+ */
+ boolean canBeApplied(List selElements) {
+ boolean rc = false;
+ if (selElements != null && selElements.size() == 1) {
+ DiscoveredElement elem = (DiscoveredElement) selElements.get(0);
+ switch (elem.getEntryKind()) {
+ case DiscoveredElement.INCLUDE_PATH:
+ case DiscoveredElement.SYMBOL_DEFINITION:
+ discoveredEntry = elem.getEntry();
+ rc = true;
+ }
+ }
+ setEnabled(rc);
+ return rc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+ if (discoveredEntry != null) {
+ // copy to clipboard
+ clipboard.setContents(new Object[] {discoveredEntry},
+ new Transfer[] {TextTransfer.getInstance()});
+ discoveredEntry = null;
+ }
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java
new file mode 100644
index 00000000000..f3c1a404669
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/DiscoveryOptionsBlock.java
@@ -0,0 +1,379 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.MakeProjectNature;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
+import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
+import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.make.internal.ui.preferences.TabFolderLayout;
+import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * A dialog to set scanner config discovery options.
+ *
+ * @author vhirsl
+ * @since 3.0
+ */
+public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
+ private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
+
+ private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
+ private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
+ private static final String SC_GROUP_LABEL = PREFIX + ".scGroup.label"; //$NON-NLS-1$
+ private static final String SC_ENABLED_BUTTON = PREFIX + ".scGroup.enabled.button"; //$NON-NLS-1$
+ private static final String SC_PROBLEM_REPORTING_ENABLED_BUTTON = PREFIX + ".scGroup.problemReporting.enabled.button"; //$NON-NLS-1$
+ private static final String SC_SELECTED_PROFILE_COMBO = PREFIX + ".scGroup.selectedProfile.combo"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_GROUP_LABEL = PREFIX + ".boProvider.group.label"; //$NON-NLS-1$
+ private static final String SC_APPLY_PROGRESS_MESSAGE = PREFIX + ".apply.progressMessage"; //$NON-NLS-1$
+
+ private Button scEnabledButton;
+ private Button scProblemReportingEnabledButton;
+ private Combo profileComboBox;
+ private Composite profileComp;
+
+ private boolean needsSCNature = false;
+ private boolean fCreatePathContainer = false;
+ private boolean isValid = true;
+ private boolean persistedProfileChanged = false; // new persisted selected profile different than the old one
+
+ /**
+ *
+ */
+ public DiscoveryOptionsBlock() {
+ super(MakeUIPlugin.getResourceString(DIALOG_TITLE));
+ setDescription(MakeUIPlugin.getResourceString(DIALOG_DESCRIPTION));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#setContainer(org.eclipse.cdt.ui.dialogs.ICOptionContainer)
+ */
+ public void setContainer(ICOptionContainer container) {
+ super.setContainer(container);
+ if (container.getProject() == null) {
+ fCreatePathContainer = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ // Create the composite control for the tab
+ int tabColumns = 2;
+ Font font = parent.getFont();
+ Composite composite = ControlFactory.createComposite(parent, 1);
+ ((GridLayout)composite.getLayout()).marginHeight = 0;
+ ((GridLayout)composite.getLayout()).marginWidth = 0;
+ ((GridLayout)composite.getLayout()).verticalSpacing = 0;
+ ((GridData)composite.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
+ composite.setFont(font);
+ setControl(composite);
+
+ MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.SCANNER_CONFIG_DISCOVERY_OPTIONS);
+
+ // create a composite for general scanner config discovery options
+ Composite scComp = ControlFactory.createComposite(composite, 1);
+ ((GridLayout)scComp.getLayout()).marginHeight = 0;
+ ((GridLayout)scComp.getLayout()).marginTop = 5;
+ scComp.setFont(font);
+
+ // Create a group for scanner config discovery
+ if (createScannerConfigControls(scComp, tabColumns)) {
+ // create a composite for discovery profile options
+ profileComp = new Composite(composite, SWT.NULL);
+ // ((GridLayout)profileComp.getLayout()).marginHeight = 5;
+ // ((GridLayout)profileComp.getLayout()).marginWidth = 5;
+ // ((GridLayout)profileComp.getLayout()).verticalSpacing = 5;
+ profileComp.setFont(font);
+ profileComp.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+ profileComp.setLayout(new TabFolderLayout());
+
+ // Must set the composite parent to super class.
+ setCompositeParent(profileComp);
+ // fire a change event, to quick start.
+ handleDiscoveryProfileChanged();
+ // enable controls depending on the state of auto discovery
+ enableAllControls();
+ }
+ parent.layout(true);
+ }
+
+ private boolean createScannerConfigControls(Composite parent, int numColumns) {
+ // Check if it is an old project
+ IProject project = getContainer().getProject();
+ boolean showMissingBuilder = false;
+ try {
+ if (project != null && project.hasNature(MakeProjectNature.NATURE_ID)
+ && !project.hasNature(ScannerConfigNature.NATURE_ID)) {
+ needsSCNature = true; // legacy project
+ }
+ } catch (CoreException e) {
+ showMissingBuilder = true;
+ }
+
+ if (showMissingBuilder || (!needsSCNature && !isInitialized())) {
+ ControlFactory.createEmptySpace(parent);
+ ControlFactory.createLabel(parent, MakeUIPlugin.getResourceString(MISSING_BUILDER_MSG));
+ return false;
+ }
+
+ Group scGroup = ControlFactory.createGroup(parent,
+ MakeUIPlugin.getResourceString(SC_GROUP_LABEL), numColumns);
+ scGroup.setFont(parent.getFont());
+ ((GridData)scGroup.getLayoutData()).grabExcessHorizontalSpace = true;
+ ((GridData)scGroup.getLayoutData()).horizontalSpan = numColumns;
+ ((GridData)scGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
+
+ // Add main SCD checkbox
+ scEnabledButton = ControlFactory.createCheckBox(scGroup,
+ MakeUIPlugin.getResourceString(SC_ENABLED_BUTTON));
+ scEnabledButton.setFont(parent.getFont());
+ ((GridData)scEnabledButton.getLayoutData()).horizontalSpan = numColumns;
+ ((GridData)scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ // VMIR* old projects will have discovery disabled by default
+ scEnabledButton.setSelection(needsSCNature ? false : getBuildInfo().isAutoDiscoveryEnabled());
+ scEnabledButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ enableAllControls();
+ }
+ });
+ // handleScannerConfigEnable(); Only if true in VMIR*
+
+ // Add problem reporting checkbox
+ scProblemReportingEnabledButton = ControlFactory.createCheckBox(scGroup,
+ MakeUIPlugin.getResourceString(SC_PROBLEM_REPORTING_ENABLED_BUTTON));
+ scProblemReportingEnabledButton.setFont(parent.getFont());
+ ((GridData)scProblemReportingEnabledButton.getLayoutData()).horizontalSpan = numColumns;
+ ((GridData)scProblemReportingEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ scProblemReportingEnabledButton.setSelection(getBuildInfo().isProblemReportingEnabled());
+
+ // Add profile combo box
+ Label label = ControlFactory.createLabel(scGroup,
+ MakeUIPlugin.getResourceString(SC_SELECTED_PROFILE_COMBO));
+ ((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
+
+ profileComboBox = new Combo(scGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
+ profileComboBox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ getBuildInfo().setSelectedProfileId(getCurrentProfileId());
+ handleDiscoveryProfileChanged();
+ }
+ });
+ // fill the combobox and set the initial value
+ for (Iterator items = getDiscoveryProfileIdList().iterator(); items.hasNext();) {
+ String profileId = (String)items.next();
+ String pageName = getDiscoveryProfileName(profileId);
+ if (pageName != null) {
+ profileComboBox.add(pageName);
+ if (profileId.equals(getBuildInfo().getSelectedProfileId())) {
+ profileComboBox.setText(pageName);
+ }
+ }
+ }
+ profileComboBox.setEnabled(scEnabledButton.getSelection());
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ private void enableAllControls() {
+ boolean isSCDEnabled = scEnabledButton.getSelection();
+ scProblemReportingEnabledButton.setEnabled(isSCDEnabled);
+ profileComboBox.setEnabled(isSCDEnabled);
+ profileComp.setVisible(isSCDEnabled);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ if (!visible) {
+ if (!checkDialogForChanges()) {
+ createBuildInfo();
+ restoreFromBuildinfo(getBuildInfo());
+ enableAllControls();
+ handleDiscoveryProfileChanged();
+
+ getCurrentPage().performDefaults();
+ }
+ }
+ super.setVisible(visible);
+ enableAllControls();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryOptionsBlock#getCurrentProfileId()
+ */
+ protected String getCurrentProfileId() {
+ String selectedProfileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
+ String selectedProfileId = getDiscoveryProfileId(selectedProfileName);
+ return selectedProfileId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(MakeUIPlugin.getResourceString(SC_APPLY_PROGRESS_MESSAGE), 3);
+
+ // init buildInfo
+ final IProject project = getContainer().getProject();
+ // Create new build info in case of new C++ project wizard
+ createBuildInfo();
+
+ if (getBuildInfo() != null) {
+ populateBuildInfo(getBuildInfo());
+ monitor.worked(1);
+
+ if (scEnabledButton.getSelection()) {
+ getCurrentPage().performApply();
+ }
+ monitor.worked(1);
+
+ if (project != null) {
+ configureProject(project, monitor);
+ }
+ getBuildInfo().save();
+ if (isProfileDifferentThenPersisted()) {
+ if (project != null) {
+ changeDiscoveryContainer(project);
+ }
+ updatePersistedProfile();
+ }
+ }
+ monitor.done();
+ }
+
+ private void configureProject(IProject project, IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask(MakeUIPlugin.getResourceString(SC_APPLY_PROGRESS_MESSAGE), 3);
+
+ if (needsSCNature) {
+ ScannerConfigNature.addScannerConfigNature(project);
+ needsSCNature = false;
+ fCreatePathContainer = true;
+ }
+ if (fCreatePathContainer) {
+ createDiscoveredPathContainer(project, monitor);
+ fCreatePathContainer = false;
+ }
+ }
+
+ /**
+ * @param project
+ * @param monitor
+ * @throws CModelException
+ */
+ private void createDiscoveredPathContainer(IProject project, IProgressMonitor monitor) throws CModelException {
+ IPathEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
+ ICProject cProject = CoreModel.getDefault().create(project);
+ if (cProject != null) {
+ IPathEntry[] entries = cProject.getRawPathEntries();
+ List newEntries = new ArrayList(Arrays.asList(entries));
+ if (!newEntries.contains(container)) {
+ newEntries.add(container);
+ cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), monitor);
+ }
+ }
+ // create a new discovered scanner config store
+ MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
+ }
+
+ /**
+ * @param project
+ */
+ private void changeDiscoveryContainer(IProject project) {
+ String profileId = getBuildInfo().getSelectedProfileId();
+ ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
+ getSCProfileConfiguration(profileId).getProfileScope();
+ List changedResources = new ArrayList();
+// changedResources.add(project.getFullPath());
+ changedResources.add(project);
+ MakeCorePlugin.getDefault().getDiscoveryManager().changeDiscoveredContainer(
+ project, profileScope, changedResources);
+ }
+
+ private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
+ if (buildInfo != null) {
+ buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
+ String profileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
+ buildInfo.setSelectedProfileId(getDiscoveryProfileId(profileName));
+ buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+ */
+
+ public void performDefaults() {
+ if (!isInitialized() && !needsSCNature) {
+ // Missing builder info on a non-legacy project
+ return;
+ }
+ createDefaultBuildInfo();
+
+ restoreFromBuildinfo(getBuildInfo());
+ enableAllControls();
+
+ getCurrentPage().performDefaults();
+
+ handleDiscoveryProfileChanged();
+ }
+
+ private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
+ if (buildInfo != null) {
+ scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
+ String profileId = buildInfo.getSelectedProfileId();
+ profileComboBox.setText(getDiscoveryProfileName(profileId));
+ scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled());
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractDiscoveryPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java
similarity index 54%
rename from build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractDiscoveryPage.java
rename to build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java
index 3923be1cafa..867542f2299 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/newui/AbstractDiscoveryPage.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerFileSCDProfilePage.java
@@ -1,20 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2007 Intel Corporation and others.
+ * Copyright (c) 2004, 2005 IBM Corporation 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:
- * Intel Corporation - Initial API and implementation
+ * IBM - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.managedbuilder.ui.newui;
+package org.eclipse.cdt.make.ui.dialogs;
import java.io.File;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.BuildOutputReaderJob;
-import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
-import org.eclipse.cdt.ui.newui.NewUIMessages;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
@@ -22,8 +23,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -40,204 +39,105 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
- * Abstract SCD profile page
+ * SCD per project profile property/preference page
*
* @author vhirsl
*/
-public abstract class AbstractDiscoveryPage extends DialogPage {
- protected static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
- protected static final String PROFILE_GROUP_LABEL = PREFIX + ".profile.group.label"; //$NON-NLS-1$
- protected static final String VARIABLES_BUTTON = PREFIX + ".common.variables.button"; //$NON-NLS-1$
+public class GCCPerFileSCDProfilePage extends AbstractDiscoveryPage {
private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
- private static final String BO_PROVIDER_LOAD_BUTTON = PREFIX + ".boProvider.load.button"; //$NON-NLS-1$
private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
private static final String BO_PROVIDER_OPEN_FILE_DIALOG = PREFIX + ".boProvider.browse.openFileDialog"; //$NON-NLS-1$
-
- protected IBuildInfoContainer fContainer; // parent
- protected Shell shell;
-
- // thread synchronization
- protected static Object lock = AbstractDiscoveryPage.class;
- protected static AbstractDiscoveryPage instance;
- protected static boolean loadButtonInitialEnabled = true;
+ private static final String BO_PROVIDER_LOAD_BUTTON = PREFIX + ".boProvider.load.button"; //$NON-NLS-1$
- // controls affected by LOAD button
- // if descendant do not use it, it's not obligatory to initialize them.
- protected Button bopLoadButton;
- protected Button bopEnabledButton;
- protected Text bopOpenFileText;
-
- public AbstractDiscoveryPage() { super(); }
- public AbstractDiscoveryPage(String title) { super(title); }
- public AbstractDiscoveryPage(String title, ImageDescriptor image) { super(title, image); }
- protected IBuildInfoContainer getContainer() { return fContainer; }
- protected void setContainer(IBuildInfoContainer container) { fContainer = container; }
- /**
- * @param title
- * @param image
- */
+ private static final String providerId = "makefileGenerator"; //$NON-NLS-1$
- protected Button addVariablesButton(Composite parent, final Text control) {
- shell = parent.getShell();
- Button variablesButton = ControlFactory.createPushButton(parent,
- AbstractCPropertyTab.VARIABLESBUTTON_NAME);
- ((GridData) variablesButton.getLayoutData()).widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
- variablesButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent arg0) {
- handleVariablesButtonSelected(control);
- }
- });
- return variablesButton;
- }
+ private Button bopEnabledButton;
+ private Text bopOpenFileText;
+ private Button bopLoadButton;
- /**
- * A variable entry button has been pressed for the given text field. Prompt
- * the user for a variable and enter the result in the given field.
- */
- private void handleVariablesButtonSelected(Text textField) {
- String s = AbstractCPropertyTab.getVariableDialog(shell, fContainer.getConfiguration());
- if (s != null) textField.append(s);
- }
-
- public abstract void initializeValues();
- protected abstract void handlebopEnabledButtonPress();
- protected abstract void createSpecific(Composite parent);
-
- // Handle Load button press
- protected void handleBOPLoadFileButtonSelected() {
- loadButtonInitialEnabled = false;
- bopLoadButton.setEnabled(false);
-
- IProject project = getContainer().getProject();
- Job readerJob = new BuildOutputReaderJob(project, getContainer().getContext(), getContainer().getBuildInfo());
- readerJob.setPriority(Job.LONG);
- readerJob.addJobChangeListener(new JobChangeAdapter() {
- public void done(IJobChangeEvent event) {
- synchronized (lock) {
- if (!instance.shell.isDisposed()) {
- instance.shell.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!instance.shell.isDisposed()) {
- loadButtonInitialEnabled = instance.bopEnabledButton.getSelection() && handleModifyOpenFileText();
- instance.bopLoadButton.setEnabled(loadButtonInitialEnabled);
- }
- else {
- loadButtonInitialEnabled = true;
- }
- }
- });
- }
- else {
- loadButtonInitialEnabled = true;
- }
- }
- }
- });
- readerJob.schedule();
- }
+ // thread syncronization
+ private static Object lock = GCCPerFileSCDProfilePage.class;
+ private Shell shell;
+ private static GCCPerFileSCDProfilePage instance;
+ private static boolean loadButtonInitialEnabled = true;
- protected boolean handleModifyOpenFileText() {
- String fileName = getBopOpenFileText();
- bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
- fileName.length() > 0 &&
- (new File(fileName)).exists());
- return bopLoadButton.getEnabled();
- }
-
- protected String getBopOpenFileText() {
- // from project relative path to absolute path
- String fileName = bopOpenFileText.getText().trim();
- if (fileName.length() > 0) {
- IPath filePath = new Path(fileName);
- if (!filePath.isAbsolute()) {
- if (getContainer().getProject() != null) {
- IPath projectPath = getContainer().getProject().getLocation();
- filePath = projectPath.append(filePath);
- fileName = filePath.toString();
- }
- }
- }
- return fileName;
- }
-
- protected void setBopOpenFileText(String fileName) {
- // from absolute path to project relative path
- if (fileName.length() > 0) {
- IPath filePath = new Path(fileName);
- if (filePath.isAbsolute()) {
- if (getContainer().getProject() != null) {
- IPath projectPath = getContainer().getProject().getLocation();
- if (projectPath.isPrefixOf(filePath)) {
- filePath = filePath.removeFirstSegments(projectPath.segmentCount());
- filePath = filePath.setDevice(null);
- fileName = filePath.toString();
- }
- }
- }
- }
- bopOpenFileText.setText(fileName);
- }
-
- /**
- * A part of "createControl()" method: creates common widgets
- * @param parent
- * @return
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
- Group profileGroup = ControlFactory.createGroup(parent, NewUIMessages.getResourceString(PROFILE_GROUP_LABEL), 3);
+ Composite page = ControlFactory.createComposite(parent, 1);
+// ((GridData) page.getLayoutData()).grabExcessVerticalSpace = true;
+// ((GridData) page.getLayoutData()).verticalAlignment = GridData.FILL;
+
+ // Add the profile UI contribution.
+ Group profileGroup = ControlFactory.createGroup(page,
+ MakeUIPlugin.getResourceString(PROFILE_GROUP_LABEL), 3);
+
GridData gd = (GridData) profileGroup.getLayoutData();
- gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
+// PixelConverter converter = new PixelConverter(profileGroup);
+// gd.heightHint = converter.convertVerticalDLUsToPixels(DEFAULT_HEIGHT);
((GridLayout) profileGroup.getLayout()).makeColumnsEqualWidth = false;
// Add bop enabled checkbox
- bopEnabledButton = ControlFactory.createCheckBox(profileGroup, NewUIMessages.getResourceString(BO_PROVIDER_PARSER_ENABLED_BUTTON));
- bopEnabledButton.setFont(parent.getFont());
+ bopEnabledButton = ControlFactory.createCheckBox(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_PARSER_ENABLED_BUTTON));
+// bopEnabledButton.setFont(parent.getFont());
((GridData)bopEnabledButton.getLayoutData()).horizontalSpan = 3;
((GridData)bopEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
bopEnabledButton.addSelectionListener(new SelectionAdapter() {
+
public void widgetSelected(SelectionEvent e) {
- handlebopEnabledButtonPress();
handleModifyOpenFileText();
}
+
});
// load label
- Label loadLabel = ControlFactory.createLabel(profileGroup, NewUIMessages.getResourceString(BO_PROVIDER_OPEN_LABEL));
+ Label loadLabel = ControlFactory.createLabel(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
((GridData) loadLabel.getLayoutData()).horizontalSpan = 2;
// load button
- bopLoadButton = ControlFactory.createPushButton(profileGroup, NewUIMessages.getResourceString(BO_PROVIDER_LOAD_BUTTON));
- ((GridData) bopLoadButton.getLayoutData()).widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
+ bopLoadButton = ControlFactory.createPushButton(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
+ ((GridData) bopLoadButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(bopLoadButton);
bopLoadButton.addSelectionListener(new SelectionAdapter() {
+
public void widgetSelected(SelectionEvent event) {
handleBOPLoadFileButtonSelected();
}
+
});
if (getContainer().getProject() == null) { // project properties
bopLoadButton.setVisible(false);
}
+
// text field
bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
bopOpenFileText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- getContainer().getBuildInfo().setBuildOutputFilePath(getBopOpenFileText());
handleModifyOpenFileText();
}
});
bopLoadButton.setEnabled(loadButtonInitialEnabled && handleModifyOpenFileText());
// browse button
- Button browseButton = ControlFactory.createPushButton(profileGroup, NewUIMessages.getResourceString(BO_PROVIDER_BROWSE_BUTTON));
- ((GridData) browseButton.getLayoutData()).widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
+ Button browseButton = ControlFactory.createPushButton(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_BROWSE_BUTTON));
+ ((GridData) browseButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(browseButton);
browseButton.addSelectionListener(new SelectionAdapter() {
+
public void widgetSelected(SelectionEvent event) {
handleBOPBrowseButtonSelected();
}
+
private void handleBOPBrowseButtonSelected() {
FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
- dialog.setText(NewUIMessages.getResourceString(BO_PROVIDER_OPEN_FILE_DIALOG));
+ dialog.setText(MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_FILE_DIALOG)); //$NON-NLS-1$
String fileName = getBopOpenFileText();
IPath filterPath;
if (fileName.length() == 0 && getContainer().getProject() != null) {
@@ -258,17 +158,133 @@ public abstract class AbstractDiscoveryPage extends DialogPage {
// variable button
addVariablesButton(profileGroup, bopOpenFileText);
-
- createSpecific(profileGroup);
-
- setControl(profileGroup);
+
+ setControl(page);
// set the shell variable; must be after setControl
+ //lock.acquire();
synchronized (lock) {
shell = getShell();
instance = this;
}
-
- // this parameter should be always set.
- getContainer().getBuildInfo().setBuildOutputFileActionEnabled(true);
+ //lock.release();
+ initializeValues();
}
+
+ protected boolean handleModifyOpenFileText() {
+ String fileName = getBopOpenFileText();
+ bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
+ fileName.length() > 0 &&
+ (new File(fileName)).exists());
+ return bopLoadButton.getEnabled();
+ }
+
+ private String getBopOpenFileText() {
+ // from project relative path to absolute path
+ String fileName = bopOpenFileText.getText().trim();
+ if (fileName.length() > 0) {
+ IPath filePath = new Path(fileName);
+ if (!filePath.isAbsolute()) {
+ if (getContainer().getProject() != null) {
+ IPath projectPath = getContainer().getProject().getLocation();
+ filePath = projectPath.append(filePath);
+ fileName = filePath.toString();
+ }
+ }
+ }
+ return fileName;
+ }
+
+ private void setBopOpenFileText(String fileName) {
+ // from absolute path to project relative path
+ if (fileName.length() > 0) {
+ IPath filePath = new Path(fileName);
+ if (filePath.isAbsolute()) {
+ if (getContainer().getProject() != null) {
+ IPath projectPath = getContainer().getProject().getLocation();
+ if (projectPath.isPrefixOf(filePath)) {
+ filePath = filePath.removeFirstSegments(projectPath.segmentCount());
+ filePath = filePath.setDevice(null);
+ fileName = filePath.toString();
+ }
+ }
+ }
+ }
+ bopOpenFileText.setText(fileName);
+ }
+
+ private void initializeValues() {
+ bopEnabledButton.setSelection(getContainer().getBuildInfo().isBuildOutputParserEnabled());
+ setBopOpenFileText(getContainer().getBuildInfo().getBuildOutputFilePath());
+ }
+
+ private void handleBOPLoadFileButtonSelected() {
+ if (!getContainer().checkDialogForChanges()) return;
+ loadButtonInitialEnabled = false;
+ bopLoadButton.setEnabled(false);
+
+ // populate buildInfo to be used by the reader job
+ populateBuildInfo(getContainer().getBuildInfo());
+ IProject project = getContainer().getProject();
+ Job readerJob = new BuildOutputReaderJob(project, getContainer().getBuildInfo());
+ readerJob.setPriority(Job.LONG);
+ readerJob.addJobChangeListener(new JobChangeAdapter() {
+
+ public void done(IJobChangeEvent event) {
+ //lock.acquire();
+ synchronized (lock) {
+ if (!instance.shell.isDisposed()) {
+ instance.shell.getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ if (!instance.shell.isDisposed()) {
+ loadButtonInitialEnabled = instance.bopEnabledButton.getSelection() && handleModifyOpenFileText();
+ instance.bopLoadButton.setEnabled(loadButtonInitialEnabled);
+ }
+ else {
+ loadButtonInitialEnabled = true;
+ }
+ }
+
+ });
+ }
+ else {
+ loadButtonInitialEnabled = true;
+ }
+ }
+ //lock.release();
+ }
+
+ });
+ readerJob.schedule();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#isValid()
+ */
+ protected boolean isValid() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#populateBuildInfo(org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2)
+ */
+ protected void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
+ if (buildInfo != null) {
+ buildInfo.setBuildOutputFileActionEnabled(true);
+ buildInfo.setBuildOutputFilePath(getBopOpenFileText());
+ buildInfo.setBuildOutputParserEnabled(bopEnabledButton.getSelection());
+ buildInfo.setProviderOutputParserEnabled(providerId, bopEnabledButton.getSelection());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#restoreFromBuildinfo(org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2)
+ */
+ protected void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
+ if (buildInfo != null) {
+ setBopOpenFileText(buildInfo.getBuildOutputFilePath());
+ bopEnabledButton.setSelection(buildInfo.isBuildOutputParserEnabled());
+ }
+ }
+
}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java
new file mode 100644
index 00000000000..58d565d1975
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/GCCPerProjectSCDProfilePage.java
@@ -0,0 +1,380 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.ui.dialogs;
+
+import java.io.File;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.BuildOutputReaderJob;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * SCD per project profile property/preference page
+ *
+ * @author vhirsl
+ */
+public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
+ private static final String BO_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".boProvider.parser.enabled.button"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_OPEN_LABEL = PREFIX + ".boProvider.open.label"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_BROWSE_BUTTON = PREFIX + ".boProvider.browse.button"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_OPEN_FILE_DIALOG = PREFIX + ".boProvider.browse.openFileDialog"; //$NON-NLS-1$
+ private static final String BO_PROVIDER_LOAD_BUTTON = PREFIX + ".boProvider.load.button"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_PARSER_ENABLED_BUTTON = PREFIX + ".siProvider.parser.enabled.button"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_LABEL = PREFIX + ".siProvider.command.label"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_BROWSE_BUTTON = PREFIX + ".siProvider.browse.button"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_DIALOG = PREFIX + ".siProvider.browse.runCommandDialog"; //$NON-NLS-1$
+ private static final String SI_PROVIDER_COMMAND_ERROR_MESSAGE= PREFIX + ".siProvider.command.errorMessage"; //$NON-NLS-1$
+
+ private static final String providerId = "specsFile"; //$NON-NLS-1$
+
+ // thread syncronization
+ //private static ILock lock = Platform.getJobManager().newLock();
+// private static Object lock = new Object();
+ private static Object lock = GCCPerProjectSCDProfilePage.class;
+ private Shell shell;
+ private static GCCPerProjectSCDProfilePage instance;
+ private static boolean loadButtonInitialEnabled = true;
+
+ private Button bopEnabledButton;
+ private Text bopOpenFileText;
+ private Button bopLoadButton;
+ private Button sipEnabledButton;
+ private Text sipRunCommandText;
+
+ private boolean isValid = true;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite page = ControlFactory.createComposite(parent, 1);
+// ((GridData) page.getLayoutData()).grabExcessVerticalSpace = true;
+// ((GridData) page.getLayoutData()).verticalAlignment = GridData.FILL;
+
+ // Add the profile UI contribution.
+ Group profileGroup = ControlFactory.createGroup(page,
+ MakeUIPlugin.getResourceString(PROFILE_GROUP_LABEL), 3);
+
+ GridData gd = (GridData) profileGroup.getLayoutData();
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+// PixelConverter converter = new PixelConverter(parent);
+// gd.heightHint = converter.convertVerticalDLUsToPixels(DEFAULT_HEIGHT);
+ ((GridLayout) profileGroup.getLayout()).makeColumnsEqualWidth = false;
+
+ // Add bop enabled checkbox
+ bopEnabledButton = ControlFactory.createCheckBox(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_PARSER_ENABLED_BUTTON));
+// bopEnabledButton.setFont(parent.getFont());
+ ((GridData)bopEnabledButton.getLayoutData()).horizontalSpan = 3;
+ ((GridData)bopEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ bopEnabledButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ handleModifyOpenFileText();
+ }
+
+ });
+
+ // load label
+ Label loadLabel = ControlFactory.createLabel(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_LABEL));
+ ((GridData) loadLabel.getLayoutData()).horizontalSpan = 2;
+
+ // load button
+ bopLoadButton = ControlFactory.createPushButton(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_LOAD_BUTTON));
+ ((GridData) bopLoadButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(bopLoadButton);
+ bopLoadButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleBOPLoadFileButtonSelected();
+ }
+
+ });
+ if (getContainer().getProject() == null) { // project properties
+ bopLoadButton.setVisible(false);
+ }
+
+ // text field
+ bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
+ bopOpenFileText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ handleModifyOpenFileText();
+ }
+ });
+ bopLoadButton.setEnabled(loadButtonInitialEnabled && handleModifyOpenFileText());
+
+ // browse button
+ Button browseButton = ControlFactory.createPushButton(profileGroup,
+ MakeUIPlugin.getResourceString(BO_PROVIDER_BROWSE_BUTTON));
+ ((GridData) browseButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(browseButton);
+ browseButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleBOPBrowseButtonSelected();
+ }
+
+ private void handleBOPBrowseButtonSelected() {
+ FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+ dialog.setText(MakeUIPlugin.getResourceString(BO_PROVIDER_OPEN_FILE_DIALOG)); //$NON-NLS-1$
+ String fileName = getBopOpenFileText();
+ IPath filterPath;
+ if (fileName.length() == 0 && getContainer().getProject() != null) {
+ filterPath = getContainer().getProject().getLocation();
+ }
+ else {
+ IPath filePath = new Path(fileName);
+ filterPath = filePath.removeLastSegments(1).makeAbsolute();
+ }
+ dialog.setFilterPath(filterPath.toOSString());
+ String res = dialog.open();
+ if (res == null) {
+ return;
+ }
+ setBopOpenFileText(res);
+ }
+ });
+
+ // variable button
+ addVariablesButton(profileGroup, bopOpenFileText);
+
+ ControlFactory.createSeparator(profileGroup, 3);
+
+ // si provider enabled checkbox
+ sipEnabledButton = ControlFactory.createCheckBox(profileGroup,
+ MakeUIPlugin.getResourceString(SI_PROVIDER_PARSER_ENABLED_BUTTON));
+// sipEnabledButton.setFont(parent.getFont());
+ ((GridData)sipEnabledButton.getLayoutData()).horizontalSpan = 3;
+ ((GridData)sipEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
+ sipEnabledButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+// bopLoadButton.setEnabled(sipEnabledButton.getSelection());
+ }
+
+ });
+
+ // si command label
+ Label siCommandLabel = ControlFactory.createLabel(profileGroup,
+ MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_LABEL));
+ ((GridData) siCommandLabel.getLayoutData()).horizontalSpan = 3;
+
+ // text field
+ sipRunCommandText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
+ //((GridData) sipRunCommandText.getLayoutData()).horizontalSpan = 2;
+ sipRunCommandText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ handleModifyRunCommandText();
+ }
+ });
+
+ // si browse button
+ Button siBrowseButton = ControlFactory.createPushButton(profileGroup,
+ MakeUIPlugin.getResourceString(SI_PROVIDER_BROWSE_BUTTON));
+ ((GridData) siBrowseButton.getLayoutData()).widthHint =
+ SWTUtil.getButtonWidthHint(browseButton);
+ siBrowseButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ handleSIPBrowseButtonSelected();
+ }
+
+ private void handleSIPBrowseButtonSelected() {
+ FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+ dialog.setText(MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_DIALOG)); //$NON-NLS-1$
+ String fileName = sipRunCommandText.getText().trim();
+ int lastSeparatorIndex = fileName.lastIndexOf(File.separator);
+ if (lastSeparatorIndex != -1) {
+ dialog.setFilterPath(fileName.substring(0, lastSeparatorIndex));
+ }
+ String res = dialog.open();
+ if (res == null) {
+ return;
+ }
+ sipRunCommandText.setText(res);
+ }
+ });
+
+ setControl(page);
+ // set the shell variable; must be after setControl
+ //lock.acquire();
+ synchronized (lock) {
+ shell = getShell();
+ instance = this;
+ }
+ //lock.release();
+ initializeValues();
+ }
+
+ protected boolean handleModifyOpenFileText() {
+ String fileName = getBopOpenFileText();
+ bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
+ fileName.length() > 0 &&
+ new File(fileName).exists());
+ return bopLoadButton.getEnabled();
+ }
+
+ protected void handleModifyRunCommandText() {
+ String cmd = sipRunCommandText.getText().trim();
+ isValid = (cmd.length() > 0) ? true : false;
+
+ getContainer().updateContainer();
+ }
+
+ private String getBopOpenFileText() {
+ // from project relative path to absolute path
+ String fileName = bopOpenFileText.getText().trim();
+ if (fileName.length() > 0) {
+ IPath filePath = new Path(fileName);
+ if (!filePath.isAbsolute()) {
+ if (getContainer().getProject() != null) {
+ IPath projectPath = getContainer().getProject().getLocation();
+ filePath = projectPath.append(filePath);
+ fileName = filePath.toString();
+ }
+ }
+ }
+ return fileName;
+ }
+
+ private void setBopOpenFileText(String fileName) {
+ // from absolute path to project relative path
+ if (fileName.length() > 0) {
+ IPath filePath = new Path(fileName);
+ if (filePath.isAbsolute()) {
+ if (getContainer().getProject() != null) {
+ IPath projectPath = getContainer().getProject().getLocation();
+ if (projectPath.isPrefixOf(filePath)) {
+ filePath = filePath.removeFirstSegments(projectPath.segmentCount());
+ filePath = filePath.setDevice(null);
+ fileName = filePath.toString();
+ }
+ }
+ }
+ }
+ bopOpenFileText.setText(fileName);
+ }
+
+ private void initializeValues() {
+ bopEnabledButton.setSelection(getContainer().getBuildInfo().isBuildOutputParserEnabled());
+ setBopOpenFileText(getContainer().getBuildInfo().getBuildOutputFilePath());
+ sipEnabledButton.setSelection(getContainer().getBuildInfo().isProviderOutputParserEnabled(providerId));
+ sipRunCommandText.setText(getContainer().getBuildInfo().getProviderRunCommand(providerId));
+ }
+
+ private void handleBOPLoadFileButtonSelected() {
+ if (!getContainer().checkDialogForChanges()) return;
+ loadButtonInitialEnabled = false;
+ bopLoadButton.setEnabled(false);
+
+ // populate buildInfo to be used by the reader job
+ populateBuildInfo(getContainer().getBuildInfo());
+ IProject project = getContainer().getProject();
+ Job readerJob = new BuildOutputReaderJob(project, getContainer().getBuildInfo());
+ readerJob.setPriority(Job.LONG);
+ readerJob.addJobChangeListener(new JobChangeAdapter() {
+
+ public void done(IJobChangeEvent event) {
+ //lock.acquire();
+ synchronized (lock) {
+ if (!instance.shell.isDisposed()) {
+ instance.shell.getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ if (!instance.shell.isDisposed()) {
+ loadButtonInitialEnabled = instance.bopEnabledButton.getSelection() && handleModifyOpenFileText();
+ instance.bopLoadButton.setEnabled(loadButtonInitialEnabled);
+ }
+ else {
+ loadButtonInitialEnabled = true;
+ }
+ }
+
+ });
+ }
+ else {
+ loadButtonInitialEnabled = true;
+ }
+ }
+ //lock.release();
+ }
+
+ });
+ readerJob.schedule();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#isValid()
+ */
+ public boolean isValid() {
+ return isValid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ return (isValid) ? null : MakeUIPlugin.getResourceString(SI_PROVIDER_COMMAND_ERROR_MESSAGE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#populateBuildInfo(org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2)
+ */
+ protected void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
+ if (buildInfo != null) {
+ buildInfo.setBuildOutputFileActionEnabled(true);
+ buildInfo.setBuildOutputFilePath(getBopOpenFileText());
+ buildInfo.setBuildOutputParserEnabled(bopEnabledButton.getSelection());
+
+ buildInfo.setProviderOutputParserEnabled(providerId, sipEnabledButton.getSelection());
+ buildInfo.setProviderRunCommand(providerId, sipRunCommandText.getText().trim());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage#restoreFromBuildinfo(org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2)
+ */
+ protected void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
+ if (buildInfo != null) {
+ setBopOpenFileText(buildInfo.getBuildOutputFilePath());
+ bopEnabledButton.setSelection(buildInfo.isBuildOutputParserEnabled());
+
+ sipEnabledButton.setSelection(buildInfo.isProviderOutputParserEnabled(providerId));
+ sipRunCommandText.setText(buildInfo.getProviderRunCommand(providerId));
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
index cb9f60f540a..ca8560fa576 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
@@ -10,15 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.make.ui.dialogs;
+import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.internal.ui.MessageLine;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
@@ -71,7 +68,6 @@ public class MakeTargetDialog extends Dialog {
IMakeTargetManager fTargetManager;
IContainer fContainer;
- IConfiguration fConfiguration;
private IPath buildCommand;
private boolean isDefaultCommand;
@@ -107,28 +103,19 @@ public class MakeTargetDialog extends Dialog {
super(parentShell);
fContainer = container;
fTargetManager = MakeCorePlugin.getDefault().getTargetManager();
- IBuilder builder = null;
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(fContainer);
- if(info == null){
- throw new CoreException(new Status(IStatus.ERROR, MakeUIPlugin.getUniqueIdentifier(), -1,
- MakeUIPlugin.getResourceString("project {0} does not have build info associated"), null));
- }
-
- fConfiguration = info.getDefaultConfiguration();
String[] id = fTargetManager.getTargetBuilders(container.getProject());
if (id.length == 0) {
throw new CoreException(new Status(IStatus.ERROR, MakeUIPlugin.getUniqueIdentifier(), -1,
MakeUIPlugin.getResourceString("MakeTargetDialog.exception.noTargetBuilderOnProject"), null)); //$NON-NLS-1$
}
-
targetBuildID = id[0];
-// builder = ManagedBuilderCorePlugin.createBuilderForEclipseBuilder(fConfiguration, fTargetManager.getBuilderID(targetBuildID));
- builder = fConfiguration.getBuilder();
- isStopOnError = builder.isStopOnError();
- isDefaultCommand = builder.isDefaultBuildCmd();
- buildCommand = builder.getBuildCommand();
- buildArguments = builder.getBuildArguments();
- targetString = builder.getIncrementalBuildTarget();
+ IMakeBuilderInfo buildInfo = MakeCorePlugin.createBuildInfo(container.getProject(),
+ fTargetManager.getBuilderID(targetBuildID));
+ isStopOnError = buildInfo.isStopOnError();
+ isDefaultCommand = buildInfo.isDefaultBuildCmd();
+ buildCommand = buildInfo.getBuildCommand();
+ buildArguments = buildInfo.getBuildArguments();
+ targetString = buildInfo.getIncrementalBuildTarget();
}
protected void configureShell(Shell newShell) {
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java
index a6f2cabe62d..9d3003c21c5 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java
@@ -86,7 +86,7 @@ public class ConvertToMakeProjectWizardPage extends ConvertProjectWizardPage {
super.convertProject(project, new SubProgressMonitor(monitor, 1), projectID);
MakeProjectNature.addNature(project, new SubProgressMonitor(monitor, 1));
ScannerConfigNature.addScannerConfigNature(project);
-//FIXME ScannerConfigNature.initializeDiscoveryOptions(project);
+ ScannerConfigNature.initializeDiscoveryOptions(project);
CCorePlugin.getDefault().mapCProjectOwner(project, projectID, true);
} finally {
monitor.done();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
index 3687155142c..b94c37c9d04 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF
@@ -6,9 +6,12 @@ Bundle-Version: 4.0.0.qualifier
Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Export-Package: org.eclipse.cdt.managedbuilder.buildmodel,
+Export-Package: org.eclipse.cdt.build.core.scannerconfig,
+ org.eclipse.cdt.build.internal.core.scannerconfig,
+ org.eclipse.cdt.build.internal.core.scannerconfig2,
+ org.eclipse.cdt.managedbuilder.buildmodel,
+ org.eclipse.cdt.managedbuilder.buildproperties,
org.eclipse.cdt.managedbuilder.core,
- org.eclipse.cdt.newmake.core,
org.eclipse.cdt.managedbuilder.envvar,
org.eclipse.cdt.managedbuilder.internal.buildmodel,
org.eclipse.cdt.managedbuilder.internal.core,
@@ -21,16 +24,11 @@ Export-Package: org.eclipse.cdt.managedbuilder.buildmodel,
org.eclipse.cdt.managedbuilder.makegen.internal,
org.eclipse.cdt.managedbuilder.projectconverter,
org.eclipse.cdt.managedbuilder.scannerconfig,
- org.eclipse.cdt.managedbuilder.buildproperties,
- org.eclipse.cdt.make.internal.core.scannerconfig,
- org.eclipse.cdt.make.internal.core.scannerconfig.gnu,
- org.eclipse.cdt.make.internal.core.scannerconfig.jobs,
- org.eclipse.cdt.make.internal.core.scannerconfig.util,
- org.eclipse.cdt.make.internal.core.scannerconfig2,
- org.eclipse.cdt.make.core.scannerconfig
+ org.eclipse.cdt.newmake.core
Require-Bundle: org.eclipse.cdt.core;bundle-version="[4.0.0,5.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)"
+ org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
+ org.eclipse.cdt.make.core
Eclipse-LazyStart: true
diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
index 18ed2a7ae5d..fbdcf30dd12 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
@@ -6,7 +6,6 @@
-
@@ -90,7 +89,7 @@
+ point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
@@ -105,7 +104,7 @@
+ point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
@@ -120,7 +119,7 @@
+ point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
@@ -135,7 +134,7 @@
+ point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
@@ -150,7 +149,7 @@
+ point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
@@ -224,8 +223,8 @@
name="pre-4.0 projects converter"
point="org.eclipse.cdt.core.projectConverter">
@@ -392,7 +391,7 @@
+ class="org.eclipse.cdt.build.core.scannerconfig.ScannerConfigNature">
+ class="org.eclipse.cdt.build.core.scannerconfig.ScannerConfigBuilder">
+
+
+
+
diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/ScannerConfigurationDiscoveryProfile.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/ScannerConfigurationDiscoveryProfile.exsd
deleted file mode 100644
index 7f0f29f5614..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/schema/ScannerConfigurationDiscoveryProfile.exsd
+++ /dev/null
@@ -1,254 +0,0 @@
-
-
-
-
-
-
-
-
- A unified definition of a scanner configuration profile. Usually consists of <p>
-- A make build output parser <p>
-- A scanner info collector <p>
-- An external scanner info generator <p>
- - An external scanner info generator output parser <p>
-
-
-
-
-
-
- Definition of a profile:
-- A scanner info collector
-- A make build output parser
-- A number of external scanner info providers
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Profile id.
-
-
-
-
-
-
- The name of the profile will be presented to the user.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Java class that implements IScannerInfoCollector interface.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Make build output or external scanner info provider output parser.
-
-
-
-
-
-
- Java class that implements IScannerInfoConsoleParser interface.
-
-
-
-
-
-
-
-
-
- Comma separated list of compiler commands to use for detecting lines with preprocessor options.
-
-Example: "gcc, g++, cc, c++"
-
-
-
-
-
-
-
-
-
- Build output provider is make build or/and build output file.
-
-
-
-
-
-
-
-
-
-
-
-
-
- Either a command with arguments whose output will provide scanner information or a file that contains the scanner info.
-
-
-
-
-
-
-
-
-
-
-
-
-
- An id of the specific provider.
-
-
-
-
-
-
-
-
-
-
-
- A fully qualified name of the Java class that implements <samp>org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider2</samp> interface.
-If not specified then <samp>org.eclipse.cdt.make.internal.core.scannerconfig.DefaultExternalScannerInfoProvider</samp> is the default one used.
-
-
-
-
-
-
-
-
-
- A command to run. Example: <samp>gcc</samp>.
-
-
-
-
-
-
- Arguments for the command. Example: <samp>-E -P -v -dD</samp>.
-
-
-
-
-
-
-
-
-
-
-
- A fully qualified name of the Java class that implements <samp>org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoReader</samp> interface.
-If not specified then <samp>org.eclipse.cdt.make.internal.core.scannerconfig.DefaultExternalScannerInfoReader</samp> is the default one used.
-
-
-
-
-
-
-
-
-
- A file containing a make build output or scanner information in some other form.
-
-
-
-
-
-
-
-
-
-
-
- 3.0
-
-
-
-
-
-
-
-
- [Enter extension point usage example here.]
-
-
-
-
-
-
-
-
- [Enter API information here.]
-
-
-
-
-
-
-
-
- <samp>org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile</samp>
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/CfgInfoContext.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/CfgInfoContext.java
new file mode 100644
index 00000000000..26981082486
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/CfgInfoContext.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.build.core.scannerconfig;
+
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.core.resources.IProject;
+
+public final class CfgInfoContext{
+ private static final String DELIMITER = ";";
+ private static final int NULL_OBJ_CODE = 29;
+ private IConfiguration fCfg;
+ private IResourceInfo fRcInfo;
+ private ITool fTool;
+ private IInputType fInType;
+ private InfoContext fContext;
+
+ public CfgInfoContext(IResourceInfo rcInfo, ITool tool, IInputType inType){
+ this(rcInfo, tool, inType, null);
+ }
+
+ private CfgInfoContext(IResourceInfo rcInfo, ITool tool, IInputType inType, InfoContext baseContext){
+ this.fRcInfo = rcInfo;
+ this.fTool = tool;
+ this.fInType = inType;
+ this.fCfg = fRcInfo.getParent();
+ this.fContext = baseContext;
+ }
+
+ public CfgInfoContext(IConfiguration cfg){
+ this(cfg, null);
+ }
+
+ private CfgInfoContext(IConfiguration cfg, InfoContext baseContext){
+ this.fCfg = cfg;
+ this.fContext = baseContext;
+ }
+
+ public IConfiguration getConfiguration(){
+ return fCfg;
+ }
+
+ public IResourceInfo getResourceInfo(){
+ return fRcInfo;
+ }
+
+ public ITool getTool(){
+ return fTool;
+ }
+
+ public IInputType getInputType(){
+ return fInType;
+ }
+
+ public InfoContext toInfoContext(){
+ if(fContext == null){
+ IProject project = fCfg.getOwner().getProject();
+ StringBuffer buf = new StringBuffer();
+ buf.append(fCfg.getId());
+ if(fRcInfo != null){
+ buf.append(DELIMITER);
+ buf.append(fRcInfo.getId());
+ }
+
+ if(fTool != null){
+ buf.append(DELIMITER);
+ buf.append(fTool.getId());
+ }
+
+ if(fInType != null){
+ buf.append(DELIMITER);
+ buf.append(fInType.getId());
+ }
+
+ String instanceId = buf.toString();
+ fContext = new InfoContext(project, instanceId);
+ }
+ return fContext;
+ }
+
+ public static CfgInfoContext fromInfoContext(IConfiguration cfg, InfoContext context) {
+ IProject project = context.getProject();
+ if(project == null)
+ return null;
+
+ String instanceId = context.getInstanceId();
+ if(instanceId.length() == 0)
+ return null;
+
+ String[] ids = CDataUtil.stringToArray(instanceId, DELIMITER);
+ String cfgId = ids[0];
+ if(!cfgId.equals(cfg.getId()))
+ return null;
+
+ String rcInfoId = null, toolId = null, inTypeId = null;
+ IResourceInfo rcInfo = null;
+ ITool tool = null;
+ IInputType inType = null;
+
+ switch(ids.length){
+ case 4:
+ inTypeId = ids[3];
+ case 3:
+ toolId = ids[2];
+ case 2:
+ rcInfoId = ids[1];
+ }
+
+ if(rcInfoId != null){
+ rcInfo = (IResourceInfo)find(cfg.getResourceInfos(), rcInfoId);
+ if(rcInfo == null){
+ return null;
+ }
+ }
+
+ if(toolId != null){
+ tool = (ITool)find(rcInfo.getTools(), toolId);
+ if(tool == null)
+ return null;
+ }
+
+ if(inTypeId != null){
+ inType = (IInputType)find(tool.getInputTypes(), inTypeId);
+ if(inType == null)
+ return null;
+ }
+
+ if(rcInfo != null)
+ return new CfgInfoContext(rcInfo, tool, inType, context);
+ return new CfgInfoContext(cfg, context);
+ }
+
+ private static IBuildObject find(IBuildObject objs[], String id){
+ for(int i = 0; i < objs.length; i++){
+ if(objs[i].getId().equals(id))
+ return objs[i];
+ }
+ return null;
+ }
+
+ public boolean equals(Object obj) {
+ if(this == obj)
+ return true;
+
+ if(!(obj instanceof CfgInfoContext))
+ return false;
+
+ CfgInfoContext other = (CfgInfoContext)obj;
+ if(!checkBuildObjects(other.fCfg, fCfg))
+ return false;
+
+ if(!checkBuildObjects(other.fRcInfo, fRcInfo))
+ return false;
+
+ if(!checkBuildObjects(other.fTool, fTool))
+ return false;
+
+ if(!checkBuildObjects(other.fInType, fInType))
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int code = getCode(fCfg);
+ code += getCode(fRcInfo);
+ code += getCode(fTool);
+ code += getCode(fInType);
+ return code;
+ }
+
+ private boolean checkBuildObjects(IBuildObject bo1, IBuildObject bo2){
+ if(bo1 == null)
+ return bo2 == null;
+ if(bo2 == null)
+ return false;
+ return bo1.getId().equals(bo2.getId());
+ }
+
+ private int getCode(IBuildObject bo){
+ if(bo == null)
+ return NULL_OBJ_CODE;
+ return bo.getId().hashCode();
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ICfgScannerConfigBuilderInfo2Set.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ICfgScannerConfigBuilderInfo2Set.java
new file mode 100644
index 00000000000..7ff1fe81bf1
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ICfgScannerConfigBuilderInfo2Set.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation 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:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.build.core.scannerconfig;
+
+import java.util.Map;
+
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.runtime.CoreException;
+
+
+public interface ICfgScannerConfigBuilderInfo2Set {
+ boolean isPerRcTypeDiscovery();
+
+ void setPerRcTypeDiscovery(boolean on);
+
+ Map getInfoMap();
+
+ CfgInfoContext[] getContexts();
+
+ IScannerConfigBuilderInfo2 getInfo(CfgInfoContext context);
+
+ IScannerConfigBuilderInfo2 applyInfo(CfgInfoContext context, IScannerConfigBuilderInfo2 base) throws CoreException;
+
+ IConfiguration getConfiguration();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigBuilder.java
similarity index 69%
rename from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
rename to build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigBuilder.java
index 8f852d35e9e..f92d886c19d 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation 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
@@ -8,16 +8,22 @@
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
+package org.eclipse.cdt.build.core.scannerconfig;
import java.util.Iterator;
import java.util.Map;
+import java.util.Properties;
+import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
+import org.eclipse.cdt.build.internal.core.scannerconfig.jobs.CfgSCJobsUtil;
+import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
import org.eclipse.cdt.core.resources.ACBuilder;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.SCJobsUtil;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@@ -29,8 +35,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
-import sun.security.action.GetPropertyAction;
-
/**
* Runs after standard make builder.
* Consolidates discovered scanner configuration and updates project's scanner configuration.
@@ -76,7 +80,7 @@ public class ScannerConfigBuilder extends ACBuilder {
}
}
- ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().updateCoreSettings(getProject(), cfgs);
+ CfgDiscoveredPathManager.getInstance().updateCoreSettings(getProject(), cfgs);
}
@@ -94,18 +98,19 @@ public class ScannerConfigBuilder extends ACBuilder {
// getProject().getName());
// ScannerInfoCollector.getInstance().updateScannerConfiguration(getProject(), new SubProgressMonitor(monitor, 100));
// }
- IConfigurationScannerConfigBuilderInfo info = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
+ ICfgScannerConfigBuilderInfo2Set info = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
IProject project = cfg.getOwner().getProject();
Map infoMap = info.getInfoMap();
int num = infoMap.size();
if(num != 0){
+ Properties envProps = calcEnvironment(cfg);
monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), num);
for(Iterator iter = infoMap.entrySet().iterator(); iter.hasNext();){
try {
Map.Entry entry = (Map.Entry)iter.next();
- InfoContext c = (InfoContext)entry.getKey();
+ CfgInfoContext c = (CfgInfoContext)entry.getKey();
IScannerConfigBuilderInfo2 buildInfo2 = (IScannerConfigBuilderInfo2)entry.getValue();
- build(c, buildInfo2, (flags & (~PERFORM_CORE_UPDATE)), new SubProgressMonitor(monitor, 1));
+ build(c, buildInfo2, (flags & (~PERFORM_CORE_UPDATE)), envProps, new SubProgressMonitor(monitor, 1));
} catch (CoreException e){
// builder not installed or disabled
// autodiscoveryEnabled = false;
@@ -115,12 +120,24 @@ public class ScannerConfigBuilder extends ACBuilder {
}
}
if((flags & PERFORM_CORE_UPDATE) != 0)
- ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().updateCoreSettings(project, new IConfiguration[]{cfg});
+ CfgDiscoveredPathManager.getInstance().updateCoreSettings(project, new IConfiguration[]{cfg});
}
}
- public static SCProfileInstance build(InfoContext context, IScannerConfigBuilderInfo2 buildInfo2, int flags, IProgressMonitor monitor) throws CoreException{
+ private static Properties calcEnvironment(IConfiguration cfg){
+ Properties envProps = new Properties();
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
+ IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
+ IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
+ for(int i = 0; i < vars.length; i++){
+ envProps.setProperty(vars[i].getName(), vars[i].getValue());
+ }
+
+ return envProps;
+ }
+
+ public static SCProfileInstance build(CfgInfoContext context, IScannerConfigBuilderInfo2 buildInfo2, int flags, Properties env, IProgressMonitor monitor) throws CoreException{
IConfiguration cfg = context.getConfiguration();
IProject project = cfg.getOwner().getProject();
boolean autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled();
@@ -130,14 +147,17 @@ public class ScannerConfigBuilder extends ACBuilder {
monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
project.getName());
+ if(env == null)
+ env = calcEnvironment(cfg);
+
// get scanner info from all external providers
- SCProfileInstance instance = SCJobsUtil.getProviderScannerInfo(project, context, null, buildInfo2, new SubProgressMonitor(monitor, 70));
+ SCProfileInstance instance = CfgSCJobsUtil.getProviderScannerInfo(project, context, null, buildInfo2, env, new SubProgressMonitor(monitor, 70));
// update and persist scanner configuration
- SCJobsUtil.updateScannerConfiguration(project, context, instance, buildInfo2, new SubProgressMonitor(monitor, 30));
+ CfgSCJobsUtil.updateScannerConfiguration(project, context, instance, buildInfo2, new SubProgressMonitor(monitor, 30));
if((flags & PERFORM_CORE_UPDATE) != 0)
- ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().updateCoreSettings(project, new IConfiguration[]{cfg});
+ CfgDiscoveredPathManager.getInstance().updateCoreSettings(project, new IConfiguration[]{cfg});
return instance;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigNature.java
similarity index 98%
rename from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java
rename to build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigNature.java
index 02a9da22024..bbb54e4af5f 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigNature.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/core/scannerconfig/ScannerConfigNature.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation 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
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
+package org.eclipse.cdt.build.core.scannerconfig;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.ICommand;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/CfgDiscoveredPathManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/CfgDiscoveredPathManager.java
new file mode 100644
index 00000000000..d106e3261d8
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/CfgDiscoveredPathManager.java
@@ -0,0 +1,279 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 QNX Software Systems 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:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.build.internal.core.scannerconfig;
+
+import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
+import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
+import org.eclipse.cdt.build.core.scannerconfig.ScannerConfigBuilder;
+import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
+import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
+import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+
+public class CfgDiscoveredPathManager implements IResourceChangeListener {
+
+ public static CfgDiscoveredPathManager fInstance;
+
+ private IDiscoveredPathManager fBaseMngr;
+
+ private CfgDiscoveredPathManager() {
+ fBaseMngr = MakeCorePlugin.getDefault().getDiscoveryManager();
+ }
+
+ public static CfgDiscoveredPathManager getInstance(){
+ if(fInstance == null){
+ fInstance = new CfgDiscoveredPathManager();
+ fInstance.startup();
+ }
+ return fInstance;
+ }
+
+ public static void stop(){
+ if(fInstance != null)
+ fInstance.shutdown();
+ }
+
+ public void startup() {
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
+ }
+
+ public void shutdown() {
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+ */
+ public void resourceChanged(IResourceChangeEvent event) {
+ if (event.getSource() instanceof IWorkspace) {
+ IResource resource = event.getResource();
+
+ switch (event.getType()) {
+ case IResourceChangeEvent.POST_CHANGE :
+// DiscoveredScannerInfoStore.getInstance().updateScannerConfigStore(event.getDelta());
+ break;
+ case IResourceChangeEvent.PRE_DELETE :
+ case IResourceChangeEvent.PRE_CLOSE :
+ if (resource.getType() == IResource.PROJECT) {
+// fDiscoveredMap.remove(resource);
+ }
+ break;
+ }
+ }
+ }
+
+ public void updateCoreSettings(final IProject project, final IConfiguration cfgs[]) {
+ try {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ManagedBuildManager.updateCoreSettings(project, cfgs);
+ }
+ };
+ CoreModel.run(runnable, null);
+ }
+ catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+
+
+ public IDiscoveredPathManager.IDiscoveredPathInfo getDiscoveredInfo(IProject project,
+ CfgInfoContext context) throws CoreException {
+
+ context = adjustContext(context);
+
+ IDiscoveredPathManager.IDiscoveredPathInfo info = getCachedPathInfo(context);
+ if (info == null) {
+ info = loadPathInfo(project, context.getConfiguration(), context);
+ setCachedPathInfo(context, info);
+// if(info instanceof DiscoveredPathInfo && !((DiscoveredPathInfo)info).isLoadded()){
+// info = createPathInfo(project, context);
+// setCachedPathInfo(context, info);
+// }
+ }
+ return info;
+ }
+
+ private IDiscoveredPathManager.IDiscoveredPathInfo loadPathInfo(IProject project, IConfiguration cfg, CfgInfoContext context) throws CoreException{
+ IDiscoveredPathManager.IDiscoveredPathInfo info = fBaseMngr.getDiscoveredInfo(cfg.getOwner().getProject(), context.toInfoContext());
+ if(!DiscoveredScannerInfoStore.getInstance().hasInfo(project, context.toInfoContext(), info.getSerializable())){
+ setCachedPathInfo(context, info);
+ ICfgScannerConfigBuilderInfo2Set container = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
+ IScannerConfigBuilderInfo2 buildInfo = container.getInfo(context);
+ if(buildInfo != null){
+ SCProfileInstance instance = ScannerConfigBuilder.build(context, buildInfo, 0, null, new NullProgressMonitor());
+ if(instance != null){
+ IScannerInfoCollector newC = instance.getScannerInfoCollector();
+ if(newC instanceof IScannerInfoCollector2){
+ info = ((IScannerInfoCollector2)newC).createPathInfoObject();
+// setCachedPathInfo(context, info);
+ }
+ }
+ }
+ }
+ return info;
+ }
+
+ private IDiscoveredPathManager.IDiscoveredPathInfo getCachedPathInfo(CfgInfoContext context){
+ ICfgScannerConfigBuilderInfo2Set cfgInfo = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
+ IDiscoveredPathManager.IDiscoveredPathInfo info = null;
+ boolean queryCfg = !cfgInfo.isPerRcTypeDiscovery();
+ if(!queryCfg){
+ Tool tool = (Tool)context.getTool();
+ if(tool != null){
+ info = tool.getDiscoveredPathInfo(context.getInputType());
+ } else {
+ queryCfg = true;
+ }
+ }
+ if(queryCfg) {
+ info = ((Configuration)context.getConfiguration()).getDiscoveredPathInfo();
+ }
+ return info;
+ }
+
+ private CfgInfoContext adjustContext(CfgInfoContext context){
+ return adjustContext(context, null);
+
+ }
+
+ private CfgInfoContext adjustContext(CfgInfoContext context, ICfgScannerConfigBuilderInfo2Set cfgInfo){
+ if(cfgInfo == null)
+ cfgInfo = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
+
+ boolean queryCfg = !cfgInfo.isPerRcTypeDiscovery();
+
+ Tool tool = (Tool)context.getTool();
+ IResourceInfo rcInfo = context.getResourceInfo();
+ IInputType inType = context.getInputType();
+ boolean adjust = false;
+ CfgInfoContext newContext = context;
+
+ if(!queryCfg){
+ if(tool != null){
+ if(inType != null){
+ if(!tool.hasScannerConfigSettings(inType)){
+// tool = null;
+ inType = null;
+ adjust = true;
+ }
+ }
+ if(inType == null){
+ if(!tool.hasScannerConfigSettings(null)){
+ tool = null;
+ adjust = true;
+ }
+ }
+ }
+ if(tool == null){
+ if(inType != null){
+ inType = null;
+ adjust = true;
+ }
+
+ if(rcInfo != null){
+ ToolChain tc = rcInfo instanceof FolderInfo ?
+ (ToolChain)((FolderInfo)rcInfo).getToolChain()
+ : (ToolChain)((ResourceConfiguration)rcInfo).getBaseToolChain();
+
+ if(tc != null){
+ if(!tc.hasScannerConfigSettings()){
+ adjust = true;
+ rcInfo = null;
+ }
+ }
+ }
+ }
+ } else {
+ if(tool != null){
+ tool = null;
+ adjust = true;
+ }
+ if(rcInfo != null){
+ rcInfo = null;
+ adjust = true;
+ }
+ if(inType != null){
+ inType = null;
+ adjust = true;
+ }
+ }
+
+ if(adjust){
+ if(rcInfo == null)
+ newContext = new CfgInfoContext(context.getConfiguration());
+ else
+ newContext = new CfgInfoContext(rcInfo, tool, inType);
+ }
+
+ return newContext;
+ }
+
+ private IDiscoveredPathManager.IDiscoveredPathInfo setCachedPathInfo(CfgInfoContext context, IDiscoveredPathManager.IDiscoveredPathInfo info){
+ ICfgScannerConfigBuilderInfo2Set cfgInfo = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
+ boolean cacheOnCfg = !cfgInfo.isPerRcTypeDiscovery();
+ IDiscoveredPathManager.IDiscoveredPathInfo oldInfo = null;
+ if(!cacheOnCfg){
+ Tool tool = (Tool)context.getTool();
+ if(tool != null){
+ if(info != null)
+ oldInfo = tool.setDiscoveredPathInfo(context.getInputType(), info);
+ else
+ oldInfo = tool.clearDiscoveredPathInfo(context.getInputType());
+ }
+ } else {
+ if(info != null)
+ oldInfo = ((Configuration)context.getConfiguration()).setDiscoveredPathInfo(info);
+ else
+ oldInfo = ((Configuration)context.getConfiguration()).clearDiscoveredPathInfo();
+ }
+ return oldInfo;
+ }
+
+ public void removeDiscoveredInfo(IProject project, CfgInfoContext context) {
+// if(context == null)
+// context = ScannerConfigUtil.createContextForProject(project);
+
+ context = adjustContext(context);
+
+ IDiscoveredPathManager.IDiscoveredPathInfo info = setCachedPathInfo(context, null);
+ fBaseMngr.removeDiscoveredInfo(project, context.toInfoContext());
+// if (info != null) {
+// fireUpdate(INFO_REMOVED, info);
+// }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/jobs/CfgSCJobsUtil.java
similarity index 87%
rename from build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java
rename to build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/jobs/CfgSCJobsUtil.java
index eb48193bf9e..ec82c97fb67 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/SCJobsUtil.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig/jobs/CfgSCJobsUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation 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
@@ -8,16 +8,16 @@
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.jobs;
+package org.eclipse.cdt.build.internal.core.scannerconfig.jobs;
import java.util.List;
+import java.util.Properties;
+import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
@@ -31,7 +31,7 @@ import org.eclipse.core.runtime.Platform;
*
* @author vhirsl
*/
-public class SCJobsUtil {
+public class CfgSCJobsUtil {
private static class RC {
public RC(boolean init) {
rc = init;
@@ -70,15 +70,16 @@ public class SCJobsUtil {
* @param monitor
*/
public static SCProfileInstance getProviderScannerInfo(final IProject project,
- final InfoContext context,
+ final CfgInfoContext context,
SCProfileInstance profileInstance,
final IScannerConfigBuilderInfo2 buildInfo,
+ final Properties env,
final IProgressMonitor monitor) {
final RC rc = new RC(false);
// get the collector
if(profileInstance == null){
profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, context, buildInfo.getSelectedProfileId());
+ getSCProfileInstance(project, context.toInfoContext(), buildInfo.getSelectedProfileId());
}
final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
@@ -92,7 +93,7 @@ public class SCJobsUtil {
ISafeRunnable runnable = new ISafeRunnable() {
public void run() {
- esiProvider.invokeProvider(monitor, project, providerId, buildInfo, collector);
+ esiProvider.invokeProvider(monitor, project, context.toInfoContext(), providerId, buildInfo, collector, env);
rc.set(true);
}
@@ -125,18 +126,18 @@ public class SCJobsUtil {
* @param monitor
*/
public static boolean updateScannerConfiguration(IProject project,
- InfoContext context,
+ CfgInfoContext context,
SCProfileInstance profileInstance,
IScannerConfigBuilderInfo2 buildInfo,
final IProgressMonitor monitor) {
final RC rc = new RC(false);
// get the collector
- if(context == null)
- context = ScannerConfigUtil.createContextForProject(project);
+// if(context == null)
+// context = ScannerConfigUtil.createContextForProject(project);
if(profileInstance == null){
profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, context, buildInfo.getSelectedProfileId());
+ getSCProfileInstance(project, context.toInfoContext(), buildInfo.getSelectedProfileId());
}
IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
if (collector instanceof IScannerInfoCollector2) {
@@ -161,13 +162,14 @@ public class SCJobsUtil {
}
public static SCProfileInstance readBuildOutputFile(final IProject project,
- final InfoContext context,
+ final CfgInfoContext context,
final IScannerConfigBuilderInfo2 buildInfo,
+ final Properties env,
final IProgressMonitor monitor) {
final RC rc = new RC(false);
// get the collector
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, context, buildInfo.getSelectedProfileId());
+ getSCProfileInstance(project, context.toInfoContext(), buildInfo.getSelectedProfileId());
final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
final IExternalScannerInfoProvider esiProvider = profileInstance.
createBuildOutputProvider();
@@ -176,7 +178,7 @@ public class SCJobsUtil {
ISafeRunnable runnable = new ISafeRunnable() {
public void run() {
- esiProvider.invokeProvider(monitor, project, null, buildInfo, collector);
+ esiProvider.invokeProvider(monitor, project, context.toInfoContext(), null, buildInfo, collector, env);
rc.set(true);
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigInfoFactory2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigInfoFactory2.java
new file mode 100644
index 00000000000..64003a7fa12
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigInfoFactory2.java
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.build.internal.core.scannerconfig2;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
+import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2Set;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.cdt.managedbuilder.internal.core.InputType;
+import org.eclipse.cdt.managedbuilder.internal.core.Tool;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
+
+
+/**
+ * New ScannerConfigInfoFactory
+ *
+ * @author vhirsl
+ */
+public class CfgScannerConfigInfoFactory2 {
+ private static final QualifiedName CONTAINER_INFO_PROPERTY = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "ScannerConfigBuilderInfo2Container"); //$NON-NLS-1$
+
+ private static class ContainerInfo{
+ ICProjectDescription fDes;
+ IScannerConfigBuilderInfo2Set fContainer;
+
+ ContainerInfo(ICProjectDescription des, IScannerConfigBuilderInfo2Set container){
+ this.fDes = des;
+ this.fContainer = container;
+ }
+ }
+ private static class CfgInfo implements ICfgScannerConfigBuilderInfo2Set {
+ private Configuration cfg;
+ private IScannerConfigBuilderInfo2Set fContainer;
+// private HashMap map;
+
+ CfgInfo(Configuration cfg){
+ this.cfg = (Configuration)cfg;
+// init();
+ }
+
+ public CfgInfoContext[] getContexts() {
+ Map map = createMap();
+ return (CfgInfoContext[])map.keySet().toArray(new CfgInfoContext[map.size()]);
+ }
+
+ public IScannerConfigBuilderInfo2 getInfo(CfgInfoContext context) {
+ return (IScannerConfigBuilderInfo2)createMap().get(context);
+// IScannerConfigBuilderInfo2 info = null;
+// if(!isPerRcTypeDiscovery()){
+// info = cfg.getScannerConfigInfo();
+// if(info == null){
+// info = ScannerConfigInfoFactory2.create(cfg, ManagedBuilderCorePlugin.getDefault().getPluginPreferences());
+// }
+// } else {
+// Tool tool = (Tool)context.getTool();
+// if(tool != null)
+// info = tool.getScannerConfigInfo(context.getInputType());
+//// else
+//// info = getDefaultInfo();
+// }
+// return info;
+ }
+
+ public boolean isPerRcTypeDiscovery() {
+ return cfg.isPerRcTypeDiscovery();
+ }
+
+ private IScannerConfigBuilderInfo2Set getContainer() throws CoreException{
+ if(fContainer == null){
+ ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
+ if(cfgDes != null){
+ ICProjectDescription projDes = cfgDes.getProjectDescription();
+ if(projDes != null){
+ ContainerInfo cInfo = (ContainerInfo)projDes.getSessionProperty(CONTAINER_INFO_PROPERTY);
+ if(cInfo != null && cInfo.fDes == projDes){
+ fContainer = cInfo.fContainer;
+ } else {
+ fContainer = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(cfg.getOwner().getProject());
+ cInfo = new ContainerInfo(projDes, fContainer);
+ projDes.setSessionProperty(CONTAINER_INFO_PROPERTY, cInfo);
+ }
+ }
+ }
+
+ if(fContainer == null){
+ fContainer = ScannerConfigProfileManager.createScannerConfigBuildInfo2Set(cfg.getOwner().getProject());
+ }
+ }
+ return fContainer;
+ }
+
+ private Map createMap(){
+ HashMap map = new HashMap();
+ try{
+ IScannerConfigBuilderInfo2Set container = getContainer();
+
+ boolean isPerRcType = cfg.isPerRcTypeDiscovery();
+ Map baseMap = container.getInfoMap();
+ if(!isPerRcType){
+ CfgInfoContext c = new CfgInfoContext(cfg);
+ InfoContext baseContext = c.toInfoContext();
+ IScannerConfigBuilderInfo2 info = container.getInfo(baseContext);
+
+ if(info == null){
+ String id = cfg.getDiscoveryProfileId();
+ if(id != null)
+ info = container.createInfo(baseContext, id);
+ else
+ info = container.createInfo(baseContext);
+ }
+ map.put(new CfgInfoContext(cfg), info);
+ } else {
+ Map configMap = getConfigInfoMap(baseMap);
+
+ IResourceInfo[] rcInfos = cfg.getResourceInfos();
+ for(int i = 0; i < rcInfos.length; i++){
+ ITool tools[];
+ IResourceInfo rcInfo = rcInfos[i];
+ if(rcInfo instanceof IFolderInfo) {
+ tools = ((IFolderInfo)rcInfo).getFilteredTools();
+ } else {
+ tools = ((IFileInfo)rcInfo).getToolsToInvoke();
+ }
+ for(int k = 0; k < tools.length; k++){
+ Tool tool = (Tool)tools[k];
+ IInputType types[] = tool.getInputTypes();
+ if(types.length != 0){
+ for(int t = 0; t < types.length; t++){
+ InputType type = (InputType)types[t];
+ CfgInfoContext context = new CfgInfoContext(rcInfo, tool, type);
+ IScannerConfigBuilderInfo2 info = (IScannerConfigBuilderInfo2)configMap.remove(context);
+ if(info == null && type.hasScannerConfigSettings()){
+ InfoContext baseContext = context.toInfoContext();
+ if(!type.isExtensionElement() && type.getSuperClass() != null){
+ CfgInfoContext tmpCfgC = new CfgInfoContext(rcInfo, tool, type.getSuperClass());
+ info = (IScannerConfigBuilderInfo2)configMap.get(tmpCfgC);
+ if(info != null){
+ info = container.createInfo(baseContext, info);
+ }
+ }
+
+ if(info == null){
+ String id = type.getDiscoveryProfileId(tool);
+ if(id != null){
+ info = container.createInfo(baseContext, id);
+ } else {
+ info = container.createInfo(baseContext);
+ }
+ }
+ }
+
+ if(info != null){
+ map.put(context, info);
+ }
+ }
+ } else {
+ CfgInfoContext context = new CfgInfoContext(rcInfo, tool, null);
+ IScannerConfigBuilderInfo2 info = (IScannerConfigBuilderInfo2)configMap.get(context);
+ if(info == null && tool.hasScannerConfigSettings(null)){
+ String id = tool.getDiscoveryProfileId();
+ InfoContext baseContext = context.toInfoContext();
+ if(id != null){
+ info = container.createInfo(baseContext, id);
+ } else {
+ info = container.createInfo(baseContext);
+ }
+ }
+ if(info != null){
+ map.put(context, info);
+ }
+ }
+ }
+ }
+
+ if(!configMap.isEmpty()){
+ for(Iterator iter = configMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ CfgInfoContext c = (CfgInfoContext)entry.getKey();
+ if(c.getResourceInfo() != null || c.getTool() != null || c.getInputType() != null){
+ InfoContext baseC = c.toInfoContext();
+ if(!baseC.isDefaultContext())
+ container.removeInfo(baseC);
+ }
+ }
+ }
+ }
+ } catch (CoreException e){
+ ManagedBuilderCorePlugin.log(e);
+ }
+
+ return map;
+ }
+
+ private Map getConfigInfoMap(Map baseMap){
+ Map map = new HashMap();
+
+ for(Iterator iter = baseMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ InfoContext baseContext = (InfoContext)entry.getKey();
+ CfgInfoContext c = CfgInfoContext.fromInfoContext(cfg, baseContext);
+ if(c != null){
+ IScannerConfigBuilderInfo2 info = (IScannerConfigBuilderInfo2)entry.getValue();
+ map.put(c, info);
+ }
+ }
+
+ return map;
+ }
+
+ public Map getInfoMap() {
+ return createMap();
+ }
+
+ public void setPerRcTypeDiscovery(boolean on) {
+ cfg.setPerRcTypeDiscovery(on);
+ }
+
+ public IScannerConfigBuilderInfo2 applyInfo(CfgInfoContext context,
+ IScannerConfigBuilderInfo2 base) {
+ try {
+ IScannerConfigBuilderInfo2 newInfo;
+ IScannerConfigBuilderInfo2Set container = getContainer();
+ InfoContext baseContext = context.toInfoContext();
+ if(base != null){
+ newInfo = container.createInfo(baseContext, base);
+ } else {
+ if(!baseContext.isDefaultContext())
+ container.removeInfo(baseContext);
+ newInfo = getInfo(context);
+ }
+
+ return newInfo;
+ } catch (CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ return null;
+ }
+
+ public IConfiguration getConfiguration() {
+ return cfg;
+ }
+ }
+
+ public static ICfgScannerConfigBuilderInfo2Set create(IConfiguration cfg){
+ Configuration c = (Configuration)cfg;
+ ICfgScannerConfigBuilderInfo2Set container = c.getCfgScannerConfigInfo();
+ if(container == null){
+ container = new CfgInfo(c);
+ c.setCfgScannerConfigInfo(container);
+ }
+ return container;
+ }
+
+ public static void save(ICProjectDescription des, ICProjectDescription baseDescription) throws CoreException{
+ ContainerInfo info = (ContainerInfo)des.getSessionProperty(CONTAINER_INFO_PROPERTY);
+ if(info != null){
+ if(info.fDes == baseDescription){
+ IScannerConfigBuilderInfo2Set baseContainer = info.fContainer;
+ baseContainer.save();
+ }
+ des.setSessionProperty(CONTAINER_INFO_PROPERTY, null);
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigProfileManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigProfileManager.java
new file mode 100644
index 00000000000..452360f52ff
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/build/internal/core/scannerconfig2/CfgScannerConfigProfileManager.java
@@ -0,0 +1,28 @@
+package org.eclipse.cdt.build.internal.core.scannerconfig2;
+
+import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
+import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.core.resources.IProject;
+
+public class CfgScannerConfigProfileManager {
+
+ public static ICfgScannerConfigBuilderInfo2Set getCfgScannerConfigBuildInfo(IConfiguration cfg){
+ return CfgScannerConfigInfoFactory2.create(cfg);
+ }
+
+ public static InfoContext createDefaultContext(IProject project){
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ IConfiguration cfg = null;
+ if(info != null && info.isValid()){
+ cfg = info.getDefaultConfiguration();
+ }
+
+ if(cfg != null)
+ return new CfgInfoContext(cfg).toInfoContext();
+ return new InfoContext(project);
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java
deleted file mode 100644
index d775b0be7eb..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfo.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Discovered portion of scanner configuration
- * @deprecated
- * @author vhirsl
- */
-public class DiscoveredScannerInfo implements IScannerInfo {
- private IProject project;
- private LinkedHashMap discoveredPaths;
- private LinkedHashMap discoveredSymbols;
-
- private ArrayList activePaths;
- private ArrayList removedPaths;
-
- private ArrayList activeSymbols;
- private ArrayList removedSymbols;
-
- private org.eclipse.cdt.newmake.core.MakeScannerInfo userInfo;
-
- /**
- * @param project
- */
- public DiscoveredScannerInfo(IProject project) {
- this.project = project;
- }
-
- public IProject getProject() {
- return project;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IScannerInfo#getDefinedSymbols()
- */
- public synchronized Map getDefinedSymbols() {
- Map dSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols);
- dSymbols.putAll(userInfo.getDefinedSymbols());
- return dSymbols;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IScannerInfo#getIncludePaths()
- */
- public synchronized String[] getIncludePaths() {
- String[] iPaths = new String[getUserIncludePaths().length + getActiveIncludePaths().length];
- System.arraycopy(getUserIncludePaths(), 0, iPaths, 0, getUserIncludePaths().length);
- System.arraycopy(getActiveIncludePaths(), 0, iPaths, getUserIncludePaths().length, getActiveIncludePaths().length);
- return iPaths;
- }
-
- public org.eclipse.cdt.newmake.core.MakeScannerInfo getUserScannerInfo() {
- return userInfo;
- }
-
- public synchronized void setUserScannerInfo( org.eclipse.cdt.newmake.core.MakeScannerInfo info) {
- userInfo = info;
- }
-
- public LinkedHashMap getDiscoveredIncludePaths() {
- if (discoveredPaths == null) {
- return new LinkedHashMap();
- }
- return new LinkedHashMap(discoveredPaths);
- }
- public synchronized void setDiscoveredIncludePaths(LinkedHashMap paths) {
- discoveredPaths = new LinkedHashMap(paths);
- createPathLists();
- }
-
- /**
- * Populates active and removed include path lists
- */
- private void createPathLists() {
- List aPaths = getActivePathList();
- aPaths.clear();
- List rPaths = getRemovedPathList();
- rPaths.clear();
-
- for (Iterator i = discoveredPaths.keySet().iterator(); i.hasNext(); ) {
- String path = (String) i.next();
- Boolean removed = (Boolean) discoveredPaths.get(path);
- if (removed == null || removed.booleanValue() == false) {
- aPaths.add(path);
- }
- else {
- rPaths.add(path);
- }
- }
- }
-
- public LinkedHashMap getDiscoveredSymbolDefinitions() {
- if (discoveredSymbols == null) {
- return new LinkedHashMap();
- }
- return new LinkedHashMap(discoveredSymbols);
- }
- public synchronized void setDiscoveredSymbolDefinitions(LinkedHashMap symbols) {
- discoveredSymbols = new LinkedHashMap(symbols);
- createSymbolsLists();
- }
-
- /**
- * Populates active and removed defined symbols sets
- */
- private void createSymbolsLists() {
- List aSymbols = getActiveSymbolsList();
- aSymbols.clear();
- List rSymbols = getRemovedSymbolsList();
- rSymbols.clear();
-
- aSymbols.addAll(ScannerConfigUtil.scSymbolsSymbolEntryMap2List(discoveredSymbols, true));
- rSymbols.addAll(ScannerConfigUtil.scSymbolsSymbolEntryMap2List(discoveredSymbols, false));
- }
-
- public String[] getUserIncludePaths() {
- if (userInfo == null) {
- return new String[0];
- }
- return userInfo.getIncludePaths();
- }
- public String[] getActiveIncludePaths() {
- return (String[]) getActivePathList().toArray(new String[getActivePathList().size()]);
- }
- public String[] getRemovedIncludePaths() {
- return (String[])getRemovedPathList().toArray(new String[getRemovedPathList().size()]);
- }
-
- public String[] getUserSymbolDefinitions() {
- if (userInfo == null) {
- return new String[0];
- }
- return userInfo.getPreprocessorSymbols();
- }
- public String[] getActiveSymbolDefinitions() {
- return (String[]) getActiveSymbolsList().toArray(new String[getActiveSymbolsList().size()]);
- }
- public String[] getRemovedSymbolDefinitions() {
- return (String[]) getRemovedSymbolsList().toArray(new String[getRemovedSymbolsList().size()]);
- }
- public String[] getPreprocessorSymbols() {
- // user specified + active
- String[] userSymbols = getUserSymbolDefinitions();
- String[] discActiveSymbols = getActiveSymbolDefinitions();
- String[] rv = new String[userSymbols.length + discActiveSymbols.length];
- System.arraycopy(userSymbols, 0, rv, 0, userSymbols.length);
- System.arraycopy(discActiveSymbols, 0, rv, userSymbols.length, discActiveSymbols.length);
- return rv;
- }
-
- private List getActivePathList() {
- if (activePaths == null) {
- activePaths = new ArrayList();
- }
- return activePaths;
- }
-
- private List getRemovedPathList() {
- if (removedPaths == null) {
- removedPaths = new ArrayList();
- }
- return removedPaths;
- }
-
- private List getActiveSymbolsList() {
- if (activeSymbols == null) {
- activeSymbols = new ArrayList();
- }
- return activeSymbols;
- }
-
- private List getRemovedSymbolsList() {
- if (removedSymbols == null) {
- removedSymbols = new ArrayList();
- }
- return removedSymbols;
- }
-
- public void update() throws CoreException {
- DiscoveredScannerInfoProvider.updateScannerInfo(this);
- }
-
- /**
- * @param userPaths
- */
- public void setUserIncludePaths(List userPaths) {
- userInfo.setIncludePaths((String[]) userPaths.toArray(new String[userPaths.size()]));
- }
-
- /**
- * @param userSymbols
- */
- public void setUserDefinedSymbols(List userSymbols) {
- userInfo.setPreprocessorSymbols((String[]) userSymbols.toArray(new String[userSymbols.size()]));
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java
deleted file mode 100644
index 0817c773d1a..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/DiscoveredScannerInfoProvider.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.ICDescriptor;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
-import org.eclipse.cdt.core.resources.ScannerProvider;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.QualifiedName;
-
-/**
- * Provider of both user specified and discovered scanner info
- *
- * @deprecated @author vhirsl
- */
-public class DiscoveredScannerInfoProvider extends ScannerProvider {
-
- // This is the id of the IScannerInfoProvider extension point entry
- public static final String INTERFACE_IDENTITY = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".DiscoveredScannerInfoProvider"; //$NON-NLS-1$
-
- // Name we will use to store build property with the project
- private static final QualifiedName scannerInfoProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(),
- "discoveredMakeBuildInfo"); //$NON-NLS-1$
-
- // Singleton
- private static DiscoveredScannerInfoProvider instance;
- public static DiscoveredScannerInfoProvider getDefault() {
- if (instance == null) {
- instance = new DiscoveredScannerInfoProvider();
- }
- return instance;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#getScannerInformation(org.eclipse.core.resources.IResource)
- */
- public IScannerInfo getScannerInformation(IResource resource) {
- try {
- getDiscoveredScannerInfo(resource.getProject(), true);
- } catch (CoreException e) {
- }
- return super.getScannerInformation(resource);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#subscribe(org.eclipse.core.resources.IResource,
- * org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
- */
- public void subscribe(IResource resource, IScannerInfoChangeListener listener) {
- super.subscribe(resource, listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.core.parser.IScannerInfoProvider#unsubscribe(org.eclipse.core.resources.IResource,
- * org.eclipse.cdt.core.parser.IScannerInfoChangeListener)
- */
- public void unsubscribe(IResource resource, IScannerInfoChangeListener listener) {
- super.unsubscribe(resource, listener);
- }
-
- public DiscoveredScannerInfo getDiscoveredScannerInfo(IProject project, boolean cacheInfo) throws CoreException {
- DiscoveredScannerInfo scannerInfo = null;
- // See if there's already one associated with the resource for this
- // session
- scannerInfo = (DiscoveredScannerInfo)project.getSessionProperty(scannerInfoProperty);
-
- if (scannerInfo == null) {
- scannerInfo = new DiscoveredScannerInfo(project);
- // this will convert user info
- org.eclipse.cdt.newmake.core.MakeScannerInfo makeScannerInfo = org.eclipse.cdt.newmake.core.MakeScannerProvider.getDefault().getMakeScannerInfo(
- project, cacheInfo);
- scannerInfo.setUserScannerInfo(makeScannerInfo);
-
- // migrate to new C Path Entries
- IContainerEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
- ICProject cProject = CoreModel.getDefault().create(project);
- if (cProject != null) {
- IPathEntry[] entries = cProject.getRawPathEntries();
- List newEntries = new ArrayList(Arrays.asList(entries));
- if (!newEntries.contains(container)) {
- newEntries.add(container);
- cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), null);
- }
- }
- ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project);
- descriptor.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); // remove scanner provider which will fallback to default
- // cpath provider.
- // place holder to that we don't convert again.
- project.setSessionProperty(scannerInfoProperty, scannerInfo);
- }
- return scannerInfo;
- }
-
- /**
- * The build model manager for standard builds only caches the build information for a resource on a per-session basis. This
- * method allows clients of the build model manager to programmatically remove the association between the resource and the
- * information while the reource is still open or in the workspace. The Eclipse core will take care of removing it if a resource
- * is closed or deleted.
- *
- * @param resource
- */
- public static void removeScannerInfo(IResource resource) {
- try {
- resource.getProject().setSessionProperty(scannerInfoProperty, null);
- } catch (CoreException e) {
- }
- }
-
- /**
- * Persists build-specific information in the build file. Build information for standard make projects consists of preprocessor
- * symbols and includes paths. Other project-related information is stored in the persistent properties of the project.
- *
- * @param scannerInfo
- */
- static void updateScannerInfo(DiscoveredScannerInfo scannerInfo) throws CoreException {
- // no longer supported!
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IConfigurationScannerConfigBuilderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IConfigurationScannerConfigBuilderInfo.java
deleted file mode 100644
index 8fe675fff26..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IConfigurationScannerConfigBuilderInfo.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Intel Corporation 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-
-
-public interface IConfigurationScannerConfigBuilderInfo {
- boolean isPerRcTypeDiscovery();
-
- void setPerRcTypeDiscovery(boolean on);
-
- Map getInfoMap();
-
- InfoContext[] getContexts();
-
- IScannerConfigBuilderInfo2 getInfo(InfoContext context);
-
- IScannerConfigBuilderInfo2 applyInfo(InfoContext context, IScannerConfigBuilderInfo2 base) throws CoreException;
-
- IScannerConfigBuilderInfo2 getDefaultInfo();
-
-// boolean isAutoDiscoveryEnabled();
-// void setAutoDiscoveryEnabled(boolean enable);
-//
-// boolean isProblemReportingEnabled();
-// void setProblemReportingEnabled(boolean enable);
-//
-// String getSelectedProfileId();
-// void setSelectedProfileId(String profileId);
-//
-// List getProfileIdList();
-//
-// // SCD profile - buildOutputProvider options
-// boolean isBuildOutputFileActionEnabled();
-// void setBuildOutputFileActionEnabled(boolean enable);
-//
-// String getBuildOutputFilePath();
-// void setBuildOutputFilePath(String path);
-//
-// boolean isBuildOutputParserEnabled();
-// void setBuildOutputParserEnabled(boolean enable);
-//
-// // SCD profile - scanner info provider options
-// List getProviderIdList();
-//// void addSIProvider(String providerId);
-//// void removeSIProvider(String providerId);
-//
-// boolean isProviderOutputParserEnabled(String providerId);
-// void setProviderOutputParserEnabled(String providerId, boolean enable);
-//
-// boolean isUseDefaultProviderCommand(String providerId);
-// void setUseDefaultProviderCommand(String providerId, boolean enable);
-//
-// String getProviderRunCommand(String providerId);
-// void setProviderRunCommand(String providerId, String command);
-//
-// String getProviderRunArguments(String providerId);
-// void setProviderRunArguments(String providerId, String arguments);
-//
-// String getProviderOpenFilePath(String providerId);
-// void setProviderOpenFilePath(String providerId, String filePath);
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java
deleted file mode 100644
index f954abfb9cb..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IDiscoveredPathManager.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.w3c.dom.Element;
-
-public interface IDiscoveredPathManager {
- interface IDiscoveredPathInfo {
-
- IProject getProject();
-
- /**
- * Get include paths for the whole project
- */
- IPath[] getIncludePaths();
- /**
- * Get defined symbols for the whole project
- */
- Map getSymbols();
-
- IDiscoveredScannerInfoSerializable getSerializable();
- }
-
- interface IPerProjectDiscoveredPathInfo extends IDiscoveredPathInfo {
- void setIncludeMap(LinkedHashMap map);
- void setSymbolMap(LinkedHashMap map);
-
- LinkedHashMap getIncludeMap();
- LinkedHashMap getSymbolMap();
- }
-
- interface IPerFileDiscoveredPathInfo extends IDiscoveredPathInfo {
- /**
- * Get include paths for the specific path (file)
- */
- IPath[] getIncludePaths(IPath path);
- /**
- * Get quote include paths (for #include "...") for the specific path (file)
- */
- IPath[] getQuoteIncludePaths(IPath path);
- /**
- * Get defined symbols for the specific path (file)
- */
- Map getSymbols(IPath path);
-
- /**
- * Get include files (gcc option -include) for the specific path (file)
- */
- IPath[] getIncludeFiles(IPath path);
- /**
- * Get macro files (gcc option -imacros) for the specific path (file)
- */
- IPath[] getMacroFiles(IPath path);
- /**
- * Returns if there is any discovered scanner info for the path
- */
- boolean isEmpty(IPath path);
- }
-
- interface IDiscoveredScannerInfoSerializable {
- /**
- * Serialize discovered scanner info to an XML element
- *
- * @param root
- */
- public void serialize(Element root);
-
- /**
- * Deserialize discovered scanner info from an XML element
- *
- * @param root
- */
- public void deserialize(Element root);
-
- /**
- * @return an id of the collector
- */
- public String getCollectorId();
- }
-
- interface IDiscoveredInfoListener {
-
- void infoChanged(IDiscoveredPathInfo info);
- void infoRemoved(IDiscoveredPathInfo info);
- }
-
- IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException;
- IDiscoveredPathInfo getDiscoveredInfo(IProject project, InfoContext context) throws CoreException;
-
- void removeDiscoveredInfo(IProject project);
- void removeDiscoveredInfo(IProject project, InfoContext context);
-
- void updateDiscoveredInfo(IDiscoveredPathInfo info, List changedResources) throws CoreException;
- void updateDiscoveredInfo(IDiscoveredPathInfo info, InfoContext context, List changedResources) throws CoreException;
-
- void changeDiscoveredContainer(IProject project, ScannerConfigScope profileScope, List changedResources);
-// void changeDiscoveredContainer(IProject project, InfoContext context, ScannerConfigScope profileScope, List changedResources);
-
- void updateCoreSettings(IProject project, IConfiguration cfgs[]);
-
- void addDiscoveredInfoListener(IDiscoveredInfoListener listener);
- void removeDiscoveredInfoListener(IDiscoveredInfoListener listener);
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java
deleted file mode 100644
index 5d390c7361d..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IExternalScannerInfoProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Interface for providers of C/C++ scanner info
- *
- * @author vhirsl
- */
-public interface IExternalScannerInfoProvider {
- /**
- * Invokes a provider to generate scanner info.
- *
- * @param monitor
- * @param resource project - current project being built
- * @param providerId - id of the provider
- * @param buildInfo - settings for ScannerConfigBuilder
- * @param collector - scanner info collector for the resource (project)
- */
- public boolean invokeProvider(IProgressMonitor monitor,
- IResource resource,
- String providerId,
- IScannerConfigBuilderInfo2 buildInfo,
- IScannerInfoCollector collector);
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java
deleted file mode 100644
index f063bdbb6dd..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Settings for ScannerConfigBuilder
- *
- * @author vhirsl
- */
-public interface IScannerConfigBuilderInfo {
- boolean isAutoDiscoveryEnabled();
- void setAutoDiscoveryEnabled(boolean enabled) throws CoreException;
-
- String getMakeBuilderConsoleParserId();
- void setMakeBuilderConsoleParserId(String parserId) throws CoreException;
-
- boolean isESIProviderCommandEnabled();
- void setESIProviderCommandEnabled(boolean enabled) throws CoreException;
-
- boolean isDefaultESIProviderCmd();
- void setUseDefaultESIProviderCmd(boolean on) throws CoreException;
-
- IPath getESIProviderCommand();
- void setESIProviderCommand(IPath command) throws CoreException;
-
- String getESIProviderArguments();
- void setESIProviderArguments(String args) throws CoreException;
-
- String getESIProviderConsoleParserId();
- void setESIProviderConsoleParserId(String parserId) throws CoreException;
-
- boolean isMakeBuilderConsoleParserEnabled();
- void setMakeBuilderConsoleParserEnabled(boolean enabled) throws CoreException;
-
- boolean isSIProblemGenerationEnabled();
- void setSIProblemGenerationEnabled(boolean enabled) throws CoreException;
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java
deleted file mode 100644
index 6069064435a..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerConfigBuilderInfo2.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * New interface to replace IScannerConfigBuildInfo
- * Persisted in .cdtproject file
- *
- * @author vhirsl
- */
-public interface IScannerConfigBuilderInfo2 {
- // general SCD options
- boolean isAutoDiscoveryEnabled();
- void setAutoDiscoveryEnabled(boolean enable);
-
- boolean isProblemReportingEnabled();
- void setProblemReportingEnabled(boolean enable);
-
- String getSelectedProfileId();
- void setSelectedProfileId(String profileId);
-
- List getProfileIdList();
-
- // SCD profile - buildOutputProvider options
- boolean isBuildOutputFileActionEnabled();
- void setBuildOutputFileActionEnabled(boolean enable);
-
- String getBuildOutputFilePath();
- void setBuildOutputFilePath(String path);
-
- boolean isBuildOutputParserEnabled();
- void setBuildOutputParserEnabled(boolean enable);
-
- // SCD profile - scanner info provider options
- List getProviderIdList();
-// void addSIProvider(String providerId);
-// void removeSIProvider(String providerId);
-
- boolean isProviderOutputParserEnabled(String providerId);
- void setProviderOutputParserEnabled(String providerId, boolean enable);
-
- boolean isUseDefaultProviderCommand(String providerId);
- void setUseDefaultProviderCommand(String providerId, boolean enable);
-
- String getProviderRunCommand(String providerId);
- void setProviderRunCommand(String providerId, String command);
-
- String getProviderRunArguments(String providerId);
- void setProviderRunArguments(String providerId, String arguments);
-
- String getProviderOpenFilePath(String providerId);
- void setProviderOpenFilePath(String providerId, String filePath);
-
- /**
- * Persist the buildInfo.
- * @throws CoreException
- */
- void save() throws CoreException;
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java
deleted file mode 100644
index e1a6a2c1af0..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Interface for scanner info collector.
- * Used by scanner info console parsers.
- * Eclipse independent.
- *
- * @author vhirsl
- */
-public interface IScannerInfoCollector {
- /**
- * Contribute to resource's scanner configuration
- *
- * @param resource - if used from within Eclipse it is expected that resource is a
- * member of org.eclipse.core.resources.IResource
hierarchy.
- * If used outside of Eclipse then resource is expected to be a
- * java.io.File type.
- * @param scannerInfo - a map of key - list pairs, where key is the type of extra info
- * i.e. target specific options or imacros commands,...
- */
- public void contributeToScannerConfig(Object resource, Map scannerInfo);
-
- /**
- * Returns specific piece of discovered scanner info for a resource
- * discovered during the last collection cycle
- * @param type
- * @param resource
- * @return
- */
- public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type);
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java
deleted file mode 100644
index 539be721a22..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector2.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * New scanner info collector interface - Eclipse dependent
- *
- * @author vhirsl
- */
-public interface IScannerInfoCollector2 extends IScannerInfoCollector {
- /**
- * @param project
- */
- public void setProject(IProject project);
-
- /**
- * Relegate discovered scanner configuration to a scanner info provider
- * @param monitor
- * @throws CoreException
- */
- public void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException;
-
- /**
- * Create and return new IDiscoveredPathInfo that can hopefully serialize
- * discovered scanner config to a file
- *
- * @return pathInfo
- * @throws CoreException
- */
- public IDiscoveredPathInfo createPathInfoObject();
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector3.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector3.java
deleted file mode 100644
index 6b57c79f099..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollector3.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Intel Corporation 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-
-public interface IScannerInfoCollector3 extends IScannerInfoCollector2 {
- void setContext(InfoContext context);
-
- InfoContext getContext();
-
- boolean isInfoCollected();
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java
deleted file mode 100644
index 5b7d92aabe3..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoCollectorCleaner.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import org.eclipse.core.resources.IResource;
-
-/**
- * Utility functions some collectors may need
- *
- * @author vhirsl
- */
-public interface IScannerInfoCollectorCleaner {
- /**
- * Delete all discovered paths for the resource
- *
- * @param project
- */
- public void deleteAllPaths(IResource resource);
-
- /**
- * Delete all discovered symbols for the resource
- *
- * @param project
- */
- public void deleteAllSymbols(IResource resource);
-
- /**
- * Delete a specific include path
- *
- * @param resource
- * @param path
- */
- public void deletePath(IResource resource, String path);
-
- /**
- * Delete a specific symbol definition
- *
- * @param resource
- * @param path
- */
- public void deleteSymbol(IResource resource, String symbol);
-
- /**
- * Delete all discovered scanner info for the resource
- *
- * @param resource
- */
- public void deleteAll(IResource resource);
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java
deleted file mode 100644
index 3c4dcffd456..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/IScannerInfoConsoleParser.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import org.eclipse.cdt.core.IConsoleParser;
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Parses a line of command output looking for scanner info entries.
- *
- * @author vhirsl
- */
-public interface IScannerInfoConsoleParser extends IConsoleParser {
- /**
- * One time initialization of a console parser.
- *
- * @param project
- * @param workingDirectory
- * @param collector - scanner info collector
- * @param markerGenerator
- */
- public void startup(IProject project, IPath workingDirectory,
- IScannerInfoCollector collector, IMarkerGenerator markerGenerator);
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/InfoContext.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/InfoContext.java
deleted file mode 100644
index 0b37653da5e..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/InfoContext.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Intel Corporation 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:
- * Intel Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-
-public final class InfoContext{
- private static final int NULL_OBJ_CODE = 29;
- private IConfiguration fCfg;
- private IResourceInfo fRcInfo;
- private ITool fTool;
- private IInputType fInType;
-
- public InfoContext(IResourceInfo rcInfo, ITool tool, IInputType inType){
- this.fRcInfo = rcInfo;
- this.fTool = tool;
- this.fInType = inType;
- this.fCfg = fRcInfo.getParent();
- }
-
- public InfoContext(IConfiguration cfg){
- this.fCfg = cfg;
- }
-
- public IConfiguration getConfiguration(){
- return fCfg;
- }
-
- public IResourceInfo getResourceInfo(){
- return fRcInfo;
- }
-
- public ITool getTool(){
- return fTool;
- }
-
- public IInputType getInputType(){
- return fInType;
- }
-
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
-
- if(!(obj instanceof InfoContext))
- return false;
-
- InfoContext other = (InfoContext)obj;
- if(!checkBuildObjects(other.fCfg, fCfg))
- return false;
-
- if(!checkBuildObjects(other.fRcInfo, fRcInfo))
- return false;
-
- if(!checkBuildObjects(other.fTool, fTool))
- return false;
-
- if(!checkBuildObjects(other.fInType, fInType))
- return false;
-
- return true;
- }
-
- public int hashCode() {
- int code = getCode(fCfg);
- code += getCode(fRcInfo);
- code += getCode(fTool);
- code += getCode(fInType);
- return code;
- }
-
- private boolean checkBuildObjects(IBuildObject bo1, IBuildObject bo2){
- if(bo1 == null)
- return bo2 == null;
- if(bo2 == null)
- return false;
- return bo1.getId().equals(bo2.getId());
- }
-
- private int getCode(IBuildObject bo){
- if(bo == null)
- return NULL_OBJ_CODE;
- return bo.getId().hashCode();
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java
deleted file mode 100644
index 8e042cd88d7..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigScope.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-/**
- * Profile scope enum
- *
- * @author vhirsl
- */
-public class ScannerConfigScope {
- public static final ScannerConfigScope PROJECT_SCOPE = new ScannerConfigScope("project"); //$NON-NLS-1$
- public static final ScannerConfigScope FILE_SCOPE = new ScannerConfigScope("file"); //$NON-NLS-1$
-
- public String toString() {
- return scope;
- }
-
- private String scope;
- private ScannerConfigScope(String scope) {
- this.scope = scope;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object arg0) {
- if (arg0 == null) return false;
- if (arg0 == this) return true;
- if (arg0 instanceof ScannerConfigScope) return scope.equals(((ScannerConfigScope)arg0).scope);
- return false;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return scope.hashCode();
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java
deleted file mode 100644
index de3732ec1ec..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerInfoTypes.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.core.scannerconfig;
-
-/**
- * Typesafe enum pattern
- *
- * @author vhirsl
- */
-public class ScannerInfoTypes {
- public static final ScannerInfoTypes COMPILER_COMMAND = new ScannerInfoTypes(1); // CCommandDSC
- public static final ScannerInfoTypes UNDISCOVERED_COMPILER_COMMAND = new ScannerInfoTypes(2); // CCommandDSC whose SI has not been resolved
- public static final ScannerInfoTypes INCLUDE_PATHS = new ScannerInfoTypes(10);
- public static final ScannerInfoTypes QUOTE_INCLUDE_PATHS = new ScannerInfoTypes(11);
- public static final ScannerInfoTypes SYMBOL_DEFINITIONS = new ScannerInfoTypes(12);
- public static final ScannerInfoTypes TARGET_SPECIFIC_OPTION = new ScannerInfoTypes(13) ;
- public static final ScannerInfoTypes COMPILER_VERSION_INFO = new ScannerInfoTypes(14);
-
- private final int _enum;
-
- private ScannerInfoTypes(int val) {
- _enum = val;
- }
- public final int toInt() {
- return _enum;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java
deleted file mode 100644
index 2cb82a804e9..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathContainer.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-public class DiscoveredPathContainer implements IPathEntryContainer {
- public static final IPath CONTAINER_ID = new Path("org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"); //$NON-NLS-1$
-
- protected final IProject fProject;
- private IPathEntry[] fPathEntries;
-
- public DiscoveredPathContainer(IProject project) {
- fProject = project;
- fPathEntries = null;
- }
-
-// public IPathEntry[] getPathEntries() {
-// IPathEntry[] fPathEntries;
-// try {
-// fPathEntries = getPathEntries(getPathEntryMap());
-// } catch (CoreException e) {
-// MakeCorePlugin.log(e);
-// return new IPathEntry[0];
-// }
-// return fPathEntries;
-// }
-
- public String getDescription() {
- return MakeMessages.getString("DiscoveredContainer.description"); //$NON-NLS-1$
- }
-
- public IPath getPath() {
- return CONTAINER_ID;
- }
-
- public IPathEntry[] getPathEntries() {
- if (fPathEntries == null) {
- try {
- fPathEntries = computeNewPathEntries();
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- return new IPathEntry[0];
- }
- }
- return fPathEntries;
- }
-
- private IPathEntry[] computeNewPathEntries() throws CoreException {
- IDiscoveredPathInfo info = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
- IPath[] includes = info.getIncludePaths();
- Map syms = info.getSymbols();
- List entries = new ArrayList(includes.length + syms.size());
- for (int i = 0; i < includes.length; i++) {
- entries.add(CoreModel.newIncludeEntry(Path.EMPTY, Path.EMPTY, includes[i], true)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- Iterator iter = syms.entrySet().iterator();
- while (iter.hasNext()) {
- Entry entry = (Entry)iter.next();
- entries.add(CoreModel.newMacroEntry(Path.EMPTY, (String)entry.getKey(), (String)entry.getValue())); //$NON-NLS-1$
- }
- return (IPathEntry[])entries.toArray(new IPathEntry[entries.size()]);
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java
deleted file mode 100644
index 79c64a55e18..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInfo.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-public class DiscoveredPathInfo implements IPerProjectDiscoveredPathInfo, IDiscoveredScannerInfoSerializable {
- public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$
- public static final String PATH = "path"; //$NON-NLS-1$
- public static final String DEFINED_SYMBOL = "definedSymbol"; //$NON-NLS-1$
- public static final String SYMBOL = "symbol"; //$NON-NLS-1$
- public static final String REMOVED = "removed"; //$NON-NLS-1$
-
- final private IProject project;
- private LinkedHashMap discoveredPaths;
- private LinkedHashMap discoveredSymbols;
-
- private List activePaths;
- private Map activeSymbols;
-
- private boolean loadded;
-
- public DiscoveredPathInfo(IProject project) {
- this.project = project;
- discoveredPaths = new LinkedHashMap();
- discoveredSymbols = new LinkedHashMap();
- }
-
- public DiscoveredPathInfo(IProject project, IScannerInfoCollector collector) {
- this(project);
- if(collector != null)
- init(collector);
- }
-
- private void init(IScannerInfoCollector c){
- List list = c.getCollectedScannerInfo(project, ScannerInfoTypes.INCLUDE_PATHS);
- if(list != null){
- for(Iterator iter = list.iterator(); iter.hasNext();){
- String s = (String)iter.next();
- if(s != null){
- discoveredPaths.put(s, null);
- }
- }
- }
- activePaths = null;
-
- list = c.getCollectedScannerInfo(project, ScannerInfoTypes.SYMBOL_DEFINITIONS);
- if(list != null){
- ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(discoveredSymbols, list, true);
- }
- activeSymbols = null;
- }
-
-
- public IProject getProject() {
- return project;
- }
-
- public synchronized Map getSymbols() {
- if (activeSymbols == null) {
- createSymbolsMap();
- }
- Map dSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols);
- return dSymbols;
- }
-
- public synchronized IPath[] getIncludePaths() {
- if ( activePaths == null) {
- createPathLists();
- }
- return (IPath[])activePaths.toArray(new IPath[activePaths.size()]);
- }
-
- public LinkedHashMap getIncludeMap() {
- return new LinkedHashMap(discoveredPaths);
- }
-
- public synchronized void setIncludeMap(LinkedHashMap paths) {
- discoveredPaths = new LinkedHashMap(paths);
- activePaths = null;
- }
-
- /**
- * Populates active and removed include path lists
- */
- private void createPathLists() {
- List aPaths = getActivePathList();
- aPaths.clear();
-
- for (Iterator i = discoveredPaths.keySet().iterator(); i.hasNext(); ) {
- String path = (String) i.next();
- Boolean removed = (Boolean) discoveredPaths.get(path);
- if (removed == null || removed.booleanValue() == false) {
- aPaths.add(new Path(path));
- }
- }
- }
-
- public LinkedHashMap getSymbolMap() {
- return new LinkedHashMap(discoveredSymbols);
- }
-
- public synchronized void setSymbolMap(LinkedHashMap symbols) {
- discoveredSymbols = new LinkedHashMap(symbols);
- activeSymbols = null;
- }
-
- /**
- * Populates active symbols sets
- */
- private void createSymbolsMap() {
- Map aSymbols = getActiveSymbolsMap();
- aSymbols.clear();
-
- aSymbols.putAll(ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols));
- }
-
- private List getActivePathList() {
- if (activePaths == null) {
- activePaths = new ArrayList();
- }
- return activePaths;
- }
-
- private Map getActiveSymbolsMap() {
- if (activeSymbols == null) {
- activeSymbols = new HashMap();
- }
- return activeSymbols;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element)
- */
- public void serialize(Element collectorElem) {
- Document doc = collectorElem.getOwnerDocument();
-
- Map includes = getIncludeMap();
- Iterator iter = includes.keySet().iterator();
- while (iter.hasNext()) {
- Element pathElement = doc.createElement(INCLUDE_PATH);
- String include = (String)iter.next();
- pathElement.setAttribute(PATH, include);
- Boolean removed = (Boolean)includes.get(include);
- if (removed != null && removed.booleanValue() == true) {
- pathElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
- }
- collectorElem.appendChild(pathElement);
- }
- // Now do the same for the symbols
- Map symbols = getSymbolMap();
- iter = symbols.keySet().iterator();
- while (iter.hasNext()) {
- String symbol = (String)iter.next();
- SymbolEntry se = (SymbolEntry)symbols.get(symbol);
- for (Iterator i = se.getActiveRaw().iterator(); i.hasNext();) {
- String value = (String)i.next();
- Element symbolElement = doc.createElement(DEFINED_SYMBOL);
- symbolElement.setAttribute(SYMBOL, value);
- collectorElem.appendChild(symbolElement);
- }
- for (Iterator i = se.getRemovedRaw().iterator(); i.hasNext();) {
- String value = (String)i.next();
- Element symbolElement = doc.createElement(DEFINED_SYMBOL);
- symbolElement.setAttribute(SYMBOL, value);
- symbolElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
- collectorElem.appendChild(symbolElement);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
- */
- public void deserialize(Element collectorElem) {
- loadded = true;
- LinkedHashMap includes = getIncludeMap();
- LinkedHashMap symbols = getSymbolMap();
-
- Node child = collectorElem.getFirstChild();
- while (child != null) {
- if (child.getNodeName().equals(INCLUDE_PATH)) {
- // Add the path to the property list
- includes.put( ((Element)child).getAttribute(PATH), Boolean.valueOf( ((Element)child).getAttribute(REMOVED)));
- } else if (child.getNodeName().equals(DEFINED_SYMBOL)) {
- // Add the symbol to the symbol list
- String symbol = ((Element)child).getAttribute(SYMBOL);
- String removed = ((Element)child).getAttribute(REMOVED);
- boolean bRemoved = (removed != null && removed.equals("true")); //$NON-NLS-1$
- ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol, !bRemoved);
- }
- child = child.getNextSibling();
- }
-
- setIncludeMap(includes);
- setSymbolMap(symbols);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#getCollectorId()
- */
- public String getCollectorId() {
- return PerProjectSICollector.COLLECTOR_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable()
- */
- public IDiscoveredScannerInfoSerializable getSerializable() {
- return this;
- }
-
- public boolean isLoadded(){
- return loadded;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java
deleted file mode 100644
index 3e0cd10ab51..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathInitializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.PathEntryContainerInitializer;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-
-public class DiscoveredPathInitializer extends PathEntryContainerInitializer {
-
- public void initialize(IPath containerPath, ICProject cProject) throws CoreException {
-// IProject project = cProject.getProject();
-// InfoContext context = ScannerConfigUtil.createContextForProject(project);
-// IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(context);
-// ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
-// getSCProfileConfiguration(buildInfo.getSelectedProfileId()).getProfileScope();
-// if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new DiscoveredPathContainer(project), null);
-// }
-// else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject}, new PerFileDiscoveredPathContainer(project), null);
-// }
-// else {
-// throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), 1,
-// MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
-// }
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
deleted file mode 100644
index 365cbb97681..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
-import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
-import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.internal.core.Tool;
-import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-
-public class DiscoveredPathManager implements IDiscoveredPathManager, IResourceChangeListener {
-
-// private Map fDiscoveredMap = new HashMap();
- private List listeners = Collections.synchronizedList(new ArrayList());
-
- private static final int INFO_CHANGED = 1;
- private static final int INFO_REMOVED = 2;
-
- public DiscoveredPathManager() {
-
- }
-
- public void startup() {
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
- }
-
- public void shutdown() {
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- if (event.getSource() instanceof IWorkspace) {
- IResource resource = event.getResource();
-
- switch (event.getType()) {
- case IResourceChangeEvent.POST_CHANGE :
- DiscoveredScannerInfoStore.getInstance().updateScannerConfigStore(event.getDelta());
- break;
- case IResourceChangeEvent.PRE_DELETE :
- case IResourceChangeEvent.PRE_CLOSE :
- if (resource.getType() == IResource.PROJECT) {
-// fDiscoveredMap.remove(resource);
- }
- break;
- }
- }
- }
-
- public IDiscoveredPathInfo getDiscoveredInfo(IProject project) throws CoreException {
-// IDiscoveredPathInfo info = (IDiscoveredPathInfo)fDiscoveredMap.get(project);
-// if (info == null) {
-// info = loadPathInfo(project);
-// fDiscoveredMap.put(project, info);
-// }
-// return info;
-// InfoContext c = ScannerConfigUtil.createContextForProject(project);
-// if(c != null)
- return getDiscoveredInfo(project, null);
-// return null;
- }
-
- private IDiscoveredPathInfo loadPathInfo(IConfiguration cfg, InfoContext c) throws CoreException {
- IDiscoveredPathInfo pathInfo = null;
-
- IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(c);
- IScannerInfoCollector collector = null;
- if(buildInfo != null){
- String profileId = buildInfo.getSelectedProfileId();
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(c, profileId);
- collector = profileInstance.getScannerInfoCollector();
-
- if (collector instanceof IScannerInfoCollector2) {
- IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
- pathInfo = collector2.createPathInfoObject();
- if(collector2 instanceof IScannerInfoCollector3){
- IScannerInfoCollector3 collector3 = (IScannerInfoCollector3)collector2;
- if(!collector3.isInfoCollected()){
- setCachedPathInfo(c, pathInfo);
- SCProfileInstance instance = ScannerConfigBuilder.build(c, buildInfo, 0, new NullProgressMonitor());
- if(instance != null){
- IScannerInfoCollector newC = instance.getScannerInfoCollector();
- if(newC instanceof IScannerInfoCollector2){
- pathInfo = ((IScannerInfoCollector2)newC).createPathInfoObject();
- }
- }
- }
- }
- }
- }
-
- if(pathInfo == null) {
- IProject project = c.getConfiguration().getOwner().getProject();
- pathInfo = new DiscoveredPathInfo(project, collector);
- }
- return pathInfo;
- }
-
-// private IDiscoveredPathInfo createPathInfo(IProject project, InfoContext context) throws CoreException{
-// IConfigurationScannerConfigBuilderInfo cfgInfo = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
-//
-// IScannerConfigBuilderInfo2 info2 =cfgInfo.getInfo(context);
-// if(info2 != null){
-// ScannerConfigBuilder.build(context, info2, 0, new NullProgressMonitor());
-// }
-// info = new DiscoveredPathInfo(project);
-// return info;
-// }
-
- public void removeDiscoveredInfo(IProject project) {
- removeDiscoveredInfo(project, null);
-
-// IDiscoveredPathInfo info = (IDiscoveredPathInfo)fDiscoveredMap.remove(project);
-// if (info != null) {
-// fireUpdate(INFO_REMOVED, info);
-// }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#updateDiscoveredInfo(org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo, java.util.List)
- */
- public void updateDiscoveredInfo(IDiscoveredPathInfo info, List changedResources) throws CoreException {
-// InfoContext c = ScannerConfigUtil.createContextForProject(info.getProject());
-// if(c != null)
- updateDiscoveredInfo(info, null, changedResources);
-// if (fDiscoveredMap.get(info.getProject()) != null) {
-// IDiscoveredScannerInfoSerializable serializable = info.getSerializable();
-// if (serializable != null) {
-// IProject project = info.getProject();
-// DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(project, serializable);
-// fireUpdate(INFO_CHANGED, info);
-//
-//// ICProject cProject = CoreModel.getDefault().create(info.getProject());
-//// if (cProject != null) {
-//// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-//// new DiscoveredPathContainer(info.getProject()), null);
-//// }
-// IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
-// String profileId = buildInfo.getSelectedProfileId();
-// ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
-// getSCProfileConfiguration(profileId).getProfileScope();
-// changeDiscoveredContainer(project, profileScope, changedResources);
-// }
-// else {
-// throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
-// MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$
-// }
-// }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager#changeDiscoveredContainer(org.eclipse.core.resources.IProject, java.lang.String)
- */
- public void changeDiscoveredContainer(final IProject project, final ScannerConfigScope profileScope, final List changedResources) {
-// InfoContext c = ScannerConfigUtil.createContextForProject(project);
-// if(c != null){
- changeDiscoveredContainer(project, null, profileScope, changedResources);
-// }
-// // order here is of essence
-// // 1. clear DiscoveredPathManager's path info cache
-// IDiscoveredPathInfo oldInfo = (IDiscoveredPathInfo) fDiscoveredMap.remove(project);
-//
-// // 2. switch the containers
-// try {
-// IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
-// public void run(IProgressMonitor monitor) throws CoreException {
-// ICProject cProject = CoreModel.getDefault().create(project);
-// if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-// new DiscoveredPathContainer(project), null);
-// }
-// else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
-// PerFileDiscoveredPathContainer container = new PerFileDiscoveredPathContainer(project);
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-// container, null);
-// if (changedResources != null) {
-// List changeDelta = new ArrayList(changedResources.size());
-// for (Iterator i = changedResources.iterator(); i.hasNext(); ) {
-// IResource resource = (IResource) i.next();
-// IPath path = resource.getFullPath();
-// changeDelta.add(new PathEntryContainerChanged(path,
-// PathEntryContainerChanged.INCLUDE_CHANGED |
-// PathEntryContainerChanged.MACRO_CHANGED)); // both include paths and symbols changed
-// }
-// CoreModel.pathEntryContainerUpdates(container,
-// (PathEntryContainerChanged[]) changeDelta.toArray(new PathEntryContainerChanged[changeDelta.size()]),
-// null);
-// }
-// }
-// else {
-// ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), 1,
-// MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
-// }
-//
-// }
-// };
-// CoreModel.run(runnable, null);
-// }
-// catch (CoreException e) {
-// ManagedBuilderCorePlugin.log(e);
-// }
-//
-// // 3. clear the container's path entry cache
-// if (oldInfo != null) {
-// fireUpdate(INFO_REMOVED, oldInfo);
-// }
- }
-
- private void fireUpdate(final int type, final IDiscoveredPathInfo info) {
- Object[] list = listeners.toArray();
- for (int i = 0; i < list.length; i++) {
- final IDiscoveredInfoListener listener = (IDiscoveredInfoListener)list[i];
- if (listener != null) {
- Platform.run(new ISafeRunnable() {
-
- public void handleException(Throwable exception) {
- IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1,
- CCorePlugin.getResourceString("CDescriptorManager.exception.listenerError"), exception); //$NON-NLS-1$
- CCorePlugin.log(status);
- }
-
- public void run() throws Exception {
- switch (type) {
- case INFO_CHANGED :
- listener.infoChanged(info);
- break;
- case INFO_REMOVED :
- listener.infoRemoved(info);
- break;
- }
- }
- });
- }
- }
- }
-
- public void addDiscoveredInfoListener(IDiscoveredInfoListener listener) {
- listeners.add(listener);
- }
-
- public void removeDiscoveredInfoListener(IDiscoveredInfoListener listener) {
- listeners.remove(listener);
- }
-
- public void changeDiscoveredContainer(final IProject project,
- InfoContext c, final ScannerConfigScope profileScope,
- final List changedResources) {
- // order here is of essence
- // 1. clear DiscoveredPathManager's path info cache
- final InfoContext context = adjustContext(c);
-// Tool tool = (Tool)context.getTool();
- IDiscoveredPathInfo oldInfo = setCachedPathInfo(context, null);
-// if(context == null)
-// context = ScannerConfigUtil.createContextForProject(project);
- // 2. switch the containers
- try {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
-// ICProject cProject = CoreModel.getDefault().create(project);
-// if (ScannerConfigScope.PROJECT_SCOPE.equals(profileScope)) {
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-// new DiscoveredPathContainer(project), null);
-// }
-// else if (ScannerConfigScope.FILE_SCOPE.equals(profileScope)) {
-// PerFileDiscoveredPathContainer container = new PerFileDiscoveredPathContainer(project);
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-// container, null);
-// if (changedResources != null) {
-// List changeDelta = new ArrayList(changedResources.size());
-// for (Iterator i = changedResources.iterator(); i.hasNext(); ) {
-// IResource resource = (IResource) i.next();
-// IPath path = resource.getFullPath();
-// changeDelta.add(new PathEntryContainerChanged(path,
-// PathEntryContainerChanged.INCLUDE_CHANGED |
-// PathEntryContainerChanged.MACRO_CHANGED)); // both include paths and symbols changed
-// }
-// CoreModel.pathEntryContainerUpdates(container,
-// (PathEntryContainerChanged[]) changeDelta.toArray(new PathEntryContainerChanged[changeDelta.size()]),
-// null);
-// }
-// }
-// else {
-// ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), 1,
-// MakeMessages.getString("DiscoveredContainer.ScopeErrorMessage"), null)); //$NON-NLS-1$
-// }
-//
- if(context == null)
- ManagedBuildManager.updateCoreSettings(project);
- else
- ManagedBuildManager.updateCoreSettings(context.getConfiguration());
- }
- };
- CoreModel.run(runnable, null);
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
-
- // 3. clear the container's path entry cache
- if (oldInfo != null) {
- fireUpdate(INFO_REMOVED, oldInfo);
- }
- }
-
- public void updateCoreSettings(final IProject project, final IConfiguration cfgs[]) {
- try {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- ManagedBuildManager.updateCoreSettings(project, cfgs);
- }
- };
- CoreModel.run(runnable, null);
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
-
-
- public IDiscoveredPathInfo getDiscoveredInfo(IProject project,
- InfoContext context) throws CoreException {
- if(context == null)
- context = ScannerConfigUtil.createContextForProject(project);
-
- context = adjustContext(context);
-
- IDiscoveredPathInfo info = getCachedPathInfo(context);
- if (info == null) {
- info = loadPathInfo(context.getConfiguration(), context);
- setCachedPathInfo(context, info);
-// if(info instanceof DiscoveredPathInfo && !((DiscoveredPathInfo)info).isLoadded()){
-// info = createPathInfo(project, context);
-// setCachedPathInfo(context, info);
-// }
- }
- return info;
- }
-
- private IDiscoveredPathInfo getCachedPathInfo(InfoContext context){
- IConfigurationScannerConfigBuilderInfo cfgInfo = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
- IDiscoveredPathInfo info = null;
- boolean queryCfg = !cfgInfo.isPerRcTypeDiscovery();
- if(!queryCfg){
- Tool tool = (Tool)context.getTool();
- if(tool != null){
- info = tool.getDiscoveredPathInfo(context.getInputType());
- } else {
- queryCfg = true;
- }
- }
- if(queryCfg) {
- info = ((Configuration)context.getConfiguration()).getDiscoveredPathInfo();
- }
- return info;
- }
-
- private InfoContext adjustContext(InfoContext context){
- return adjustContext(context, null);
-
- }
-
- private InfoContext adjustContext(InfoContext context, IConfigurationScannerConfigBuilderInfo cfgInfo){
- if(cfgInfo == null)
- cfgInfo = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
-
- boolean queryCfg = !cfgInfo.isPerRcTypeDiscovery();
-
- Tool tool = (Tool)context.getTool();
- IResourceInfo rcInfo = context.getResourceInfo();
- IInputType inType = context.getInputType();
- boolean adjust = false;
- InfoContext newContext = context;
-
- if(!queryCfg){
- if(tool != null){
- if(inType != null){
- if(!tool.hasScannerConfigSettings(inType)){
-// tool = null;
- inType = null;
- adjust = true;
- }
- }
- if(inType == null){
- if(!tool.hasScannerConfigSettings(null)){
- tool = null;
- adjust = true;
- }
- }
- }
- if(tool == null){
- if(inType != null){
- inType = null;
- adjust = true;
- }
-
- if(rcInfo != null){
- ToolChain tc = rcInfo instanceof FolderInfo ?
- (ToolChain)((FolderInfo)rcInfo).getToolChain()
- : (ToolChain)((ResourceConfiguration)rcInfo).getBaseToolChain();
-
- if(tc != null){
- if(!tc.hasScannerConfigSettings()){
- adjust = true;
- rcInfo = null;
- }
- }
- }
- }
- } else {
- if(tool != null){
- tool = null;
- adjust = true;
- }
- if(rcInfo != null){
- rcInfo = null;
- adjust = true;
- }
- if(inType != null){
- inType = null;
- adjust = true;
- }
- }
-
- if(adjust){
- if(rcInfo == null)
- newContext = new InfoContext(context.getConfiguration());
- else
- newContext = new InfoContext(rcInfo, tool, inType);
- }
-
- return newContext;
- }
-
- private IDiscoveredPathInfo setCachedPathInfo(InfoContext context, IDiscoveredPathInfo info){
- IConfigurationScannerConfigBuilderInfo cfgInfo = ScannerConfigProfileManager.getCfgScannerConfigBuildInfo(context.getConfiguration());
- boolean cacheOnCfg = !cfgInfo.isPerRcTypeDiscovery();
- IDiscoveredPathInfo oldInfo = null;
- if(!cacheOnCfg){
- Tool tool = (Tool)context.getTool();
- if(tool != null){
- if(info != null)
- oldInfo = tool.setDiscoveredPathInfo(context.getInputType(), info);
- else
- oldInfo = tool.clearDiscoveredPathInfo(context.getInputType());
- }
- } else {
- if(info != null)
- oldInfo = ((Configuration)context.getConfiguration()).setDiscoveredPathInfo(info);
- else
- oldInfo = ((Configuration)context.getConfiguration()).clearDiscoveredPathInfo();
- }
- return oldInfo;
- }
-
- public void removeDiscoveredInfo(IProject project, InfoContext context) {
- if(context == null)
- context = ScannerConfigUtil.createContextForProject(project);
-
- context = adjustContext(context);
-
- IDiscoveredPathInfo info = setCachedPathInfo(context, null);
- if (info != null) {
- fireUpdate(INFO_REMOVED, info);
- }
- }
-
- public void updateDiscoveredInfo(IDiscoveredPathInfo info,
- InfoContext context, List changedResources) throws CoreException {
-// if(context == null){
-// updateDiscoveredInfo(info, changedResources);
-// return;
-// }
- if(context == null)
- context = ScannerConfigUtil.createContextForProject(info.getProject());
- context = adjustContext(context);
-
- IDiscoveredPathInfo oldInfo = getCachedPathInfo(context);
- if (oldInfo != null) {
- IDiscoveredScannerInfoSerializable serializable = info.getSerializable();
- if (serializable != null) {
- DiscoveredScannerInfoStore.getInstance().saveDiscoveredScannerInfoToState(context, serializable);
- fireUpdate(INFO_CHANGED, info);
-
-// ICProject cProject = CoreModel.getDefault().create(info.getProject());
-// if (cProject != null) {
-// CoreModel.setPathEntryContainer(new ICProject[]{cProject},
-// new DiscoveredPathContainer(info.getProject()), null);
-// }
- IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.createScannerConfigBuildInfo2(context);
- String profileId = buildInfo.getSelectedProfileId();
- ScannerConfigScope profileScope = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(profileId).getProfileScope();
-// changeDiscoveredContainer(context.getConfiguration().getOwner().getProject(),
-// context,
-// profileScope,
-// changedResources);
- }
- else {
- throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("DiscoveredPathManager.Info_Not_Serializable"), null)); //$NON-NLS-1$
- }
- setCachedPathInfo(context, info);
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java
deleted file mode 100644
index 97198be41ee..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredScannerInfoStore.java
+++ /dev/null
@@ -1,485 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-import org.xml.sax.SAXException;
-
-/**
- * Discovered scanner info persistance store
- *
- * @author vhirsl
- */
-public class DiscoveredScannerInfoStore {
- private static final QualifiedName dscFileNameProperty = new
- QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "discoveredScannerConfigFileName"); //$NON-NLS-1$
- private static final String CDESCRIPTOR_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".discoveredScannerInfo"; //$NON-NLS-1$
- public static final String SCD_STORE_VERSION = "scdStore"; //$NON-NLS-1$
- public static final String SI_ELEM = "scannerInfo"; //$NON-NLS-1$
- public static final String COLLECTOR_ELEM = "collector"; //$NON-NLS-1$
- public static final String CFG_ELEM = "configuration"; //$NON-NLS-1$
- public static final String TOOL_ELEM = "tool"; //$NON-NLS-1$
- public static final String INTYPE_ELEM = "inputType"; //$NON-NLS-1$
- public static final String ID_ATTR = "id"; //$NON-NLS-1$
-
- private static DiscoveredScannerInfoStore instance;
-
- private Map fDocumentMap = new HashMap();
-
- public static DiscoveredScannerInfoStore getInstance() {
- if (instance == null) {
- instance = new DiscoveredScannerInfoStore();
- }
- return instance;
- }
- /**
- *
- */
- private DiscoveredScannerInfoStore() {
- }
-
- public void loadDiscoveredScannerInfoFromState(InfoContext context, IDiscoveredScannerInfoSerializable serializable) throws CoreException{
- loadDiscoveredScannerInfoFromState(context.getConfiguration().getOwner().getProject(), context, serializable);
- }
-
- public void loadDiscoveredScannerInfoFromState(IProject project, IDiscoveredScannerInfoSerializable serializable) throws CoreException{
- loadDiscoveredScannerInfoFromState(project, null, serializable);
- }
-
- public void loadDiscoveredScannerInfoFromState(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable)
- throws CoreException {
- // Get the document
- Document document = getDocument(project);
- if (document != null) {
- NodeList rootList = document.getElementsByTagName(SI_ELEM);
- if (rootList.getLength() > 0) {
- Element rootElem = (Element) rootList.item(0);
-
- if(context != null && context.getConfiguration() != null){
- IConfiguration cfg = context.getConfiguration();
- ITool tool = context.getTool();
- IInputType inType = context.getInputType();
-
- Element cfgElem = findChild(rootElem, CFG_ELEM, ID_ATTR, cfg.getId());
- Element toolElem = null;
- Element inTypeEl = null;
-
-
- if(cfgElem != null){
- if(tool != null){
- toolElem = findChild(cfgElem, TOOL_ELEM, ID_ATTR, tool.getId());
- if(toolElem != null){
- if(inType != null){
- inTypeEl = findChild(toolElem, INTYPE_ELEM, ID_ATTR, inType.getId());
- }
- }
- }
- }
-
- if(inType != null){
- rootElem = inTypeEl;
- } else if(tool != null){
- rootElem = toolElem;
- } else if(cfg != null){
- rootElem = cfgElem;
- }
- }
-
-
- // get the collector element
- if(rootElem != null){
- NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM);
- if (collectorList.getLength() > 0) {
- // find the collector element
- for (int i = 0; i < collectorList.getLength(); ++i) {
- Element collectorElem = (Element) collectorList.item(i);
- String collectorId = collectorElem.getAttribute(ID_ATTR);
- if (serializable.getCollectorId().equals(collectorId)) {
- serializable.deserialize(collectorElem);
- break;
- }
- }
- }
- }
- }
- }
- }
-
- private Document getDocument(IProject project) throws CoreException {
- // Get the document
- Document document = (Document) fDocumentMap.get(project);
- if (document == null) {
- try {
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- IPath path = getDiscoveredScannerConfigStore(project);
- if (path.toFile().exists()) {
- // read form file
- FileInputStream file = new FileInputStream(path.toFile());
- document = builder.parse(file);
- Node rootElem = document.getFirstChild();
- if (rootElem.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) {
- // no version info; upgrade
- upgradeDocument(document, project);
- }
- }
- else {
- // create new document
- document = builder.newDocument();
- ProcessingInstruction pi = document.createProcessingInstruction(SCD_STORE_VERSION, "version=\"2\""); //$NON-NLS-1$
- document.appendChild(pi);
- Element rootElement = document.createElement(SI_ELEM); //$NON-NLS-1$
- rootElement.setAttribute(ID_ATTR, CDESCRIPTOR_ID); //$NON-NLS-1$
- document.appendChild(rootElement);
- }
- fDocumentMap.put(project, document);
- }
- catch (IOException e) {
- ManagedBuilderCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
- }
- catch (ParserConfigurationException e) {
- ManagedBuilderCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
- }
- catch (SAXException e) {
- ManagedBuilderCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
- }
- }
- return document;
- }
-
- /**
- * @param document
- * @param project
- */
- private void upgradeDocument(Document document, IProject project) {
- Element rootElem = (Element) document.getElementsByTagName(SI_ELEM).item(0); //$NON-NLS-1$
- ProcessingInstruction pi = document.createProcessingInstruction(SCD_STORE_VERSION, "version=\"2.0\""); //$NON-NLS-1$
- document.insertBefore(pi, rootElem);
-
- Element collectorElem = document.createElement(COLLECTOR_ELEM);
- collectorElem.setAttribute(ID_ATTR, PerProjectSICollector.COLLECTOR_ID);
- for (Node child = rootElem.getFirstChild(); child != null; child = rootElem.getFirstChild()) {
- collectorElem.appendChild(rootElem.removeChild(child));
- }
- rootElem.appendChild(collectorElem);
- }
-
- private Element findChild(Element parentElem, String name, String attr, String attrValue){
- Element cfgElem = null;
- NodeList cfgList = parentElem.getElementsByTagName(name);
- if (cfgList.getLength() > 0) {
- // find per file collector element and remove children
- for (int i = 0; i < cfgList.getLength(); ++i) {
- Element cElem = (Element) cfgList.item(i);
- String value = cElem.getAttribute(attr);
- if (value.equals(attrValue)) {
- cfgElem = cElem;
- break;
- }
- }
- }
-
- return cfgElem;
- }
-
- private void clearChildren(Element cElem){
- for (Node child = cElem.getFirstChild(); child != null;
- child = cElem.getFirstChild()) {
- cElem.removeChild(child);
- }
- }
-
-
-
- /**
- * @param scannerInfo
- * @param rootElement
- * @param doc
- */
- private void saveDiscoveredScannerInfo(IDiscoveredScannerInfoSerializable serializable, Document doc, InfoContext context) {
- NodeList rootList = doc.getElementsByTagName(SI_ELEM);
- if (rootList.getLength() > 0) {
- Element rootElem = (Element) rootList.item(0);
- if(context != null){
- IConfiguration cfg = context.getConfiguration();
- ITool tool = context.getTool();
- IInputType inType = context.getInputType();
-
- // get the collector element
- if(cfg != null){
- Element cfgElem = findChild(rootElem, CFG_ELEM, ID_ATTR, cfg.getId());
- Element toolElem = null;
- Element inTypeElem = null;
- if(cfgElem != null){
- if(tool != null){
- toolElem = findChild(cfgElem, TOOL_ELEM, ID_ATTR, tool.getId());
- if(toolElem != null){
- if(inType != null){
- inTypeElem = findChild(toolElem, INTYPE_ELEM, ID_ATTR, inType.getId());
- }
- }
- }
- }
- if(cfgElem == null){
- cfgElem = doc.createElement(CFG_ELEM);
- cfgElem.setAttribute(ID_ATTR, cfg.getId());
- rootElem.appendChild(cfgElem);
- }
- if(tool != null){
- if(toolElem == null){
- toolElem = doc.createElement(TOOL_ELEM);
- toolElem.setAttribute(ID_ATTR, tool.getId());
- cfgElem.appendChild(toolElem);
- }
- if(inType != null){
- if(inTypeElem == null){
- inTypeElem = doc.createElement(INTYPE_ELEM);
- inTypeElem.setAttribute(ID_ATTR, inType.getId());
- toolElem.appendChild(inTypeElem);
- }
- }
- }
-
- if(inTypeElem != null){
- rootElem = inTypeElem;
- } else if(toolElem != null){
- rootElem = toolElem;
- } else {
- rootElem = cfgElem;
- }
- }
- }
- // get the collector element
- Element collectorElem = null;
- NodeList collectorList = rootElem.getElementsByTagName(COLLECTOR_ELEM);
- if (collectorList.getLength() > 0) {
- // find per file collector element and remove children
- for (int i = 0; i < collectorList.getLength(); ++i) {
- Element cElem = (Element) collectorList.item(i);
- String collectorId = cElem.getAttribute(ID_ATTR);
- if (serializable.getCollectorId().equals(collectorId)) {
- for (Node child = cElem.getFirstChild(); child != null;
- child = cElem.getFirstChild()) {
- cElem.removeChild(child);
- }
- collectorElem = cElem;
- break;
- }
- }
- }
- if (collectorElem == null) {
- // create per profile element
- collectorElem = doc.createElement(COLLECTOR_ELEM);
- collectorElem.setAttribute(ID_ATTR, serializable.getCollectorId());
- rootElem.appendChild(collectorElem);
- }
-
- // Save the discovered scanner info
- serializable.serialize(collectorElem);
- }
- }
-
- public void saveDiscoveredScannerInfoToState(InfoContext context, IDiscoveredScannerInfoSerializable serializable) throws CoreException {
- saveDiscoveredScannerInfoToState(context.getConfiguration().getOwner().getProject(), context, serializable);
- }
-
- public void saveDiscoveredScannerInfoToState(IProject project, IDiscoveredScannerInfoSerializable serializable) throws CoreException {
- saveDiscoveredScannerInfoToState(project, null, serializable);
- }
-
- public void saveDiscoveredScannerInfoToState(IProject project, InfoContext context, IDiscoveredScannerInfoSerializable serializable) throws CoreException {
- Document document = getDocument(project);
- // Create document
- try {
- saveDiscoveredScannerInfo(serializable, document, context);
-
- // Transform the document to something we can save in a file
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- DOMSource source = new DOMSource(document);
- StreamResult result = new StreamResult(stream);
- transformer.transform(source, result);
-
- // Save the document
- try {
- IPath path = getDiscoveredScannerConfigStore(project);
- FileOutputStream file = new FileOutputStream(path.toFile());
- file.write(stream.toByteArray());
- file.close();
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
- }
-
- // Close the streams
- stream.close();
- } catch (TransformerException e) {
- ManagedBuilderCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
- } catch (IOException e) {
- ManagedBuilderCorePlugin.log(e);
- throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("DiscoveredPathManager.File_Error_Message"), e)); //$NON-NLS-1$
- }
- }
-
- public IPath getDiscoveredScannerConfigStore(IProject project) {
- String fileName = project.getName() + ".sc"; //$NON-NLS-1$
- String storedFileName = null;
- try {
- storedFileName = project.getPersistentProperty(dscFileNameProperty);
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e.getStatus());
- }
- if (storedFileName != null && !storedFileName.equals(fileName)) {
- // try to move 2.x file name format to 3.x file name format
- movePluginStateFile(storedFileName, fileName);
- }
- try {
- project.setPersistentProperty(dscFileNameProperty, fileName);
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e.getStatus());
- }
-
- return ManagedBuilderCorePlugin.getWorkingDirectory().append(fileName);
- }
-
- /**
- * @param delta
- */
- public void updateScannerConfigStore(IResourceDelta delta) {
- try {
- delta.accept(new IResourceDeltaVisitor() {
-
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
- if (resource instanceof IProject) {
- IProject project = (IProject) resource;
- int kind = delta.getKind();
- switch (kind) {
- case IResourceDelta.REMOVED:
- if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
- // project renamed
- IPath newPath = delta.getMovedToPath();
- IProject newProject = delta.getResource().getWorkspace().
- getRoot().getProject(newPath.toString());
- scProjectRenamed(project, newProject);
- }
- else {
- // project deleted
- scProjectDeleted(project);
- }
- // remove from cache
- fDocumentMap.put(project, null);
- }
- return false;
- }
- return true;
- }
-
- });
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
-
- private void scProjectDeleted(IProject project) {
- String scFileName = project.getName() + ".sc"; //$NON-NLS-1$
- deletePluginStateFile(scFileName);
- }
-
- /**
- * @param scFileName
- */
- private void deletePluginStateFile(String scFileName) {
- IPath path = ManagedBuilderCorePlugin.getWorkingDirectory().append(scFileName);
- File file = path.toFile();
- if (file.exists()) {
- file.delete();
- }
- }
-
- private void scProjectRenamed(IProject project, IProject newProject) {
- String scOldFileName = project.getName() + ".sc"; //$NON-NLS-1$
- String scNewFileName = newProject.getName() + ".sc"; //$NON-NLS-1$
- movePluginStateFile(scOldFileName, scNewFileName);
- try {
- newProject.setPersistentProperty(dscFileNameProperty, scNewFileName);
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
-
- /**
- * @param oldFileName
- * @param newFileName
- */
- private void movePluginStateFile(String oldFileName, String newFileName) {
- IPath oldPath = ManagedBuilderCorePlugin.getWorkingDirectory().append(oldFileName);
- IPath newPath = ManagedBuilderCorePlugin.getWorkingDirectory().append(newFileName);
- File oldFile = oldPath.toFile();
- File newFile = newPath.toFile();
- if (oldFile.exists()) {
- oldFile.renameTo(newFile);
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java
deleted file mode 100644
index 25bc5c9afe9..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathContainer.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-public class PerFileDiscoveredPathContainer extends DiscoveredPathContainer
- implements IPathEntryContainerExtension {
-
- public PerFileDiscoveredPathContainer(IProject project) {
- super(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IPathEntryContainerExtension#getPathEntries(org.eclipse.core.runtime.IPath, int)
- */
- public IPathEntry[] getPathEntries(IPath path, int mask) {
- ArrayList entries = new ArrayList();
- try {
- IDiscoveredPathInfo info = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
- if (info instanceof IPerFileDiscoveredPathInfo) {
- IPerFileDiscoveredPathInfo filePathInfo = (IPerFileDiscoveredPathInfo) info;
-
- if ((mask & IPathEntry.CDT_INCLUDE) != 0) {
- IPath[] includes = filePathInfo.getIncludePaths(path);
- for (int i = 0; i < includes.length; i++) {
- // add as a system include path
- entries.add(CoreModel.newIncludeEntry(path, Path.EMPTY, includes[i], true));
- }
- includes = filePathInfo.getQuoteIncludePaths(path);
- for (int i = 0; i < includes.length; i++) {
- // add as a local include path
- entries.add(CoreModel.newIncludeEntry(path, Path.EMPTY, includes[i], false));
- }
- }
- if ((mask & IPathEntry.CDT_MACRO) != 0) {
- Map syms = filePathInfo.getSymbols(path);
- for (Iterator iter = syms.entrySet().iterator(); iter.hasNext(); ) {
- Entry entry = (Entry)iter.next();
- entries.add(CoreModel.newMacroEntry(path, (String)entry.getKey(), (String)entry.getValue())); //$NON-NLS-1$
- }
- }
- // compare the resource with include and macros files
- IPath fullResPath = fProject.getWorkspace().getRoot().getFile(path).getLocation();
- if (fullResPath == null) {
- fullResPath = path;
- }
- if ((mask & IPathEntry.CDT_INCLUDE_FILE) != 0) {
- IPath[] includeFiles = filePathInfo.getIncludeFiles(path);
- for (int i = 0; i < includeFiles.length; i++) {
- if (!includeFiles[i].equals(fullResPath)) {
- entries.add(CoreModel.newIncludeFileEntry(path, includeFiles[i]));
- }
- }
- }
- if ((mask & IPathEntry.CDT_MACRO_FILE) != 0) {
- IPath[] imacrosFiles = filePathInfo.getMacroFiles(path);
- for (int i = 0; i < imacrosFiles.length; i++) {
- if (!imacrosFiles[i].equals(fullResPath)) {
- entries.add(CoreModel.newMacroFileEntry(path, imacrosFiles[i]));
- }
- }
- }
- }
- }
- catch (CoreException e) {
- //
- }
- return (IPathEntry[]) entries.toArray(new IPathEntry[entries.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.model.IPathEntryContainerExtension#isEmpty(org.eclipse.core.runtime.IPath)
- */
- public boolean isEmpty(IPath path) {
- IDiscoveredPathInfo info;
- try {
- info = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
- if (info instanceof IPerFileDiscoveredPathInfo) {
- IPerFileDiscoveredPathInfo filePathInfo = (IPerFileDiscoveredPathInfo) info;
- return filePathInfo.isEmpty(path);
- }
- } catch (CoreException e) {
- }
- return false;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathInfo.java
deleted file mode 100644
index aeba3b9ce59..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/PerFileDiscoveredPathInfo.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-
-public class PerFileDiscoveredPathInfo /*implements IPerFileDiscoveredPathInfo, IDiscoveredScannerInfoSerializable*/{
-// public static final String INCLUDE_PATH = "includePath"; //$NON-NLS-1$
-// public static final String PATH = "path"; //$NON-NLS-1$
-// public static final String DEFINED_SYMBOL = "definedSymbol"; //$NON-NLS-1$
-// public static final String SYMBOL = "symbol"; //$NON-NLS-1$
-// public static final String REMOVED = "removed"; //$NON-NLS-1$
-//
-//// final private IProject project;
-// private final IConfiguration config;
-//// private LinkedHashMap discoveredPaths;
-//// private LinkedHashMap discoveredSymbols;
-//
-// private List activePaths;
-// private Map activeSymbols;
-//
-// public PerFileDiscoveredPathInfo(IConfiguration cfg) {
-// this.config = cfg;
-//// discoveredPaths = new LinkedHashMap();
-//// discoveredSymbols = new LinkedHashMap();
-// }
-//
-// public IProject getProject() {
-// return config.getOwner().getProject();
-// }
-//
-// public synchronized Map getSymbols() {
-// if (activeSymbols == null) {
-// createSymbolsMap();
-// }
-// Map dSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols);
-// return dSymbols;
-// }
-//
-// public synchronized IPath[] getIncludePaths() {
-// if ( activePaths == null) {
-// createPathLists();
-// }
-// return (IPath[])activePaths.toArray(new IPath[activePaths.size()]);
-// }
-//
-// public LinkedHashMap getIncludeMap() {
-// return new LinkedHashMap(discoveredPaths);
-// }
-//
-// public synchronized void setIncludeMap(LinkedHashMap paths) {
-// discoveredPaths = new LinkedHashMap(paths);
-// activePaths = null;
-// }
-//
-// /**
-// * Populates active and removed include path lists
-// */
-// private void createPathLists() {
-// List aPaths = getActivePathList();
-// aPaths.clear();
-//
-// for (Iterator i = discoveredPaths.keySet().iterator(); i.hasNext(); ) {
-// String path = (String) i.next();
-// Boolean removed = (Boolean) discoveredPaths.get(path);
-// if (removed == null || removed.booleanValue() == false) {
-// aPaths.add(new Path(path));
-// }
-// }
-// }
-//
-// public LinkedHashMap getSymbolMap() {
-// return new LinkedHashMap(discoveredSymbols);
-// }
-//
-// public synchronized void setSymbolMap(LinkedHashMap symbols) {
-// discoveredSymbols = new LinkedHashMap(symbols);
-// activeSymbols = null;
-// }
-//
-// /**
-// * Populates active symbols sets
-// */
-// private void createSymbolsMap() {
-// Map aSymbols = getActiveSymbolsMap();
-// aSymbols.clear();
-//
-// aSymbols.putAll(ScannerConfigUtil.scSymbolEntryMap2Map(discoveredSymbols));
-// }
-//
-// private List getActivePathList() {
-// if (activePaths == null) {
-// activePaths = new ArrayList();
-// }
-// return activePaths;
-// }
-//
-// private Map getActiveSymbolsMap() {
-// if (activeSymbols == null) {
-// activeSymbols = new HashMap();
-// }
-// return activeSymbols;
-// }
-//
-// /* (non-Javadoc)
-// * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element)
-// */
-// public void serialize(Element collectorElem) {
-// Document doc = collectorElem.getOwnerDocument();
-//
-// Map includes = getIncludeMap();
-// Iterator iter = includes.keySet().iterator();
-// while (iter.hasNext()) {
-// Element pathElement = doc.createElement(INCLUDE_PATH);
-// String include = (String)iter.next();
-// pathElement.setAttribute(PATH, include);
-// Boolean removed = (Boolean)includes.get(include);
-// if (removed != null && removed.booleanValue() == true) {
-// pathElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
-// }
-// collectorElem.appendChild(pathElement);
-// }
-// // Now do the same for the symbols
-// Map symbols = getSymbolMap();
-// iter = symbols.keySet().iterator();
-// while (iter.hasNext()) {
-// String symbol = (String)iter.next();
-// SymbolEntry se = (SymbolEntry)symbols.get(symbol);
-// for (Iterator i = se.getActiveRaw().iterator(); i.hasNext();) {
-// String value = (String)i.next();
-// Element symbolElement = doc.createElement(DEFINED_SYMBOL);
-// symbolElement.setAttribute(SYMBOL, value);
-// collectorElem.appendChild(symbolElement);
-// }
-// for (Iterator i = se.getRemovedRaw().iterator(); i.hasNext();) {
-// String value = (String)i.next();
-// Element symbolElement = doc.createElement(DEFINED_SYMBOL);
-// symbolElement.setAttribute(SYMBOL, value);
-// symbolElement.setAttribute(REMOVED, "true"); //$NON-NLS-1$
-// collectorElem.appendChild(symbolElement);
-// }
-// }
-// }
-//
-// /* (non-Javadoc)
-// * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
-// */
-// public void deserialize(Element collectorElem) {
-// LinkedHashMap includes = getIncludeMap();
-// LinkedHashMap symbols = getSymbolMap();
-//
-// Node child = collectorElem.getFirstChild();
-// while (child != null) {
-// if (child.getNodeName().equals(INCLUDE_PATH)) {
-// // Add the path to the property list
-// includes.put( ((Element)child).getAttribute(PATH), Boolean.valueOf( ((Element)child).getAttribute(REMOVED)));
-// } else if (child.getNodeName().equals(DEFINED_SYMBOL)) {
-// // Add the symbol to the symbol list
-// String symbol = ((Element)child).getAttribute(SYMBOL);
-// String removed = ((Element)child).getAttribute(REMOVED);
-// boolean bRemoved = (removed != null && removed.equals("true")); //$NON-NLS-1$
-// ScannerConfigUtil.scAddSymbolString2SymbolEntryMap(symbols, symbol, !bRemoved);
-// }
-// child = child.getNextSibling();
-// }
-//
-// setIncludeMap(includes);
-// setSymbolMap(symbols);
-// }
-//
-// /* (non-Javadoc)
-// * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#getCollectorId()
-// */
-// public String getCollectorId() {
-// return PerProjectSICollector.COLLECTOR_ID;
-// }
-//
-// /* (non-Javadoc)
-// * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSerializable()
-// */
-// public IDiscoveredScannerInfoSerializable getSerializable() {
-// return this;
-// }
-//
-//
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java
deleted file mode 100644
index 7e58166e498..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigInfoFactory.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.util.Map;
-
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Creates a ScannerConfigBuilderInfo variant
- * @author vhirsl
- */
-public class ScannerConfigInfoFactory {
- private static final String PREFIX = ManagedBuilderCorePlugin.getUniqueIdentifier();
-
- static final String BUILD_SCANNER_CONFIG_ENABLED = PREFIX + ".ScannerConfigDiscoveryEnabled"; //$NON-NLS-1$
- static final String MAKE_BUILDER_PARSER_ENABLED = PREFIX + ".makeBuilderParserEnabled"; //$NON-NLS-1$
- static final String MAKE_BUILDER_PARSER_ID = PREFIX + ".makeBuilderParserId"; //$NON-NLS-1$
- static final String ESI_PROVIDER_COMMAND_ENABLED = PREFIX + ".esiProviderCommandEnabled"; //$NON-NLS-1$
- static final String USE_DEFAULT_ESI_PROVIDER_CMD = PREFIX + ".useDefaultESIProviderCmd"; //$NON-NLS-1$
- static final String ESI_PROVIDER_COMMAND = PREFIX + ".esiProviderCommand"; //$NON-NLS-1$
- static final String ESI_PROVIDER_ARGUMENTS = PREFIX + ".esiProviderArguments"; //$NON-NLS-1$
- static final String ESI_PROVIDER_PARSER_ID = PREFIX + ".esiProviderParserId"; //$NON-NLS-1$
- static final String SI_PROBLEM_GENERATION_ENABLED = PREFIX + ".siProblemGenerationEnabled"; //$NON-NLS-1$
- /**
- * @since 3.0
- */
- static final String SI_PROFILE_ID = PREFIX + ".siProfileId"; //$NON-NLS-1$
-
- /**
- *
- * @author vhirsl
- */
- private abstract static class Store implements IScannerConfigBuilderInfo {
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#isAutoDiscoveryEnabled()
- */
- public boolean isAutoDiscoveryEnabled() {
- return getBoolean(BUILD_SCANNER_CONFIG_ENABLED);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setAutoDiscoveryEnabled(boolean)
- */
- public void setAutoDiscoveryEnabled(boolean enabled) throws CoreException {
- putString(BUILD_SCANNER_CONFIG_ENABLED, Boolean.toString(enabled));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#isMakeBuilderConsoleParserEnabled()
- */
- public boolean isMakeBuilderConsoleParserEnabled() {
- if (getString(MAKE_BUILDER_PARSER_ENABLED) == null ||
- getString(MAKE_BUILDER_PARSER_ENABLED).length() == 0) { // if no property then default to true
- return true;
- }
- return getBoolean(MAKE_BUILDER_PARSER_ENABLED);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setMakeBuilderConsoleParserEnabled(boolean)
- */
- public void setMakeBuilderConsoleParserEnabled(boolean enabled) throws CoreException {
- putString(MAKE_BUILDER_PARSER_ENABLED, Boolean.toString(enabled));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#getMakeBuilderConsoleParserId()
- */
- public String getMakeBuilderConsoleParserId() {
- String parserId = getString(MAKE_BUILDER_PARSER_ID);
- if (parserId == null || parserId.length() == 0) {
- String[] parserIds = ManagedBuilderCorePlugin.getDefault().
- getScannerInfoConsoleParserIds("makeBuilder"); //$NON-NLS-1$
- // the default is the first one in the registry
- parserId = parserIds[0];
- }
- return parserId;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setMakeBuilderConsoleParserId(java.lang.String)
- */
- public void setMakeBuilderConsoleParserId(String parserId) throws CoreException {
- putString(MAKE_BUILDER_PARSER_ID, parserId);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#isESIProviderCommandEnabled()
- */
- public boolean isESIProviderCommandEnabled() {
- if (getString(ESI_PROVIDER_COMMAND_ENABLED) == null ||
- getString(ESI_PROVIDER_COMMAND_ENABLED).length() == 0) { // if no property then default to true
- return true;
- }
- return getBoolean(ESI_PROVIDER_COMMAND_ENABLED);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setESIProviderCommandEnabled(boolean)
- */
- public void setESIProviderCommandEnabled(boolean enabled) throws CoreException {
- putString(ESI_PROVIDER_COMMAND_ENABLED, Boolean.toString(enabled));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#isDefaultESIProviderCmd()
- */
- public boolean isDefaultESIProviderCmd() {
- if (getString(USE_DEFAULT_ESI_PROVIDER_CMD) == null ||
- getString(USE_DEFAULT_ESI_PROVIDER_CMD).length() == 0) { // if no property then default to true
- return true;
- }
- return getBoolean(USE_DEFAULT_ESI_PROVIDER_CMD);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setUseDefaultESIProviderCmd(boolean)
- */
- public void setUseDefaultESIProviderCmd(boolean on) throws CoreException {
- putString(USE_DEFAULT_ESI_PROVIDER_CMD, Boolean.toString(on));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#getESIProviderCommand()
- */
- public IPath getESIProviderCommand() {
- if (isDefaultESIProviderCmd()) {
- String command = getESIProviderParameter("defaultCommand"); //$NON-NLS-1$
- if (command == null) {
- return new Path("gcc"); //$NON-NLS-1$
- }
- return new Path(command);
- }
- return new Path(getString(ESI_PROVIDER_COMMAND));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setESIProviderCommand(org.eclipse.core.runtime.IPath)
- */
- public void setESIProviderCommand(IPath command) throws CoreException {
- putString(ESI_PROVIDER_COMMAND, command.toString());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#getESIProviderArguments()
- */
- public String getESIProviderArguments() {
- if (isDefaultESIProviderCmd()) {
- String attributes = getESIProviderParameter("defaultAttributes"); //$NON-NLS-1$
- if (attributes == null) {
- attributes = "-E -P -v -dD ${plugin_state_location}/${specs_file}"; //$NON-NLS-1$
- }
- return attributes;
- }
- return getString(ESI_PROVIDER_ARGUMENTS);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setESIProviderArguments(java.lang.String)
- */
- public void setESIProviderArguments(String args) throws CoreException {
- putString(ESI_PROVIDER_ARGUMENTS, args);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#getESIProviderConsoleParserId()
- */
- public String getESIProviderConsoleParserId() {
- String parserId = getString(ESI_PROVIDER_PARSER_ID);
- if (parserId == null || parserId.length() == 0) {
- String[] parserIds = ManagedBuilderCorePlugin.getDefault().
- getScannerInfoConsoleParserIds("externalScannerInfoProvider"); //$NON-NLS-1$
- // the default is the first one in the registry
- parserId = parserIds[0];
- }
- return parserId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setESIProviderConsoleParserId(java.lang.String)
- */
- public void setESIProviderConsoleParserId(String parserId) throws CoreException {
- putString(ESI_PROVIDER_PARSER_ID, parserId);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#isSIProblemGenerationEnabled()
- */
- public boolean isSIProblemGenerationEnabled() {
- if (getString(SI_PROBLEM_GENERATION_ENABLED) == null ||
- getString(SI_PROBLEM_GENERATION_ENABLED).length() == 0) { // if no property then default to true
- return true;
- }
- return getBoolean(SI_PROBLEM_GENERATION_ENABLED);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setSIProblemGenerationEnabled(boolean)
- */
- public void setSIProblemGenerationEnabled(boolean enabled) throws CoreException {
- putString(SI_PROBLEM_GENERATION_ENABLED, Boolean.toString(enabled));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#getProfileId()
- */
- public String getProfileId() {
- String profileId = getString(SI_PROFILE_ID);
- if (profileId == null || profileId.length() == 0) {
- profileId = ScannerConfigProfileManager.getDefaultSIProfileId();
- // the default is the first one in the registry
- }
- return profileId;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo#setProfileId(java.lang.String)
- */
- public void setProfileId(String profileId) throws CoreException {
- putString(SI_PROFILE_ID, profileId);
- }
-
- protected boolean getBoolean(String property) {
- return Boolean.valueOf(getString(property)).booleanValue();
- }
-
- protected abstract String getBuilderID();
- protected abstract String getString(String property);
- protected abstract void putString(String name, String value) throws CoreException;
-
- protected String getESIProviderParameter(String name) {
- IExtension extension =
- Platform.getExtensionRegistry().getExtension(
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- ManagedBuilderCorePlugin.EXTERNAL_SI_PROVIDER_SIMPLE_ID,
- // TODO VMIR make this configurable
- ManagedBuilderCorePlugin.DEFAULT_EXTERNAL_SI_PROVIDER_ID);
- if (extension == null)
- return null;
- IConfigurationElement[] configs = extension.getConfigurationElements();
- if (configs.length == 0)
- return null;
- IConfigurationElement[] runElement = configs[0].getChildren("run"); //$NON-NLS-1$
- IConfigurationElement[] paramElement = runElement[0].getChildren("parameter"); //$NON-NLS-1$
- for (int i = 0; i < paramElement.length; i++) {
- if (paramElement[i].getAttribute("name").equals(name)) { //$NON-NLS-1$
- return paramElement[i].getAttribute("value"); //$NON-NLS-1$
- }
- }
- return null;
- }
- }
-
- private static class Preference extends Store {
- private Preferences prefs;
- private String builderID;
- private boolean useDefaults;
-
- Preference(Preferences prefs, String builderID, boolean useDefaults) {
- this.prefs = prefs;
- this.builderID = builderID;
- this.useDefaults = useDefaults;
- }
-
- protected void putString(String name, String value) {
- if (useDefaults) {
- prefs.setDefault(name, value);
- } else {
- prefs.setValue(name, value);
- }
- }
-
- protected String getString(String property) {
- if (useDefaults) {
- return prefs.getDefaultString(property);
- }
- return prefs.getString(property);
- }
-
- protected String getBuilderID() {
- return builderID;
- }
- }
-
- private static class BuildProperty extends Store {
- private IProject project;
- private String builderID;
- private Map args;
-
- BuildProperty(IProject project, String builderID) throws CoreException {
- this.project = project;
- this.builderID = builderID;
- ICommand builder = ScannerConfigNature.getBuildSpec(project.getDescription(), builderID);
- if (builder == null) {
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("ScannerConfigInfoFactory.Missing_Builder")//$NON-NLS-1$
- + builderID, null));
- }
- args = builder.getArguments();
- }
-
- protected void putString(String name, String value) throws CoreException {
- String curValue = (String) args.get(name);
- if (curValue != null && curValue.equals(value)) {
- return;
- }
- IProjectDescription description = project.getDescription();
- ICommand builder = ScannerConfigNature.getBuildSpec(description, builderID);
- args.put(name, value);
- builder.setArguments(args);
- ManagedCProjectNature.setBuildSpec(description, builder);
- project.setDescription(description, null);
- }
-
- protected String getString(String name) {
- String value = (String) args.get(name);
- return value == null ? "" : value; //$NON-NLS-1$
- }
-
- protected String getBuilderID() {
- return builderID;
- }
- }
-
- private static class BuildArguments extends Store {
- private Map args;
- private String builderID;
-
- BuildArguments(Map args, String builderID) {
- this.args = args;
- this.builderID = builderID;
- }
-
- protected void putString(String name, String value) {
- args.put(name, value);
- }
-
- protected String getString(String name) {
- return (String) args.get(name);
- }
-
- protected String getBuilderID() {
- return builderID;
- }
- }
-
- public static IScannerConfigBuilderInfo create(Preferences prefs, String builderID, boolean useDefaults) {
- return new ScannerConfigInfoFactory.Preference(prefs, builderID, useDefaults);
- }
-
- public static IScannerConfigBuilderInfo create(IProject project, String builderID) throws CoreException {
- return new ScannerConfigInfoFactory.BuildProperty(project, builderID);
- }
-
- public static IScannerConfigBuilderInfo create(Map args, String builderID) {
- return new ScannerConfigInfoFactory.BuildArguments(args, builderID);
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java
deleted file mode 100644
index d38addd322c..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerConfigUtil.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Utility class that handles some Scanner Config specifig collection conversions
- *
- * @author vhirsl
- */
-public final class ScannerConfigUtil {
- /**
- * Adds all new discovered symbols/values to the existing ones.
- *
- * @param sumSymbols - a map of [String, Map] where Map is a SymbolEntry
- * @param symbols
- * @return boolean
- */
- public static boolean scAddSymbolsList2SymbolEntryMap(Map sumSymbols, List symbols, boolean active) {
- boolean rc = false;
- for (Iterator i = symbols.iterator(); i.hasNext(); ) {
- String symbol = (String) i.next();
- String key;
- String value = null;
- int index = symbol.indexOf("="); //$NON-NLS-1$
- if (index != -1) {
- key = symbol.substring(0, index).trim();
- value = symbol.substring(index + 1).trim();
- } else {
- key = symbol.trim();
- }
- SymbolEntry sEntry = (SymbolEntry) sumSymbols.get(key);
- if (sEntry == null) {
- // make only the first one to be active
- sEntry = new SymbolEntry(key, value, true);
- rc = true;
- }
- else {
- rc |= sEntry.add(value, active);
- }
- sumSymbols.put(key, sEntry);
- }
- return rc;
- }
-
- /**
- * Gets all discovered symbols with either active or removed values
- * @param sumSymbols
- * @param active - false = removed
- * @return
- */
- public static List scSymbolsSymbolEntryMap2List(Map sumSymbols, boolean active) {
- Set symbols = sumSymbols.entrySet();
- List rv = new ArrayList(symbols.size());
- for (Iterator i = symbols.iterator(); i.hasNext(); ) {
- SymbolEntry sEntry = (SymbolEntry) ((Map.Entry) i.next()).getValue();
- if (active) {
- rv.addAll(sEntry.getActiveRaw());
- }
- else {
- rv.addAll(sEntry.getRemovedRaw());
- }
- }
- return rv;
- }
-
- /**
- * MapsSymbolEntryMap to a plain Map
- *
- * @param sumSymbols (in) - discovered symbols in SymbolEntryMap
- * @return - active symbols as a plain Map
- */
- public static Map scSymbolEntryMap2Map(Map sumSymbols) {
- Map rv = new HashMap();
- for (Iterator i = sumSymbols.keySet().iterator(); i.hasNext(); ) {
- String key = (String) i.next();
- SymbolEntry values = (SymbolEntry) sumSymbols.get(key);
- for (Iterator j = values.getValuesOnly(true).iterator(); j.hasNext(); ) {
- String value = (String) j.next();
- rv.put(key, value); // multiple active values will be condensed to one !!!
- }
- }
- return rv;
- }
-
- /**
- * Adds a single symbol definition string ("DEBUG_LEVEL=4") to the SymbolEntryMap
- *
- * @param symbols
- * @param symbol
- * @param active
- */
- public static boolean scAddSymbolString2SymbolEntryMap(Map symbols, String symbol, boolean active) {
- boolean rc = false;
- String key;
- String value = null;
- int index = symbol.indexOf("="); //$NON-NLS-1$
- if (index != -1) {
- key = getSymbolKey(symbol);
- value = getSymbolValue(symbol);
- } else {
- key = symbol.trim();
- }
- SymbolEntry sEntry = (SymbolEntry) symbols.get(key);
- if (sEntry == null) {
- // make only the first one to be active
- sEntry = new SymbolEntry(key, value, active);
- rc = true;
- }
- else {
- rc |= sEntry.add(value, active);
- }
- symbols.put(key, sEntry);
- return rc;
- }
-
- /**
- * @param result (out)
- * @param addend (in)
- * @return
- */
- public static boolean scAddSymbolEntryMap2SymbolEntryMap(Map result, Map addend) {
- boolean rc = false;
- for (Iterator i = addend.keySet().iterator(); i.hasNext(); ) {
- String key = (String) i.next();
- if (result.keySet().contains(key)) {
- SymbolEntry rSE = (SymbolEntry) result.get(key);
- SymbolEntry aSE = (SymbolEntry) addend.get(key);
- List activeValues = rSE.getActiveRaw();
- for (Iterator j = aSE.getActiveRaw().iterator(); j.hasNext(); ) {
- String aValue = (String) j.next();
- if (!activeValues.contains(aValue)) {
- // result does not contain addend's value; add it
- rSE.add(getSymbolValue(aValue), true);
- rc |= true;
- }
- }
- List removedValues = rSE.getRemovedRaw();
- for (Iterator j = aSE.getRemovedRaw().iterator(); j.hasNext(); ) {
- String aValue = (String) j.next();
- if (!removedValues.contains(aValue)) {
- // result does not contain addend's value; add it
- rSE.add(getSymbolValue(aValue), false);
- rc |= true;
- }
- }
- }
- else {
- // result does not contain the symbol; add it
- // shallow copy
- SymbolEntry aSymbolEntry = (SymbolEntry) addend.get(key);
- result.put(key, aSymbolEntry);
- rc |= true;
- }
- }
- return rc;
- }
-
- /**
- * Returns a symbol key (i.e. for DEF=1 returns DEF)
- *
- * @param symbol - in
- * @param key - out
- */
- public static String getSymbolKey(String symbol) {
- int index = symbol.indexOf('=');
- if (index != -1) {
- return symbol.substring(0, index).trim();
- }
- return symbol;
- }
-
- /**
- * Returns a symbol value (i.e. for DEF=1 returns 1)
- *
- * @param symbol - in
- * @param key - out (may be null)
- */
- public static String getSymbolValue(String symbol) {
- int index = symbol.indexOf('=');
- if (index != -1) {
- return symbol.substring(index+1).trim();
- }
- return null;
- }
-
- /**
- * Removes a symbol value from the symbol entry. If it was an only value than
- * it symbol entry will be removed alltogether.
- *
- * @param symbol
- * @param symbolEntryMap map of [symbol's key, symbolEntry]
- */
- public static void removeSymbolEntryValue(String symbol, Map symbolEntryMap) {
- String key = getSymbolKey(symbol);
- String value = getSymbolValue(symbol);
- // find it in the discoveredSymbols Map of SymbolEntries
- SymbolEntry se = (SymbolEntry) symbolEntryMap.get(key);
- if (se != null) {
- se.remove(value);
- if (se.numberOfValues() == 0) {
- symbolEntryMap.remove(key);
- }
- }
- }
-
- /**
- * Swaps two include paths in the include paths Map.
- * Used by Up/Down discovered paths
- *
- * @param sumPaths
- * @param index1
- * @param index2
- * @return new map of include paths
- */
- public static LinkedHashMap swapIncludePaths(LinkedHashMap sumPaths, int index1, int index2) {
- int size = sumPaths.size();
- if (index1 == index2 ||
- !(index1 >= 0 && index1 < size &&
- index2 >= 0 && index2 < size)) {
- return sumPaths;
- }
- ArrayList pathKeyList = new ArrayList(sumPaths.keySet());
- String temp1 = (String) pathKeyList.get(index1);
- String temp2 = (String) pathKeyList.get(index2);
- pathKeyList.set(index1, temp2);
- pathKeyList.set(index2, temp1);
-
- LinkedHashMap newSumPaths = new LinkedHashMap(sumPaths.size());
- for (Iterator i = pathKeyList.iterator(); i.hasNext(); ) {
- String key = (String) i.next();
- newSumPaths.put(key, sumPaths.get(key));
- }
- return newSumPaths;
- }
-
- /**
- * Tokenizes string with quuotes
- *
- * @param String
- * @return String[]
- */
- public static String[] tokenizeStringWithQuotes(String line, String quoteStyle) {
- ArrayList allTokens = new ArrayList();
- String[] tokens = line.split(quoteStyle);
- for (int i = 0; i < tokens.length; ++i) {
- if (i % 2 == 0) { // even tokens need further tokenization
- String[] sTokens = tokens[i].split("\\s+"); //$NON-NLS-1$
- for (int j = 0; j < sTokens.length; allTokens.add(sTokens[j++]));
- }
- else {
- allTokens.add(tokens[i]);
- }
- }
- return (String[]) allTokens.toArray(new String[allTokens.size()]);
- }
-
- /**
- * Converts array of IPath-s to array of String-s
- *
- * @param paths
- * @return
- */
- public static String[] iPathArray2StringArray(IPath[] paths) {
- String[] rv = new String[paths.length];
- for (int i = 0; i < paths.length; ++i) {
- rv[i] = paths[i].toString();
- }
- return rv;
- }
-
- public static InfoContext createContextForProject(IProject project){
- IConfiguration cfg = getActiveConfiguration(project);
- if(cfg != null)
- return new InfoContext(cfg);
- return null;
- }
-
- public static IConfiguration getActiveConfiguration(IProject project){
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- if(info != null)
- return info.getDefaultConfiguration();
- return null;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
deleted file mode 100644
index a287cb2df45..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig;
-
-import java.io.OutputStream;
-
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * A factory that creates a ConsoleOutputStreamSniffer,
- * ScannerInfoConsoleParser and optionally a ScannerInfoConsoleParserUtility.
- *
- * @author vhirsl
- */
-public class ScannerInfoConsoleParserFactory {
-
- /**
- * Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser
- * and a utility.
- *
- * @param outputStream
- * @param errorStream
- * @param currentProject
- * @param providerId
- * @param scBuildInfo
- * @param markerGenerator
- * @return ConsoleOutputSniffer
- */
- public static ConsoleOutputSniffer getESIProviderOutputSniffer(
- OutputStream outputStream,
- OutputStream errorStream,
- IProject currentProject,
- String providerId,
- IScannerConfigBuilderInfo2 scBuildInfo,
- IScannerInfoCollector collector,
- IMarkerGenerator markerGenerator) {
- if (scBuildInfo.isProviderOutputParserEnabled(providerId)) {
- // get the ESIProvider console parser
- InfoContext context = null;
- IConfiguration cfg = null;
- IBuilder builder = null;
- if(collector instanceof IScannerInfoCollector3){
- context = ((IScannerInfoCollector3)collector).getContext();
- }
- if(context == null){
- context = ScannerConfigUtil.createContextForProject(currentProject);
- }
- if(context != null){
- cfg = context.getConfiguration();
- }
- if(cfg != null){
- builder = cfg.getBuilder();
- }
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId());
- IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId);
- IPath buildDirectory;
- if(builder != null) {
- buildDirectory = ManagedBuildManager.getBuildLocation(cfg, builder);
- } else {
- buildDirectory = currentProject.getLocation();
- }
- clParser.startup(currentProject, buildDirectory, collector, markerGenerator);
- // create an output stream sniffer
- return new ConsoleOutputSniffer(outputStream, errorStream, new
- IScannerInfoConsoleParser[] {clParser});
- }
- return null;
- }
-
- /**
- * Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser
- * and a utility.
- *
- * @param outputStream
- * @param errorStream
- * @param currentProject
- * @param workingDirectory
- * @param buildInfo
- * @param markerGenerator
- * @param IScannerInfoCollector2
- * @return ConsoleOutputSniffer
- */
- public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
- OutputStream outputStream,
- OutputStream errorStream,
- IProject currentProject,
- IPath workingDirectory,
- IScannerConfigBuilderInfo2 scBuildInfo,
- IMarkerGenerator markerGenerator,
- IScannerInfoCollector collector) {
- IConfiguration cfg = ScannerConfigUtil.getActiveConfiguration(currentProject);
- return getMakeBuilderOutputSniffer(outputStream, errorStream, cfg, null, workingDirectory, scBuildInfo, markerGenerator, collector);
- }
-
- /**
- * Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser
- * and a utility.
- *
- * @param outputStream
- * @param errorStream
- * @param cfg
- * @param workingDirectory
- * @param buildInfo
- * @param markerGenerator
- * @param IScannerInfoCollector2
- * @return ConsoleOutputSniffer
- */
- public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
- OutputStream outputStream,
- OutputStream errorStream,
- IConfiguration cfg,
- InfoContext context,
- IPath workingDirectory,
- IScannerConfigBuilderInfo2 scBuildInfo,
- IMarkerGenerator markerGenerator,
- IScannerInfoCollector collector) {
- try {
- // get the SC builder settings
- IProject project = cfg.getOwner().getProject();
- if (project.hasNature(ScannerConfigNature.NATURE_ID)) {
- if(context == null){
- context = new InfoContext(cfg);
- }
- if (scBuildInfo == null) {
- try {
- scBuildInfo = ScannerConfigProfileManager.
- createScannerConfigBuildInfo2(context);
- }
- catch (CoreException e) {
- // builder not installed or disabled
- }
- }
- if (scBuildInfo != null &&
- scBuildInfo.isAutoDiscoveryEnabled() &&
- scBuildInfo.isBuildOutputParserEnabled()) {
- // get the make builder console parser
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(context, scBuildInfo.getSelectedProfileId());
- IScannerInfoConsoleParser clParser = profileInstance.createBuildOutputParser();
- if(clParser != null){
- if (collector == null) {
- collector = profileInstance.getScannerInfoCollector();
- }
- clParser.startup(project, workingDirectory, collector,
- scBuildInfo.isProblemReportingEnabled() ? markerGenerator : null);
- // create an output stream sniffer
- return new ConsoleOutputSniffer(outputStream, errorStream, new
- IScannerInfoConsoleParser[] {clParser});
- }
- }
- }
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e.getStatus());
- }
- return null;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java
deleted file mode 100644
index 56848a305b8..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.BuildOutputProvider;
-import org.eclipse.core.resources.IProject;
-
-/**
- * Common stuff for all GNU build output parsers
- *
- * @author vhirsl
- */
-public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsoleParser {
- private static final String[] COMPILER_INVOCATION = {
- "gcc", "g++", "cc", "c++" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- };
-
- private IProject project;
- private IScannerInfoCollector collector;
- private InfoContext context;
-
- private boolean bMultiline = false;
- private String sMultiline = ""; //$NON-NLS-1$
-
- /**
- * @return Returns the project.
- */
- protected IProject getProject() {
- return project;
- }
- /**
- * @return Returns the collector.
- */
- protected IScannerInfoCollector getCollector() {
- return collector;
- }
-
- public void startup(IProject project, IScannerInfoCollector collector) {
- this.project = project;
- this.collector = collector;
- if(collector instanceof IScannerInfoCollector3){
- context = ((IScannerInfoCollector3)collector).getContext();
- } else {
- context = ScannerConfigUtil.createContextForProject(project);
- }
-
- }
-
- /**
- * Returns array of additional compiler commands to look for
- *
- * @return String[]
- */
- public String[] getCompilerCommands() {
- if (project != null) {
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, context, ScannerConfigProfileManager.NULL_PROFILE_ID);
- BuildOutputProvider boProvider = profileInstance.getProfile().getBuildOutputProviderElement();
- if (boProvider != null) {
- String compilerCommandsString = boProvider.getScannerInfoConsoleParser().getCompilerCommands();
- if (compilerCommandsString != null && compilerCommandsString.length() > 0) {
- String[] compilerCommands = compilerCommandsString.split(",\\s+"); //$NON-NLS-1$
- if (compilerCommands.length > 0) {
- String[] compilerInvocation = new String[COMPILER_INVOCATION.length + compilerCommands.length];
- System.arraycopy(COMPILER_INVOCATION, 0, compilerInvocation, 0, COMPILER_INVOCATION.length);
- System.arraycopy(compilerCommands, 0, compilerInvocation, COMPILER_INVOCATION.length, compilerCommands.length);
- return compilerInvocation;
- }
- }
- }
- }
- return COMPILER_INVOCATION;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String)
- */
- public boolean processLine(String line) {
- boolean rc = false;
- // check for multiline commands (ends with '\')
- if (line.endsWith("\\")) { //$NON-NLS-1$
- sMultiline += line.substring(0, line.length()-1);// + " ";
- bMultiline = true;
- return rc;
- }
- if (bMultiline) {
- line = sMultiline + line;
- bMultiline = false;
- sMultiline = ""; //$NON-NLS-1$
- }
- TraceUtil.outputTrace("AbstractGCCBOPConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$
- // make\[[0-9]*\]: error_desc
- int firstColon= line.indexOf(':');
- String make = line.substring(0, firstColon + 1);
- if (firstColon != -1 && make.indexOf("make") != -1) { //$NON-NLS-1$
- boolean enter = false;
- String msg = line.substring(firstColon + 1).trim();
- if ((enter = msg.startsWith("Entering directory")) || //$NON-NLS-1$
- (msg.startsWith("Leaving directory"))) { //$NON-NLS-1$
- int s = msg.indexOf('`');
- int e = msg.indexOf('\'');
- if (s != -1 && e != -1) {
- String dir = msg.substring(s+1, e);
- if (getUtility() != null) {
- getUtility().changeMakeDirectory(dir, getDirectoryLevel(line), enter);
- }
- return rc;
- }
- }
- }
- // call sublclass to process a single line
- return processSingleLine(line);
- }
-
- private int getDirectoryLevel(String line) {
- int s = line.indexOf('[');
- int num = 0;
- if (s != -1) {
- int e = line.indexOf(']');
- String number = line.substring(s + 1, e).trim();
- try {
- num = Integer.parseInt(number);
- } catch (NumberFormatException exc) {
- }
- }
- return num;
- }
-
- protected abstract boolean processSingleLine(String line);
- protected abstract AbstractGCCBOPConsoleParserUtility getUtility();
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#shutdown()
- */
- public void shutdown() {
- if (getUtility() != null) {
- getUtility().reportProblems();
- }
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java
deleted file mode 100644
index 60a029e8aea..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * Common utilities for GCC build output console parsers
- *
- * @author vhirsl
- */
-public abstract class AbstractGCCBOPConsoleParserUtility {
- private IProject project;
- private IPath fBaseDirectory;
- private Vector fDirectoryStack;
- private IMarkerGenerator fMarkerGenerator;
- private ArrayList fErrors;
-
- /**
- *
- */
- public AbstractGCCBOPConsoleParserUtility(IProject project, IPath workingDirectory,
- IMarkerGenerator markerGenerator) {
- fDirectoryStack = new Vector();
- fErrors = new ArrayList();
- this.project = project;
- fBaseDirectory = project.getLocation();
- if (workingDirectory != null) {
- pushDirectory(workingDirectory);
- }
- }
-
- /**
- * @return Returns the fBaseDirectory.
- */
- protected IPath getBaseDirectory() {
- return fBaseDirectory;
- }
- /**
- * @return Returns the fDirectoryStack.
- */
- protected Vector getDirectoryStack() {
- return fDirectoryStack;
- }
- /**
- * @return Returns the fErrors.
- */
- protected ArrayList getErrors() {
- return fErrors;
- }
- /**
- * @return Returns the fMarkerGenerator.
- */
- protected IMarkerGenerator getMarkerGenerator() {
- return fMarkerGenerator;
- }
- /**
- * @return Returns the project.
- */
- protected IProject getProject() {
- return project;
- }
-
- public IPath getWorkingDirectory() {
- if (fDirectoryStack.size() != 0) {
- return (IPath) fDirectoryStack.lastElement();
- }
- // Fallback to the Project Location
- // FIXME: if the build did not start in the Project ?
- return fBaseDirectory;
- }
-
- protected void pushDirectory(IPath dir) {
- if (dir != null) {
- IPath pwd = null;
- if (fBaseDirectory.isPrefixOf(dir)) {
- pwd = dir.removeFirstSegments(fBaseDirectory.segmentCount());
- } else {
- // check if it is a cygpath
- pwd= convertCygpath(dir);
- }
- fDirectoryStack.addElement(pwd);
- }
- }
-
- public static IPath convertCygpath(IPath path) {
- if (path.segmentCount() > 1 && path.segment(0).equals("cygdrive")) { //$NON-NLS-1$
- StringBuffer buf = new StringBuffer(2);
- buf.append(Character.toUpperCase(path.segment(1).charAt(0)));
- buf.append(':');
- path = path.removeFirstSegments(2);
- path = path.setDevice(buf.toString());
- path = path.makeAbsolute();
- }
- return path;
- }
-
- protected IPath popDirectory() {
- int i = getDirectoryLevel();
- if (i != 0) {
- IPath dir = (IPath) fDirectoryStack.lastElement();
- fDirectoryStack.removeElementAt(i - 1);
- return dir;
- }
- return new Path(""); //$NON-NLS-1$
- }
-
- protected int getDirectoryLevel() {
- return fDirectoryStack.size();
- }
-
- public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir) {
- if (enterDir) {
- /* Sometimes make screws up the output, so
- * "leave" events can't be seen. Double-check level
- * here.
- */
- for (int parseLevel = getDirectoryLevel(); dirLevel < parseLevel; parseLevel = getDirectoryLevel()) {
- popDirectory();
- }
- pushDirectory(new Path(dir));
- } else {
- popDirectory();
- /* Could check to see if they match */
- }
- }
-
- public boolean reportProblems() {
- boolean reset = false;
- for (Iterator iter = fErrors.iterator(); iter.hasNext(); ) {
- Problem problem = (Problem) iter.next();
- if (problem.severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) {
- reset = true;
- }
- if (problem.file == null) {
- fMarkerGenerator.addMarker(
- project,
- problem.lineNumber,
- problem.description,
- problem.severity,
- problem.variableName);
- } else {
- fMarkerGenerator.addMarker(
- problem.file,
- problem.lineNumber,
- problem.description,
- problem.severity,
- problem.variableName);
- }
- }
- fErrors.clear();
- return reset;
- }
-
- protected class Problem {
- protected IResource file;
- protected int lineNumber;
- protected String description;
- protected int severity;
- protected String variableName;
-
- public Problem(IResource file, int lineNumber, String desciption, int severity, String variableName) {
- this.file = file;
- this.lineNumber = lineNumber;
- this.description = desciption;
- this.severity = severity;
- this.variableName = variableName;
- }
- }
-
- /**
- * Called by the console line parsers to generate a problem marker.
- */
- public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName) {
- // No need to collect markers if marker generator is not present
- if (fMarkerGenerator != null) {
- Problem problem = new Problem(file, lineNumber, desc, severity, varName);
- fErrors.add(problem);
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java
deleted file mode 100644
index 2e5126a63ff..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-
-
-/**
- * GCC per file build output parser
- *
- * @author vhirsl
- */
-public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
- private final static String[] FILE_EXTENSIONS = {
- ".c", ".cc", ".cpp", ".cxx", ".C", ".CC", ".CPP", ".CXX" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- };
- private final static List FILE_EXTENSIONS_LIST = Arrays.asList(FILE_EXTENSIONS);
-
- private String[] compilerInvocation;
- private GCCPerFileBOPConsoleParserUtility fUtil;
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator)
- */
- public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) {
- fUtil = (project != null && workingDirectory != null && markerGenerator != null) ?
- new GCCPerFileBOPConsoleParserUtility(project, workingDirectory, markerGenerator) : null;
- super.startup(project, collector);
-
- // check additional compiler commands from extension point manifest
- compilerInvocation = getCompilerCommands();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#getUtility()
- */
- protected AbstractGCCBOPConsoleParserUtility getUtility() {
- return fUtil;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#processSingleLine(java.lang.String)
- */
- protected boolean processSingleLine(String line) {
- boolean rc = false;
- // GCC C/C++ compiler invocation
- int compilerInvocationIndex = -1;
- for (int cii = 0; cii < compilerInvocation.length; ++cii) {
- compilerInvocationIndex = line.indexOf(compilerInvocation[cii]);
- if (compilerInvocationIndex != -1)
- break;
- }
- if (compilerInvocationIndex == -1)
- return rc;
-
- // expecting that compiler invocation is the first token in the line
- String[] split = line.split("\\s+"); //$NON-NLS-1$
- String command = split[0];
- // verify that it is compiler invocation
- int cii2 = -1;
- for (int cii = 0; cii < compilerInvocation.length; ++cii) {
- cii2 = command.indexOf(compilerInvocation[cii]);
- if (cii2 != -1)
- break;
- }
- if (cii2 == -1) {
- TraceUtil.outputTrace("Error identifying compiler command", line, TraceUtil.EOL); //$NON-NLS-1$
- return rc;
- }
- // find a file name
- int extensionsIndex = -1;
- boolean found = false;
- String filePath = null;
- for (int i = 1; i < split.length; ++i) {
- int k = split[i].lastIndexOf('.');
- if (k != -1 && (split[i].length() - k < 5)) {
- String fileExtension = split[i].substring(k);
- extensionsIndex = FILE_EXTENSIONS_LIST.indexOf(fileExtension);
- if (extensionsIndex != -1) {
- filePath = split[i];
- found = true;
- break;
- }
- }
- }
-// for (int j = 0; j < FILE_EXTENSIONS.length; ++j) {
-// if (split[i].endsWith(FILE_EXTENSIONS[j])) {
-// filePath = split[i];
-// extensionsIndex = j;
-// found = true;
-// break;
-// }
-// }
-// if (found) break;
- if (!found) {
- TraceUtil.outputTrace("Error identifying file name :1", line, TraceUtil.EOL); //$NON-NLS-1$
- return rc;
- }
- // sanity check
- if (filePath.indexOf(FILE_EXTENSIONS[extensionsIndex]) == -1) {
- TraceUtil.outputTrace("Error identifying file name :2", line, TraceUtil.EOL); //$NON-NLS-1$
- return rc;
- }
- if (fUtil != null) {
- IPath pFilePath = fUtil.getAbsolutePath(filePath);
- String shortFileName = pFilePath.removeFileExtension().lastSegment();
-
- // generalize occurances of the file name
- StringBuffer genericLine = new StringBuffer();
- for (int i = 0; i < split.length; i++) {
- String token = split[i];
- if (token.equals("-include") || token.equals("-imacros")) { //$NON-NLS-1$ //$NON-NLS-2$
- ++i;
- genericLine.append(token);
- genericLine.append(' ');
- }
- else if (token.equals(filePath)) {
- split[i] = "LONG_NAME"; //$NON-NLS-1$
- }
- else if (token.startsWith(shortFileName)) {
- split[i] = token.replaceFirst(shortFileName, "SHORT_NAME"); //$NON-NLS-1$
- }
- genericLine.append(split[i]);
- genericLine.append(' ');
- }
-
- CCommandDSC cmd = fUtil.getNewCCommandDSC(genericLine.toString(), extensionsIndex > 0);
- IPath baseDirectory = fUtil.getBaseDirectory();
- if (baseDirectory.isPrefixOf(pFilePath)) {
- List cmdList = new ArrayList();
- cmdList.add(cmd);
- Map sc = new HashMap(1);
- sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList);
-
- IPath relPath = pFilePath.removeFirstSegments(baseDirectory.segmentCount());
- //Note: We add the scannerconfig even if the resource doesnt actually
- //exist below this project (which may happen when reading existing
- //build logs, because resources can be created as part of the build
- //and may not exist at the time of analyzing the config but re-built
- //later on.
- //if (getProject().exists(relPath)) {
- IFile file = getProject().getFile(relPath);
- getCollector().contributeToScannerConfig(file, sc);
- } else {
- //TODO limiting to pathes below this project means not being
- //able to work with linked resources. Linked resources could
- //be checked through IWorkspaceRoot.findFilesForLocation().
- TraceUtil.outputError("Build command for file outside project: "+pFilePath.toString(), line); //$NON-NLS-1$
- }
- // fUtil.addGenericCommandForFile2(longFileName, genericLine);
- }
- return rc;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java
deleted file mode 100644
index 73eac867443..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParserUtility.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Martin Oberhuber (Wind River Systems) - bug 155096
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.KVStringPair;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.SCDOptionsEnum;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * TODO Provide description
- *
- * @author vhirsl
- */
-public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsoleParserUtility {
- private Map directoryCommandListMap;
- private List compiledFileList;
-
- private List commandsList2;
-
- private int workingDirsN = 0;
- private int commandsN = 0;
- private int filesN = 0;
-
-
- /**
- * @param markerGenerator
- * @param workingDirectory
- * @param project
- */
- public GCCPerFileBOPConsoleParserUtility(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) {
- super(project, workingDirectory, markerGenerator);
- }
-
- /**
- * Adds a mapping filename, generic_command
- * @param longFileName
- * @param genericLine
- */
- void addGenericCommandForFile(String longFileName, String genericCommand) {
- // if a file name has already been added once, return
- if (compiledFileList.contains(longFileName))
- return;
- compiledFileList.add(longFileName);
-
- String workingDir = getWorkingDirectory().toString();
- List directoryCommandList = (List) directoryCommandListMap.get(workingDir);
- if (directoryCommandList == null) {
- directoryCommandList = new ArrayList();
- directoryCommandListMap.put(workingDir, directoryCommandList);
- ++workingDirsN;
- }
- Map command21FileListMap = null;
- for (Iterator i = directoryCommandList.iterator(); i.hasNext(); ) {
- command21FileListMap = (Map) i.next();
- List fileList = (List) command21FileListMap.get(genericCommand);
- if (fileList != null) {
- if (!fileList.contains(longFileName)) {
- fileList.add(longFileName);
- ++filesN;
- }
- return;
- }
- }
- command21FileListMap = new HashMap(1);
- directoryCommandList.add(command21FileListMap);
- ++commandsN;
- List fileList = new ArrayList();
- command21FileListMap.put(genericCommand, fileList);
- fileList.add(longFileName);
- ++filesN;
- }
-
- /**
- *
- */
- void generateReport() {
- TraceUtil.metricsTrace("Stats for directory ", //$NON-NLS-1$
- "Generic command: '", "' applicable for:", //$NON-NLS-1$ //$NON-NLS-2$
- directoryCommandListMap);
- TraceUtil.summaryTrace("Discovery summary", workingDirsN, commandsN, filesN); //$NON-NLS-1$
- }
-
- /**
- * Adds a mapping command line -> file, this time without a dir
- * @param longFileName
- * @param genericLine
- */
- void addGenericCommandForFile2(String longFileName, String genericLine) {
- // if a file name has already been added once, return
- if (compiledFileList.contains(longFileName))
- return;
- compiledFileList.add(longFileName);
-
- CCommandDSC command = getNewCCommandDSC(genericLine, false); // assume .c file type
- int index = commandsList2.indexOf(command);
- if (index == -1) {
- commandsList2.add(command);
- ++commandsN;
- }
- else {
- command = (CCommandDSC) commandsList2.get(index);
- }
-// // add a file
-// command.addFile(longFileName);
-// ++filesN;
- }
-
- /**
- * @param genericLine
- * @param cppFileType
- * @return CCommandDSC compile command description
- */
- public CCommandDSC getNewCCommandDSC(String genericLine, boolean cppFileType) {
- CCommandDSC command = new CCommandDSC(cppFileType);
- String[] tokens = genericLine.split("\\s+"); //$NON-NLS-1$
- command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[0]));
- for (int i = 1; i < tokens.length; ++i) {
- String token = tokens[i];
- //Target specific options: see GccScannerInfoConsoleParser
- if (token.startsWith("-m") || //$NON-NLS-1$
- token.equals("-ansi") || //$NON-NLS-1$
- token.equals("-posix") || //$NON-NLS-1$
- token.equals("-pthread") || //$NON-NLS-1$
- token.startsWith("-O") || //$NON-NLS-1$
- token.equals("-fno-inline") || //$NON-NLS-1$
- token.startsWith("-finline") || //$NON-NLS-1$
- token.equals("-fno-exceptions") || //$NON-NLS-1$
- token.equals("-fexceptions") || //$NON-NLS-1$
- token.equals("-fshort-wchar") || //$NON-NLS-1$
- token.equals("-fshort-double") || //$NON-NLS-1$
- token.equals("-fno-signed-char") || //$NON-NLS-1$
- token.equals("-fsigned-char") || //$NON-NLS-1$
- token.startsWith("-fabi-version=") //$NON-NLS-1$
- ) {
- command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), token));
- continue;
- }
- for (int j = SCDOptionsEnum.MIN; j <= SCDOptionsEnum.MAX; ++j) {
- if (token.startsWith(SCDOptionsEnum.getSCDOptionsEnum(j).toString())) {
- String option = token.substring(
- SCDOptionsEnum.getSCDOptionsEnum(j).toString().length()).trim();
- if (option.length() > 0) {
- // ex. -I/dir
- }
- else if (SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDASH)) {
- // -I- has no parameter
- }
- else {
- // ex. -I /dir
- // take a next token
- ++i;
- if (i < tokens.length && !tokens[i].startsWith("-")) { //$NON-NLS-1$
- option = tokens[i];
- }
- else break;
- }
- if (option.length() > 0 && (
- SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE) ||
- SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.INCLUDE_FILE) ||
- SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IMACROS_FILE) ||
- SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.IDIRAFTER) ||
- SCDOptionsEnum.getSCDOptionsEnum(j).equals(SCDOptionsEnum.ISYSTEM))) {
- option = (getAbsolutePath(option)).toString();
- }
- // add the pair
- command.addSCOption(new KVStringPair(SCDOptionsEnum.getSCDOptionsEnum(j).toString(), option));
- break;
- }
- }
- }
- return command;
- }
-
- /**
- * @param filePath : String
- * @return filePath : IPath - not null
- */
- IPath getAbsolutePath(String filePath) {
- IPath pFilePath;
- if (filePath.startsWith("/")) { //$NON-NLS-1$
- return convertCygpath(new Path(filePath));
- }
- else if (filePath.startsWith("\\") || //$NON-NLS-1$
- (!filePath.startsWith(".") && //$NON-NLS-1$
- filePath.length() > 2 && filePath.charAt(1) == ':' &&
- (filePath.charAt(2) == '\\' || filePath.charAt(2) == '/'))) {
- // absolute path
- pFilePath = new Path(filePath);
- }
- else {
- // relative path
- IPath cwd = getWorkingDirectory();
- if (!cwd.isAbsolute()) {
- cwd = getBaseDirectory().append(cwd);
- }
- pFilePath = cwd.append(filePath);
- }
- return pFilePath;
- }
-
- /**
- *
- */
-// void generateReport2() {
-// StringWriter buffer = new StringWriter();
-// PrintWriter writer = new PrintWriter(buffer);
-// for (Iterator i = commandsList2.iterator(); i.hasNext(); ) {
-// CCommandDSC cmd = (CCommandDSC)i.next();
-// writer.println("Stats for generic command: '" + cmd.getCommandAsString() + "' applicable for " +
-// Integer.toString(cmd.getNumberOfFiles()) + " files: ");
-// List filesList = cmd.getFilesList();
-// if (filesList != null) {
-// for (Iterator j = filesList.iterator(); j.hasNext(); ) {
-// writer.println(" " + (String)j.next());
-// }
-// }
-// }
-// writer.close();
-//
-// TraceUtil.metricsTrace(buffer.toString());
-// TraceUtil.summaryTrace("Discovery summary", workingDirsN, commandsN, filesN);
-// }
-
- /**
- * Returns all CCommandDSC collected so far.
- * Currently this list is not filled, so it will always return an empty list.
- * @return List of CCommandDSC
- */
- public List getCCommandDSCList() {
- return new ArrayList(commandsList2);
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java
deleted file mode 100644
index 5a07a3a8fee..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileSIPConsoleParser.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Martin Oberhuber (Wind River Systems) - bug 155096
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Console parser for generated makefile output
- *
- * @author vhirsl
- */
-public class GCCPerFileSIPConsoleParser implements IScannerInfoConsoleParser {
- private final static String INCLUDE_PREAMBLE = "#include <...>"; //$NON-NLS-1$
- private final static String QUOTE_INCLUDE_PREAMBLE = "#include \"...\""; //$NON-NLS-1$
- private final static String DEFINE_PREAMBLE = "#define"; //$NON-NLS-1$
- private final static String COMMAND_ID_BEGIN = "begin generating scanner info for scd_cmd_"; //$NON-NLS-1$
- private final static String COMMAND_ID_END = "end generating scanner info for scd_cmd_"; //$NON-NLS-1$
-
- private final static int NO_INCLUDES = 0;
- private final static int QUOTE_INCLUDES = 1;
- private final static int INCLUDES = 2;
-
- private IScannerInfoCollector fCollector = null;
-
- private int expectingIncludes = NO_INCLUDES;
- private List symbols;
- private List includes;
- private List quoteIncludes;
- private int commandId = -1;
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator)
- */
- public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) {
- this.fCollector = collector;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String)
- */
- public boolean processLine(String line) {
- boolean rc = false;
- TraceUtil.outputTrace("GCCPerFileSIPConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$//$NON-NLS-2$
-
- if (line.startsWith(COMMAND_ID_BEGIN)) {
- commandId = Integer.parseInt(line.substring(COMMAND_ID_BEGIN.length()));
- symbols = new ArrayList();
- includes = new ArrayList();
- quoteIncludes = new ArrayList();
- }
- else if (line.startsWith(COMMAND_ID_END)) {
- Map scannerInfo = new HashMap();
- scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes);
- scannerInfo.put(ScannerInfoTypes.QUOTE_INCLUDE_PATHS, quoteIncludes);
- scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
- fCollector.contributeToScannerConfig(new Integer(commandId), scannerInfo);
- commandId = -1;
- rc = true;
- }
- // contribution of -dD option
- else if (line.startsWith(DEFINE_PREAMBLE)) {
- String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$
- if (defineParts[0].equals(DEFINE_PREAMBLE)) {
- String symbol = null;
- switch (defineParts.length) {
- case 2:
- symbol = defineParts[1];
- break;
- case 3:
- symbol = defineParts[1] + "=" + defineParts[2]; //$NON-NLS-1$
- break;
- }
- if (symbol != null && !symbols.contains(symbol)) {
- symbols.add(symbol);
- }
- }
- }
- // now get all the includes
- else if (line.startsWith(QUOTE_INCLUDE_PREAMBLE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
- expectingIncludes = QUOTE_INCLUDES;
- }
- else if (line.startsWith(INCLUDE_PREAMBLE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
- expectingIncludes = INCLUDES;
- }
- else if (line.startsWith("End of search list.")) { //$NON-NLS-1$
- expectingIncludes = NO_INCLUDES;
- }
- else if (expectingIncludes == QUOTE_INCLUDES) {
- if (!quoteIncludes.contains(line))
- quoteIncludes.add(line);
- }
- else if (expectingIncludes == INCLUDES) {
- if (!includes.contains(line))
- includes.add(line);
- }
-
- return rc;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown()
- */
- public void shutdown() {
-// Map scannerInfo = new HashMap();
-// scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes);
-// scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
-// fCollector.contributeToScannerConfig(fProject, scannerInfo);
-// TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$
-// "Include paths", includes, new ArrayList(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$);
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java
deleted file mode 100644
index d56c9077280..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerConfigUtil.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-/**
- * GCC related utility class
- *
- * @author vhirsl
- */
-public class GCCScannerConfigUtil {
- public static final String CPP_SPECS_FILE = "specs.cpp"; //$NON-NLS-1$
- public static final String C_SPECS_FILE = "specs.c"; //$NON-NLS-1$
-
- public static void createSpecs() {
- IPath path = ManagedBuilderCorePlugin.getWorkingDirectory();
- try {
- createSpecsFile(path, CPP_SPECS_FILE);
- createSpecsFile(path, C_SPECS_FILE);
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
-
- private static void createSpecsFile(IPath path, String fileName) throws CoreException {
- IPath specs = path.append(fileName);
- File specsFile = specs.toFile();
- if (!specsFile.exists()) {
- try {
- FileOutputStream file = new FileOutputStream(specsFile);
- file.write('\n');
- file.close();
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR,
- ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("GCCScannerConfigUtil.Error_Message"), e)); //$NON-NLS-1$
- }
- }
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java
deleted file mode 100644
index 5c7d63cc4c5..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCScannerInfoConsoleParser.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Martin Oberhuber (Wind River Systems) - bug 155096
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * Parses gcc and g++ output for -I and -D parameters.
- *
- * @author vhirsl
- */
-public class GCCScannerInfoConsoleParser extends AbstractGCCBOPConsoleParser {
- private final static String SINGLE_QUOTE_STRING = "\'"; //$NON-NLS-1$
- private final static String DOUBLE_QUOTE_STRING = "\""; //$NON-NLS-1$
- private final static char[] matchingChars = {'`', '\'', '\"'};
-
- private String[] compilerInvocation;
-
- private ScannerInfoConsoleParserUtility fUtil = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator)
- */
- public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) {
- fUtil = (project != null && workingDirectory != null && markerGenerator != null) ?
- new ScannerInfoConsoleParserUtility(project, workingDirectory, markerGenerator) : null;
- super.startup(project, collector);
-
- // check additional compiler commands from extension point manifest
- compilerInvocation = getCompilerCommands();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#getUtility()
- */
- protected AbstractGCCBOPConsoleParserUtility getUtility() {
- return fUtil;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.gnu.AbstractGCCBOPConsoleParser#processSingleLine(java.lang.String)
- */
- protected boolean processSingleLine(String line) {
- boolean rc = false;
- // Known patterns:
- // (a) gcc|g++ ... -Dxxx -Iyyy ...
- List allTokens = tokenize(line);
-// ArrayList allTokens = new ArrayList(Arrays.asList(line.split("\\s+")));//$NON-NLS-1$
- if (allTokens.size() <= 1)
- return false;
- Iterator I = allTokens.iterator();
- String token = ((String) I.next()).toLowerCase();
-
- boolean found = false;
- for (int i = 0; i < compilerInvocation.length; i++) {
- if (token.indexOf(compilerInvocation[i]) != -1) {
- found = true;
- break;
- }
- }
- if (found) {
- // Recognized gcc or g++ compiler invocation
- List includes = new ArrayList();
- List symbols = new ArrayList();
- List targetSpecificOptions = new ArrayList();
-
- rc = true;
- String fileName = null;
- // discover all -I options
- parseLineForIncludePaths(line, includes);
- // discover all -D options
- parseLineForSymbolDefinitions(line, symbols);
-
- while (I.hasNext()) {
- token = (String) I.next();
- if (token.startsWith("-m") || //$NON-NLS-1$
- token.equals("-ansi") || //$NON-NLS-1$
- token.equals("-nostdinc") || //$NON-NLS-1$
- token.equals("-posix") || //$NON-NLS-1$
- token.equals("-pthread") || //$NON-NLS-1$
- token.startsWith("-O") || //$NON-NLS-1$
- token.equals("-fno-inline") || //$NON-NLS-1$
- token.startsWith("-finline") || //$NON-NLS-1$
- token.equals("-fno-exceptions") || //$NON-NLS-1$
- token.equals("-fexceptions") || //$NON-NLS-1$
- token.equals("-fshort-wchar") || //$NON-NLS-1$
- token.equals("-fshort-double") || //$NON-NLS-1$
- token.equals("-fno-signed-char") || //$NON-NLS-1$
- token.equals("-fsigned-char") || //$NON-NLS-1$
- token.startsWith("-fabi-version=") //$NON-NLS-1$
- ) {
- if (!targetSpecificOptions.contains(token))
- targetSpecificOptions.add(token);
- }
- else if (fileName == null) {
- String possibleFileName = token.toLowerCase();
- if ((possibleFileName.startsWith(DOUBLE_QUOTE_STRING) &&
- possibleFileName.endsWith(DOUBLE_QUOTE_STRING)) ||
- (possibleFileName.startsWith(SINGLE_QUOTE_STRING) &&
- possibleFileName.endsWith(SINGLE_QUOTE_STRING))) {
- possibleFileName = possibleFileName.substring(1, possibleFileName.length()-1).trim();
- }
- if (possibleFileName.endsWith(".c") || //$NON-NLS-1$
- possibleFileName.endsWith(".cpp") || //$NON-NLS-1$
- possibleFileName.endsWith(".cc") || //$NON-NLS-1$
- possibleFileName.endsWith(".cxx") || //$NON-NLS-1$
- possibleFileName.endsWith(".C") || //$NON-NLS-1$
- possibleFileName.endsWith(".CPP") || //$NON-NLS-1$
- possibleFileName.endsWith(".CC") || //$NON-NLS-1$
- possibleFileName.endsWith(".CXX") || //$NON-NLS-1$
- possibleFileName.endsWith(".c++")) { //$NON-NLS-1$
-
- fileName = token;
- }
- }
- }
-
- if (fileName != null && fileName.startsWith("/cygdrive/")) { //$NON-NLS-1$
- fileName= AbstractGCCBOPConsoleParserUtility.convertCygpath(new Path(fileName)).toOSString();
- }
-
- IProject project = getProject();
- IFile file = null;
- List translatedIncludes = includes;
- if (includes.size() > 0) {
- if (fileName != null) {
- if (fUtil != null) {
- file = fUtil.findFile(fileName);
- if (file != null) {
- project = file.getProject();
- translatedIncludes = fUtil.translateRelativePaths(file, fileName, includes);
- }
- }
- }
- else {
- final String error = MakeMessages.getString("ConsoleParser.Filename_Missing_Error_Message"); //$NON-NLS-1$
- TraceUtil.outputError(error, line);
- if (fUtil != null) {
- fUtil.generateMarker(getProject(), -1, error + line, IMarkerGenerator.SEVERITY_WARNING, null);
- }
- }
- if (file == null && fUtil != null) { // real world case
- // remove include paths since there was no chance to translate them
- translatedIncludes.clear();
- }
- }
- // Contribute discovered includes and symbols to the ScannerInfoCollector
- if (translatedIncludes.size() > 0 || symbols.size() > 0) {
- Map scannerInfo = new HashMap();
- scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, translatedIncludes);
- scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
- scannerInfo.put(ScannerInfoTypes.TARGET_SPECIFIC_OPTION, targetSpecificOptions);
- getCollector().contributeToScannerConfig(project, scannerInfo);
-
- TraceUtil.outputTrace("Discovered scanner info for file \'" + fileName + '\'', //$NON-NLS-1$
- "Include paths", includes, translatedIncludes, "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return rc;
- }
-
- /**
- * @param line
- * @return list of tokens
- */
- private List tokenize(String line) {
- List rv = new ArrayList(2);
- // find special characters that need to be matched: `, ' and "
- // First Matching Chararcter
- int prevFmc = line.length();
- int emc = -1;
- char matchingChar = 0;
- for (int i = 0; i < matchingChars.length; ++i) {
- char ch = matchingChars[i];
- int fmc = line.indexOf(ch);
- if (fmc > -1 && fmc < prevFmc) {
- emc = line.indexOf(ch, fmc+1);
- if (emc > fmc) {
- matchingChar = ch;
- prevFmc = fmc;
- }
- }
- }
- if (matchingChar != 0) { // found matched chars
- String prefix = line.substring(0, prevFmc).trim();
- rv.addAll(Arrays.asList(prefix.split("\\s+")));//$NON-NLS-1$
-
- rv.add(line.substring(prevFmc, emc+1));
-
- // recursion
- rv.addAll(tokenize(line.substring(emc+1).trim()));
- }
- else {
- rv.addAll(Arrays.asList(line.split("\\s+")));//$NON-NLS-1$
- }
- return rv;
- }
-
- /**
- * @param line
- * @param includes
- */
- private void parseLineForIncludePaths(String line, List includes) {
- final String fDashI = "-I"; //$NON-NLS-1$
- int prevIndex = 0;
- for (int index = line.indexOf(fDashI, prevIndex); index != -1;
- prevIndex = index+2, index = line.indexOf(fDashI, prevIndex)) {
- String delimiter = "\\s+"; //$NON-NLS-1$
- if (line.charAt(index-1) == '\'' || line.charAt(index-1) == '\"') {
- // look for only one more ' or "
- delimiter = String.valueOf(line.charAt(index-1));
- }
- String postfix = line.substring(index+2).trim();
- if (postfix.charAt(0) == '-') { // empty -I
- continue;
- }
- if (postfix.startsWith(SINGLE_QUOTE_STRING) || postfix.startsWith(DOUBLE_QUOTE_STRING)) {
- delimiter = postfix.substring(0, 1);
- }
- String[] tokens = postfix.split(delimiter);
- int tokIndex = (tokens.length > 1 && tokens[0].length() == 0) ? 1 : 0;
- String iPath = tokens[tokIndex];
- String temp = iPath;
- // check for '\ '
- for (++tokIndex; (temp.endsWith("\\") && tokIndex < tokens.length && //$NON-NLS-1$
- tokens[tokIndex].length() > 0 && !tokens[tokIndex].startsWith("-")); //$NON-NLS-1$
- ++tokIndex) {
- int beg = postfix.indexOf(temp)+temp.length();
- int end = postfix.indexOf(tokens[tokIndex])+tokens[tokIndex].length();
- iPath = iPath.substring(0, iPath.length()-1) + postfix.substring(beg, end);
- temp += postfix.substring(beg, end);
- }
- String nPath = iPath;
- if (fUtil != null) {
- nPath = fUtil.normalizePath(iPath);
- }
- if (!includes.contains(nPath)) {
- includes.add(nPath);
- }
- }
- }
-
- /**
- * @param line
- * @param symbols
- */
- private void parseLineForSymbolDefinitions(String line, List symbols) {
- final String fDashD = "-D"; //$NON-NLS-1$
- int prevIndex = 0;
- String delimiter = null;
- String splitRegex = "\\s+"; //$NON-NLS-1$
- for (int index = line.indexOf(fDashD, prevIndex); index != -1;
- prevIndex = index+2, index = line.indexOf(fDashD, prevIndex)) {
- int nDelimiterSymbols = 2;
- String postfix = line.substring(index+2).trim();
- if (postfix.charAt(0) == '-') { // empty -D
- continue;
- }
- if (line.charAt(index-1) == '\'' || line.charAt(index-1) == '\"') {
- // look for only one more ' or "
- delimiter = String.valueOf(line.charAt(index-1));
- nDelimiterSymbols = 1;
- }
- else {
- String[] tokens = postfix.split(splitRegex, 2);
- if (tokens.length > 0 && tokens[0].length() > 0) {
- int sQuoteIndex = tokens[0].indexOf(SINGLE_QUOTE_STRING);
- int dQuoteIndex = tokens[0].indexOf(DOUBLE_QUOTE_STRING);
- if (sQuoteIndex == -1 && dQuoteIndex == -1) {
- // simple case, no quotes
- if (!symbols.contains(tokens[0])) {
- symbols.add(tokens[0]);
- }
- continue;
- }
- else {
- delimiter = (sQuoteIndex != -1 && (dQuoteIndex == -1 || sQuoteIndex < dQuoteIndex)) ? SINGLE_QUOTE_STRING : DOUBLE_QUOTE_STRING;
- }
- }
- else
- continue;
- }
-
- // find next matching delimiter
- int nextDelimiterIndex = -1;
- int prevDelimiterIndex = -1;
- do {
- nextDelimiterIndex = postfix.indexOf(delimiter, nextDelimiterIndex+1);
- if (nextDelimiterIndex == 0 || (nextDelimiterIndex > 0 && postfix.charAt(nextDelimiterIndex-1) != '\\')) {
- --nDelimiterSymbols;
- if (nDelimiterSymbols > 0) {
- prevDelimiterIndex = nextDelimiterIndex;
- }
- }
- }
- while (nDelimiterSymbols > 0 && nextDelimiterIndex != -1);
- if (nDelimiterSymbols > 0)
- continue; // non matching delimiter
-
- // take everything up to the last delimiter
- boolean bStartsWithDelimiter = postfix.startsWith(delimiter);
- String symbol = postfix.substring(bStartsWithDelimiter ? 1 : 0, nextDelimiterIndex);
- if (!bStartsWithDelimiter) {
- // there is still a delimiter to be removed
- if (prevDelimiterIndex != -1) {
- symbol = symbol.substring(0, prevDelimiterIndex) + symbol.substring(prevDelimiterIndex+1);
- }
- }
- // transform '\"' into '"'
- if (delimiter.equals(DOUBLE_QUOTE_STRING)) {
- symbol = symbol.replaceAll("\\\\\"", DOUBLE_QUOTE_STRING); //$NON-NLS-1$
- }
- if (!symbols.contains(symbol)) {
- symbols.add(symbol);
- }
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java
deleted file mode 100644
index 7e378667105..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCSpecsConsoleParser.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Parses output of gcc -c -v specs.c or
- * g++ -c -v specs.cpp
- * command
- *
- * @author vhirsl
- */
-public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
- private final String INCLUDE = "#include"; //$NON-NLS-1$
- private final String DEFINE = "#define"; //$NON-NLS-1$
-
- private IProject fProject = null;
- private IScannerInfoCollector fCollector = null;
-
- private boolean expectingIncludes = false;
- private List symbols = new ArrayList();
- private List includes = new ArrayList();
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector, org.eclipse.cdt.core.IMarkerGenerator)
- */
- public void startup(IProject project, IPath workingDirectory, IScannerInfoCollector collector, IMarkerGenerator markerGenerator) {
- this.fProject = project;
- this.fCollector = collector;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#processLine(java.lang.String)
- */
- public boolean processLine(String line) {
- boolean rc = false;
- TraceUtil.outputTrace("GCCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // contribution of -dD option
- if (line.startsWith(DEFINE)) {
- String[] defineParts = line.split("\\s+", 3); //$NON-NLS-1$
- if (defineParts[0].equals(DEFINE)) {
- String symbol = null;
- switch (defineParts.length) {
- case 2:
- symbol = defineParts[1];
- break;
- case 3:
- symbol = defineParts[1] + "=" + defineParts[2]; //$NON-NLS-1$
- break;
- }
- if (symbol != null && !symbols.contains(symbol)) { //$NON-NLS-1$
- symbols.add(symbol);
- }
- }
- }
- // now get all the includes
- else if (line.startsWith(INCLUDE) && line.endsWith("search starts here:")) { //$NON-NLS-1$
- expectingIncludes = true;
- }
- else if (line.startsWith("End of search list.")) { //$NON-NLS-1$
- expectingIncludes = false;
- }
- else if (expectingIncludes) {
- if (!includes.contains(line))
- includes.add(line);
- }
-
- return rc;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown()
- */
- public void shutdown() {
- Map scannerInfo = new HashMap();
- scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, includes);
- scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
- fCollector.contributeToScannerConfig(fProject, scannerInfo);
- TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$
- "Include paths", includes, new ArrayList(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$);
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java
deleted file mode 100644
index 815e0cf2eb0..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * Implements error reporting mechanism and file/path translation mechanism
- * Taken from ErrorParserManager and modified.
- *
- * @author vhirsl
- */
-public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParserUtility {
- /*
- * For tracking the location of files being compiled
- */
- private Map fFilesInProject;
- private List fCollectedFiles;
- private List fNameConflicts;
-
- public ScannerInfoConsoleParserUtility(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) {
- super(project, workingDirectory, markerGenerator);
-
- fFilesInProject = new HashMap();
- fCollectedFiles = new ArrayList();
- fNameConflicts = new ArrayList();
-
- collectFiles(getProject(), fCollectedFiles);
-
- for (int i = 0; i < fCollectedFiles.size(); i++) {
- IFile curr = (IFile) fCollectedFiles.get(i);
- Object existing = fFilesInProject.put(curr.getName(), curr);
- if (existing != null) {
- fNameConflicts.add(curr.getName());
- }
- }
- }
-
- /**
- * Called by the console line parsers to find a file with a given name.
- * @param fileName
- * @return IFile or null
- */
- public IFile findFile(String fileName) {
- IFile file = findFilePath(fileName);
- if (file == null) {
- // Try the project's map.
- file = findFileName(fileName);
- if (file != null) {
- // If there is a conflict then try all files in the project.
- if (isConflictingName(fileName)) {
- file = null;
-
- // Create a problem marker
- final String error = MakeMessages.getString("ConsoleParser.Ambiguous_Filepath_Error_Message"); //$NON-NLS-1$
- TraceUtil.outputError(error, fileName);
- generateMarker(getProject(), -1, error+fileName, IMarkerGenerator.SEVERITY_WARNING, null);
- }
- }
- }
- return file;
- }
-
- /**
- * @param filePath
- * @return
- */
- protected IFile findFilePath(String filePath) {
- IPath path = null;
- IPath fp = new Path(filePath);
- if (fp.isAbsolute()) {
- if (getBaseDirectory().isPrefixOf(fp)) {
- int segments = getBaseDirectory().matchingFirstSegments(fp);
- path = fp.removeFirstSegments(segments);
- } else {
- path = fp;
- }
- } else {
- path = getWorkingDirectory().append(filePath);
- }
-
- IFile file = null;
- // The workspace may throw an IllegalArgumentException
- // Catch it and the parser should fallback to scan the entire project.
- try {
- file = findFileInWorkspace(path);
- } catch (Exception e) {
- }
-
- // We have to do another try, on Windows for cases like "TEST.C" vs "test.c"
- // We use the java.io.File canonical path.
- if (file == null || !file.exists()) {
- File f = path.toFile();
- try {
- String canon = f.getCanonicalPath();
- path = new Path(canon);
- file = findFileInWorkspace(path);
- } catch (IOException e1) {
- }
- }
- return (file != null && file.exists()) ? file : null;
- }
-
- /**
- * @param fileName
- * @return
- */
- protected IFile findFileName(String fileName) {
- IPath path = new Path(fileName);
- return (IFile) fFilesInProject.get(path.lastSegment());
- }
-
- protected IFile findFileInWorkspace(IPath path) {
- IFile file = null;
- if (path.isAbsolute()) {
- IWorkspaceRoot root = getProject().getWorkspace().getRoot();
- file = root.getFileForLocation(path);
- // It may be a link resource so we must check it also.
- if (file == null) {
- IFile[] files = root.findFilesForLocation(path);
- for (int i = 0; i < files.length; i++) {
- if (files[i].getProject().equals(getProject())) {
- file = files[i];
- break;
- }
- }
- }
-
- } else {
- file = getProject().getFile(path);
- }
- return file;
- }
-
- protected void collectFiles(IContainer parent, List result) {
- try {
- IResource[] resources = parent.members();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (resource instanceof IFile) {
- result.add(resource);
- } else if (resource instanceof IContainer) {
- collectFiles((IContainer) resource, result);
- }
- }
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e.getStatus());
- }
- }
-
- protected boolean isConflictingName(String fileName) {
- IPath path = new Path(fileName);
- return fNameConflicts.contains(path.lastSegment());
- }
-
- public List translateRelativePaths(IFile file, String fileName, List includes) {
- List translatedIncludes = new ArrayList(includes.size());
- for (Iterator i = includes.iterator(); i.hasNext(); ) {
- String include = (String) i.next();
- IPath includePath = new Path(include);
- if (!includePath.isAbsolute() && !includePath.isUNC()) { // do not translate UNC paths
- // First try the current working directory
- IPath cwd = getWorkingDirectory();
- if (!cwd.isAbsolute()) {
- cwd = getBaseDirectory().append(cwd);
- }
-
- IPath filePath = new Path(fileName);
- if (!filePath.isAbsolute()) {
- // check if the cwd is the right one
- // appending fileName to cwd should yield file path
- filePath = cwd.append(fileName);
- }
- if (!filePath.toString().equalsIgnoreCase(file.getLocation().toString())) {
- // must be the cwd is wrong
- // check if file name starts with ".."
- if (fileName.startsWith("..")) { //$NON-NLS-1$
- // probably multiple choices for cwd, hopeless
- final String error = MakeMessages.getString("ConsoleParser.Working_Directory_Error_Message"); //$NON-NLS-1$
- TraceUtil.outputError(error, fileName); //$NON-NLS-1$
- generateMarker(file, -1, error, IMarkerGenerator.SEVERITY_WARNING, fileName);
- break;
- }
- else {
- // remove common segments at the end
- IPath tPath = new Path(fileName);
- if (fileName.startsWith(".")) { //$NON-NLS-1$
- tPath = tPath.removeFirstSegments(1);
- }
- // get the file path from the file
- filePath = file.getLocation();
- IPath lastFileSegment = filePath.removeFirstSegments(filePath.segmentCount() - tPath.segmentCount());
- if (lastFileSegment.matchingFirstSegments(tPath) == tPath.segmentCount()) {
- cwd = filePath.removeLastSegments(tPath.segmentCount());
- }
- }
- }
-
- IPath candidatePath = cwd.append(includePath);
- File dir = candidatePath.toFile();
- include = candidatePath.toString();
- if (!dir.exists()) {
- final String error = MakeMessages.getString("ConsoleParser.Nonexistent_Include_Path_Error_Message"); //$NON-NLS-1$
- TraceUtil.outputError(error, include);
-// generateMarker(file, -1, error+include, IMarkerGenerator.SEVERITY_WARNING, fileName);
- }
- }
- // TODO VMIR for now add unresolved paths as well
- translatedIncludes.add(include);
- }
- return translatedIncludes;
- }
-
- public String normalizePath(String path) {
- int column = path.indexOf(':');
- if (column > 0) {
- char driveLetter = path.charAt(column - 1);
- if (Character.isLowerCase(driveLetter)) {
- StringBuffer sb = new StringBuffer();
- if (column - 1 > 0) {
- sb.append(path.substring(0, column-1));
- }
- sb.append(Character.toUpperCase(driveLetter));
- sb.append(path.substring(column));
- path = sb.toString();
- }
- }
- if (path.indexOf('.') == -1 || path.equals(".")) { //$NON-NLS-1$
- return (new Path(path)).toString(); // convert separators to '/'
- }
- // lose "./" segments since they confuse the Path normalization
- StringBuffer buf = new StringBuffer(path);
- int len = buf.length();
- StringBuffer newBuf = new StringBuffer(buf.length());
- int scp = 0; // starting copy point
- int ssp = 0; // starting search point
- int sdot;
- boolean validPrefix;
- while (ssp < len && (sdot = buf.indexOf(".", ssp)) != -1) { //$NON-NLS-1$
- validPrefix = false;
- int ddot = buf.indexOf("..", ssp);//$NON-NLS-1$
- if (sdot < ddot || ddot == -1) {
- newBuf.append(buf.substring(scp, sdot));
- scp = sdot;
- ssp = sdot + 1;
- if (ssp < len) {
- if (sdot == 0 || buf.charAt(sdot - 1) == '/' || buf.charAt(sdot - 1) == '\\') {
- validPrefix = true;
- }
- char nextChar = buf.charAt(ssp);
- if (validPrefix && nextChar == '/') {
- ++ssp;
- scp = ssp;
- }
- else if (validPrefix && nextChar == '\\') {
- ++ssp;
- if (ssp < len - 1 && buf.charAt(ssp) == '\\') {
- ++ssp;
- }
- scp = ssp;
- }
- else {
- // no path delimiter, must be '.' inside the path
- scp = ssp - 1;
- }
- }
- }
- else if (sdot == ddot) {
- ssp = sdot + 2;
- }
- }
- newBuf.append(buf.substring(scp, len));
-
- IPath orgPath = new Path(newBuf.toString());
- return orgPath.toString();
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java
deleted file mode 100644
index a684369dc96..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.jobs;
-
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
-
-/**
- * Build output reader job
- *
- * @author vhirsl
- */
-public class BuildOutputReaderJob extends Job {
- private static final String JOB_NAME = "Build Output Reader"; //$NON-NLS-1$
-
- private IResource resource;
- private IScannerConfigBuilderInfo2 buildInfo;
- private InfoContext context;
-
- /**
- * @param project
- * @param buildInfo
- */
- /*uncomment
- public BuildOutputReaderJob(IProject project, IScannerConfigBuilderInfo2 buildInfo) {
- this(project, null, buildInfo);
- }
- */
-
- public BuildOutputReaderJob(IProject project, InfoContext context, IScannerConfigBuilderInfo2 buildInfo) {
- super(JOB_NAME);
- this.resource = project;
- this.buildInfo = buildInfo;
- if(context == null)
- context = ScannerConfigUtil.createContextForProject(project);
- this.context = context;
- setUser(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus run(IProgressMonitor monitor) {
- IProject project = resource.getProject();
- monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$
- monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
- project.getName());
-
- SCProfileInstance instance = SCJobsUtil.readBuildOutputFile(project, context, buildInfo, new SubProgressMonitor(monitor, 70));
- boolean rc = instance != null;
- instance = SCJobsUtil.getProviderScannerInfo(project, context, instance, buildInfo, new SubProgressMonitor(monitor, 20));
- rc |= instance != null;
- if (rc) {
- rc = SCJobsUtil.updateScannerConfiguration(project, buildInfo, new SubProgressMonitor(monitor, 10));
- }
-
- monitor.done();
- return (rc == true) ? Status.OK_STATUS : Status.CANCEL_STATUS;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java
deleted file mode 100644
index ecc6439f43b..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * Class that represents a compiler command and related scanner configuration
- *
- * @author vhirsl
- */
-public class CCommandDSC {
- private final static String SINGLE_SPACE = " "; //$NON-NLS-1$
- private final static String CMD_DESCRIPTION_ELEM = "commandDescription"; //$NON-NLS-1$
- private final static String CMD_SI_ELEM = "commandScannerInfo"; //$NON-NLS-1$
- private final static String OPTION_ELEM = "option"; //$NON-NLS-1$
- private final static String SI_ITEM_ELEM = "siItem"; //$NON-NLS-1$
- private final static String KEY_ATTR = "key"; //$NON-NLS-1$
- private final static String VALUE_ATTR = "value"; //$NON-NLS-1$
- private final static String QUOTE_INCLUDE_ATTR = "quote"; //$NON-NLS-1$
- private final static String KIND_ATTR = "kind"; //$NON-NLS-1$
-
- private int commandId;
- private List compilerCommand; // members are KVStringPair objects
- private boolean discovered;
- private boolean cppFileType; // C or C++ file type
-
- private List symbols;
- private List includes;
- private List quoteIncludes;
-
- /**
- * @param cppFileType2
- */
- public CCommandDSC(boolean cppFileType) {
- compilerCommand = new ArrayList();
- discovered = false;
- this.cppFileType = cppFileType;
-
- symbols = new ArrayList();
- includes = new ArrayList();
- quoteIncludes = new ArrayList();
- }
-
- public boolean appliesToCPPFileType() {
- return cppFileType;
- }
-
- public void addSCOption(KVStringPair option) {
- compilerCommand.add(option);
- }
-
- /**
- * @return
- */
- public Integer getCommandIdAsInteger() {
- return new Integer(getCommandId());
- }
- /**
- * @return Returns the commandId.
- */
- public int getCommandId() {
- return commandId;
- }
- /**
- * @param commandId The commandId to set.
- */
- public void setCommandId(int commandId) {
- this.commandId = commandId;
- }
-
- public String toString() {
- String commandAsString = new String();
- for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
- KVStringPair optionPair = (KVStringPair)i.next();
- commandAsString += optionPair.getKey() + SINGLE_SPACE +
- optionPair.getValue() + SINGLE_SPACE;
- }
- return commandAsString.trim();
- }
-
- public int getId() {
- return commandId;
- }
-
- /**
- * Returns a command where -imacros and -include options have been removed
- * @return
- */
- public String getSCDRunnableCommand(boolean quoteIncludePaths) {
- String commandAsString = new String();
- for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
- KVStringPair optionPair = (KVStringPair)i.next();
- if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) {
- commandAsString += optionPair.getValue() + SINGLE_SPACE;
- }
- else {
- // skip -include and -imacros options
- if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) ||
- optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString()))
- continue;
- if (quoteIncludePaths) {
- if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString())) {
- commandAsString += optionPair.getKey() + SINGLE_SPACE +
- "\"" + optionPair.getValue() + "\"" + SINGLE_SPACE; //$NON-NLS-1$//$NON-NLS-2$
- }
- }
- else {
- commandAsString += optionPair.getKey() + SINGLE_SPACE +
- optionPair.getValue() + SINGLE_SPACE;
- }
- }
- }
- return commandAsString.trim();
- }
-
- /**
- * @return list of strings
- */
- public List getImacrosFile() {
- List imacrosFiles = new ArrayList();
- for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
- KVStringPair optionPair = (KVStringPair)i.next();
- if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString())) {
- imacrosFiles.add(optionPair.getValue());
- }
- }
- return imacrosFiles;
- }
-
- /**
- * @return list of strings
- */
- public List getIncludeFile() {
- List includeFiles = new ArrayList();
- for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
- KVStringPair optionPair = (KVStringPair)i.next();
- if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) {
- includeFiles.add(optionPair.getValue());
- }
- }
- return includeFiles;
- }
-
-// public List getFilesList() {
-// return files;
-// }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object arg0) {
- if (arg0 != null && arg0.getClass().equals(this.getClass())) {
- CCommandDSC other = (CCommandDSC)arg0;
- return (compilerCommand.equals(other.compilerCommand) &&
- cppFileType == other.cppFileType);
- }
- return false;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return compilerCommand.hashCode();
- }
-
- /**
- * @return Returns the includes as strings.
- */
- public List getIncludes() {
- return includes;
- }
- /**
- * @param includes The includes to set.
- */
- public void setIncludes(List includes) {
- this.includes = includes;
- }
- /**
- * @return Returns the quote include paths as strings (for #include "...")
- */
- public List getQuoteIncludes() {
- return quoteIncludes;
- }
- /**
- * @param includes. Quote include paths (for #include "...")
- */
- public void setQuoteIncludes(List includes) {
- quoteIncludes = includes;
- }
- /**
- * @return Returns the symbols.
- */
- public List getSymbols() {
- return symbols;
- }
- /**
- * @param symbols The symbols to set.
- */
- public void setSymbols(List symbols) {
- this.symbols = symbols;
- }
- /**
- * @return Returns the discovered.
- */
- public boolean isDiscovered() {
- return discovered;
- }
- /**
- * @param discovered The discovered to set.
- */
- public void setDiscovered(boolean discovered) {
- this.discovered = discovered;
- }
-
- /**
- * @param cmdElem
- */
- public void serialize(Element cmdElem) {
- Document doc = cmdElem.getOwnerDocument();
- // serialize the command
- Element cmdDescElem = doc.createElement(CMD_DESCRIPTION_ELEM);
- for (Iterator i = compilerCommand.iterator(); i.hasNext(); ) {
- Element optionElem = doc.createElement(OPTION_ELEM);
- KVStringPair option = (KVStringPair) i.next();
- optionElem.setAttribute(KEY_ATTR, option.getKey());
- optionElem.setAttribute(VALUE_ATTR, option.getValue());
- cmdDescElem.appendChild(optionElem);
- }
- cmdElem.appendChild(cmdDescElem);
- // serialize includes and symbols
- Element siElem = doc.createElement(CMD_SI_ELEM);
- for (Iterator j = quoteIncludes.iterator(); j.hasNext(); ) {
- Element siItem = doc.createElement(SI_ITEM_ELEM);
- siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$
- siItem.setAttribute(VALUE_ATTR, (String) j.next());
- siItem.setAttribute(QUOTE_INCLUDE_ATTR, "true"); //$NON-NLS-1$
- siElem.appendChild(siItem);
- }
- for (Iterator j = includes.iterator(); j.hasNext(); ) {
- Element siItem = doc.createElement(SI_ITEM_ELEM);
- siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$
- siItem.setAttribute(VALUE_ATTR, (String) j.next());
- siElem.appendChild(siItem);
- }
- for (Iterator j = symbols.iterator(); j.hasNext(); ) {
- Element siItem = doc.createElement(SI_ITEM_ELEM);
- siItem.setAttribute(KIND_ATTR, "SYMBOL_DEFINITION"); //$NON-NLS-1$
- siItem.setAttribute(VALUE_ATTR, (String) j.next());
- siElem.appendChild(siItem);
- }
- cmdElem.appendChild(siElem);
- }
-
- /**
- * @param cmdElem
- */
- public void deserialize(Element cmdElem) {
- // read command options
- NodeList descList = cmdElem.getElementsByTagName(CMD_DESCRIPTION_ELEM);
- if (descList.getLength() > 0) {
- Element descElem = (Element) descList.item(0);
- NodeList optionList = descElem.getElementsByTagName(OPTION_ELEM);
- for (int i = 0; i < optionList.getLength(); ++i) {
- Element optionElem = (Element) optionList.item(i);
- String key = optionElem.getAttribute(KEY_ATTR);
- String value = optionElem.getAttribute(VALUE_ATTR);
- KVStringPair option = new KVStringPair(key, value);
- addSCOption(option);
- }
- }
- // read associated scanner info
- NodeList siList = cmdElem.getElementsByTagName(CMD_SI_ELEM);
- if (siList.getLength() > 0) {
- Element siElem = (Element) siList.item(0);
- NodeList siItemList = siElem.getElementsByTagName(SI_ITEM_ELEM);
- for (int i = 0; i < siItemList.getLength(); ++i) {
- Element siItemElem = (Element) siItemList.item(i);
- String kind = siItemElem.getAttribute(KIND_ATTR);
- String value = siItemElem.getAttribute(VALUE_ATTR);
- String quote = siItemElem.getAttribute(QUOTE_INCLUDE_ATTR);
- if (kind.equals("INCLUDE_PATH")) { //$NON-NLS-1$
- if (quote.equals("true")) { //$NON-NLS-1$
- quoteIncludes.add(value);
- }
- else {
- includes.add(value);
- }
- }
- else if (kind.equals("SYMBOL_DEFINITION")) { //$NON-NLS-1$
- symbols.add(value);
- }
- }
- setDiscovered(true);
- }
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java
deleted file mode 100644
index 7536e0bea40..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.util;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.IBinaryParser;
-import org.eclipse.cdt.core.ICExtensionReference;
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.SCMarkerGenerator;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.cdt.utils.CygPath;
-import org.eclipse.cdt.utils.ICygwinToolsFactroy;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * Use binary parser's 'cygpath' command to translate cygpaths to absolute paths.
- *
- * @author vhirsl
- */
-public class CygpathTranslator {
- private static final String CYGPATH_ERROR_MESSAGE = "CygpathTranslator.NotAvailableErrorMessage"; //$NON-NLS-1$
- private CygPath cygPath = null;
- private boolean isAvailable = false;
-
- public CygpathTranslator(IProject project) {
- SCMarkerGenerator scMarkerGenerator = new SCMarkerGenerator();
- try {
- ICExtensionReference[] parserRef = CCorePlugin.getDefault().getBinaryParserExtensions(project);
- for (int i = 0; i < parserRef.length; i++) {
- try {
- IBinaryParser parser = (IBinaryParser)parserRef[i].createExtension();
- ICygwinToolsFactroy cygwinToolFactory = (ICygwinToolsFactroy) parser.getAdapter(ICygwinToolsFactroy.class);
- if (cygwinToolFactory != null) {
- cygPath = cygwinToolFactory.getCygPath();
- if (cygPath != null) {
- isAvailable = true;
- break;
- }
- }
- } catch (ClassCastException e) {
- }
- }
- // No CygPath specified in BinaryParser page or not supported.
- // Hoping that cygpath is on the path.
- if (cygPath == null && Platform.getOS().equals(Platform.OS_WIN32)) {
- cygPath = new CygPath("cygpath"); //$NON-NLS-1$
- isAvailable = true;
- }
- }
- catch (CoreException e) {
- }
- catch (IOException e) {
- isAvailable = false;
- scMarkerGenerator = new SCMarkerGenerator();
- scMarkerGenerator.addMarker(project, -1,
- MakeMessages.getString(CYGPATH_ERROR_MESSAGE),
- IMarkerGenerator.SEVERITY_WARNING, null);
- }
- if (isAvailable) {
- // remove problem markers
- scMarkerGenerator.removeMarker(project, -1,
- MakeMessages.getString(CYGPATH_ERROR_MESSAGE),
- IMarkerGenerator.SEVERITY_WARNING, null);
- }
- }
-
- /**
- * @param sumIncludes
- * @return
- */
- public static List translateIncludePaths(IProject project, List sumIncludes) {
- // first check if cygpath translation is needed at all
- boolean translationNeeded = false;
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) {
- String include = (String) i.next();
- if (include.startsWith("/")) { //$NON-NLS-1$
- translationNeeded = true;
- break;
- }
- }
- }
- if (!translationNeeded) {
- return sumIncludes;
- }
-
- CygpathTranslator cygpath = new CygpathTranslator(project);
- if (cygpath.cygPath == null) return sumIncludes;
-
- List translatedIncludePaths = new ArrayList();
- for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) {
- String includePath = (String) i.next();
- IPath realPath = new Path(includePath);
- if (realPath.toFile().exists()) {
- translatedIncludePaths.add(includePath);
- }
- else {
- String translatedPath = includePath;
- if (cygpath.isAvailable) {
- try {
- translatedPath = cygpath.cygPath.getFileName(includePath);
- }
- catch (IOException e) {
- TraceUtil.outputError("CygpathTranslator unable to translate path: ", includePath); //$NON-NLS-1$
- }
- }
- if (!translatedPath.equals(includePath)) {
- // Check if the translated path exists
- IPath transPath = new Path(translatedPath);
- if (transPath.toFile().exists()) {
- translatedIncludePaths.add(transPath.toPortableString());
- }
- else {
- // TODO VMIR for now add even if it does not exist
- translatedIncludePaths.add(translatedPath);
- }
- }
- else {
- // TODO VMIR for now add even if it does not exist
- translatedIncludePaths.add(translatedPath);
- }
- }
- }
- cygpath.cygPath.dispose();
- return translatedIncludePaths;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java
deleted file mode 100644
index 26f45e381cf..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVList.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Key - Value (List) pair
- *
- * @author vhirsl
- */
-public class KVList {
- String key;
- List value;
-
- public KVList(String key) {
- this.key = key;
- this.value = new ArrayList();
- }
-
- /**
- * List must not be null
.
- */
- public KVList(String key, List value) {
- this.key = key;
- this.value = value;
- }
-
- String getKey() {
- return key;
- }
-
- List getValue() {
- return value;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java
deleted file mode 100644
index 4df20b5d79e..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.util;
-
-/**
- * Key - Value String Pair
- *
- * @author vhirsl
- */
-public class KVStringPair {
- private String key;
- private String value;
-
- /**
- *
- */
- public KVStringPair(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getValue() {
- return value;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object arg0) {
- if (arg0 != null && arg0.getClass().equals(this.getClass())) {
- KVStringPair arg = (KVStringPair) arg0;
- return (key.equals(arg.getKey()) && value.equals(arg.getValue()));
- }
- return false;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return 17 * key.hashCode() + value.hashCode();
- }
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return key + " -> " + value; //$NON-NLS-1$
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java
deleted file mode 100644
index 74eef6af315..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.util;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * Log writer utility
- *
- * @author vhirsl
- */
-public class LogWriter {
- protected File logFile = null;
- protected Writer log = null;
- protected boolean newSession = true;
-
- protected static final String SESSION = "*** SESSION";//$NON-NLS-1$
- protected static final String ENTRY = "ENTRY";//$NON-NLS-1$
- protected static final String SUBENTRY = "SUBENTRY";//$NON-NLS-1$
- protected static final String MESSAGE = "MESSAGE";//$NON-NLS-1$
- protected static final String STACK = "STACK";//$NON-NLS-1$
-
- protected static final String LINE_SEPARATOR;
- protected static final String TAB_STRING = "\t";//$NON-NLS-1$
- protected static final long MAXLOG_SIZE = 10000000;
- static {
- String s = System.getProperty("line.separator");//$NON-NLS-1$
- LINE_SEPARATOR = s == null ? "\n" : s;//$NON-NLS-1$
- }
-
- /**
- *
- */
- public LogWriter(File log) {
- this.logFile = log;
- if(log.length() > MAXLOG_SIZE){
- log.delete();
- }
- openLogFile();
- }
-
- protected void closeLogFile() throws IOException {
- try {
- if (log != null) {
- log.flush();
- log.close();
- }
- } finally {
- log = null;
- }
- }
-
- protected void openLogFile() {
- try {
- log = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(logFile.getAbsolutePath(), true), "UTF-8"));//$NON-NLS-1$
- if (newSession) {
- writeHeader();
- newSession = false;
- }
- } catch (IOException e) {
- // there was a problem opening the log file so log to the console
- //log = logForStream(System.err);
- }
- }
- protected void writeHeader() throws IOException {
- writeln();
- write(SESSION);
- writeSpace();
- String date = getDate();
- write(date);
- writeSpace();
- for (int i=SESSION.length()+date.length(); i<78; i++) {
- write("-");//$NON-NLS-1$
- }
- writeln();
- }
-
- protected String getDate() {
- try {
- DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss.SS"); //$NON-NLS-1$
- return formatter.format(new Date());
- } catch (Exception e) {
- // If there were problems writing out the date, ignore and
- // continue since that shouldn't stop us from losing the rest
- // of the information
- }
- return Long.toString(System.currentTimeMillis());
- }
-
- /**
- * Writes the given string to the log, followed by the line terminator string.
- */
- public void writeln(String s) throws IOException {
- write(s);
- writeln();
- }
- /**
- * Shuts down the log.
- */
- public synchronized void shutdown() {
- try {
- if (logFile != null) {
- closeLogFile();
- logFile = null;
- } else {
- if (log != null) {
- Writer old = log;
- log = null;
- old.flush();
- old.close();
- }
- }
- } catch (Exception e) {
- //we've shutdown the log, so not much else we can do!
- e.printStackTrace();
- }
- }
-
- protected void write(Throwable throwable) throws IOException {
- if (throwable == null)
- return;
- write(STACK);
- writeSpace();
- boolean isCoreException = throwable instanceof CoreException;
- if (isCoreException)
- writeln("1");//$NON-NLS-1$
- else
- writeln("0");//$NON-NLS-1$
- throwable.printStackTrace(new PrintWriter(log));
- if (isCoreException) {
- CoreException e = (CoreException) throwable;
- write(e.getStatus(), 0);
- }
- }
-
- public synchronized void log(IStatus status){
- try {
- this.write(status, 0);
- } catch (IOException e) {
- }
- }
- protected void write(IStatus status, int depth) throws IOException {
- if (depth == 0) {
- write(ENTRY);
- } else {
- write(SUBENTRY);
- writeSpace();
- write(Integer.toString(depth));
- }
- writeSpace();
- write(status.getPlugin());
- writeSpace();
- write(Integer.toString(status.getSeverity()));
- writeSpace();
- write(Integer.toString(status.getCode()));
- writeSpace();
- write(getDate());
- writeln();
-
- write(MESSAGE);
- writeSpace();
- writeln(status.getMessage());
-
- //Took out the stack dump - too much space
- //write(status.getException());
-
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- write(children[i], depth+1);
- }
- }
- }
-
- protected void writeln() throws IOException {
- write(LINE_SEPARATOR);
- }
- protected void write(String message) throws IOException {
- if (message != null)
- log.write(message);
- }
- protected void writeSpace() throws IOException {
- write(" ");//$NON-NLS-1$
- }
-
- public synchronized void flushLog(){
- try {
- log.flush();
- } catch (IOException e) {}
- }
-
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java
deleted file mode 100644
index 376efa68ef3..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.util;
-
-/**
- * Enumeration class for scanner configuration affecting command line options
- *
- * @author vhirsl
- */
-public final class SCDOptionsEnum {
-
- public static final SCDOptionsEnum COMMAND = new SCDOptionsEnum(0); // gcc or similar command
- public static final int MIN = 1;
- public static final SCDOptionsEnum DEFINE = new SCDOptionsEnum(1); // -D name
- public static final SCDOptionsEnum UNDEFINE = new SCDOptionsEnum(2); // -U name
- public static final SCDOptionsEnum IDASH = new SCDOptionsEnum(3); // -I-
- public static final SCDOptionsEnum INCLUDE = new SCDOptionsEnum(4); // -I dir
- public static final SCDOptionsEnum NOSTDINC = new SCDOptionsEnum(5); // -nostdinc
- public static final SCDOptionsEnum NOSTDINCPP = new SCDOptionsEnum(6); // -nostdinc++
- public static final SCDOptionsEnum INCLUDE_FILE = new SCDOptionsEnum(7); // -include file
- public static final SCDOptionsEnum IMACROS_FILE = new SCDOptionsEnum(8); // -imacros file
- public static final SCDOptionsEnum IDIRAFTER = new SCDOptionsEnum(9); // -idirafter dir
- public static final SCDOptionsEnum ISYSTEM = new SCDOptionsEnum(10); // -isystem dir
- public static final SCDOptionsEnum IPREFIX = new SCDOptionsEnum(11); // -iprefix prefix
- public static final SCDOptionsEnum IWITHPREFIX = new SCDOptionsEnum(12); // -iwithprefix dir
- public static final SCDOptionsEnum IWITHPREFIXBEFORE = new SCDOptionsEnum(13); // -iwithprefixbefore dir
- public static final int MAX = 13;
-
- private static final String[] SCDOPTION_STRING_VALS = {
- "cc", //$NON-NLS-1$
- "-D", //$NON-NLS-1$
- "-U", //$NON-NLS-1$
- "-I-", //$NON-NLS-1$
- "-I", //$NON-NLS-1$
- "-nostdinc", //$NON-NLS-1$
- "-nostdinc++", //$NON-NLS-1$
- "-include", //$NON-NLS-1$
- "-imacros", //$NON-NLS-1$
- "-idirafter", //$NON-NLS-1$
- "-isystem", //$NON-NLS-1$
- "-iprefix", //$NON-NLS-1$
- "-iwithprefix", //$NON-NLS-1$
- "-iwithprefixbefore" //$NON-NLS-1$
- };
- private static final SCDOptionsEnum SCDOPTIONS[] = {
- COMMAND, DEFINE, UNDEFINE, IDASH, INCLUDE, NOSTDINC, NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE,
- IDIRAFTER, ISYSTEM, IPREFIX, IWITHPREFIX, IWITHPREFIXBEFORE
- };
-
- /**
- *
- */
- private SCDOptionsEnum(int val) {
- this._enum = val;
- }
-
- public int getEnumValue() {
- return _enum;
- }
-
- public static SCDOptionsEnum getSCDOptionsEnum(int val) {
- if (val >= 0 && val <= MAX) {
- return SCDOPTIONS[val];
- }
- return null;
- }
-
- public static SCDOptionsEnum getSCDOptionsEnum(String desc) {
- for (int i = 0; i <= MAX; ++i) {
- if (desc.equals(SCDOPTION_STRING_VALS[i])) {
- return SCDOPTIONS[i];
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object arg0) {
- if (arg0 == null) return false;
- if (arg0 == this) return true;
- if (arg0 instanceof SCDOptionsEnum) return (_enum == ((SCDOptionsEnum)arg0)._enum);
- return false;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return _enum*17 + 11;
- }
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return SCDOPTION_STRING_VALS[_enum];
- }
-
- private final int _enum;
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java
deleted file mode 100644
index 0066722a245..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.make.internal.core.scannerconfig.util;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * Represents a symbol definition with possible multiple values
- * example:
- * LOG_LEVEL
- * LOG_LEVEL = 2
- * LOG_LEVEL = LOG_BASE + 1
- * @author vhirsl
- */
-public class SymbolEntry {
- private static final String UNSPECIFIED_VALUE = "1"; //$NON-NLS-1$
- private String name;
- private Map values; // Values can be either in the active (selected) group or in the removed group
-
-// public SymbolEntry(String name) {
-// this.name = name;
-// }
-
- public SymbolEntry(String name, String value) {
- this(name, value, true);
- }
- public SymbolEntry(String name, String value, boolean active) {
- this.name = name;
- if (values == null) {
- values = new LinkedHashMap(1);
- }
- values.put(value, Boolean.valueOf(active));
- }
- public SymbolEntry(SymbolEntry se) {
- name = se.name;
- // deep copy
- values = new LinkedHashMap(se.values.size());
- for (Iterator i = se.values.keySet().iterator(); i.hasNext(); ) {
- String key = (String) i.next();
- Boolean value = (Boolean) se.values.get(key);
- values.put(key, Boolean.valueOf(value.booleanValue()));
- }
- }
-
- public boolean add(String value) {
- return add(value, true);
- }
- public boolean add(String value, boolean active) {
- boolean rc = false;
- if (!values.containsKey(value)) {
- values.put(value, Boolean.valueOf(active));
- rc = true;
- }
- return rc;
- }
- public void replace(String value, boolean active) {
- values.put(value, Boolean.valueOf(active));
- }
-
-// private void addAll(SymbolEntry se) {
-// values.putAll(se.values);
-// }
-
- public void remove(String value) {
- values.remove(value);
- }
- public void removeAll() {
- values = null;
- }
-
- public List getActive() {
- return get(true, true, true);
- }
- public List getActiveRaw() {
- return get(false, true, true);
- }
-
- public List getRemoved() {
- return get(true, true, false);
- }
- public List getRemovedRaw() {
- return get(false, true, false);
- }
-
- public List getAll() {
- return get(true, false, true /*don't care*/);
- }
- public List getAllRaw() {
- return get(false, false, true /*don't care*/);
- }
-
- /**
- * Utility function to retrieve values as a set.
- *
- * @param format - false = raw
- * @param subset - false = all
- * @param active - false = removed
- * @return List
- */
- private List get(boolean format, boolean subset, boolean active) {
- List rv = new ArrayList(values.size());
- for (Iterator i = values.keySet().iterator(); i.hasNext(); ) {
- String val = (String) i.next();
- if (subset && ((Boolean) values.get(val)).booleanValue() != active)
- continue;
- if (format) {
- rv.add(name + "=" + (val == null ? UNSPECIFIED_VALUE : val));//$NON-NLS-1$
- }
- else {
- rv.add(name + (val == null ? "" : "=" + val));//$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return rv;
- }
- /**
- * Returns only value part of all active entries
- * @return List
- */
- public List getValuesOnly(boolean active) {
- List rv = new ArrayList(values.size());
- for (Iterator i = values.keySet().iterator(); i.hasNext(); ) {
- String val = (String) i.next();
- if (((Boolean) values.get(val)).booleanValue() == active) {
- rv.add(val == null ? UNSPECIFIED_VALUE : val);
- }
- }
- return rv;
- }
-
- public int numberOfValues() {
- return values.size();
- }
-
- public String toString() {
- StringBuffer buffer = new StringBuffer(name);
- buffer.append(':');
- for (Iterator i = values.keySet().iterator(); i.hasNext(); ) {
- String val = (String) i.next();
- buffer.append('\t');
- buffer.append((val == null) ? "null" : val);//$NON-NLS-1$
- if (((Boolean) values.get(val)).booleanValue() == true) {
- buffer.append("(active)");//$NON-NLS-1$
- }
- buffer.append('\n');
- }
- return buffer.toString();
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java
deleted file mode 100644
index 5307335a72f..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig.util;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-
-/**
- * Tracebility related utility functions
- *
- * @author vhirsl
- */
-public class TraceUtil {
- public static final String EOL = System.getProperty("line.separator"); //$NON-NLS-1$
- public static boolean SCANNER_CONFIG = false;
- private static LogWriter logger = null;
-
- static {
- logger = new LogWriter(ManagedBuilderCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$
- }
- /* (non-Javadoc)
- * @see java.lang.Object#finalize()
- */
- protected void finalize() throws Throwable {
- logger.shutdown();
- super.finalize();
- }
-
- public static boolean isTracing() {
- return SCANNER_CONFIG;
- }
-
- public static void outputTrace(String prefix, String msg, String postfix) {
- if (isTracing()) {
- //System.out.println();
- System.out.println(prefix + ' ' + msg + ' ' + postfix);
- }
- }
-
- /**
- * For traces of type:
- * Title:
- * Subtitle1:
- * item1[0]
- * item1[1]
- * ...
- * Subtitle2:
- * item2[0]
- * item2[1]
- * ...
- * @param title
- * @param col1
- * @param col2
- */
- public static void outputTrace(String title, String subtitle1, List item1, List item1new, String subtitle2, List item2) {
- if (isTracing()) {
- //System.out.println();
- System.out.println(title);
- final String prefix = " "; //$NON-NLS-1$
- final String doublePrefix = " "; //$NON-NLS-1$
- System.out.println(prefix + subtitle1 + " (" + item1.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$
- int count = 0;
- for (Iterator i = item1.iterator(), j = item1new.iterator(); i.hasNext(); ) {
- System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" +(String)i.next() + (j.hasNext()?"\' -> \'" + (String)j.next():"") + '\''); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- System.out.println(prefix + subtitle2 + " (" + item2.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$
- count = 0;
- for (Iterator i = item2.iterator(); i.hasNext(); ) {
- System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" + (String)i.next() + '\''); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * @param string
- * @param line
- */
- public static void outputError(String string, String line) {
- if (isTracing()) {
- System.out.println();
- System.out.println("Error: " + string + line); //$NON-NLS-1$
- }
- }
-
- /**
- * @param title
- * @param subtitlePrefix
- * @param subtitlePostfix
- * @param map - el grande map
- */
- public static void metricsTrace(String title, String subtitlePrefix, String subtitlePostfix, Map directoryCommandListMap) {
- try {
- logger.writeln();
- logger.writeln(" *** NEW METRICS TRACE ***"); //$NON-NLS-1$
- logger.writeln();
- for (Iterator k = directoryCommandListMap.keySet().iterator(); k.hasNext(); ) {
- String dir = (String) k.next();
- logger.writeln(title + dir + ":"); //$NON-NLS-1$
- List directoryCommandList = (List) directoryCommandListMap.get(dir);
- if (directoryCommandList == null) {
- logger.writeln(" --- empty ---" + EOL); //$NON-NLS-1$
- return;
- }
- for (Iterator i = directoryCommandList.iterator(); i.hasNext(); ) {
- Map command21FileListMap = (Map) i.next();
- String[] commands = (String[]) command21FileListMap.keySet().toArray(new String[1]);
- logger.writeln(" " + subtitlePrefix + commands[0] + subtitlePostfix); //$NON-NLS-1$
- List fileList = (List) command21FileListMap.get(commands[0]);
- for (Iterator j = fileList.iterator(); j.hasNext(); ) {
- String fileName = (String) j.next();
- logger.writeln(" " + fileName); //$NON-NLS-1$
- }
- }
- }
- logger.flushLog();
- }
- catch (IOException e) {}
- }
-
- /**
- * @param title
- * @param workingDirsN
- * @param commandsN
- * @param filesN
- */
- public static void summaryTrace(String title, int workingDirsN, int commandsN, int filesN) {
- try {
- logger.writeln();
- logger.writeln(" *** METRICS SUMMARY ***"); //$NON-NLS-1$
- logger.writeln();
- logger.writeln(title);
- logger.writeln(" Number of directories visited: " + Integer.toString(workingDirsN)); //$NON-NLS-1$
- logger.writeln(" Number of generic commands: " + Integer.toString(commandsN)); //$NON-NLS-1$
- logger.writeln(" Number of compiled files: " + Integer.toString(filesN)); //$NON-NLS-1$
- logger.flushLog();
- }
- catch (IOException e) {}
- }
-
- /**
- * @param trace : String
- */
- public static void metricsTrace(String trace) {
- try {
- logger.writeln();
- logger.writeln(" *** NEW METRICS TRACE 2 ***"); //$NON-NLS-1$
- logger.writeln();
- logger.writeln(trace);
- logger.flushLog();
- }
- catch (IOException e) {}
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
deleted file mode 100644
index 601f57fd98a..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CommandLauncher;
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.cdt.newmake.internal.core.StreamMonitor;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-/**
- * New default external scanner info provider of type 'run'
- *
- * @author vhirsl
- */
-public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
- private static final String EXTERNAL_SI_PROVIDER_ERROR = "ExternalScannerInfoProvider.Provider_Error"; //$NON-NLS-1$
- private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
- private static final String LANG_ENV_VAR = "LANG"; //$NON-NLS-1$
-
- protected IResource resource;
- protected String providerId;
- protected IScannerConfigBuilderInfo2 buildInfo;
- protected IScannerInfoCollector collector;
- // To be initialized by a subclass
- protected IPath fWorkingDirectory;
- protected IPath fCompileCommand;
- protected String[] fCompileArguments;
-
- private SCMarkerGenerator markerGenerator = new SCMarkerGenerator();
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider#invokeProvider(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.resources.IResource, java.lang.String, org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2)
- */
- public boolean invokeProvider(IProgressMonitor monitor,
- IResource resource,
- String providerId,
- IScannerConfigBuilderInfo2 buildInfo,
- IScannerInfoCollector collector) {
- // initialize fields
- this.resource = resource;
- this.providerId = providerId;
- this.buildInfo = buildInfo;
- this.collector = collector;
-
- IProject currentProject = resource.getProject();
- // call a subclass to initialize protected fields
- if (!initialize()) {
- return false;
- }
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 100); //$NON-NLS-1$
-
- try {
- IConsole console = CCorePlugin.getDefault().getConsole(EXTERNAL_SI_PROVIDER_CONSOLE_ID);
- console.start(currentProject);
- OutputStream cos = console.getOutputStream();
-
- // Before launching give visual cues via the monitor
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs")); //$NON-NLS-1$
-
- String errMsg = null;
- CommandLauncher launcher = new CommandLauncher();
- // Print the command for visual interaction.
- launcher.showCommand(true);
-
- // add additional arguments
- // subclass can change default behavior
- String[] compileArguments = prepareArguments(
- buildInfo.isUseDefaultProviderCommand(providerId));
-
- String ca = coligate(compileArguments);
-
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Invoking_Command") //$NON-NLS-1$
- + fCompileCommand.toString() + ca);
- cos = new StreamMonitor(new SubProgressMonitor(monitor, 70), cos, 100);
-
- ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getESIProviderOutputSniffer(
- cos, cos, currentProject, providerId, buildInfo, collector, markerGenerator);
- OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream());
- OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream());
- TraceUtil.outputTrace("Default provider is executing command:", fCompileCommand.toString() + ca, ""); //$NON-NLS-1$ //$NON-NLS-2$
- Process p = launcher.execute(fCompileCommand, compileArguments, setEnvironment(launcher), fWorkingDirectory);
- if (p != null) {
- try {
- // Close the input of the Process explicitely.
- // We will never write to it.
- p.getOutputStream().close();
- } catch (IOException e) {
- }
- if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0)) != CommandLauncher.OK) {
- errMsg = launcher.getErrorMessage();
- }
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Parsing_Output")); //$NON-NLS-1$
- }
- else {
- errMsg = launcher.getErrorMessage();
- }
-
- if (errMsg != null) {
- String errorDesc = MakeMessages.getFormattedString(EXTERNAL_SI_PROVIDER_ERROR,
- fCompileCommand.toString() + ca);
- markerGenerator.addMarker(currentProject, -1, errorDesc, IMarkerGenerator.SEVERITY_WARNING, null);
- }
-
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Creating_Markers")); //$NON-NLS-1$
- consoleOut.close();
- consoleErr.close();
- cos.close();
- }
- catch (Exception e) {
- CCorePlugin.log(e);
- }
- finally {
- monitor.done();
- }
- return true;
- }
-
-
- /**
- * Initialization of protected fields.
- * Subclasses are most likely to override default implementation.
- *
- * @param currentProject
- * @return boolean
- */
- protected boolean initialize() {
-
- IProject currProject = resource.getProject();
- IConfiguration cfg = null;
- IBuilder builder = null;
- if(collector instanceof IScannerInfoCollector3){
- InfoContext context = ((IScannerInfoCollector3)collector).getContext();
- if(context != null)
- cfg = context.getConfiguration();
- }
-
- if(cfg == null){
- cfg = ScannerConfigUtil.getActiveConfiguration(currProject);
- }
-
- if(cfg != null){
- builder = cfg.getBuilder();
- }
-
- //fWorkingDirectory = resource.getProject().getLocation();
- if(builder != null){
- IPath fullPath = ManagedBuildManager.getBuildFullPath(cfg, builder);
- if(fullPath != null){
- IResource rc = ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath);
- if(rc != null && rc.getType() != IResource.FILE){
- fWorkingDirectory = rc.getLocation();
- }
- }
- }
- if(fWorkingDirectory == null)
- fWorkingDirectory = currProject.getLocation();
-
- fCompileCommand = new Path(buildInfo.getProviderRunCommand(providerId));
- fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(buildInfo.getProviderRunArguments(providerId), "\"");//$NON-NLS-1$
- return (fCompileCommand != null);
- }
-
- /**
- * Add additional arguments. For example: tso - target specific options
- * Base class implementation returns compileArguments.
- * Subclasses are most likely to override default implementation.
- *
- * @param isDefaultCommand
- * @param collector
- * @return
- */
- protected String[] prepareArguments(boolean isDefaultCommand) {
- return fCompileArguments;
- }
-
- /**
- * @param array
- * @return
- */
- private String coligate(String[] array) {
- StringBuffer sb = new StringBuffer(128);
- for (int i = 0; i < array.length; ++i) {
- sb.append(' ');
- sb.append(array[i]);
- }
- String ca = sb.toString();
- return ca;
- }
-
- /**
- * @param launcher
- * @return
- */
- protected String[] setEnvironment(CommandLauncher launcher) {
- // Set the environmennt, some scripts may need the CWD var to be set.
- IConfiguration cfg = null;
- if(collector instanceof IScannerInfoCollector3){
- InfoContext context = ((IScannerInfoCollector3)collector).getContext();
- if(context != null){
- cfg = context.getConfiguration();
- }
- }
- String[] env = null;
- if(cfg != null){
- IEnvironmentVariable[] vars = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg, true);
- List list = new ArrayList(vars.length);
- for(int i = 0; i < vars.length; i++){
- String var = vars[i].getName();
- if(var != null && (var = var.trim()).length() != 0){
- String val = vars[i].getValue();
- if(val != null && (val = val.trim()).length() != 0){
- var = var + "=" + val; //$NON-NLS-1$
- }
- list.add(var);
- }
- }
- env = (String[])list.toArray(new String[list.size()]);
- } else {
- Properties props = launcher.getEnvironment();
- props.put("CWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
- props.put("PWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
- // On POSIX (Linux, UNIX) systems reset LANG variable to English with UTF-8 encoding
- // since GNU compilers can handle only UTF-8 characters. English language is chosen
- // beacuse GNU compilers inconsistently handle different locales when generating
- // output of the 'gcc -v' command. Include paths with locale characters will be
- // handled properly regardless of the language as long as the encoding is set to UTF-8.
- if (props.containsKey(LANG_ENV_VAR)) {
- props.put(LANG_ENV_VAR, "en_US.UTF-8"); //$NON-NLS-1$
- }
-// String[] env = null;
- ArrayList envList = new ArrayList();
- Enumeration names = props.propertyNames();
- if (names != null) {
- while (names.hasMoreElements()) {
- String key = (String) names.nextElement();
- envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
- }
- env = (String[]) envList.toArray(new String[envList.size()]);
- }
- }
- return env;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java
deleted file mode 100644
index 0b25b732203..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * New default external scanner info provider of type 'open'
- *
- * @author vhirsl
- */
-public class DefaultSIFileReader implements IExternalScannerInfoProvider {
- private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
-
- private long fileSize = 0;
-
- private SCMarkerGenerator markerGenerator = new SCMarkerGenerator();
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider#invokeProvider(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.resources.IResource, java.lang.String, org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2)
- */
- public boolean invokeProvider(IProgressMonitor monitor,
- IResource resource,
- String providerId,
- IScannerConfigBuilderInfo2 buildInfo,
- IScannerInfoCollector collector) {
- boolean rc = false;
- IProject project = resource.getProject();
- // input
- BufferedReader reader = getStreamReader(buildInfo.getBuildOutputFilePath());
- if (reader == null)
- return rc;
- // output
- IConsole console = CCorePlugin.getDefault().getConsole(EXTERNAL_SI_PROVIDER_CONSOLE_ID);
- console.start(project);
- OutputStream ostream;
- try {
- ostream = console.getOutputStream();
- }
- catch (CoreException e) {
- ostream = null;
- }
-
- IConfiguration cfg = null;
- IBuilder builder = null;
- InfoContext context = null;
- if(collector instanceof IScannerInfoCollector3){
- context = ((IScannerInfoCollector3)collector).getContext();
- if(context != null)
- cfg = context.getConfiguration();
- }
-
- if(cfg == null){
- cfg = ScannerConfigUtil.getActiveConfiguration(project);
- }
-
- if(cfg != null){
- builder = cfg.getBuilder();
- }
-
- // get build location
- IPath buildDirectory;
- if(builder != null)
- buildDirectory = ManagedBuildManager.getBuildLocation(cfg, builder);
- else
- buildDirectory = project.getLocation();
-
- ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.
- getMakeBuilderOutputSniffer(ostream, null, cfg, context, buildDirectory, buildInfo, markerGenerator, collector);
- if (sniffer != null) {
- ostream = (sniffer == null ? null : sniffer.getOutputStream());
- }
-
- rc = readFileToOutputStream(monitor, reader, ostream);
-
- return rc;
- }
-
- /**
- * @param inputFileName
- * @return
- */
- private BufferedReader getStreamReader(String inputFileName) {
- BufferedReader reader = null;
- try {
- fileSize = new File(inputFileName).length();
- reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFileName)));
- } catch (FileNotFoundException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- return reader;
- }
-
- /**
- * Precondition: Neither input nor output are null
- * @param monitor
- * @return
- */
- private boolean readFileToOutputStream(IProgressMonitor monitor, BufferedReader reader, OutputStream ostream) {
- final String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
- monitor.beginTask("Reading build output ...", (int)((fileSize == 0) ? 10000 : fileSize)); //$NON-NLS-1$
- // check if build output file exists
- String line;
- try {
- while ((line = reader.readLine()) != null) {
- if (monitor.isCanceled()) {
- return false;
- }
-
- line += lineSeparator;
- byte[] bytes = line.getBytes();
- ostream.write(bytes);
- monitor.worked(bytes.length);
- }
- } catch (IOException e) {
- ManagedBuilderCorePlugin.log(e);
- } finally {
- try {
- ostream.flush();
- } catch (IOException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- try {
- ostream.close();
- } catch (IOException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
- monitor.done();
- return true;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java
deleted file mode 100644
index daeb45aced6..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/GCCSpecsRunSIProvider.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.CCProjectNature;
-import org.eclipse.cdt.core.CProjectNature;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerConfigUtil;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Runs a command to retrieve compiler intrinsic scanner info from 'specs' file.
- *
- * @author vhirsl
- */
-public class GCCSpecsRunSIProvider extends DefaultRunSIProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#initialize()
- */
- protected boolean initialize() {
- boolean rc = super.initialize();
-
- if (rc) {
- String targetFile = "dummy"; //$NON-NLS-1$
- IProject project = resource.getProject();
- try {
- if (project.hasNature(CCProjectNature.CC_NATURE_ID)) {
- targetFile = GCCScannerConfigUtil.CPP_SPECS_FILE;
- }
- else if (project.hasNature(CProjectNature.C_NATURE_ID)) {
- targetFile = GCCScannerConfigUtil.C_SPECS_FILE;
- }
- // replace string variables in compile arguments
- // TODO Vmir - use string variable replacement
- for (int i = 0; i < fCompileArguments.length; ++i) {
- fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{plugin_state_location\\}", //$NON-NLS-1$
- ManagedBuilderCorePlugin.getWorkingDirectory().toString());
- fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{specs_file\\}", targetFile); //$NON-NLS-1$
- }
- } catch (CoreException e) {
- //TODO VMIR better error handling
- ManagedBuilderCorePlugin.log(e.getStatus());
- rc = false;
- }
- }
- return rc;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#prepareArguments(boolean)
- */
- protected String[] prepareArguments(boolean isDefaultCommand) {
- List tso = collector.getCollectedScannerInfo(resource.getProject(), ScannerInfoTypes.TARGET_SPECIFIC_OPTION);
- if (tso == null || tso.size() == 0) {
- return fCompileArguments;
- }
-
- String[] rv = null;
- // commandArguments may have multiple arguments; tokenizing
- int nTokens = 0;
- if (fCompileArguments != null && fCompileArguments.length > 0) {
- nTokens = fCompileArguments.length;
- rv = new String[nTokens + tso.size()];
- System.arraycopy(fCompileArguments, 0, rv, 0, nTokens);
- }
- else {
- rv = new String[tso.size()];
- }
- for (int i = 0; i < tso.size(); ++i) {
- rv[nTokens + i] = (String) tso.get(i);
- }
- return rv;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java
deleted file mode 100644
index d960ccafe83..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerFileSICollector.java
+++ /dev/null
@@ -1,843 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation 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:
- * IBM - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredScannerInfoSerializable;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Per file scanner info collector
- *
- * @author vhirsl
- */
-public class PerFileSICollector implements IScannerInfoCollector3, IScannerInfoCollectorCleaner {
- private static final int INCLUDE_PATH = 1;
- private static final int QUOTE_INCLUDE_PATH = 2;
- private static final int INCLUDE_FILE = 3;
- private static final int MACROS_FILE = 4;
-
- public class ScannerInfoData implements IDiscoveredScannerInfoSerializable {
- private Map commandIdToFilesMap; // command id and set of files it applies to
- private Map fileToCommandIdMap; // maps each file to the corresponding command id
- private Map commandIdCommandMap; // map of all commands
-
- public ScannerInfoData() {
- commandIdCommandMap = new LinkedHashMap(); // [commandId, command]
- fileToCommandIdMap = new HashMap(); // [file, commandId]
- commandIdToFilesMap = new HashMap(); // [commandId, set of files]
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#serialize(org.w3c.dom.Element)
- */
- public void serialize(Element collectorElem) {
- Document doc = collectorElem.getOwnerDocument();
-
- List commandIds = new ArrayList(commandIdCommandMap.keySet());
- Collections.sort(commandIds);
- for (Iterator i = commandIds.iterator(); i.hasNext(); ) {
- Integer commandId = (Integer) i.next();
- CCommandDSC command = (CCommandDSC) commandIdCommandMap.get(commandId);
-
- Element cmdElem = doc.createElement(CC_ELEM);
- collectorElem.appendChild(cmdElem);
- cmdElem.setAttribute(ID_ATTR, commandId.toString());
- cmdElem.setAttribute(FILE_TYPE_ATTR, command.appliesToCPPFileType() ? "c++" : "c"); //$NON-NLS-1$ //$NON-NLS-2$
- // write command and scanner info
- command.serialize(cmdElem);
- // write files command applies to
- Element filesElem = doc.createElement(APPLIES_TO_ATTR);
- cmdElem.appendChild(filesElem);
- Set files = (Set) commandIdToFilesMap.get(commandId);
- if (files != null) {
- for (Iterator j = files.iterator(); j.hasNext(); ) {
- Element fileElem = doc.createElement(FILE_ELEM);
- IFile file = (IFile) j.next();
- IPath path = file.getProjectRelativePath();
- fileElem.setAttribute(PATH_ATTR, path.toString());
- filesElem.appendChild(fileElem);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#deserialize(org.w3c.dom.Element)
- */
- public void deserialize(Element collectorElem) {
- isInfoCollected = true;
- for (Node child = collectorElem.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeName().equals(CC_ELEM)) {
- Element cmdElem = (Element) child;
- boolean cppFileType = cmdElem.getAttribute(FILE_TYPE_ATTR).equals("c++"); //$NON-NLS-1$
- CCommandDSC command = new CCommandDSC(cppFileType);
- command.setCommandId(Integer.parseInt(cmdElem.getAttribute(ID_ATTR)));
- // deserialize command
- command.deserialize(cmdElem);
- // get set of files the command applies to
- NodeList appliesList = cmdElem.getElementsByTagName(APPLIES_TO_ATTR);
- if (appliesList.getLength() > 0) {
- Element appliesElem = (Element) appliesList.item(0);
- NodeList fileList = appliesElem.getElementsByTagName(FILE_ELEM);
- for (int i = 0; i < fileList.getLength(); ++i) {
- Element fileElem = (Element) fileList.item(i);
- String fileName = fileElem.getAttribute(PATH_ATTR);
- IFile file = project.getFile(fileName);
- addCompilerCommand(file, command);
- }
- applyFileDeltas();
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore.IDiscoveredScannerInfoSerializable#getCollectorId()
- */
- public String getCollectorId() {
- return COLLECTOR_ID;
- }
-
- }
-
- private static class ProjectScannerInfo {
- IPath[] includePaths;
- IPath[] quoteIncludePaths;
- IPath[] includeFiles;
- IPath[] macrosFiles;
- Map definedSymbols;
- public boolean isEmpty() {
- return (includePaths.length == 0 &&
- quoteIncludePaths.length == 0 &&
- includeFiles.length == 0 &&
- macrosFiles.length == 0 &&
- definedSymbols.size() == 0);
- }
- }
-
- public static final String COLLECTOR_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".PerFileSICollector"; //$NON-NLS-1$
- private static final String CC_ELEM = "compilerCommand"; //$NON-NLS-1$
- private static final String ID_ATTR = "id"; //$NON-NLS-1$
- private static final String FILE_TYPE_ATTR = "fileType"; //$NON-NLS-1$
- private static final String APPLIES_TO_ATTR = "appliesToFiles"; //$NON-NLS-1$
- private static final String FILE_ELEM = "file"; //$NON-NLS-1$
- private static final String PATH_ATTR = "path"; //$NON-NLS-1$
-
- IProject project;
- InfoContext context;
-
- private boolean isInfoCollected;
-
- private ScannerInfoData sid; // scanner info data
- private ProjectScannerInfo psi = null; // sum of all scanner info
-
-// private List siChangedForFileList; // list of files for which scanner info has changed
- private Map siChangedForFileMap; // (file, comandId) map for deltas
- private List siChangedForCommandIdList; // list of command ids for which scanner info has changed
-
- private SortedSet freeCommandIdPool; // sorted set of free command ids
- private int commandIdCounter = 0;
-
- /**
- *
- */
- public PerFileSICollector() {
- sid = new ScannerInfoData();
-
-// siChangedForFileList = new ArrayList();
- siChangedForFileMap = new HashMap();
- siChangedForCommandIdList = new ArrayList();
-
- freeCommandIdPool = new TreeSet();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#setProject(org.eclipse.core.resources.IProject)
- */
- public void setProject(IProject project) {
- this.project = project;
- this.context = ScannerConfigUtil.createContextForProject(project);
- try {
- // deserialize from SI store
- DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, sid);
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
-
-
- public void setContext(InfoContext context) {
- this.context = context;
- this.project = context.getConfiguration().getOwner().getProject();
-
- try {
- // deserialize from SI store
- DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, sid);
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map)
- */
- public synchronized void contributeToScannerConfig(Object resource, Map scannerInfo) {
- // check the resource
- String errorMessage = null;
- if (resource == null) {
- errorMessage = "resource is null";//$NON-NLS-1$
- }
- else if (resource instanceof Integer) {
- addScannerInfo(((Integer)resource), scannerInfo);
- return;
- }
- else if (!(resource instanceof IFile)) {
- errorMessage = "resource is not an IFile";//$NON-NLS-1$
- }
- else if (((IFile) resource).getProject() == null) {
- errorMessage = "project is null";//$NON-NLS-1$
- }
- else if (((IFile) resource).getProject() != project) {
- errorMessage = "wrong project";//$NON-NLS-1$
- }
- if (errorMessage != null) {
- TraceUtil.outputError("PerFileSICollector.contributeToScannerConfig : ", errorMessage); //$NON-NLS-1$
- return;
- }
- IFile file = (IFile) resource;
- isInfoCollected = true;
-
- for (Iterator i = scannerInfo.keySet().iterator(); i.hasNext(); ) {
- ScannerInfoTypes type = (ScannerInfoTypes) i.next();
- if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) {
- List commands = (List) scannerInfo.get(type);
- for (Iterator j = commands.iterator(); j.hasNext(); ) {
- addCompilerCommand(file, (CCommandDSC) j.next());
- }
- }
- else {
- addScannerInfo(type, (List) scannerInfo.get(type));
- }
- }
- }
-
- /**
- * @param commandId
- * @param scannerInfo
- */
- private void addScannerInfo(Integer commandId, Map scannerInfo) {
- CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(commandId);
- if (cmd != null) {
- List siItem = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
- cmd.setSymbols(siItem);
- siItem = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
- cmd.setIncludes(CygpathTranslator.translateIncludePaths(project, siItem));
- siItem = (List) scannerInfo.get(ScannerInfoTypes.QUOTE_INCLUDE_PATHS);
- cmd.setQuoteIncludes(siItem);
-
- cmd.setDiscovered(true);
- }
- }
-
- /**
- * @param file
- * @param object
- */
- void addCompilerCommand(IFile file, CCommandDSC cmd) {
- List existingCommands = new ArrayList(sid.commandIdCommandMap.values());
- int index = existingCommands.indexOf(cmd);
- if (index != -1) {
- cmd = (CCommandDSC) existingCommands.get(index);
- }
- else {
- int commandId = -1;
- if (!freeCommandIdPool.isEmpty()) {
- Integer freeCommandId = (Integer) freeCommandIdPool.first();
- freeCommandIdPool.remove(freeCommandId);
- commandId = freeCommandId.intValue();
- }
- else {
- commandId = ++commandIdCounter;
- }
- cmd.setCommandId(commandId);
- sid.commandIdCommandMap.put(cmd.getCommandIdAsInteger(), cmd);
- }
-
- generateFileDelta(file, cmd);
- }
-
- /**
- * @param file
- * @param cmd
- */
- private void generateFileDelta(IFile file, CCommandDSC cmd) {
- Integer commandId = cmd.getCommandIdAsInteger();
- Integer oldCommandId = (Integer) sid.fileToCommandIdMap.get(file);
-
- if (oldCommandId != null && oldCommandId.equals(commandId)) {
- // already exists; remove form delta
- siChangedForFileMap.remove(file);
- }
- else {
- // new (file, commandId) pair
- siChangedForFileMap.put(file, commandId);
- }
- }
-
- /**
- * @param file
- * @param cmd
- */
- void applyFileDeltas() {
- for (Iterator i = siChangedForFileMap.keySet().iterator(); i.hasNext(); ) {
- IFile file = (IFile) i.next();
- Integer commandId = (Integer) siChangedForFileMap.get(file);
- if (commandId != null) {
-
- // update sid.commandIdToFilesMap
- Set fileSet = (Set) sid.commandIdToFilesMap.get(commandId);
- if (fileSet == null) {
- fileSet = new HashSet();
- sid.commandIdToFilesMap.put(commandId, fileSet);
- }
- if (fileSet.add(file)) {
- // update fileToCommandIdsMap
- boolean change = true;
- Integer oldCommandId = (Integer) sid.fileToCommandIdMap.get(file);
- if (oldCommandId != null) {
- if (oldCommandId.equals(commandId)) {
- change = false;
- }
- else {
- Set oldFileSet = (Set) sid.commandIdToFilesMap.get(oldCommandId);
- oldFileSet.remove(file);
- }
- }
- if (change) {
- sid.fileToCommandIdMap.put(file, commandId);
- // TODO generate change event for this resource
-// IPath path = file.getFullPath();
-// if (!siChangedForFileList.contains(path)) {
-// siChangedForFileList.add(path);
-// }
- }
- }
- }
- }
- generateProjectScannerInfo();
- }
-
- private void generateProjectScannerInfo() {
- psi = new ProjectScannerInfo();
- psi.includePaths = getAllIncludePaths(INCLUDE_PATH);
- psi.quoteIncludePaths = getAllIncludePaths(QUOTE_INCLUDE_PATH);
- psi.includeFiles = getAllIncludePaths(INCLUDE_FILE);
- psi.macrosFiles = getAllIncludePaths(MACROS_FILE);
- psi.definedSymbols = getAllSymbols();
- }
-
- private void removeUnusedCommands() {
- for (Iterator i = sid.commandIdToFilesMap.entrySet().iterator(); i.hasNext(); ) {
- Entry entry = (Entry) i.next();
- Integer cmdId = (Integer) entry.getKey();
- Set fileSet = (Set) entry.getValue();
- if (fileSet.isEmpty()) {
- // return cmdId to the free command id pool
- freeCommandIdPool.add(cmdId);
- }
- }
- for (Iterator i = freeCommandIdPool.iterator(); i.hasNext(); ) {
- Integer cmdId = (Integer) i.next();
- // the command does not have any files associated; remove
- sid.commandIdCommandMap.remove(cmdId);
- sid.commandIdToFilesMap.remove(cmdId);
- }
- while (!freeCommandIdPool.isEmpty()) {
- Integer last = (Integer) freeCommandIdPool.last();
- if (last.intValue() == commandIdCounter) {
- freeCommandIdPool.remove(last);
- --commandIdCounter;
- }
- else break;
- }
- }
-
- /**
- * @param type
- * @param object
- */
- private void addScannerInfo(ScannerInfoTypes type, List delta) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#updateScannerConfiguration(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
-// removeUnusedCommands();
- monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
- if (scannerInfoChanged()) {
- applyFileDeltas();
- removeUnusedCommands();
- monitor.worked(50);
- monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
- try {
- // update scanner configuration
-// MakeCorePlugin.getDefault().getDiscoveryManager().
-// updateDiscoveredInfo(createPathInfoObject(), siChangedForFileList);
- IDiscoveredPathInfo pathInfo = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context);
- if (!(pathInfo instanceof IPerFileDiscoveredPathInfo)) {
- pathInfo = createPathInfoObject();
- }
- ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().
- updateDiscoveredInfo(pathInfo, context, new ArrayList(siChangedForFileMap.keySet()));
- monitor.worked(50);
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
-// siChangedForFileList.clear();
- siChangedForFileMap.clear();
- siChangedForCommandIdList.clear();
-
- monitor.done();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject()
- */
- public IDiscoveredPathInfo createPathInfoObject() {
- return new PerFileDiscoveredPathInfo();
- }
-
- private boolean scannerInfoChanged() {
-// return !siChangedForFileList.isEmpty();
- return !siChangedForFileMap.isEmpty();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
- */
- public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
- List rv = new ArrayList();
- // check the resource
- String errorMessage = null;
- if (resource == null) {
- errorMessage = "resource is null";//$NON-NLS-1$
- }
- else if (!(resource instanceof IResource)) {
- errorMessage = "resource is not an IResource";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() == null) {
- errorMessage = "project is null";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() != project) {
- errorMessage = "wrong project";//$NON-NLS-1$
- }
-
- if (errorMessage != null) {
- TraceUtil.outputError("PerProjectSICollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$
- }
- else if (project.equals(((IResource)resource).getProject())) {
- if (type.equals(ScannerInfoTypes.COMPILER_COMMAND)) {
- for (Iterator i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext(); ) {
- Integer cmdId = (Integer) i.next();
- Set fileSet = (Set) sid.commandIdToFilesMap.get(cmdId);
- if (!fileSet.isEmpty()) {
- rv.add(sid.commandIdCommandMap.get(cmdId));
- }
- }
- }
- else if (type.equals(ScannerInfoTypes.UNDISCOVERED_COMPILER_COMMAND)) {
-// if (!siChangedForFileList.isEmpty()) {
- if (scannerInfoChanged()) {
- if (siChangedForCommandIdList.isEmpty()) {
-// for (Iterator i = siChangedForFileList.iterator(); i.hasNext(); ) {
- for (Iterator i = siChangedForFileMap.keySet().iterator(); i.hasNext(); ) {
-// IPath path = (IPath) i.next();
- IFile file = (IFile) i.next();
- Integer cmdId = (Integer) siChangedForFileMap.get(file);
- if (cmdId != null) {
- if (!siChangedForCommandIdList.contains(cmdId)) {
- siChangedForCommandIdList.add(cmdId);
- }
- }
- }
- }
- Collections.sort(siChangedForCommandIdList);
- for (Iterator i = siChangedForCommandIdList.iterator(); i.hasNext(); ) {
- Integer cmdId = (Integer) i.next();
- CCommandDSC command = (CCommandDSC) sid.commandIdCommandMap.get(cmdId);
- rv.add(command);
- }
- }
- }
- }
- return rv;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllPaths(org.eclipse.core.resources.IResource)
- */
- public void deleteAllPaths(IResource resource) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllSymbols(org.eclipse.core.resources.IResource)
- */
- public void deleteAllSymbols(IResource resource) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deletePath(org.eclipse.core.resources.IResource, java.lang.String)
- */
- public void deletePath(IResource resource, String path) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteSymbol(org.eclipse.core.resources.IResource, java.lang.String)
- */
- public void deleteSymbol(IResource resource, String symbol) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource)
- */
- public void deleteAll(IResource resource) {
- if (resource.equals(project)) {
-// siChangedForFileList = new ArrayList();
- siChangedForFileMap.clear();
- Set changedFiles = sid.fileToCommandIdMap.keySet();
- for (Iterator i = changedFiles.iterator(); i.hasNext(); ) {
- IFile file = (IFile) i.next();
-// IPath path = file.getFullPath();
-// siChangedForFileList.add(path);
- siChangedForFileMap.put(file, null);
- }
-
- sid = new ScannerInfoData();
- psi = null;
-
- commandIdCounter = 0;
- freeCommandIdPool.clear();
- }
- }
-
- /**
- * Per file DPI object
- *
- * @author vhirsl
- */
- public class PerFileDiscoveredPathInfo implements IPerFileDiscoveredPathInfo {
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getProject()
- */
- public IProject getProject() {
- return project;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths()
- */
- public IPath[] getIncludePaths() {
-// return new IPath[0];
- return getAllIncludePaths(INCLUDE_PATH);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols()
- */
- public Map getSymbols() {
-// return new HashMap();
- return getAllSymbols();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludePaths(org.eclipse.core.runtime.IPath)
- */
- public IPath[] getIncludePaths(IPath path) {
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null && cmd.isDiscovered()) {
- return stringListToPathArray(cmd.getIncludes());
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
- return psi.includePaths;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getQuoteIncludePaths(org.eclipse.core.runtime.IPath)
- */
- public IPath[] getQuoteIncludePaths(IPath path) {
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null && cmd.isDiscovered()) {
- return stringListToPathArray(cmd.getQuoteIncludes());
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
- return psi.quoteIncludePaths;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getSymbols(org.eclipse.core.runtime.IPath)
- */
- public Map getSymbols(IPath path) {
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null && cmd.isDiscovered()) {
- List symbols = cmd.getSymbols();
- Map definedSymbols = new HashMap(symbols.size());
- for (Iterator i = symbols.iterator(); i.hasNext(); ) {
- String symbol = (String) i.next();
- String key = ScannerConfigUtil.getSymbolKey(symbol);
- String value = ScannerConfigUtil.getSymbolValue(symbol);
- definedSymbols.put(key, value);
- }
- return definedSymbols;
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
- return psi.definedSymbols;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo#getIncludeFiles(org.eclipse.core.runtime.IPath)
- */
- public IPath[] getIncludeFiles(IPath path) {
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null) {
- return stringListToPathArray(cmd.getIncludeFile());
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
- return psi.includeFiles;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getMacroFiles(org.eclipse.core.runtime.IPath)
- */
- public IPath[] getMacroFiles(IPath path) {
- // get the command
- CCommandDSC cmd = getCommand(path);
- if (cmd != null) {
- return stringListToPathArray(cmd.getImacrosFile());
- }
- // use project scope scanner info
- if (psi == null) {
- generateProjectScannerInfo();
- }
- return psi.macrosFiles;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#getSerializable()
- */
- public IDiscoveredScannerInfoSerializable getSerializable() {
- return sid;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerFileDiscoveredPathInfo#isEmpty(org.eclipse.core.runtime.IPath)
- */
- public boolean isEmpty(IPath path) {
- boolean rc = true;
- IResource resource = project.getWorkspace().getRoot().findMember(path);
- if (resource != null) {
- if (resource instanceof IFile) {
- rc = (getCommand((IFile)resource) == null);
- }
- else if (resource instanceof IProject) {
- rc = (psi == null || psi.isEmpty());
- }
- }
- return rc;
- }
-
- }
-
- /**
- * @param path
- * @return
- */
- private CCommandDSC getCommand(IPath path) {
- try {
- IFile file = project.getWorkspace().getRoot().getFile(path);
- return getCommand(file);
- }
- catch (Exception e) {
- return null;
- }
- }
-
- private CCommandDSC getCommand(IFile file) {
- CCommandDSC cmd = null;
- if (file != null) {
- Integer cmdId = (Integer) sid.fileToCommandIdMap.get(file);
- if (cmdId != null) {
- // get the command
- cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId);
- }
- }
- return cmd;
- }
-
- /**
- * @param type can be one of the following:
- * INCLUDE_PATH
- * QUOTE_INCLUDE_PATH
- * INCLUDE_FILE
- * MACROS_FILE
- *
- * @return list of IPath(s).
- */
- private IPath[] getAllIncludePaths(int type) {
- List allIncludes = new ArrayList();
- for (Iterator i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext(); ) {
- Integer cmdId = (Integer) i.next();
- CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId);
- if (cmd.isDiscovered()) {
- List discovered = null;
- switch (type) {
- case INCLUDE_PATH:
- discovered = cmd.getIncludes();
- break;
- case QUOTE_INCLUDE_PATH:
- discovered = cmd.getQuoteIncludes();
- break;
- case INCLUDE_FILE:
- discovered = cmd.getIncludeFile();
- break;
- case MACROS_FILE:
- discovered = cmd.getImacrosFile();
- break;
- }
- for (Iterator j = discovered.iterator(); j.hasNext(); ) {
- String include = (String) j.next();
- if (!allIncludes.contains(include)) {
- allIncludes.add(include);
- }
- }
- }
- }
- return stringListToPathArray(allIncludes);
- }
-
- /**
- * @param discovered
- * @param allIncludes
- * @return
- */
- private IPath[] stringListToPathArray(List discovered) {
- List allIncludes = new ArrayList(discovered.size());
- for (Iterator j = discovered.iterator(); j.hasNext(); ) {
- String include = (String) j.next();
- if (!allIncludes.contains(include)) {
- allIncludes.add(new Path(include));
- }
- }
- return (IPath[])allIncludes.toArray(new IPath[allIncludes.size()]);
- }
-
- /**
- * @return
- */
- private Map getAllSymbols() {
- Map symbols = new HashMap();
- for (Iterator i = sid.commandIdCommandMap.keySet().iterator(); i.hasNext(); ) {
- Integer cmdId = (Integer) i.next();
- CCommandDSC cmd = (CCommandDSC) sid.commandIdCommandMap.get(cmdId);
- if (cmd.isDiscovered()) {
- List discovered = cmd.getSymbols();
- for (Iterator j = discovered.iterator(); j.hasNext(); ) {
- String symbol = (String) j.next();
- String key = ScannerConfigUtil.getSymbolKey(symbol);
- String value = ScannerConfigUtil.getSymbolValue(symbol);
- symbols.put(key, value);
- }
- }
- }
- return symbols;
- }
-
- public InfoContext getContext() {
- return context;
- }
-
- public boolean isInfoCollected() {
- return isInfoCollected;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java
deleted file mode 100644
index 37a6cae52dc..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/PerProjectSICollector.java
+++ /dev/null
@@ -1,526 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector3;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IPerProjectDiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredScannerInfoStore;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.newmake.internal.core.MakeMessages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.w3c.dom.Element;
-
-/**
- * New per project scanner info collector
- *
- * @since 3.0
- * @author vhirsl
- */
-public class PerProjectSICollector implements IScannerInfoCollector3, IScannerInfoCollectorCleaner {
- public static final String COLLECTOR_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".PerProjectSICollector"; //$NON-NLS-1$
-
- private IProject project;
- private InfoContext context;
-
- private Map discoveredSI;
-// private List discoveredIncludes;
-// private List discoveredSymbols;
-// private List discoveredTSO; // target specific options
- // cumulative values
- private List sumDiscoveredIncludes;
- private Map sumDiscoveredSymbols;
- private boolean scPersisted = false;
- private boolean isInfoCollected;
-
- public PerProjectSICollector() {
- discoveredSI = new HashMap();
-// discoveredIncludes = new ArrayList();
-// discoveredSymbols = new ArrayList();
-// discoveredTSO = new ArrayList();
-//
- sumDiscoveredIncludes = new ArrayList();
- sumDiscoveredSymbols = new LinkedHashMap();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#setProject(org.eclipse.core.resources.IProject)
- */
- public void setProject(IProject project) {
- this.project = project;
- this.context = ScannerConfigUtil.createContextForProject(project);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map)
- */
- public synchronized void contributeToScannerConfig(Object resource, Map scannerInfo) {
- // check the resource
- String errorMessage = null;
- if (resource == null) {
- errorMessage = "resource is null";//$NON-NLS-1$
- }
- else if (!(resource instanceof IResource)) {
- errorMessage = "resource is not an IResource";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() == null) {
- errorMessage = "project is null";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() != project) {
- errorMessage = "wrong project";//$NON-NLS-1$
- }
- if (errorMessage != null) {
- TraceUtil.outputError("PerProjectSICollector.contributeToScannerConfig : ", errorMessage); //$NON-NLS-1$
- return;
- }
-
- isInfoCollected = true;
-
- if (scPersisted) {
- // delete discovered scanner config
- discoveredSI.clear();
- // new collection cycle
- scPersisted = false;
- }
-// try {
-// if (project.hasNature(MakeProjectNature.NATURE_ID) && // limits to StandardMake projects
-// (project.hasNature(CProjectNature.C_NATURE_ID) ||
-// project.hasNature(CCProjectNature.CC_NATURE_ID))) {
-
- for (Iterator I = scannerInfo.keySet().iterator(); I.hasNext(); ) {
- ScannerInfoTypes siType = (ScannerInfoTypes) I.next();
- List delta = (List) scannerInfo.get(siType);
-
- List discovered = (List) discoveredSI.get(siType);
- if (discovered == null) {
- discovered = new ArrayList(delta);
- discoveredSI.put(siType, discovered);
- }
- else {
- if (siType.equals(ScannerInfoTypes.INCLUDE_PATHS)) {
- contribute(discovered, delta, true);
- }
- else {
- contribute(discovered, delta, false);
- }
- }
- }
-// }
-// }
-// catch (CoreException e) {
-// ManagedBuilderCorePlugin.log(e);
-// }
- }
-
- /**
- * @param discovered symbols | includes | targetSpecificOptions
- * @param delta symbols | includes | targetSpecificOptions
- * @param ordered - to preserve order or append at the end
- * @return true if there is a change in discovered symbols | includes | targetSpecificOptions
- */
- private boolean contribute(List discovered, List delta, boolean ordered) {
- if (delta == null || delta.isEmpty())
- return false;
- return addItemsWithOrder(discovered, delta, ordered);
- }
-
- /**
- * Adds new items to the already accumulated ones preserving order
- *
- * @param sumIncludes - previously accumulated items
- * @param includes - items to be added
- * @param ordered - to preserve order or append at the end
- * @return boolean - true if added
- */
- private boolean addItemsWithOrder(List sumIncludes, List includes, boolean ordered) {
- boolean addedIncludes = false;
- int prev = sumIncludes.size() - 1; // index of previously added/found contribution in already discovered list
- for (Iterator i = includes.iterator(); i.hasNext(); ) {
- String item = (String) i.next();
- if (!sumIncludes.contains(item)) {
- sumIncludes.add(prev + 1, item);
- addedIncludes = true;
- }
- prev = ordered ? sumIncludes.indexOf(item) : sumIncludes.size() - 1;
- }
- return addedIncludes;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#updateScannerConfiguration(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IProgressMonitor)
- */
- public synchronized void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- IDiscoveredPathInfo pathInfo = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project, context);
- if (pathInfo instanceof IPerProjectDiscoveredPathInfo) {
- IPerProjectDiscoveredPathInfo projectPathInfo = (IPerProjectDiscoveredPathInfo) pathInfo;
-
- monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
- if (pathInfo != null) {
- monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
- if (scannerConfigNeedsUpdate(projectPathInfo)) {
- monitor.worked(50);
- monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
- try {
- // update scanner configuration
- List resourceDelta = new ArrayList(1);
- resourceDelta.add(project);
- ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo, context, resourceDelta);
- monitor.worked(50);
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
- }
- monitor.done();
- scPersisted = true;
- }
- }
-
- /**
- * Compare discovered include paths and symbol definitions with the ones from scanInfo.
- *
- * @param scanInfo
- * @return
- */
- private boolean scannerConfigNeedsUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
- boolean addedIncludes = includePathsNeedUpdate(discPathInfo);
- boolean addedSymbols = definedSymbolsNeedUpdate(discPathInfo);
-
- return (addedIncludes | addedSymbols);
- }
-
- /**
- * Compare include paths with already discovered.
- *
- * @param discPathInfo
- * @param includes
- * @return
- */
- private boolean includePathsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
- boolean addedIncludes = false;
- List discoveredIncludes = (List) discoveredSI.get(ScannerInfoTypes.INCLUDE_PATHS);
- if (discoveredIncludes != null) {
- // Step 1. Add discovered scanner config to the existing discovered scanner config
- // add the includes from the latest discovery
-// if (sumDiscoveredIncludes == null) {
-// sumDiscoveredIncludes = new ArrayList(discoveredIncludes);
-// addedIncludes = true;
-// }
-// else {
-// addedIncludes = addItemsWithOrder(sumDiscoveredIncludes, discoveredIncludes, true);
-// }
-// instead
- addedIncludes = addItemsWithOrder(sumDiscoveredIncludes, discoveredIncludes, true);
-
- // try to translate cygpaths to absolute paths
- List finalSumIncludes = CygpathTranslator.translateIncludePaths(project, sumDiscoveredIncludes);
-
- // Step 2. Get project's scanner config
- LinkedHashMap persistedIncludes = discPathInfo.getIncludeMap();
-
- // Step 3. Merge scanner config from steps 1 and 2
- // order is important, use list to preserve it
- ArrayList persistedKeyList = new ArrayList(persistedIncludes.keySet());
- addedIncludes = addItemsWithOrder(persistedKeyList, finalSumIncludes, true);
-
- LinkedHashMap newPersistedIncludes;
- if (addedIncludes) {
- newPersistedIncludes = new LinkedHashMap(persistedKeyList.size());
- for (Iterator i = persistedKeyList.iterator(); i.hasNext(); ) {
- String include = (String) i.next();
- if (persistedIncludes.containsKey(include)) {
- newPersistedIncludes.put(include, persistedIncludes.get(include));
- }
- else {
- newPersistedIncludes.put(include,
- ((new Path(include)).toFile().exists()) ? Boolean.FALSE : Boolean.TRUE);
- }
- }
- }
- else {
- newPersistedIncludes = persistedIncludes;
- }
-
- // Step 4. Set resulting scanner config
- discPathInfo.setIncludeMap(newPersistedIncludes);
- }
- return addedIncludes;
- }
-
- /**
- * Compare symbol definitions with already discovered.
- *
- * @param discPathInfo
- * @param symbols
- * @return
- */
- private boolean definedSymbolsNeedUpdate(IPerProjectDiscoveredPathInfo discPathInfo) {
- boolean addedSymbols = false;
- List discoveredSymbols = (List) discoveredSI.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
- if (discoveredSymbols != null) {
- // Step 1. Add discovered scanner config to the existing discovered scanner config
- // add the symbols from the latest discovery
-// if (sumDiscoveredSymbols == null) {
-// sumDiscoveredSymbols = new LinkedHashMap();
-// }
- addedSymbols = ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(sumDiscoveredSymbols, discoveredSymbols, false);
-
- // Step 2. Get project's scanner config
- LinkedHashMap persistedSymbols = discPathInfo.getSymbolMap();
-
- // Step 3. Merge scanner config from steps 1 and 2
- LinkedHashMap candidateSymbols = new LinkedHashMap(persistedSymbols);
- addedSymbols |= ScannerConfigUtil.scAddSymbolEntryMap2SymbolEntryMap(candidateSymbols, sumDiscoveredSymbols);
-
- // Step 4. Set resulting scanner config
- discPathInfo.setSymbolMap(candidateSymbols);
- }
- return addedSymbols;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#getCollectedScannerInfo(java.lang.Object, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
- */
- public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
- List rv = null;
- // check the resource
- String errorMessage = null;
- if (resource == null) {
- errorMessage = "resource is null";//$NON-NLS-1$
- }
- else if (!(resource instanceof IResource)) {
- errorMessage = "resource is not an IResource";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() == null) {
- errorMessage = "project is null";//$NON-NLS-1$
- }
- else if (((IResource) resource).getProject() != project) {
- errorMessage = "wrong project";//$NON-NLS-1$
- }
-
- if (errorMessage != null) {
- TraceUtil.outputError("PerProjectSICollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$
- }
- else if (project.equals(((IResource)resource).getProject())) {
- rv = (List) discoveredSI.get(type);
- }
- return rv;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#getDefinedSymbols()
- */
- public Map getDefinedSymbols() {
- Map definedSymbols = ScannerConfigUtil.scSymbolEntryMap2Map(sumDiscoveredSymbols);
- return definedSymbols;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#getIncludePaths()
- */
- public List getIncludePaths() {
- return sumDiscoveredIncludes;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#serialize(org.w3c.dom.Element)
- */
- public void serialize(Element root) {
- // not supported in PerProject collector
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deserialize(org.w3c.dom.Element)
- */
- public void deserialize(Element root) {
- // not supported in PerProject collector
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllPaths(org.eclipse.core.resources.IResource)
- */
- public void deleteAllPaths(IResource resource) {
- IProject project = resource.getProject();
- if (project != null && project.equals(this.project)) {
- sumDiscoveredIncludes.clear();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteAllSymbols(org.eclipse.core.resources.IResource)
- */
- public void deleteAllSymbols(IResource resource) {
- IProject project = resource.getProject();
- if (project != null && project.equals(this.project)) {
- sumDiscoveredSymbols.clear();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deletePath(org.eclipse.core.resources.IResource, java.lang.String)
- */
- public void deletePath(IResource resource, String path) {
- IProject project = resource.getProject();
- if (project != null && project.equals(this.project)) {
- sumDiscoveredIncludes.remove(path);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorUtil#deleteSymbol(org.eclipse.core.resources.IResource, java.lang.String)
- */
- public void deleteSymbol(IResource resource, String symbol) {
- IProject project = resource.getProject();
- if (project != null && project.equals(this.project)) {
- // remove it from the Map of SymbolEntries
- ScannerConfigUtil.removeSymbolEntryValue(symbol, sumDiscoveredSymbols);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollectorCleaner#deleteAll(org.eclipse.core.resources.IResource)
- */
- public void deleteAll(IResource resource) {
- deleteAllPaths(resource);
- deleteAllSymbols(resource);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#createPathInfoObject()
- */
- public IDiscoveredPathInfo createPathInfoObject() {
- DiscoveredPathInfo pathInfo = new DiscoveredPathInfo(project);
-
- try {
- DiscoveredScannerInfoStore.getInstance().loadDiscoveredScannerInfoFromState(project, context, pathInfo);
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
-
- if(!isInfoCollected && pathInfo.isLoadded())
- isInfoCollected = true;
-
- return pathInfo;
- }
-
- /**
- * Static method to return compiler built-in scanner info.
- * Preconditions: resource has to be contained by a project that has following natures:
- * C nature, CC nature (for C++ projects), Make nature and ScannerConfig nature
- *
- * @param project
- * @throws CModelException
- */
- /*uncomment
- public static void calculateCompilerBuiltins(final IProject project) throws CModelException {
- createDiscoveredPathContainer(project, new NullProgressMonitor());
- String scdProfileId = ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID;
- SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
- getSCProfileInstance(project, scdProfileId);
- final IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.
- createScannerConfigBuildInfo2(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(),
- scdProfileId, true);
- final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
- if (collector instanceof IScannerInfoCollectorCleaner) {
- ((IScannerInfoCollectorCleaner) collector).deleteAll(project);
- }
- final IExternalScannerInfoProvider esiProvider = profileInstance.createExternalScannerInfoProvider("specsFile");//$NON-NLS-1$
-
- // Set the arguments for the provider
-
- ISafeRunnable runnable = new ISafeRunnable() {
- public void run() throws CoreException {
- IProgressMonitor monitor = new NullProgressMonitor();
- esiProvider.invokeProvider(monitor, project, "specsFile", buildInfo, collector);//$NON-NLS-1$
- if (collector instanceof IScannerInfoCollector2) {
- IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
- collector2.updateScannerConfiguration(monitor);
- }
- }
-
- public void handleException(Throwable exception) {
- if (exception instanceof OperationCanceledException) {
- throw (OperationCanceledException) exception;
- }
- }
- };
- Platform.run(runnable);
- }*/
-
- private static void createDiscoveredPathContainer(IProject project, IProgressMonitor monitor) throws CModelException {
- IPathEntry container = CoreModel.newContainerEntry(DiscoveredPathContainer.CONTAINER_ID);
- ICProject cProject = CoreModel.getDefault().create(project);
- if (cProject != null) {
- IPathEntry[] entries = cProject.getRawPathEntries();
- List newEntries = new ArrayList(Arrays.asList(entries));
- if (!newEntries.contains(container)) {
- newEntries.add(container);
- cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), monitor);
- }
- }
- // create a new discovered scanner config store
- ManagedBuilderCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
- }
-
- public void setContext(InfoContext context) {
- this.context = context;
- this.project = context.getConfiguration().getOwner().getProject();
- }
-
- public InfoContext getContext() {
- return context;
- }
-
- protected IProject getProject(){
- return project;
- }
-
- public boolean isInfoCollected() {
- return isInfoCollected;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java
deleted file mode 100644
index 2a0e7204faa..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCDMakefileGenerator.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-
-
-/**
- * A 'provider' that will generate a special makefile to generate scanner config
- *
- * @author vhirsl
- */
-public class SCDMakefileGenerator extends DefaultRunSIProvider {
- private static final String ENDL = System.getProperty("line.separator"); //$NON-NLS-1$
- private static final String DENDL = ENDL+ENDL;
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#initialize()
- */
- protected boolean initialize() {
- boolean rc = super.initialize();
-
- if (rc) {
- fWorkingDirectory = ManagedBuilderCorePlugin.getWorkingDirectory();
- // replace string variables in compile arguments
- // TODO Vmir - use string variable replacement
- for (int i = 0; i < fCompileArguments.length; ++i) {
- fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{project_name\\}", //$NON-NLS-1$
- resource.getProject().getName());
- }
- rc = generateMakefile(resource.getProject().getName());
- }
- return rc;
- }
-
- /**
- * @param name
- * @return
- */
- private boolean generateMakefile(String projectName) {
- boolean rc = false;
- if (collector instanceof IScannerInfoCollector2) {
- IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
- List commands = collector2.getCollectedScannerInfo(
- resource.getProject(), ScannerInfoTypes.UNDISCOVERED_COMPILER_COMMAND);
- if (commands != null && commands.size() > 0) {
-
- StringBuffer buffer = new StringBuffer();
- buffer.append("# This is a generated file. Please do not edit."); //$NON-NLS-1$
- buffer.append(DENDL);
- buffer.append(".PHONY: all"); //$NON-NLS-1$
- buffer.append(DENDL);
- buffer.append("COMMANDS := "); //$NON-NLS-1$
- for (Iterator i = commands.iterator(); i.hasNext(); ) {
- CCommandDSC cmd = (CCommandDSC) i.next();
- buffer.append("\t\\"+ENDL+"\t scd_cmd_"); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append(cmd.getCommandId());
- }
- buffer.append(DENDL);
- buffer.append("all: $(COMMANDS)"); //$NON-NLS-1$
- buffer.append(DENDL);
- for (Iterator i = commands.iterator(); i.hasNext(); ) {
- CCommandDSC cmd = (CCommandDSC) i.next();
- buffer.append("scd_cmd_"); //$NON-NLS-1$
- buffer.append(cmd.getCommandId());
- buffer.append(':');
- buffer.append(ENDL);
- buffer.append("\t@echo begin generating scanner info for $@"+ENDL+"\t"); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append(cmd.getSCDRunnableCommand(true)); // quoteIncludePaths
- buffer.append(" -E -P -v -dD "); //$NON-NLS-1$
- buffer.append(cmd.appliesToCPPFileType() ? "specs.cpp" : "specs.c"); //$NON-NLS-1$ //$NON-NLS-2$
- buffer.append(ENDL);
- buffer.append("\t@echo end generating scanner info for $@"); //$NON-NLS-1$
- buffer.append(DENDL);
- }
-
- File makefile = new File(fWorkingDirectory.toFile(), projectName+"_scd.mk"); //$NON-NLS-1$
- try {
- PrintStream ps = new PrintStream(new FileOutputStream(makefile));
- ps.println(buffer.toString());
- ps.close();
- rc = true;
- }
- catch (FileNotFoundException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
- }
-
- return rc;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java
deleted file mode 100644
index 4badaee97e5..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCMarkerGenerator.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.IMarkerGenerator;
-import org.eclipse.cdt.core.ProblemMarkerInfo;
-import org.eclipse.cdt.core.model.ICModelMarker;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * Scanner config discovery related marker generator
- *
- * @author vhirsl
- */
-public class SCMarkerGenerator implements IMarkerGenerator {
-
- /**
- *
- */
- public SCMarkerGenerator() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.IMarkerGenerator#addMarker(org.eclipse.core.resources.IResource, int, java.lang.String, int, java.lang.String)
- */
- public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
- ProblemMarkerInfo info = new ProblemMarkerInfo(file, lineNumber, errorDesc, severity, errorVar);
- addMarker(info);
- }
-
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.IMarkerGenerator#addMarker(org.eclipse.cdt.core.ProblemMarkerInfo)
- */
- public void addMarker(ProblemMarkerInfo problemMarkerInfo) {
- try {
- IMarker[] cur = problemMarkerInfo.file.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
- /*
- * Try to find matching markers and don't put in duplicates
- */
- if ((cur != null) && (cur.length > 0)) {
- for (int i = 0; i < cur.length; i++) {
- int line = ((Integer) cur[i].getAttribute(IMarker.LOCATION)).intValue();
- int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue();
- String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE);
- if (line == problemMarkerInfo.lineNumber && sev == mapMarkerSeverity(problemMarkerInfo.severity) && mesg.equals(problemMarkerInfo.description)) {
- return;
- }
- }
- }
-
- IMarker marker = problemMarkerInfo.file.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER);
- marker.setAttribute(IMarker.LOCATION, problemMarkerInfo.lineNumber);
- marker.setAttribute(IMarker.MESSAGE, problemMarkerInfo.description);
- marker.setAttribute(IMarker.SEVERITY, mapMarkerSeverity(problemMarkerInfo.severity));
- marker.setAttribute(IMarker.LINE_NUMBER, problemMarkerInfo.lineNumber);
- marker.setAttribute(IMarker.CHAR_START, -1);
- marker.setAttribute(IMarker.CHAR_END, -1);
- if (problemMarkerInfo.variableName != null) {
- marker.setAttribute(ICModelMarker.C_MODEL_MARKER_VARIABLE, problemMarkerInfo.variableName);
- }
- if (problemMarkerInfo.externalPath != null) {
- marker.setAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION, problemMarkerInfo.externalPath.toOSString());
- }
- }
- catch (CoreException e) {
- CCorePlugin.log(e.getStatus());
- }
-
- }
-
- public void removeMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
- IWorkspace workspace = file.getWorkspace();
- // remove specific marker
- try {
- IMarker[] markers = file.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
- if (markers != null) {
- List exactMarkers = new ArrayList();
- for (int i = 0; i < markers.length; i++) {
- IMarker marker = markers[i];
- int location = ((Integer) marker.getAttribute(IMarker.LOCATION)).intValue();
- String error = (String) marker.getAttribute(IMarker.MESSAGE);
- int sev = ((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue();
- if (location == lineNumber &&
- errorDesc.equals(error) &&
- sev == severity) {
- exactMarkers.add(marker);
- }
- }
- if (exactMarkers.size() > 0) {
- workspace.deleteMarkers((IMarker[]) exactMarkers.toArray(new IMarker[exactMarkers.size()]));
- }
- }
- }
- catch (CoreException e) {
- CCorePlugin.log(e.getStatus());
- }
- }
-
- int mapMarkerSeverity(int severity) {
- switch (severity) {
- case SEVERITY_ERROR_BUILD :
- case SEVERITY_ERROR_RESOURCE :
- return IMarker.SEVERITY_ERROR;
- case SEVERITY_INFO :
- return IMarker.SEVERITY_INFO;
- case SEVERITY_WARNING :
- return IMarker.SEVERITY_WARNING;
- }
- return IMarker.SEVERITY_ERROR;
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java
deleted file mode 100644
index 1eb1ee5815d..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/SCProfileInstance.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.Action;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.BuildOutputProvider;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoCollector;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoConsoleParser;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoProvider;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.resources.IProject;
-
-/**
- * Instantiated scanner config profile
- *
- * @author vhirsl
- */
-public class SCProfileInstance {
- private InfoContext context;
- private IProject project;
- private ScannerConfigProfile profile;
- private IScannerInfoCollector collector;
- /**
- *
- */
- public SCProfileInstance(InfoContext context, ScannerConfigProfile profile) {
- this.context = context;
- this.project = context.getConfiguration().getOwner().getProject();
- this.profile = profile;
- }
-
- public SCProfileInstance(IProject project, ScannerConfigProfile profile) {
- this.project = project;
- this.profile = profile;
- }
-
- /**
- *
- */
- private void instantiateCollector() {
- // create collector object
- collector = createScannerInfoCollector();
- if (collector != null) {
- // call collector.setProject(project) if class supports it
- Class clazz = collector.getClass();
- try {
- Object[] args = null;
- Method setMethod = null;
- if(context != null){
- try {
- setMethod = clazz.getMethod("setContext", new Class[] {InfoContext.class});//$NON-NLS-1$
- args = new Object[]{context};
- } catch(NoSuchMethodException e) {
- }
- }
-
- if(setMethod == null){
-
- try {
- setMethod = clazz.getMethod("setProject", new Class[] {IProject.class});//$NON-NLS-1$
- args = new Object[]{project};
- } catch(NoSuchMethodException e) {
- }
- }
- if(setMethod != null)
- setMethod.invoke(collector, args);
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
- } catch (InvocationTargetException e) {
- ManagedBuilderCorePlugin.log(e.getCause());
- }
- }
- // all other objects are created on request
- }
-
- /**
- * @return
- */
- public ScannerConfigProfile getProfile() {
- return profile;
- }
-
- /**
- * @return a single scannerInfoCollector object
- */
- public IScannerInfoCollector getScannerInfoCollector() {
- if (collector == null) {
- instantiateCollector();
- }
- return collector;
- }
-
- public IScannerInfoCollector createScannerInfoCollector() {
- ScannerInfoCollector collector = profile.getScannerInfoCollectorElement();
- if (collector != null) {
- return (IScannerInfoCollector) collector.createScannerInfoCollector();
- }
- return null;
- }
-
- /**
- * @return Creates new buildOutputProvider user object.
- */
- public IExternalScannerInfoProvider createBuildOutputProvider() {
- BuildOutputProvider bop = profile.getBuildOutputProviderElement();
- if (bop != null) {
- Action action = bop.getAction();
- if (action != null) {
- return (IExternalScannerInfoProvider) action.createExternalScannerInfoProvider();
- }
- }
- return null;
- }
- /**
- * @return Creates new buildOutputParser user object.
- */
- public IScannerInfoConsoleParser createBuildOutputParser() {
- BuildOutputProvider bop = profile.getBuildOutputProviderElement();
- if (bop != null) {
- ScannerInfoConsoleParser parserElement = bop.getScannerInfoConsoleParser();
- if (parserElement != null) {
- return (IScannerInfoConsoleParser) parserElement.createScannerInfoConsoleParser();
- }
- }
- return null;
- }
- /**
- * @return Creates new externalSIProvider user object.
- */
- public IExternalScannerInfoProvider createExternalScannerInfoProvider(String providerId) {
- ScannerInfoProvider provider = profile.getScannerInfoProviderElement(providerId);
- if (provider != null) {
- return (IExternalScannerInfoProvider) provider.getAction().createExternalScannerInfoProvider();
- }
- return null;
- }
- /**
- * @return Creates new esiProviderOutputParser user object.
- */
- public IScannerInfoConsoleParser createExternalScannerInfoParser(String providerId) {
- ScannerInfoProvider provider = profile.getScannerInfoProviderElement(providerId);
- if (provider != null) {
- return (IScannerInfoConsoleParser) provider.getScannerInfoConsoleParser().createScannerInfoConsoleParser();
- }
- return null;
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java
deleted file mode 100644
index 1cbd8a58d4e..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigInfoFactory2.java
+++ /dev/null
@@ -1,1207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.core.settings.model.ICStorageElement;
-import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoProvider;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IFileInfo;
-import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
-import org.eclipse.cdt.managedbuilder.internal.core.Tool;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Preferences;
-
-/**
- * New ScannerConfigInfoFactory
- *
- * @author vhirsl
- */
-public class ScannerConfigInfoFactory2 {
- // build properties
- private static final String SCANNER_CONFIG = "scannerConfiguration"; //$NON-NLS-1$
- private static final String SC_AUTODISCOVERY = "autodiscovery"; //$NON-NLS-1$
- private static final String ENABLED = "enabled"; //$NON-NLS-1$
- private static final String SELECTED_PROFILE_ID = "selectedProfileId"; //$NON-NLS-1$
- private static final String PROBLEM_REPORTING_ENABLED = "problemReportingEnabled"; //$NON-NLS-1$
- private static final String PROFILE = "profile"; //$NON-NLS-1$
- private static final String ID = "id"; //$NON-NLS-1$
- private static final String BUILD_OUTPUT_PROVIDER = "buildOutputProvider"; //$NON-NLS-1$
- private static final String OPEN_ACTION = "openAction"; //$NON-NLS-1$
- private static final String FILE_PATH = "filePath"; //$NON-NLS-1$
- private static final String PARSER = "parser"; //$NON-NLS-1$
- private static final String SCANNER_INFO_PROVIDER = "scannerInfoProvider"; //$NON-NLS-1$
- private static final String RUN_ACTION = "runAction"; //$NON-NLS-1$
- private static final String USE_DEFAULT = "useDefault"; //$NON-NLS-1$
- private static final String COMMAND = "command"; //$NON-NLS-1$
- private static final String ARGUMENTS = "arguments"; //$NON-NLS-1$
- // preferences
- private static final String DOT = ".";//$NON-NLS-1$
- private static final String SCD = "SCD.";//$NON-NLS-1$
- private static final String SCANNER_CONFIG_AUTODISCOVERY_ENABLED = "SCD.enabled";//$NON-NLS-1$
- private static final String SCANNER_CONFIG_SELECTED_PROFILE_ID = "SCD.selectedProfileId";//$NON-NLS-1$
- private static final String SCANNER_CONFIG_PROBLEM_REPORTING_ENABLED = "SCD.problemReportingEnabled"; //$NON-NLS-1$
-// following require prefix: profileId
- private static final String BUILD_OUTPUT_OPEN_ACTION_ENABLED = ".BOP.open.enabled";//$NON-NLS-1$
- private static final String BUILD_OUTPUT_OPEN_ACTION_FILE_PATH = ".BOP.open.path";//$NON-NLS-1$
- private static final String BUILD_OUTPUT_PARSER_ENABLED = ".BOP.parser.enabled";//$NON-NLS-1$
- // following require prefix: profileId + "." + SCANNER_INFO_PROVIDER + "." + providerId
- private static final String SI_PROVIDER_RUN_ACTION_USE_DEFAULT = ".run.useDefault";//$NON-NLS-1$
- private static final String SI_PROVIDER_RUN_ACTION_COMMAND = ".run.command";//$NON-NLS-1$
- private static final String SI_PROVIDER_RUN_ACTION_ARGUMENTS = ".run.arguments";//$NON-NLS-1$
- private static final String SI_PROVIDER_OPEN_ACTION_FILE_PATH = ".open.path";//$NON-NLS-1$
- private static final String SI_PROVIDER_PARSER_ENABLED = ".parser.enabled";//$NON-NLS-1$
-
- private static class CfgInfo implements IConfigurationScannerConfigBuilderInfo {
- private Configuration cfg;
-// private HashMap map;
-
- CfgInfo(Configuration cfg){
- this.cfg = (Configuration)cfg;
-// init();
- }
-
- public InfoContext[] getContexts() {
- Map map = createMap();
- return (InfoContext[])map.keySet().toArray(new InfoContext[map.size()]);
- }
-
- public IScannerConfigBuilderInfo2 getInfo(InfoContext context) {
- return (IScannerConfigBuilderInfo2)createMap().get(context);
-// IScannerConfigBuilderInfo2 info = null;
-// if(!isPerRcTypeDiscovery()){
-// info = cfg.getScannerConfigInfo();
-// if(info == null){
-// info = ScannerConfigInfoFactory2.create(cfg, ManagedBuilderCorePlugin.getDefault().getPluginPreferences());
-// }
-// } else {
-// Tool tool = (Tool)context.getTool();
-// if(tool != null)
-// info = tool.getScannerConfigInfo(context.getInputType());
-//// else
-//// info = getDefaultInfo();
-// }
-// return info;
- }
-
- public boolean isPerRcTypeDiscovery() {
- return cfg.isPerRcTypeDiscovery();
- }
-
- private Map createMap(){
- HashMap map = new HashMap();
- boolean isPerRcType = cfg.isPerRcTypeDiscovery();
- if(!isPerRcType){
- IScannerConfigBuilderInfo2 info = cfg.getScannerConfigInfo();
- if(info == null){
- String id = cfg.getDiscoveryProfileId();
- if(id == null)
- id = ScannerConfigProfileManager.NULL_PROFILE_ID;
- info = create(cfg, ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), id);
- cfg.setScannerConfigInfo(info);
- }
- map.put(new InfoContext(cfg), info);
- } else {
- IResourceInfo[] rcInfos = cfg.getResourceInfos();
- for(int i = 0; i < rcInfos.length; i++){
- ITool tools[];
- IResourceInfo rcInfo = rcInfos[i];
- if(rcInfo instanceof IFolderInfo) {
- tools = ((IFolderInfo)rcInfo).getFilteredTools();
- } else {
- tools = ((IFileInfo)rcInfo).getToolsToInvoke();
- }
- for(int k = 0; k < tools.length; k++){
- Tool tool = (Tool)tools[k];
- IInputType types[] = tool.getInputTypes();
- if(types.length != 0){
- for(int t = 0; t < types.length; t++){
- IInputType type = types[t];
- IScannerConfigBuilderInfo2 tInfo = tool.getScannerConfigInfo(type);
- if(tInfo != null){
- map.put(new InfoContext(rcInfo, tool, type), tInfo);
- }
- }
- } else {
- IScannerConfigBuilderInfo2 tInfo = tool.getScannerConfigInfo(null);
- if(tInfo != null){
- map.put(new InfoContext(rcInfo, tool, null), tInfo);
- }
- }
- }
- }
- }
- return map;
- }
-
- public Map getInfoMap() {
- return createMap();
- }
-
- public void setPerRcTypeDiscovery(boolean on) {
- cfg.setPerRcTypeDiscovery(on);
- }
-
- public IScannerConfigBuilderInfo2 getDefaultInfo() {
- IScannerConfigBuilderInfo2 info = cfg.getScannerConfigInfo();
- if(info == null){
- Map map = createMap();
- if(map.size() != 0){
- info = (IScannerConfigBuilderInfo2)map.values().iterator().next();
- } else {
- info = ScannerConfigInfoFactory2.create(cfg, ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), cfg.getDiscoveryProfileId());
- }
- }
- return info;
- }
-
- public IScannerConfigBuilderInfo2 applyInfo(InfoContext context,
- IScannerConfigBuilderInfo2 base) {
- IScannerConfigBuilderInfo2 newInfo;
- if(base != null){
- newInfo = create(context, base, ScannerConfigProfileManager.NULL_PROFILE_ID);
- setInfo(context, newInfo);
- } else {
- setInfo(context, null);
- newInfo = getInfo(context);
- }
-
- return newInfo;
- }
-
- private void setInfo(InfoContext context, IScannerConfigBuilderInfo2 info) {
- if(!isPerRcTypeDiscovery()){
- cfg.setScannerConfigInfo(info);
- } else {
- Tool tool = (Tool)context.getTool();
- if(tool != null)
- info = tool.setScannerConfigInfo(context.getInputType(), info);
-// else
-// info = getDefaultInfo();
- }
- }
-
- }
-
- private static abstract class Store implements IScannerConfigBuilderInfo2, Cloneable {
- protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
- protected boolean isDirty; // derived
-
- protected boolean autoDiscoveryEnabled;
- protected boolean problemReportingEnabled;
- protected String selectedProfile = EMPTY_STRING;
- protected LinkedHashMap profileOptionsMap; // (profileId, options)
- static class ProfileOptions implements Cloneable{
- protected boolean buildOutputFileActionEnabled;
- protected String buildOutputFilePath = EMPTY_STRING;
- protected boolean buildOutputParserEnabled;
- protected LinkedHashMap providerOptionsMap; // {providerId, options}
- static class ProviderOptions implements Cloneable{
- protected String providerKind; // derived
- protected boolean providerOutputParserEnabled;
- protected boolean providerRunUseDefault;
- protected String providerRunCommand = EMPTY_STRING;
- protected String providerRunArguments = EMPTY_STRING;
- protected String providerOpenFilePath = EMPTY_STRING;
-
- public Object clone(){
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-
-
- }
-
- protected Object clone(){
- try {
- ProfileOptions clone = (ProfileOptions) super.clone();
- clone.providerOptionsMap = (LinkedHashMap)providerOptionsMap.clone();
- for(Iterator iter = clone.providerOptionsMap.entrySet().iterator(); iter.hasNext();){
- Map.Entry entry = (Map.Entry)iter.next();
- ProviderOptions o = (ProviderOptions)entry.getValue();
- o = (ProviderOptions)o.clone();
- entry.setValue(o);
- }
- return clone;
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
- }
-
- protected void copySettingsTo(Store clone){
- clone.isDirty = isDirty;
-
- clone.autoDiscoveryEnabled = autoDiscoveryEnabled;
- clone.problemReportingEnabled = problemReportingEnabled;
- clone.selectedProfile = selectedProfile;
- clone.profileOptionsMap = (LinkedHashMap)profileOptionsMap.clone();
- for(Iterator iter = clone.profileOptionsMap.entrySet().iterator(); iter.hasNext();){
- Map.Entry entry = (Map.Entry)iter.next();
- ProfileOptions o = (ProfileOptions)entry.getValue();
- o = (ProfileOptions)o.clone();
- entry.setValue(o);
- }
- }
-
- protected Object clone() {
- try {
- Store clone = (Store)super.clone();
- copySettingsTo(clone);
- return clone;
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-
- protected Store() {
- isDirty = false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isAutoDiscoveryEnabled()
- */
- public boolean isAutoDiscoveryEnabled() {
- return autoDiscoveryEnabled;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setAutoDiscoveryEnabled(boolean)
- */
- public void setAutoDiscoveryEnabled(boolean enable) {
- autoDiscoveryEnabled = setDirty(autoDiscoveryEnabled, enable);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isSIProblemGenerationEnabled()
- */
- public boolean isProblemReportingEnabled() {
- return problemReportingEnabled;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setSIProblemGenerationEnabled(boolean)
- */
- public void setProblemReportingEnabled(boolean enable) {
- problemReportingEnabled = setDirty(problemReportingEnabled, enable);
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getSelectedProfileId()
- */
- public String getSelectedProfileId() {
- return selectedProfile;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setSelectedProfileId(java.lang.String)
- */
- public void setSelectedProfileId(String profileId) {
- selectedProfile = setDirty(selectedProfile, profileId);
-// if (isDirty) {
-// try {
-// load();
-// isDirty = false;
-// } catch (CoreException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getProfileIdList()
- */
- public List getProfileIdList() {
- return new ArrayList(profileOptionsMap.keySet());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isBuildOutputFileActionEnabled()
- */
- public boolean isBuildOutputFileActionEnabled() {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- return (po != null) ? po.buildOutputFileActionEnabled : false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setBuildOutputFileActionEnabled(boolean)
- */
- public void setBuildOutputFileActionEnabled(boolean enable) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- po.buildOutputFileActionEnabled = setDirty(po.buildOutputFileActionEnabled, enable);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getBuildOutputFilePath()
- */
- public String getBuildOutputFilePath() {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- return (po != null) ? po.buildOutputFilePath : EMPTY_STRING;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setBuildOutputFilePath(java.lang.String)
- */
- public void setBuildOutputFilePath(String path) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- po.buildOutputFilePath = setDirty(po.buildOutputFilePath, path);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isBuildOutputParserEnabled()
- */
- public boolean isBuildOutputParserEnabled() {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- return (po != null) ? po.buildOutputParserEnabled : true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setBuildOutputParserEnabled(boolean)
- */
- public void setBuildOutputParserEnabled(boolean enable) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- po.buildOutputParserEnabled = setDirty(po.buildOutputParserEnabled, enable);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getSIProviderIdList()
- */
- public List getProviderIdList() {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- return (po != null) ? new ArrayList(po.providerOptionsMap.keySet()) : new ArrayList(0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#addSIProvider(java.lang.String)
- */
-// public void addSIProvider(String providerId) {
-// providerOptionsMap.put(providerId, new ProviderOptions());
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#removeSIProvider(java.lang.String)
- */
-// public void removeSIProvider(String providerId) {
-// providerOptionsMap.put(providerId, null);
-// }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isSIProviderOutputParserEnabled(java.lang.String)
- */
- public boolean isProviderOutputParserEnabled(String providerId) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- return (ppo == null) ? false : ppo.providerOutputParserEnabled;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setSIProviderOutputParserEnabled(java.lang.String, boolean)
- */
- public void setProviderOutputParserEnabled(String providerId, boolean enable) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- if (ppo != null) {
- ppo.providerOutputParserEnabled = setDirty(ppo.providerOutputParserEnabled, enable);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#isUseDefaultProviderCommand(java.lang.String)
- */
- public boolean isUseDefaultProviderCommand(String providerId) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- return (ppo == null) ? false : ppo.providerRunUseDefault;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setUseDefaultProviderCommand(java.lang.String, boolean)
- */
- public void setUseDefaultProviderCommand(String providerId, boolean enable) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- if (ppo != null) {
- ppo.providerRunUseDefault = setDirty(ppo.providerRunUseDefault, enable);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getProviderRunCommand(java.lang.String)
- */
- public String getProviderRunCommand(String providerId) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- return (ppo == null) ? null : ppo.providerRunCommand;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setProviderRunCommand(java.lang.String, java.lang.String)
- */
- public void setProviderRunCommand(String providerId, String command) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- if (ppo != null) {
- ppo.providerRunCommand = setDirty(ppo.providerRunCommand, command);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getProviderRunArguments(java.lang.String)
- */
- public String getProviderRunArguments(String providerId) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- return (ppo == null) ? null : ppo.providerRunArguments;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setProviderRunArguments(java.lang.String, java.lang.String)
- */
- public void setProviderRunArguments(String providerId, String arguments) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- if (ppo != null) {
- ppo.providerRunArguments = setDirty(ppo.providerRunArguments, arguments);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#getProviderOpenFilePath(java.lang.String)
- */
- public String getProviderOpenFilePath(String providerId) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- return (ppo == null) ? null : ppo.providerOpenFilePath;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#setProviderOpenFilePath(java.lang.String, java.lang.String)
- */
- public void setProviderOpenFilePath(String providerId, String filePath) {
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(selectedProfile);
- if (po != null) {
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
- if (ppo != null) {
- ppo.providerOpenFilePath = setDirty(ppo.providerOpenFilePath, filePath);
- }
- }
- }
-
- private boolean setDirty(boolean l, boolean r) {
- isDirty = isDirty || (l != r);
- return r;
- }
- private String setDirty(String l, String r) {
- isDirty = isDirty || !l.equals(r);
- return r;
- }
-
- protected abstract void load(ICStorageElement el, String profileId);
-// public abstract void store();
-
- /**
- * Populate buildInfo based on profile configuration
- */
- protected void loadFromProfileConfiguration(ProfileOptions po, String profileId) {
- ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(profileId);
- List providerIds = configuredProfile.getSIProviderIds();
-
- po.buildOutputParserEnabled = false;
- po.buildOutputFileActionEnabled = false;
- po.buildOutputFilePath = EMPTY_STRING;
- if (configuredProfile.getBuildOutputProviderElement() != null) {
- po.buildOutputParserEnabled = true;
- if (configuredProfile.getBuildOutputProviderElement().getAction() != null) {
- po.buildOutputFileActionEnabled = true;
- String buildOutputFilePath = configuredProfile.getBuildOutputProviderElement().
- getAction().getAttribute("file");//$NON-NLS-1$
- po.buildOutputFilePath = (buildOutputFilePath != null) ? buildOutputFilePath : EMPTY_STRING;
- }
- }
- po.providerOptionsMap = new LinkedHashMap(providerIds.size());
- for (int i = 0; i < providerIds.size(); ++i) {
- ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
- String providerId = (String) providerIds.get(i);
- po.providerOptionsMap.put(providerId, ppo);
-
- ppo.providerOutputParserEnabled = (configuredProfile.getScannerInfoProviderElement(providerId) == null) ? false : true;
- ppo.providerKind = configuredProfile.getScannerInfoProviderElement(providerId).getProviderKind();
- String attrValue;
- if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
- attrValue = configuredProfile.getScannerInfoProviderElement(providerId).
- getAction().getAttribute(COMMAND);
- ppo.providerRunCommand = (attrValue != null) ? attrValue : EMPTY_STRING;
- attrValue = configuredProfile.getScannerInfoProviderElement(providerId).
- getAction().getAttribute(ARGUMENTS);
- ppo.providerRunArguments = (attrValue != null) ? attrValue : EMPTY_STRING;
-
- ppo.providerRunUseDefault = true;
- }
- else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) {
- attrValue = configuredProfile.getScannerInfoProviderElement(providerId).
- getAction().getAttribute("file");//$NON-NLS-1$
- ppo.providerOpenFilePath = (attrValue != null) ? attrValue : EMPTY_STRING;
- }
- }
- }
-
- }
-
- /**
- * Build properties stored in .cdtproject file
- *
- * @author vhirsl
- */
- public static class BuildProperty extends Store implements Cloneable{
-// private IProject project;
- private InfoContext context;
-// private IResourceInfo rcInfo;
-// private ITool tool;
-// private InputType inType;
- private String profileId;
-
-// private BuildProperty(IProject project, String profileId) {
-// super();
-// this.project = project;
-// this.profileId = profileId;
-// load();
-// }
-
- private BuildProperty(InfoContext context, ICStorageElement el, String profileId) {
- super();
-
- this.context = context;
-
- load(el, profileId);
- // TODO Auto-generated constructor stub
- }
-
- private BuildProperty(InfoContext context, Store store){
- super();
-
- this.context = context;
-
- store.copySettingsTo(this);
- }
-
- public boolean isDirty(){
- return isDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load()
- */
- protected void load(ICStorageElement el, String profileId) {
-
- List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds();
- List loadedProfiles = new ArrayList();
-// try {
-// descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
- ICStorageElement children[] = el.getChildren();
- for (int i = 0; i < children.length; i++) {
- ICStorageElement child = children[i];
- if (child.getName().equals(SC_AUTODISCOVERY)) {
- autoDiscoveryEnabled = Boolean.valueOf(
- child.getAttribute(ENABLED)).booleanValue();
- selectedProfile = (profileId.equals(ScannerConfigProfileManager.NULL_PROFILE_ID))
- ? child.getAttribute(SELECTED_PROFILE_ID)
- : profileId;
- problemReportingEnabled = Boolean.valueOf(
- child.getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue();
- }
- else if (child.getName().equals(PROFILE)) {
- if (profileIds.contains(child.getAttribute(ID))) {
- loadProfile(child);
- loadedProfiles.add(child.getAttribute(ID));
- }
- }
- }
- if (loadedProfiles.size() < 1) {
- // No ScannerConfigDiscovery entry, try old project location - .project
- if (migrateScannerConfigBuildInfo(ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID)) {
- loadedProfiles.add(ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID);
- }
- else {
- // disable autodiscovery
- autoDiscoveryEnabled = false;
- }
- }
- if (loadedProfiles.size() < profileIds.size()) {
- // initialize remaining profiles with default values
- for (Iterator i = profileIds.iterator(); i.hasNext(); ) {
- /*String */profileId = (String) i.next();
- if (!loadedProfiles.contains(profileId)) {
- loadDefaults(profileId);
- loadedProfiles.add(profileId);
- }
- }
-// // store migrated data
-// isDirty = true;
-// store();
-// save();
- }
-// } catch (CoreException e) {
-// ManagedBuilderCorePlugin.log(e);
-// }
- }
-
- /**
- * Load profile defaults
- * @param profileId
- */
- private void loadDefaults(String profileId) {
- ProfileOptions po = new ProfileOptions();
- po.buildOutputFileActionEnabled = false;
- po.buildOutputParserEnabled = true;
-
- ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(profileId);
-
- po.providerOptionsMap = new LinkedHashMap();
- for (Iterator i = configuredProfile.getSIProviderIds().iterator(); i.hasNext(); ) {
- String providerId = (String) i.next();
- ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
- ScannerInfoProvider configuredProvider = configuredProfile.
- getScannerInfoProviderElement(providerId);
- ppo.providerKind = configuredProvider.getProviderKind();
- ppo.providerOutputParserEnabled = false;
- if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
- ppo.providerRunUseDefault = true;
- ppo.providerRunCommand = configuredProvider.getAction().getAttribute(COMMAND);
- ppo.providerRunArguments = configuredProvider.getAction().getAttribute(ARGUMENTS);
- }
- else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) {
- ppo.providerOpenFilePath = configuredProvider.getAction().getAttribute("file");//$NON-NLS-1$
- }
-
- po.providerOptionsMap.put(providerId, ppo);
- }
-
- if (profileOptionsMap == null) {
- profileOptionsMap = new LinkedHashMap();
- }
- profileOptionsMap.put(profileId, po);
- }
-
- /**
- * @param profileId
- */
- private boolean migrateScannerConfigBuildInfo(String profileId) {
- boolean rc = true;
- try {
- IScannerConfigBuilderInfo oldInfo = ManagedBuilderCorePlugin.
- createScannerConfigBuildInfo(context.getConfiguration().getOwner().getProject(), ScannerConfigBuilder.BUILDER_ID);
- autoDiscoveryEnabled = oldInfo.isAutoDiscoveryEnabled();
- problemReportingEnabled = oldInfo.isSIProblemGenerationEnabled();
- // effectively a PerProject profile
- selectedProfile = profileId;
-
- ProfileOptions po = new ProfileOptions();
- po.buildOutputFileActionEnabled = false;
- po.buildOutputParserEnabled = oldInfo.isMakeBuilderConsoleParserEnabled();
-
- ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
- ppo.providerKind = ScannerConfigProfile.ScannerInfoProvider.RUN;
- ppo.providerOutputParserEnabled = oldInfo.isESIProviderCommandEnabled();
- ppo.providerRunUseDefault = oldInfo.isDefaultESIProviderCmd();
- ppo.providerRunCommand = oldInfo.getESIProviderCommand().toString();
- ppo.providerRunArguments = oldInfo.getESIProviderArguments();
-
- ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(selectedProfile);
- // get the one and only provider id
- String providerId = (String) configuredProfile.getSIProviderIds().get(0);
- po.providerOptionsMap = new LinkedHashMap(1);
- po.providerOptionsMap.put(providerId, ppo);
-
- profileOptionsMap = new LinkedHashMap(1);
- profileOptionsMap.put(profileId, po);
-
- // store migrated data
- isDirty = true;
- save();
- }
- catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- rc = false;
- }
- return rc;
- }
-
- /**
- * @param profile
- */
- private void loadProfile(ICStorageElement profile) {
- if (profileOptionsMap == null) {
- profileOptionsMap = new LinkedHashMap(1);
- }
- ProfileOptions po = new ProfileOptions();
- String profileId = profile.getAttribute(ID);
- profileOptionsMap.put(profileId, po);
- // get the list of providers from the profile configuration
- ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(profileId);
- List providerIds = configuredProfile.getSIProviderIds();
- int providerCounter = 0;
- po.providerOptionsMap = new LinkedHashMap(providerIds.size());
-
- ICStorageElement children[] = profile.getChildren();
- for (int i = 0; i < children.length; i++) {
- ICStorageElement child = children[i];
- // buildOutputProvider element
- if (BUILD_OUTPUT_PROVIDER.equals(child.getName())) {
- ICStorageElement grandChildren[] = child.getChildren();
- for (int k = 0; k < grandChildren.length; k++) {
- ICStorageElement grandChild = grandChildren[k];
- if (OPEN_ACTION.equals(grandChild.getName())) {
- po.buildOutputFileActionEnabled = Boolean.valueOf(
- grandChild.getAttribute(ENABLED)).booleanValue();
- po.buildOutputFilePath = grandChild.getAttribute(FILE_PATH);
- }
- else if (PARSER.equals(grandChild.getName())) {
- po.buildOutputParserEnabled = Boolean.valueOf(
- grandChild.getAttribute(ENABLED)).booleanValue();
- }
- }
- }
- else if (SCANNER_INFO_PROVIDER.equals(child.getName())) {
- String providerId = child.getAttribute(ID);
- if (providerIds.get(providerCounter).equals(providerId)) {
- // new provider
- ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
- po.providerOptionsMap.put(providerId, ppo);
- ppo.providerKind = configuredProfile.getScannerInfoProviderElement(
- providerId).getProviderKind();
-
- ICStorageElement granChildren[] = child.getChildren();
- for (int k = 0; k < granChildren.length; k++) {
- ICStorageElement grandChild = granChildren[k];
- // action
- if (RUN_ACTION.equals(grandChild.getName())) {
- ppo.providerRunUseDefault = Boolean.valueOf(
- grandChild.getAttribute(USE_DEFAULT)).booleanValue();
- ppo.providerRunCommand = grandChild.getAttribute(COMMAND);
- ppo.providerRunArguments = grandChild.getAttribute(ARGUMENTS);
- }
- else if (OPEN_ACTION.equals(grandChild.getName())) {
- ppo.providerOpenFilePath = grandChild.getAttribute(FILE_PATH);
- }
- // parser
- else if (PARSER.equals(grandChild.getName())) {
- ppo.providerOutputParserEnabled = Boolean.valueOf(
- grandChild.getAttribute(ENABLED)).booleanValue();
- }
- }
- ++providerCounter;
- }
- else {
- // mismatch - error
- // TODO Vmir define error
- }
- }
- }
- }
-
- private boolean store(ICStorageElement el) {
-// if (isDirty) {
-// ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true);
-// Element sc = descriptor.getProjectData(SCANNER_CONFIG);
-// Document doc = sc.getOwnerDocument();
-
- // Clear out all current children
-// Node child = sc.getFirstChild();
-// while (child != null) {
-// sc.removeChild(child);
-// child = sc.getFirstChild();
-// }
-
- ICStorageElement autod = el.createChild(SC_AUTODISCOVERY);
- autod.setAttribute(ENABLED, Boolean.toString(autoDiscoveryEnabled));
- autod.setAttribute(SELECTED_PROFILE_ID, selectedProfile);
- autod.setAttribute(PROBLEM_REPORTING_ENABLED, Boolean.toString(problemReportingEnabled));
-
- for (Iterator i = profileOptionsMap.keySet().iterator(); i.hasNext();) {
- String profileId = (String) i.next();
- ICStorageElement profile = el.createChild(PROFILE);
- profile.setAttribute(ID, profileId);
- store(profile, (ProfileOptions) profileOptionsMap.get(profileId));
- }
-
- isDirty = false;
- return true;
-// }
-// return false;
- }
-
- /**
- * @param profile element
- * @param profile options
- */
- private void store(ICStorageElement el, ProfileOptions po) {
- ICStorageElement child, grandchild;
- child = el.createChild(BUILD_OUTPUT_PROVIDER);
- grandchild = child.createChild(OPEN_ACTION);
- grandchild.setAttribute(ENABLED, Boolean.toString(po.buildOutputFileActionEnabled));
- grandchild.setAttribute(FILE_PATH, po.buildOutputFilePath);
- grandchild = child.createChild(PARSER);
- grandchild.setAttribute(ENABLED, Boolean.toString(po.buildOutputParserEnabled));
- // scannerInfoProvider elements
- // get the list of providers from the profile configuration
-// ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
-// getSCProfileConfiguration(selectedProfile);
-// List providerIds = configuredProfile.getSIProviderIds();
- List providerIds = new ArrayList(po.providerOptionsMap.keySet());
- for (int i = 0; i < providerIds.size(); ++i) {
- String providerId = (String) providerIds.get(i);
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions) po.providerOptionsMap.get(providerId);
-
- if (ppo != null) {
- child = el.createChild(SCANNER_INFO_PROVIDER);
- child.setAttribute(ID, providerId);
-
- // action
-// String providerKind = configuredProfile.getScannerInfoProviderElement(
-// providerId).getProviderKind();
- String providerKind = ppo.providerKind;
-
- if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
- grandchild = child.createChild(RUN_ACTION);
- grandchild.setAttribute(USE_DEFAULT, Boolean.toString(ppo.providerRunUseDefault));
- grandchild.setAttribute(COMMAND, ppo.providerRunCommand);
- grandchild.setAttribute(ARGUMENTS, ppo.providerRunArguments);
- }
- else if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) {
- grandchild = child.createChild(OPEN_ACTION);
- grandchild.setAttribute(FILE_PATH, ppo.providerOpenFilePath);
- }
- // parser
- grandchild = child.createChild(PARSER);
- grandchild.setAttribute(ENABLED, Boolean.toString(ppo.providerOutputParserEnabled));
- }
- else {
- // missing provider options - error
- // TODO Vmir define error
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#save()
- */
- public void save() throws CoreException {
- Tool tool = (Tool)context.getTool();
- if(tool != null){
- tool.setScannerConfigInfo(context.getInputType(), this);
- } else {
- Configuration cfg = (Configuration)context.getConfiguration();
- cfg.setScannerConfigInfo(this);
- }
-// if (store()) {
-// ICDescriptorOperation op = new ICDescriptorOperation() {
-//
-// public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
-// descriptor.saveProjectData();
-// }
-//
-// };
-// CCorePlugin.getDefault().getCDescriptorManager().
-// runDescriptorOperation(project, op, null);
-// }
- }
- }
-
- /**
- * Preferences
- *
- * @author vhirsl
- */
- private static class Preference extends Store implements Cloneable {
- private Preferences prefs;
- private String profileId;
- private boolean useDefaults;
-
- /**
- * @param prefs
- * @param profileId
- * @param useDefaults
- */
- public Preference(Preferences prefs, String profileId, boolean useDefaults) {
- super();
- this.prefs = prefs;
- this.profileId = profileId;
- this.useDefaults = useDefaults;
- load(null, profileId);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load()
- */
- protected void load(ICStorageElement el, String profileId) {
- autoDiscoveryEnabled = getBoolean(SCANNER_CONFIG_AUTODISCOVERY_ENABLED, Boolean.TRUE);
- selectedProfile = (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(profileId)) ?
- getString(SCANNER_CONFIG_SELECTED_PROFILE_ID) :
- profileId;
- problemReportingEnabled = getBoolean(SCANNER_CONFIG_PROBLEM_REPORTING_ENABLED);
- if (ScannerConfigProfileManager.NULL_PROFILE_ID.equals(selectedProfile) && !useDefaults) {
- // get the default value
- selectedProfile = prefs.getDefaultString(SCANNER_CONFIG_SELECTED_PROFILE_ID);
- }
- List profileIds = ScannerConfigProfileManager.getInstance().getProfileIds();
- profileOptionsMap = new LinkedHashMap(profileIds.size());
- for (Iterator I = profileIds.iterator(); I.hasNext(); ) {
- /*String */profileId = (String) I.next();
- ProfileOptions po = new ProfileOptions();
- profileOptionsMap.put(profileId, po);
-
- boolean profileStored = getBoolean(SCD + profileId + DOT + ENABLED);
- if (!profileStored && !useDefaults) {
- loadFromProfileConfiguration(po, profileId);
- continue;
- }
-
- po.buildOutputFileActionEnabled = getBoolean(SCD + profileId + BUILD_OUTPUT_OPEN_ACTION_ENABLED);
- po.buildOutputFilePath = getString(SCD + profileId + BUILD_OUTPUT_OPEN_ACTION_FILE_PATH);
- po.buildOutputParserEnabled = getBoolean(SCD + profileId + BUILD_OUTPUT_PARSER_ENABLED);
-
- ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(profileId);
- List providerIds = configuredProfile.getSIProviderIds();
- po.providerOptionsMap = new LinkedHashMap(providerIds.size());
- for (int i = 0; i < providerIds.size(); ++i) {
- String providerId = (String) providerIds.get(i);
- ProfileOptions.ProviderOptions ppo = new ProfileOptions.ProviderOptions();
- po.providerOptionsMap.put(providerId, ppo);
- ppo.providerKind = configuredProfile.getScannerInfoProviderElement(
- providerId).getProviderKind();
-
- ppo.providerOutputParserEnabled = getBoolean(SCD + profileId + DOT +
- providerId + SI_PROVIDER_PARSER_ENABLED);
- if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
- ppo.providerRunUseDefault = getBoolean(SCD + profileId + DOT + providerId +
- SI_PROVIDER_RUN_ACTION_USE_DEFAULT);
- ppo.providerRunCommand = getString(SCD + profileId + DOT + providerId +
- SI_PROVIDER_RUN_ACTION_COMMAND);
- ppo.providerRunArguments = getString(SCD + profileId + DOT + providerId +
- SI_PROVIDER_RUN_ACTION_ARGUMENTS);
- }
- else if (ppo.providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) {
- ppo.providerOpenFilePath = getString(SCD + profileId + DOT + providerId +
- SI_PROVIDER_OPEN_ACTION_FILE_PATH);
- }
- }
- }
- }
-
- private void store() {
- if (isDirty) {
- set(SCANNER_CONFIG_AUTODISCOVERY_ENABLED, autoDiscoveryEnabled);
- set(SCANNER_CONFIG_SELECTED_PROFILE_ID, selectedProfile);
- set(SCANNER_CONFIG_PROBLEM_REPORTING_ENABLED, problemReportingEnabled);
-
- List profileIds = new ArrayList(profileOptionsMap.keySet());
- for (Iterator I = profileIds.iterator(); I.hasNext(); ) {
- String profileId = (String) I.next();
- ProfileOptions po = (ProfileOptions) profileOptionsMap.get(profileId);
-
- set(SCD + profileId + DOT + ENABLED, !useDefaults);
- set(SCD + profileId + BUILD_OUTPUT_OPEN_ACTION_ENABLED, po.buildOutputFileActionEnabled);
- set(SCD + profileId + BUILD_OUTPUT_OPEN_ACTION_FILE_PATH, po.buildOutputFilePath);
- set(SCD + profileId + BUILD_OUTPUT_PARSER_ENABLED, po.buildOutputParserEnabled);
-
- ScannerConfigProfile configuredProfile = ScannerConfigProfileManager.getInstance().
- getSCProfileConfiguration(profileId);
- List providerIds = configuredProfile.getSIProviderIds();
- for (int i = 0; i < providerIds.size(); ++i) {
- String providerId = (String) providerIds.get(i);
- ProfileOptions.ProviderOptions ppo = (ProfileOptions.ProviderOptions)
- po.providerOptionsMap.get(providerId);
-
- set(SCD + profileId + DOT + providerId + SI_PROVIDER_PARSER_ENABLED,
- ppo.providerOutputParserEnabled);
-// String providerKind = configuredProfile.getScannerInfoProviderElement(
-// providerId).getProviderKind();
- String providerKind = ppo.providerKind;
-
- if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.RUN)) {
- set(SCD + profileId + DOT + providerId + SI_PROVIDER_RUN_ACTION_USE_DEFAULT,
- ppo.providerRunUseDefault);
- set(SCD + profileId + DOT + providerId + SI_PROVIDER_RUN_ACTION_COMMAND,
- ppo.providerRunCommand);
- set(SCD + profileId + DOT + providerId + SI_PROVIDER_RUN_ACTION_ARGUMENTS,
- ppo.providerRunArguments);
- }
- else if (providerKind.equals(ScannerConfigProfile.ScannerInfoProvider.OPEN)) {
- set(SCD + profileId + DOT + providerId + SI_PROVIDER_OPEN_ACTION_FILE_PATH,
- ppo.providerOpenFilePath);
- }
- }
- }
-
- isDirty = false;
- }
- }
-
- private boolean getBoolean(String name) {
- return getBoolean(name, null);
- }
-
- private boolean getBoolean(String name, Boolean defaultValue) {
- if(defaultValue != null && !prefs.contains(name)){
- return defaultValue.booleanValue();
- }
- if (useDefaults) {
- return prefs.getDefaultBoolean(name);
- }
- return prefs.getBoolean(name);
- }
- private void set(String name, boolean value) {
- if (useDefaults) {
- prefs.setDefault(name, value);
- }
- else {
- prefs.setValue(name, value);
- }
- }
-
- private String getString(String name) {
- if (useDefaults) {
- return prefs.getDefaultString(name);
- }
- return prefs.getString(name);
- }
- private void set(String name, String value) {
- if (useDefaults) {
- prefs.setDefault(name, value);
- }
- else {
- prefs.setValue(name, value);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2#save()
- */
- public void save() throws CoreException {
- store();
- }
-
- }
-
-// public static IScannerConfigBuilderInfo2 create(IProject project, String profileId) throws CoreException {
-// return new ScannerConfigInfoFactory3.BuildProperty(project, profileId);
-// }
- public static IScannerConfigBuilderInfo2 create(IConfiguration cfg, ICStorageElement el) {
- return new ScannerConfigInfoFactory2.BuildProperty(new InfoContext(cfg), el, ScannerConfigProfileManager.NULL_PROFILE_ID);
- }
-
- public static IScannerConfigBuilderInfo2 create(IConfiguration cfg, Preferences prefs, String id) {
- return create(new InfoContext(cfg), prefs, id, false);
- }
-
- public static IScannerConfigBuilderInfo2 create(InfoContext context, Preferences prefs, String profileId, boolean useDefaults) {
- ScannerConfigInfoFactory2.Preference pref = new ScannerConfigInfoFactory2.Preference(prefs, profileId, useDefaults);
- return new ScannerConfigInfoFactory2.BuildProperty(context, pref);
- }
-
- public static IScannerConfigBuilderInfo2 create(Preferences prefs, String profileId, boolean useDefaults) {
- return new ScannerConfigInfoFactory2.Preference(prefs, profileId, useDefaults);
- }
-
- public static IScannerConfigBuilderInfo2 create(InfoContext context, ICStorageElement el, String profileId) {
- return new ScannerConfigInfoFactory2.BuildProperty(context, el, profileId);
- }
-
- public static IScannerConfigBuilderInfo2 create(InfoContext context, String profileId){
- Configuration cfg = (Configuration)context.getConfiguration();
-
- IConfigurationScannerConfigBuilderInfo cfgInfo = create(cfg, false);
- return cfgInfo.getInfo(context);
-// if(cfgInfo.isPerRcTypeDiscovery()){
-// Tool tool = (Tool)context.getTool();
-// if(tool != null){
-// info = tool.getScannerConfigInfo(context.getInputType());
-// } else {
-// }
-// } else {
-// info = cfg.getScannerConfigInfo();
-// }
-//
-// return info;
- }
-
- public static IScannerConfigBuilderInfo2 create(InfoContext context,
- IScannerConfigBuilderInfo2 base, String profileId){
- ScannerConfigInfoFactory2.BuildProperty prop = (ScannerConfigInfoFactory2.BuildProperty)((ScannerConfigInfoFactory2.BuildProperty)base).clone();
- prop.context = context;
- prop.profileId = profileId;
-
- return prop;
- }
-
- public static void serialize(IScannerConfigBuilderInfo2 info, ICStorageElement el){
- ((ScannerConfigInfoFactory2.BuildProperty)info).store(el);
- }
-
- public static IConfigurationScannerConfigBuilderInfo create(IConfiguration cfg, boolean newInstance){
- Configuration c = (Configuration)cfg;
- if(newInstance)
- return new CfgInfo(c);
- return c.getCfgScannerConfigInfo();
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java
deleted file mode 100644
index 6f0bdffdf4b..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfile.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigScope;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-
-
-/**
- * SCD Profile extension point object model
- *
- * @author vhirsl
- */
-public class ScannerConfigProfile {
- /**
- * scannerInfoCollector element
- *
- * @author vhirsl
- */
- public class ScannerInfoCollector {
- private IConfigurationElement configElem;
-
- public ScannerInfoCollector(IConfigurationElement configElem) {
- this.configElem = configElem;
- }
- public Object createScannerInfoCollector() {
- try {
- return configElem.createExecutableExtension("class"); //$NON-NLS-1$
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- return null;
- }
- }
- public String getScope() {
- return configElem.getAttribute("scope"); //$NON-NLS-1$
- }
- }
- /**
- * scannerInfoConsoleParser element
- *
- * @author vhirsl
- */
- public final class ScannerInfoConsoleParser {
- private IConfigurationElement configElem;
-
- /**
- * @param scannerInfoConsoleParser
- */
- public ScannerInfoConsoleParser(IConfigurationElement configElem) {
- this.configElem = configElem;
- }
- public Object createScannerInfoConsoleParser() {
- try {
- return configElem.createExecutableExtension("class"); //$NON-NLS-1$
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- return null;
- }
- }
- public String getCompilerCommands() {
- return configElem.getAttribute("compilerCommands"); //$NON-NLS-1$
- }
- }
- /**
- * tag interface, a placeholder for either run or open element
- *
- * @author vhirsl
- */
- protected abstract class Action {
- protected IConfigurationElement configElem;
-
- protected Action(IConfigurationElement configElem) {
- this.configElem = configElem;
- }
-
- public Object createExternalScannerInfoProvider() {
- if (configElem.getAttribute("class") != null) { //$NON-NLS-1$
- try {
- return configElem.createExecutableExtension("class"); //$NON-NLS-1$
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- }
- }
- return null;
- }
-
- public String getAttribute(String name) {
- return configElem.getAttribute(name);
- }
- }
- /**
- * run element
- *
- * @author vhirsl
- */
- public final class Run extends Action {
- /**
- * @param run
- */
- public Run(IConfigurationElement run) {
- super(run);
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager.IAction#getNewExternalScannerInfoProvider()
- */
- public Object createExternalScannerInfoProvider() {
- Object provider = super.createExternalScannerInfoProvider();
- if (provider == null) {
- // use the default one
- provider = new DefaultRunSIProvider();
- }
- return provider;
- }
- }
- /**
- * open element
- *
- * @author vhirsl
- */
- public final class Open extends Action {
- /**
- * @param open
- */
- public Open(IConfigurationElement open) {
- super(open);
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager.IAction#getNewExternalScannerInfoProvider()
- */
- public Object createExternalScannerInfoProvider() {
- Object provider = super.createExternalScannerInfoProvider();
- if (provider == null) {
- // use the default one
- provider = new DefaultSIFileReader();
- }
- return provider;
- }
- }
- /**
- * buildOutputProvider element
- *
- * @author vhirsl
- */
- public final class BuildOutputProvider {
- private Open openFileAction;
- private ScannerInfoConsoleParser scannerInfoConsoleParser;
-
- public BuildOutputProvider(IConfigurationElement provider) {
- IConfigurationElement[] actions = provider.getChildren("open"); //$NON-NLS-1$
- // take the first one
- if (actions.length > 0) {
- this.openFileAction = new ScannerConfigProfile.Open(actions[0]);
- }
- IConfigurationElement[] parsers = provider.getChildren("scannerInfoConsoleParser"); //$NON-NLS-1$
- // take the first one
- this.scannerInfoConsoleParser = new ScannerConfigProfile.ScannerInfoConsoleParser(parsers[0]);
- }
-
- public Action getAction() {
- return openFileAction;
- }
- public ScannerInfoConsoleParser getScannerInfoConsoleParser() {
- return scannerInfoConsoleParser;
- }
- }
- /**
- * scannerInfoProvider element
- *
- * @author vhirsl
- */
- public final class ScannerInfoProvider {
- public static final String RUN = "run";//$NON-NLS-1$
- public static final String OPEN = "open";//$NON-NLS-1$
-
- private String providerId;
- private String providerKind; // derived attribute
- private Action action;
- private ScannerInfoConsoleParser scannerInfoConsoleParser;
-
- public ScannerInfoProvider(IConfigurationElement provider) {
- providerId = provider.getAttribute("providerId"); //$NON-NLS-1$
- IConfigurationElement[] actions = provider.getChildren();
- providerKind = actions[0].getName();
- if (providerKind.equals(RUN)) {
- this.action = new ScannerConfigProfile.Run(actions[0]);
- }
- else if (providerKind.equals(OPEN)) { //$NON-NLS-1$
- this.action = new ScannerConfigProfile.Open(actions[0]);
- }
- else {
- // TODO Vmir generate an error
- }
- IConfigurationElement[] parsers = provider.getChildren("scannerInfoConsoleParser"); //$NON-NLS-1$
- // take the first one
- scannerInfoConsoleParser = new ScannerConfigProfile.ScannerInfoConsoleParser(parsers[0]);
- }
-
- public String getProviderId() {
- return providerId;
- }
- public String getProviderKind() {
- return providerKind;
- }
- public Action getAction() {
- return action;
- }
- public ScannerInfoConsoleParser getScannerInfoConsoleParser() {
- return scannerInfoConsoleParser;
- }
- }
-
- // ScannerConfigProfile members
- private final String id;
-
- private ScannerInfoCollector scannerInfoCollector;
- private BuildOutputProvider buildOutputProvider;
- private Map scannerInfoProviders = new LinkedHashMap();
-
- /**
- * @param profileId
- */
- public ScannerConfigProfile(String profileId) {
- id = profileId;
- load();
- }
- /**
- * loads the profile from the manifest file.
- */
- private void load() {
-// IExtensionPoint extension = Platform.getExtensionRegistry().
-// getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
-// if (extension != null) {
- IExtension[] extensions = getExtensions();//extension.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- String rProfileId = extensions[i].getUniqueIdentifier();
- if (rProfileId != null && rProfileId.equals(getId())) {
- IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
- for (int j = 0; j < configElements.length; ++j) {
- String name = configElements[j].getName();
- if (scannerInfoCollector == null &&
- name.equals("scannerInfoCollector")) { //$NON-NLS-1$
- scannerInfoCollector = new ScannerConfigProfile.ScannerInfoCollector(configElements[j]);
- }
- else if (name.equals("buildOutputProvider")) { //$NON-NLS-1$
- buildOutputProvider = new ScannerConfigProfile.BuildOutputProvider(configElements[j]);
- }
- else if (name.equals("scannerInfoProvider")) { //$NON-NLS-1$
- String providerId = configElements[j].getAttribute("providerId"); //$NON-NLS-1$
- if (providerId != null && scannerInfoProviders.get(providerId) == null) {
- scannerInfoProviders.put(providerId,
- new ScannerConfigProfile.ScannerInfoProvider(configElements[j]));
- }
- }
- }
- break;
- }
- }
-// }
- }
-
- private IExtension[] getExtensions(){
- IExtensionPoint extension = Platform.getExtensionRegistry().
- getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
- List list = new ArrayList();
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- list.addAll(Arrays.asList(extensions));
- }
-
- extension = Platform.getExtensionRegistry().
- getExtensionPoint(ScannerConfigProfileManager.OLD_SI_PROFILE_FULL_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- list.addAll(Arrays.asList(extensions));
- }
-
- return (IExtension[])list.toArray(new IExtension[list.size()]);
-
- }
- /**
- * @return Returns the id.
- */
- public String getId() {
- return id;
- }
-
- // access to model objects
- /**
- * @return Returns the list of providerIds
- */
- public List getSIProviderIds() {
- return new ArrayList(scannerInfoProviders.keySet());
- }
- /**
- * @return Returns the buildOutputProvider.
- */
- public BuildOutputProvider getBuildOutputProviderElement() {
- return buildOutputProvider;
- }
- /**
- * @return Returns the scannerInfoCollector.
- */
- public ScannerInfoCollector getScannerInfoCollectorElement() {
- return scannerInfoCollector;
- }
-
- public ScannerConfigScope getProfileScope() {
- ScannerConfigScope scope = null;
- if (scannerInfoCollector != null) {
- if (scannerInfoCollector.getScope().equals(ScannerConfigScope.PROJECT_SCOPE.toString())) {
- scope = ScannerConfigScope.PROJECT_SCOPE;
- }
- else if (scannerInfoCollector.getScope().equals(ScannerConfigScope.FILE_SCOPE.toString())) {
- scope = ScannerConfigScope.FILE_SCOPE;
- }
- }
- return scope;
- }
-
- /**
- * @return Returns the scannerInfoProviders.
- */
- public ScannerInfoProvider getScannerInfoProviderElement(String providerId) {
- return (ScannerInfoProvider) scannerInfoProviders.get(providerId);
- }
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java
deleted file mode 100644
index 269b8717c67..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/ScannerConfigProfileManager.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation 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:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.make.internal.core.scannerconfig2;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-
-/**
- * Manages profiles per project
- *
- * @author vhirsl
- */
-public class ScannerConfigProfileManager {
- private static final String OLD_MAKE_CORE_PLUGIN_ID = "org.eclipse.cdt.make.core"; //$NON-NLS-1$
- public static final String SI_PROFILE_SIMPLE_ID = "ScannerConfigurationDiscoveryProfile"; //$NON-NLS-1$
- public static final String PER_PROJECT_PROFILE_ID = OLD_MAKE_CORE_PLUGIN_ID + ".GCCStandardMakePerProjectProfile"; //$NON-NLS-1$
- public static final String DEFAULT_SI_PROFILE_ID = PER_PROJECT_PROFILE_ID;
- public static final String NULL_PROFILE_ID = "";//$NON-NLS-1$
- public static final String OLD_SI_PROFILE_FULL_ID = OLD_MAKE_CORE_PLUGIN_ID + "." + SI_PROFILE_SIMPLE_ID; //$NON-NLS-1$
-
- private class CachedInstance {
- InfoContext context;
- SCProfileInstance instance;
-
- CachedInstance(InfoContext c, SCProfileInstance instance){
- this.context = c;
- this.instance = instance;
-
- }
- }
- private Map projectProfileInstance;
- private List profileIds;
-
- /**
- * Singleton pattern
- */
- private ScannerConfigProfileManager() {
- projectProfileInstance = new HashMap();
- }
- private static ScannerConfigProfileManager instance = null;
-
- public static ScannerConfigProfileManager getInstance() {
- if (instance == null) {
- instance = new ScannerConfigProfileManager();
- }
- return instance;
- }
-
- /*uncomment
- private String getProfileId(IProject project) {
- String profileId;
- IScannerConfigBuilderInfo2 buildInfo = null;
- try {
- buildInfo = createScannerConfigBuildInfo2(project);
- profileId = buildInfo.getSelectedProfileId();
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- profileId = DEFAULT_SI_PROFILE_ID;
- }
- return profileId;
- }
- */
-
- private String getProfileId(InfoContext context) {
- String profileId;
- IScannerConfigBuilderInfo2 buildInfo = null;
- try {
- buildInfo = createScannerConfigBuildInfo2(context);
- profileId = buildInfo.getSelectedProfileId();
- } catch (CoreException e) {
- ManagedBuilderCorePlugin.log(e);
- profileId = DEFAULT_SI_PROFILE_ID;
- }
- return profileId;
- }
-
- /**
- * For projects that do not have profile id specified in .project file.
- * For example managed projects.
- * @param project
- * @param profile
- */
-// public void addProfile(IProject project, ScannerConfigProfile profile) {
-// projectProfileInstance.put(project, profile);
-// }
-
- /**
- * @param project
- * @param profileId - if null, get the one associated with the project
- * @return Returns the scannerConfigProfile instance for a project.
- */
- /*uncomment
- public SCProfileInstance getSCProfileInstance(IProject project, String profileId) {
- // if not specified read from .project file
- if (profileId == NULL_PROFILE_ID) {
- profileId = getProfileId(project);
- }
- // is the project's profile already loaded?
- SCProfileInstance profileInstance = (SCProfileInstance) projectProfileInstance.get(project);
- if (profileInstance == null || !profileInstance.getProfile().getId().equals(profileId)) {
- profileInstance = new SCProfileInstance(project, getSCProfileConfiguration(profileId));
- projectProfileInstance.put(project, profileInstance);
- }
- return profileInstance;
- }
- */
-
- public SCProfileInstance getSCProfileInstance(IProject project, InfoContext context, String profileId) {
- if(context == null)
- context = ScannerConfigUtil.createContextForProject(project);
- return getSCProfileInstance(context, profileId);
- }
-
- public SCProfileInstance getSCProfileInstance(InfoContext context, String profileId) {
- // if not specified read from .project file
- if (profileId == NULL_PROFILE_ID) {
- profileId = getProfileId(context);
- }
- IResource owner = context.getConfiguration().getOwner();
- IProject project = null;
- if(owner != null)
- owner.getProject();
-
- // is the project's profile already loaded?
- CachedInstance ci = (CachedInstance)projectProfileInstance.get(project);
- SCProfileInstance profileInstance = null;
- if (ci == null || !ci.context.equals(context) || !ci.instance.getProfile().getId().equals(profileId)) {
- profileInstance = new SCProfileInstance(context, getSCProfileConfiguration(profileId));
- projectProfileInstance.put(project, new CachedInstance(context, profileInstance));
- } else {
- profileInstance = ci.instance;
- }
- return profileInstance;
- }
-
- /**
- * @param profileId
- * @return
- */
- public SCProfileInstance getSCProfileInstance(String profileId) {
- SCProfileInstance profileInstance = null;
- if (profileId != NULL_PROFILE_ID) {
- profileInstance = new SCProfileInstance((IProject)null, getSCProfileConfiguration(profileId));
- }
- return profileInstance;
- }
-
- /**
- * @param profileId - if null, get the default one
- * @return Returns the scannerConfigProfile for a project.
- */
- public ScannerConfigProfile getSCProfileConfiguration(String profileId) {
- profileId = (profileId == NULL_PROFILE_ID) ? getDefaultSIProfileId() : profileId;
- return new ScannerConfigProfile(profileId);
- }
-
- private IExtension[] getExtensions(){
- IExtensionPoint extension = Platform.getExtensionRegistry().
- getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
- List list = new ArrayList();
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- list.addAll(Arrays.asList(extensions));
- }
-
- extension = Platform.getExtensionRegistry().
- getExtensionPoint(ScannerConfigProfileManager.OLD_SI_PROFILE_FULL_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- list.addAll(Arrays.asList(extensions));
- }
-
- return (IExtension[])list.toArray(new IExtension[list.size()]);
-
- }
-
- /**
- * @return
- */
- public List getProfileIds() {
- if (profileIds == null) {
- profileIds = new ArrayList();
-// IExtensionPoint extension = Platform.getExtensionRegistry().
-// getExtensionPoint(ManagedBuilderCorePlugin.getUniqueIdentifier(), ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
-// if (extension != null) {
- IExtension[] extensions = getExtensions(); //extension.getExtensions();
- for (int i = 0; i < extensions.length; ++i) {
- String rProfileId = extensions[i].getUniqueIdentifier();
- profileIds.add(rProfileId);
- }
-// }
- }
- return profileIds;
- }
-
- /**
- * @return default profile id
- */
- public static String getDefaultSIProfileId() {
- return DEFAULT_SI_PROFILE_ID;
- }
-
- /**
- * Set selectedProfile to profileId
- * @param project
- * @param profileId
- * @return
- * @throws CoreException
- */
- /*uncomment
- public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project, String profileId) throws CoreException {
- return ScannerConfigInfoFactory2.create(project, profileId);
- }
- */
-
- /**
- * Use stored selectedProfile
- * @param project
- * @return
- * @throws CoreException
- */
- /*uncomment
- public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project) throws CoreException {
- return ScannerConfigInfoFactory2.create(project, ScannerConfigProfileManager.NULL_PROFILE_ID);
- }
- */
-
- public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(InfoContext context) throws CoreException {
- return ScannerConfigInfoFactory2.create(context, ScannerConfigProfileManager.NULL_PROFILE_ID);
- }
-
- public static IConfigurationScannerConfigBuilderInfo getCfgScannerConfigBuildInfo(IConfiguration cfg){
- return ScannerConfigInfoFactory2.create(cfg, false);
- }
-
- /**
- * Set selectedProfile to profileId
- * @param prefs
- * @param profileId
- * @param useDefaults
- * @return
- */
- public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(Preferences prefs, String profileId, boolean useDefaults) {
- return ScannerConfigInfoFactory2.create(prefs, profileId, useDefaults);
- }
-
- /**
- * Use stored selectedProfile
- * @param prefs
- * @param useDefaults
- * @return
- */
- public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(Preferences prefs, boolean useDefaults) {
- return ScannerConfigInfoFactory2.create(prefs, ScannerConfigProfileManager.NULL_PROFILE_ID, useDefaults);
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
index 9e0243d791c..5d9f22106ed 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IInputType.java
@@ -40,9 +40,6 @@ public interface IInputType extends IBuildObject {
// The attribute name for the scanner info collector
public static final String SCANNER_CONFIG_PROFILE_ID = "scannerConfigDiscoveryProfileId"; //$NON-NLS-1$
- public static final String DISCOVERY_INFO = "discoveryInfo"; //$NON-NLS-1$
-
-
/**
* Creates an inputOrder child for this InputType.
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java
index f9d171d2d24..5273f5eeaa6 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IToolChain.java
@@ -50,7 +50,6 @@ public interface IToolChain extends IBuildObject, IHoldsOptions {
// The attribute name for the scanner info collector
public static final String SCANNER_CONFIG_PROFILE_ID = "scannerConfigDiscoveryProfileId"; //$NON-NLS-1$
- public static final String DISCOVERY_INFO = "discoveryInfo"; //$NON-NLS-1$
/**
* Returns the configuration that is the parent of this tool-chain.
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
index 3f641ebc5eb..f0f53a799f7 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java
@@ -11,35 +11,23 @@
package org.eclipse.cdt.managedbuilder.core;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
-import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathManager;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigInfoFactory;
-import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerConfigUtil;
-import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
+import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DbgUtil;
import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
+import org.eclipse.cdt.managedbuilder.internal.dataprovider.ProjectConverter;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildPathEntryContainerInitializer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;
@@ -57,19 +45,9 @@ public class ManagedBuilderCorePlugin extends Plugin {
// ResourceConfiguration elements up to date. It may also be needed by AdditionalInput
// elements
- private static final String SCANNER_CONFIG = getUniqueIdentifier() + "/debug/scdiscovery"; //$NON-NLS-1$
- public static final String EXTERNAL_SI_PROVIDER_SIMPLE_ID = "ExternalScannerInfoProvider"; //$NON-NLS-1$
- public static final String SI_CONSOLE_PARSER_SIMPLE_ID = "ScannerInfoConsoleParser"; //$NON-NLS-1$
- public static final String DEFAULT_EXTERNAL_SI_PROVIDER_ID = getUniqueIdentifier() + ".DefaultExternalScannerInfoProvider"; //$NON-NLS-1$
-
- public static final String GCC_SPECS_CONSOLE_PARSER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".GCCSpecsConsoleParser"; //$NON-NLS-1$
- public static final String GCC_SCANNER_INFO_CONSOLE_PARSER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".GCCScannerInfoConsoleParser"; //$NON-NLS-1$
-
-
-
private static ResourceChangeHandler2 listener;
- private DiscoveredPathManager fDiscoveryPathManager;
+// private DiscoveredPathManager fDiscoveryPathManager;
/**
* @param descriptor
@@ -104,9 +82,7 @@ public class ManagedBuilderCorePlugin extends Plugin {
super.start(context);
configurePluginDebugOptions();
- GCCScannerConfigUtil.createSpecs();
-
-
+
// NOTE: The code below is for tracking resource renaming and deleting. This is needed to keep
// ResourceConfiguration elements up to date. It may also be needed by AdditionalInput
// elements
@@ -189,11 +165,11 @@ public class ManagedBuilderCorePlugin extends Plugin {
* @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
-
- if (fDiscoveryPathManager != null) {
- fDiscoveryPathManager.shutdown();
- fDiscoveryPathManager = null;
- }
+ CfgDiscoveredPathManager.stop();
+// if (fDiscoveryPathManager != null) {
+// fDiscoveryPathManager.shutdown();
+// fDiscoveryPathManager = null;
+// }
@@ -250,11 +226,6 @@ public class ManagedBuilderCorePlugin extends Plugin {
if(buildModel != null){
DbgUtil.DEBUG = buildModel.equalsIgnoreCase("true"); //$NON-NLS-1$
}
- String option = Platform.getDebugOption(SCANNER_CONFIG);
- if (option != null) {
- TraceUtil.SCANNER_CONFIG = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
- }
-
}
}
@@ -274,129 +245,20 @@ public class ManagedBuilderCorePlugin extends Plugin {
return BuilderFactory.createBuilderForEclipseBuilder(cfg, eclipseBuilderID);
}
- public IDiscoveredPathManager getDiscoveryManager() {
- if ( fDiscoveryPathManager == null) {
- fDiscoveryPathManager = new DiscoveredPathManager();
- fDiscoveryPathManager.startup();
- }
- return fDiscoveryPathManager;
+ public boolean isOldStyleMakeProject(IProject project){
+ return ProjectConverter.isOldStyleMakeProject(project);
}
- public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
- Preferences prefs, String builderID, boolean useDefaults) {
- return ScannerConfigInfoFactory.create(prefs, builderID, useDefaults);
- }
-
- public static IPath getWorkingDirectory() {
- return ManagedBuilderCorePlugin.getDefault().getStateLocation();
- }
-
- public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
- IProject project, String builderID) throws CoreException {
- return ScannerConfigInfoFactory.create(project, builderID);
- }
-
- public static IScannerConfigBuilderInfo createScannerConfigBuildInfo(
- Map args, String builderID) {
- return ScannerConfigInfoFactory.create(args, builderID);
- }
-
- /**
- * @param id - id specifying external scanner info provider
- * @return provider - new instance of an external scanner info provider
- */
- public IExternalScannerInfoProvider getExternalScannerInfoProvider(String id) {
- try {
- IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, EXTERNAL_SI_PROVIDER_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- String tool = extensions[i].getUniqueIdentifier();
- if (tool != null && tool.equals(id)) {
- IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
- for (int j = 0; j < configElements.length; j++) {
- IConfigurationElement[] runElement = configElements[j].getChildren("run"); //$NON-NLS-1$
- if (runElement.length > 0) {
- IExternalScannerInfoProvider builder = (IExternalScannerInfoProvider) runElement[0].createExecutableExtension("class"); //$NON-NLS-1$
- return builder;
- }
- }
- }
- }
- }
- }
- catch (CoreException e) {
- log(e);
- }
- return null;
- }
-
- /**
- * @param commandId
- * @return String[] - array of parserIds associated with the commandId or 'all'
- */
- public String[] getScannerInfoConsoleParserIds(String commandId) {
- String[] empty = new String[0];
- if (commandId == null || commandId.length() == 0) {
- commandId = "all"; //$NON-NLS-1$
- }
- IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, SI_CONSOLE_PARSER_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- List parserIds = new ArrayList(extensions.length);
- for (int i = 0; i < extensions.length; i++) {
- String parserId = extensions[i].getUniqueIdentifier();
- if (parserId != null) {
- IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
- String id = configElements[0].getAttribute("commandId");//$NON-NLS-1$
- if (id != null && (id.equals(commandId) || id.equals("all"))) { //$NON-NLS-1$
- parserIds.add(parserId);
- }
- }
- }
- return (String[])parserIds.toArray(empty);
- }
- return empty;
- }
-
- /**
- * @param parserId
- * @return parser - parser object identified by the parserId
- */
- public IScannerInfoConsoleParser getScannerInfoConsoleParser(String parserId) {
- try {
- IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, SI_CONSOLE_PARSER_SIMPLE_ID);
- if (extension != null) {
- IExtension[] extensions = extension.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- String id = extensions[i].getUniqueIdentifier();
- if (id != null && id.equals(parserId)) {
- IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
- IScannerInfoConsoleParser parser = (IScannerInfoConsoleParser)configElements[0].createExecutableExtension("class");//$NON-NLS-1$
- return parser;
- }
- }
- }
- }
- catch (CoreException e) {
- log(e);
- }
- return null;
+ public void convertOldStdMakeToNewStyle(IProject project, IProgressMonitor monitor) throws CoreException{
+ ProjectConverter.convertOldStdMakeToNewStyle(project, monitor);
}
-/*
- public static IMakeBuilderInfo createBuildInfo(Preferences prefs, String builderID, boolean useDefaults) {
- return BuildInfoFactory.create(prefs, builderID, useDefaults);
- }
-
- public static IMakeBuilderInfo createBuildInfo(IProject project, String builderID) throws CoreException {
- return BuildInfoFactory.create(project, builderID);
- }
-
- public static IMakeBuilderInfo createBuildInfo(Map args, String builderID) {
- return BuildInfoFactory.create(args, builderID);
- }
-*/
-
+// public IDiscoveredPathManager getDiscoveryManager() {
+// if ( fDiscoveryPathManager == null) {
+// fDiscoveryPathManager = new DiscoveredPathManager();
+// fDiscoveryPathManager.startup();
+// }
+// return fDiscoveryPathManager;
+// }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
index 4b133702aeb..d2787a01716 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java
@@ -640,7 +640,7 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
if(tmp != null)
autoBuildEnabled = Boolean.valueOf(tmp);
incrementalBuildTarget = element.getAttribute(ATTRIBUTE_TARGET_INCREMENTAL);
- tmp = element.getAttribute(ATTRIBUTE_AUTO_ENABLED);
+ tmp = element.getAttribute(ATTRIBUTE_INCREMENTAL_ENABLED);
if(tmp != null)
incrementalBuildEnabled = Boolean.valueOf(tmp);
cleanBuildTarget = element.getAttribute(ATTRIBUTE_TARGET_CLEAN);
@@ -1522,6 +1522,12 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
return fBuildData;
}
+// public String[] getCustomizedErrorParserIds(){
+// if(customizedErrorParserIds != null)
+// return (String[])customizedErrorParserIds.clone();
+// return null;
+// }
+
public String[] getErrorParsers() {
if(isCustomBuilder() && customizedErrorParserIds != null)
return (String[])customizedErrorParserIds.clone();
@@ -1530,6 +1536,16 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
IConfiguration parentConfig = parent.getParent();
return parentConfig.getErrorParserList();
}
+
+ public String[] getCustomizedErrorParserIds(){
+ if(customizedErrorParserIds != null)
+ return (String[])customizedErrorParserIds.clone();
+ return null;
+ }
+
+ public void setCustomizedErrorParserIds(String[] ids){
+ customizedErrorParserIds = ids != null ? (String[])ids.clone() : ids;
+ }
public void setErrorParsers(String[] parsers) throws CoreException {
if(isCustomBuilder()){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
index 634e81e8ad3..cd8afc538e5 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
@@ -293,7 +293,12 @@ public class BuilderFactory {
String type = (String)args.get(CONTENTS);
if(type == null){
IConfiguration cfg = info.getDefaultConfiguration();
- IBuilder builder = cfg.getEditableBuilder();
+ IBuilder builder;
+ if(args.size() == 0){
+ builder = cfg.getEditableBuilder();
+ } else {
+ builder = createBuilder(cfg, args);
+ }
builders = new IBuilder[]{builder};
//TODO:
} else if (CONTENTS_BUILDER.equals(type)){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
index 81578ac333e..0421d632cdd 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java
@@ -21,6 +21,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
+import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
+import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ConsoleOutputStream;
@@ -33,6 +36,8 @@ import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.util.ListComparator;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
@@ -1445,8 +1450,17 @@ public class CommonBuilder extends ACBuilder {
OutputStream stdout = epm.getOutputStream();
OutputStream stderr = epm.getOutputStream();
// Sniff console output for scanner info
+ ICfgScannerConfigBuilderInfo2Set container = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
+ CfgInfoContext context = new CfgInfoContext(cfg);
+ InfoContext baseContext;
+ IScannerConfigBuilderInfo2 info = container.getInfo(context);
+ if(info == null){
+ baseContext = new InfoContext(currProject);
+ } else {
+ baseContext = context.toInfoContext();
+ }
ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getMakeBuilderOutputSniffer(
- stdout, stderr, cfg, null, workingDirectory, null, this, null);
+ stdout, stderr, currProject, baseContext, workingDirectory, info, this, null);
OutputStream consoleOut = (sniffer == null ? stdout : sniffer.getOutputStream());
OutputStream consoleErr = (sniffer == null ? stderr : sniffer.getErrorStream());
Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
index 9cf9c34086e..801f369189e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java
@@ -20,6 +20,7 @@ import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
+import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@@ -31,10 +32,7 @@ import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
-import org.eclipse.cdt.make.core.scannerconfig.IConfigurationScannerConfigBuilderInfo;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
@@ -127,7 +125,7 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
// private IScannerConfigBuilderInfo2 scannerCfgBuilderInfo;
// private IDiscoveredPathManager.IDiscoveredPathInfo discoveredInfo;
// private Boolean isPerResourceDiscovery;
- private IConfigurationScannerConfigBuilderInfo cfgScannerInfo;
+ private ICfgScannerConfigBuilderInfo2Set cfgScannerInfo;
private boolean isPreferenceConfig;
//property name for holding the rebuild state
@@ -2753,15 +2751,15 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
tc.setPerRcTypeDiscovery(on);
}
- public IScannerConfigBuilderInfo2 getScannerConfigInfo(){
- ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
- return tc.getScannerConfigBuilderInfo();
- }
+// public IScannerConfigBuilderInfo2 getScannerConfigInfo(){
+// ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+// return tc.getScannerConfigBuilderInfo();
+// }
- public IScannerConfigBuilderInfo2 setScannerConfigInfo(IScannerConfigBuilderInfo2 info){
- ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
- return tc.setScannerConfigBuilderInfo(info);
- }
+// public IScannerConfigBuilderInfo2 setScannerConfigInfo(IScannerConfigBuilderInfo2 info){
+// ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
+// return tc.setScannerConfigBuilderInfo(info);
+// }
public IDiscoveredPathManager.IDiscoveredPathInfo setDiscoveredPathInfo(IDiscoveredPathManager.IDiscoveredPathInfo info){
ToolChain tc = (ToolChain)getRootFolderInfo().getToolChain();
@@ -2783,14 +2781,11 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
return tc.setDiscoveredPathInfo(null);
}
- public IConfigurationScannerConfigBuilderInfo getCfgScannerConfigInfo(){
- if(cfgScannerInfo == null){
- cfgScannerInfo = ScannerConfigInfoFactory2.create(this, true);
- }
+ public ICfgScannerConfigBuilderInfo2Set getCfgScannerConfigInfo(){
return cfgScannerInfo;
}
- public void setCfgScannerConfigInfo(IConfigurationScannerConfigBuilderInfo info){
+ public void setCfgScannerConfigInfo(ICfgScannerConfigBuilderInfo2Set info){
cfgScannerInfo = info;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
index 51b58f809d3..1cc8e61fa84 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
@@ -19,10 +19,6 @@ import java.util.Vector;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
@@ -81,7 +77,6 @@ public class InputType extends BuildObject implements IInputType {
private IConfigurationElement languageInfoCalculatorElement;
private ILanguageInfoCalculator languageInfoCalculator;
private String buildInfoDicsoveryProfileId;
- private IScannerConfigBuilderInfo2 scannerConfigInfo;
private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator;
@@ -143,10 +138,7 @@ public class InputType extends BuildObject implements IInputType {
} else if (iElement.getName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
AdditionalInput addlInput = new AdditionalInput(this, iElement);
getAdditionalInputList().add(addlInput);
- } else if (iElement.getName().equals(DISCOVERY_INFO)){
- ICStorageElement el = new ManagedConfigStorageElement(iElement);
- scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(null), el, ScannerConfigProfileManager.NULL_PROFILE_ID);
- }
+ }
}
}
@@ -204,9 +196,7 @@ public class InputType extends BuildObject implements IInputType {
} else if (configElement.getName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
AdditionalInput addlInput = new AdditionalInput(this, configElement);
getAdditionalInputList().add(addlInput);
- } else if(configElement.getName().equals(DISCOVERY_INFO)){
- scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(parent.getParentResourceInfo(), parent, this), configElement, ScannerConfigProfileManager.NULL_PROFILE_ID);
- }
+ }
}
}
@@ -284,9 +274,6 @@ public class InputType extends BuildObject implements IInputType {
languageInfoCalculator = inputType.languageInfoCalculator;
buildInfoDicsoveryProfileId = inputType.buildInfoDicsoveryProfileId;
- if(inputType.scannerConfigInfo != null){
- scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(parent.getParentResourceInfo(), parent, this), inputType.scannerConfigInfo, inputType.scannerConfigInfo.getSelectedProfileId());
- }
// Clone the children
if (inputType.inputOrderList != null) {
Iterator iter = inputType.getInputOrderList().listIterator();
@@ -746,11 +733,6 @@ public class InputType extends BuildObject implements IInputType {
ai.serialize(aiElement);
}
- if(scannerConfigInfo != null){
- ICStorageElement el = element.createChild(DISCOVERY_INFO);
- ScannerConfigInfoFactory2.serialize(scannerConfigInfo, el);
- }
-
// I am clean now
isDirty = false;
}
@@ -1861,32 +1843,8 @@ public class InputType extends BuildObject implements IInputType {
return calc.isInputTypeEnabled(tool, this);
}
-
- public IScannerConfigBuilderInfo2 getScannerConfigBuilderInfoElement(boolean searchSuper){
- if(scannerConfigInfo == null){
- if(superClass != null && searchSuper){
- return ((InputType)superClass).getScannerConfigBuilderInfoElement(true);
- }
- return null;
- }
- return scannerConfigInfo;
- }
- IScannerConfigBuilderInfo2 getScannerConfigBuilderInfo(ITool tool){
- IScannerConfigBuilderInfo2 info = getScannerConfigBuilderInfoElement(true);
- if(info == null){
- info = ((Tool)tool).getScannerConfigBuilderInfo();
- }
- return info;
- }
-
- public void setScannerConfigBuilderInfo(IScannerConfigBuilderInfo2 info){
- scannerConfigInfo = info;
- }
-
public boolean hasScannerConfigSettings(){
- if(getScannerConfigBuilderInfoElement(true) != null)
- return true;
if(getDiscoveryProfileIdAttribute() != null)
return true;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedConfigStorageElement.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedConfigStorageElement.java
index 1eb73d43c0b..b464e74cbd4 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedConfigStorageElement.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedConfigStorageElement.java
@@ -80,4 +80,8 @@ public class ManagedConfigStorageElement implements ICStorageElement {
public void setValue(String value) {
throw new WriteAccessException();
}
+
+ public String[] getAttributeNames() {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MapStorageElement.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MapStorageElement.java
index 0558d319366..9a230b909ba 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MapStorageElement.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MapStorageElement.java
@@ -93,6 +93,10 @@ public class MapStorageElement implements ICStorageElement {
return map;
}
+
+ protected boolean isSystemKey(String key){
+ return key.indexOf('?') == 0 && key.lastIndexOf('?') == key.length() - 1;
+ }
public void clear() {
fMap.clear();
@@ -270,4 +274,17 @@ public class MapStorageElement implements ICStorageElement {
// TODO
throw new UnsupportedOperationException();
}
+
+ public String[] getAttributeNames() {
+ List list = new ArrayList(fMap.size());
+ for(Iterator iter = fMap.entrySet().iterator(); iter.hasNext();){
+ Map.Entry entry = (Map.Entry)iter.next();
+ String key = (String)entry.getKey();
+ if(!isSystemKey(key)){
+ list.add(key);
+ }
+ }
+
+ return (String[])list.toArray(new String[list.size()]);
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java
index 7bec9ed8d0e..9cbffb2edef 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PropertyManager.java
@@ -83,12 +83,17 @@ public class PropertyManager {
protected Map getLoaddedData(IConfiguration cfg){
Map map = null;
+ IProject proj = null;
try {
- IProject proj = cfg.getOwner().getProject();
- map = (Map)proj.getSessionProperty(propsSessionProperty);
+ if(!((Configuration)cfg).isPreference()){
+ proj = cfg.getOwner().getProject();
+ map = (Map)proj.getSessionProperty(propsSessionProperty);
+ }
if(map == null){
map = new HashMap();
- proj.setSessionProperty(propsSessionProperty, map);
+ if(proj != null){
+ proj.setSessionProperty(propsSessionProperty, map);
+ }
}
map = (Map)map.get(cfg.getId());
} catch (CoreException e) {
@@ -97,6 +102,9 @@ public class PropertyManager {
}
protected void clearLoaddedData(IConfiguration cfg){
+ if(((Configuration)cfg).isPreference())
+ return;
+
IProject proj = cfg.getOwner().getProject();
try {
proj.setSessionProperty(propsSessionProperty, null);
@@ -368,6 +376,9 @@ public class PropertyManager {
}
public void clearProperties(IConfiguration cfg){
+ if(cfg.getOwner() == null)
+ return;
+
clearLoaddedData(cfg);
storeData(cfg, null);
}
@@ -391,7 +402,7 @@ public class PropertyManager {
}
public void serialize(IConfiguration cfg){
- if(cfg.isTemporary())
+ if(cfg.isTemporary() || cfg.getOwner() == null)
return;
storeData(cfg);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
index 33d28d46255..a17d6da8b6b 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
@@ -29,10 +29,6 @@ import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.BuildException;
@@ -56,7 +52,6 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildLanguageData;
import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
@@ -157,66 +152,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
private HashMap typeToDataMap = new HashMap();
private boolean fDataMapInited;
private List identicalList;
- private HashMap scannerInfoMap;
private HashMap discoveredInfoMap = new HashMap();
private String scannerConfigDiscoveryProfileId;
- private IScannerConfigBuilderInfo2 scannerConfigInfo;
-
-
- interface IScannerConfigInfo {
- String getProfileId();
-
- IScannerConfigBuilderInfo2 getInfo2();
- }
-
- static class ScannerConfigInfo implements IScannerConfigInfo {
- private String profileId;
- private IScannerConfigBuilderInfo2 info2;
-
- public ScannerConfigInfo(ICStorageElement el, InfoContext context){
- profileId = el.getAttribute(IInputType.SCANNER_CONFIG_PROFILE_ID);
-
- ICStorageElement children[] = el.getChildren();
- for(int i = 0; i < children.length; i++){
- if(IInputType.DISCOVERY_INFO.equals(children[i].getName())){
- String defaultProfile = profileId;
- if(defaultProfile == null)
- defaultProfile = ScannerConfigProfileManager.NULL_PROFILE_ID;
-
- ScannerConfigInfoFactory2.create(context, children[i], defaultProfile);
- break;
- }
- }
- }
-
- public ScannerConfigInfo(IManagedConfigElement el, InfoContext context){
- this(new ManagedConfigStorageElement(el), context);
- }
-
- public ScannerConfigInfo(String profileId, IScannerConfigBuilderInfo2 info2){
- this.profileId = profileId;
- this.info2 = info2;
- }
-
- public void serialize(ICStorageElement element){
- if(profileId != null){
- element.setAttribute(IInputType.SCANNER_CONFIG_PROFILE_ID, profileId);
- }
-
- if(info2 != null){
- ICStorageElement el = element.createChild(IInputType.DISCOVERY_INFO);
- ScannerConfigInfoFactory2.serialize(info2, el);
- }
- }
-
- public IScannerConfigBuilderInfo2 getInfo2() {
- return info2;
- }
-
- public String getProfileId() {
- return profileId;
- }
- }
/*
* C O N S T R U C T O R S
@@ -268,12 +205,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
addEnvVarBuildPath(new EnvVarBuildPath(this,toolElement));
} else if (toolElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){
loadProperties(toolElement);
- } else if(toolElement.getName().equals(IToolChain.DISCOVERY_INFO)){
- ICStorageElement se = new ManagedConfigStorageElement(toolElement);
- String profileId = getDiscoveryProfileId();
- if(profileId == null)
- profileId = ScannerConfigProfileManager.NULL_PROFILE_ID;
- scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(null), se, profileId);
}
}
}
@@ -315,9 +246,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
setName(name);
setVersion(getVersionFromId());
- if(!superClass.isExtensionElement()){
- ((Tool)superClass).updateScannerInfoSettingsToInputTypes();
- }
+// if(!superClass.isExtensionElement()){
+// ((Tool)superClass).updateScannerInfoSettingsToInputTypes();
+// }
isExtensionTool = isExtensionElement;
if (isExtensionElement) {
@@ -353,9 +284,9 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
setVersion(getVersionFromId());
isExtensionTool = isExtensionElement;
- if(superClass != null && !superClass.isExtensionElement()){
- ((Tool)superClass).updateScannerInfoSettingsToInputTypes();
- }
+// if(superClass != null && !superClass.isExtensionElement()){
+// ((Tool)superClass).updateScannerInfoSettingsToInputTypes();
+// }
if (isExtensionElement) {
// Hook me up to the Managed Build Manager
ManagedBuildManager.addExtensionTool(this);
@@ -400,12 +331,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
} else if (toolElement.getName().equals(ITool.OUTPUT_TYPE)) {
OutputType outputType = new OutputType(this, toolElement);
addOutputType(outputType);
- } else if(toolElement.getName().equals(IToolChain.DISCOVERY_INFO)){
- String profileId = getDiscoveryProfileId();
- if(profileId == null)
- profileId = ScannerConfigProfileManager.NULL_PROFILE_ID;
- scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), this, null), toolElement, profileId);
- }
+ }
}
String rebuild = PropertyManager.getInstance().getProperty(this, REBUILD_STATE);
@@ -510,7 +436,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if(tool.envVarBuildPathList != null)
envVarBuildPathList = new ArrayList(tool.envVarBuildPathList);
- tool.updateScannerInfoSettingsToInputTypes();
+// tool.updateScannerInfoSettingsToInputTypes();
// Clone the children in superclass
super.copyChildren(tool);
@@ -1143,7 +1069,7 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
super.serialize(element);
// Serialize my children
- updateScannerInfoSettingsToInputTypes();
+// updateScannerInfoSettingsToInputTypes();
Iterator iter;
List typeElements = getInputTypeList();
@@ -1186,10 +1112,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
if(scannerConfigDiscoveryProfileId != null)
element.setAttribute(IToolChain.SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
- if(scannerConfigInfo != null){
- ICStorageElement cfgInfoEl = element.createChild(IToolChain.DISCOVERY_INFO);
- ScannerConfigInfoFactory2.serialize(scannerConfigInfo, cfgInfoEl);
- }
saveRebuildState();
@@ -1200,33 +1122,33 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
}
}
- private void updateScannerInfoSettingsToInputTypes(){
- if(isExtensionTool)
- return;
-
- HashMap scannerCfgMap = getScannerInfoMap(false);
- if(scannerCfgMap != null){
- scannerCfgMap = (HashMap)scannerCfgMap.clone();
- for(Iterator iter = scannerCfgMap.entrySet().iterator(); iter.hasNext();){
- Map.Entry entry = (Map.Entry)iter.next();
- String id = (String)entry.getKey();
- InputType type = (InputType)getInputTypeById(id);
- if(type == null)
- continue;
-
- ScannerConfigInfoFactory2.BuildProperty info = (ScannerConfigInfoFactory2.BuildProperty)entry.getValue();
- if(info.isDirty()){
- if(type.isExtensionElement()){
- type = (InputType)getEdtableInputType(type);
- }
- type.setScannerConfigBuilderInfo(info);
- } else {
- if(type.getScannerConfigBuilderInfoElement(false) != null)
- type.setScannerConfigBuilderInfo(info);
- }
- }
- }
- }
+// private void updateScannerInfoSettingsToInputTypes(){
+// if(isExtensionTool)
+// return;
+//
+// HashMap scannerCfgMap = getScannerInfoMap(false);
+// if(scannerCfgMap != null){
+// scannerCfgMap = (HashMap)scannerCfgMap.clone();
+// for(Iterator iter = scannerCfgMap.entrySet().iterator(); iter.hasNext();){
+// Map.Entry entry = (Map.Entry)iter.next();
+// String id = (String)entry.getKey();
+// InputType type = (InputType)getInputTypeById(id);
+// if(type == null)
+// continue;
+//
+// ScannerConfigInfoFactory2.BuildProperty info = (ScannerConfigInfoFactory2.BuildProperty)entry.getValue();
+// if(info.isDirty()){
+// if(type.isExtensionElement()){
+// type = (InputType)getEdtableInputType(type);
+// }
+// type.setScannerConfigBuilderInfo(info);
+// } else {
+// if(type.getScannerConfigBuilderInfoElement(false) != null)
+// type.setScannerConfigBuilderInfo(info);
+// }
+// }
+// }
+// }
/*
* P A R E N T A N D C H I L D H A N D L I N G
@@ -1266,14 +1188,14 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
typeToDataMap.put(type, data);
}
- HashMap scannerInfoMap = getScannerInfoMap(false);
- if(scannerInfoMap != null){
- IScannerConfigBuilderInfo2 info = (IScannerConfigBuilderInfo2)scannerInfoMap.get(getTypeKey(superClass));
- if(info != null){
- info = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), this, type), info, info.getSelectedProfileId());
- scannerInfoMap.put(getTypeKey(type), info);
- }
- }
+// HashMap scannerInfoMap = getScannerInfoMap(false);
+// if(scannerInfoMap != null){
+// IScannerConfigBuilderInfo2 info = (IScannerConfigBuilderInfo2)scannerInfoMap.get(getTypeKey(superClass));
+// if(info != null){
+// info = ScannerConfigInfoFactory2.create(new CfgInfoContext(getParentResourceInfo(), this, type), info, info.getSelectedProfileId());
+// scannerInfoMap.put(getTypeKey(type), info);
+// }
+// }
}
addInputType(type);
setDirty(true);
@@ -3918,48 +3840,8 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
return name;
}
- public IScannerConfigBuilderInfo2 setScannerConfigInfo(IInputType type, IScannerConfigBuilderInfo2 info){
- if(isExtensionTool)
- return null;
- InputType inType = (InputType)type;
- HashMap map = getScannerInfoMap(true);
- IScannerConfigBuilderInfo2 oldInfo = (IScannerConfigBuilderInfo2)map.put(getTypeKey(inType), info);
- return oldInfo;
- }
-
- public IScannerConfigBuilderInfo2 getScannerConfigInfo(IInputType type){
- if(isExtensionTool)
- return null;
- InputType inType = (InputType)type;
- IScannerConfigBuilderInfo2 info = null;
-// if(inType.getParent() == this){
-// info = inType.getScannerConfigBuilderInfo();
-// }
-
- if(info == null){
- HashMap scannerInfoMap = getScannerInfoMap(true);
- info = (IScannerConfigBuilderInfo2)scannerInfoMap.get(getTypeKey(inType));
-
- if(info == null){
- boolean create = inType != null ? inType.getDiscoveryProfileIdAttribute() != null : getDiscoveryProfileIdAttribute() != null;
- if(create){
- String id = inType != null ? inType.getDiscoveryProfileId(this) : null;
- if(id == null)
- id = ScannerConfigProfileManager.NULL_PROFILE_ID;
- info = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), this, type), ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), id, false);
- }
- }
- if(info != null)
- scannerInfoMap.put(getTypeKey(inType), info);
- }
-
- return info;
- }
-
private boolean typeContributesToScannerConfig(InputType inType){
// InputType inType = (InputType)type;
- if(inType.getScannerConfigBuilderInfo(this) != null)
- return true;
if(inType.getDiscoveryProfileId(this) != null)
return true;
@@ -3975,8 +3857,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
}
private boolean hasScannerConfigSettings(){
- if(getScannerConfigBuilderInfoElement(true) != null)
- return true;
if(getDiscoveryProfileIdAttribute() != null)
return true;
@@ -3984,30 +3864,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
return false;
}
- private HashMap getScannerInfoMap(boolean create){
- if(scannerInfoMap == null && create && !isExtensionTool){
- Collection types = getLanguageInputTypes();
- scannerInfoMap = new HashMap();
- if(types != null){
- if(types.size() != 0){
- for(Iterator iter = types.iterator(); iter.hasNext();){
- InputType type = (InputType)iter.next();
- IScannerConfigBuilderInfo2 info = type.getScannerConfigBuilderInfoElement(true);
- if(info != null){
- if(info != type.getScannerConfigBuilderInfoElement(false)){
- info = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), this, type), info, ScannerConfigProfileManager.NULL_PROFILE_ID);
- }
- scannerInfoMap.put(getTypeKey(type), info);
- }
- }
- } else {
-
- }
- }
- }
- return scannerInfoMap;
- }
-
public IDiscoveredPathManager.IDiscoveredPathInfo setDiscoveredPathInfo(IInputType type, IDiscoveredPathManager.IDiscoveredPathInfo info){
return (IDiscoveredPathManager.IDiscoveredPathInfo)discoveredInfoMap.put(getTypeKey(type), info);
}
@@ -4026,30 +3882,6 @@ public class Tool extends HoldsOptions implements ITool, IOptionCategory, IMatch
return null;
}
- public IScannerConfigBuilderInfo2 getScannerConfigBuilderInfoElement(boolean searchSuper){
- if(scannerConfigInfo == null){
- if(superClass != null && searchSuper){
- return ((Tool)superClass).getScannerConfigBuilderInfoElement(true);
- }
- return null;
- }
- return scannerConfigInfo;
- }
-
- IScannerConfigBuilderInfo2 getScannerConfigBuilderInfo(){
- IScannerConfigBuilderInfo2 info = getScannerConfigBuilderInfoElement(true);
- if(info == null){
- IToolChain tc = getToolChain();
- if(tc != null)
- info = ((ToolChain)tc).getScannerConfigBuilderInfo();
- }
- return info;
- }
-
- public void setScannerConfigBuilderInfo(IScannerConfigBuilderInfo2 info){
- scannerConfigInfo = info;
- }
-
public String getDiscoveryProfileIdAttribute(){
if(scannerConfigDiscoveryProfileId == null && superClass != null)
return ((Tool)superClass).getDiscoveryProfileIdAttribute();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
index 55a01ffa408..6ac833d5073 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolChain.java
@@ -25,10 +25,6 @@ import java.util.StringTokenizer;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType;
import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
@@ -120,7 +116,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
private IFolderInfo parentFolderInfo;
- private IScannerConfigBuilderInfo2 scannerConfigInfo;
private IDiscoveredPathManager.IDiscoveredPathInfo discoveredInfo;
private Boolean isRcTypeBasedDiscovery;
@@ -194,13 +189,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
addTool(toolChild);
} else if (toolChainElement.getName().equals(SupportedProperties.SUPPORTED_PROPERTIES)){
loadProperties(toolChainElement);
- } else if(toolChainElement.getName().equals(DISCOVERY_INFO)){
- ICStorageElement el = new ManagedConfigStorageElement(toolChainElement);
- String profileId = getScannerConfigDiscoveryProfileId();
- if(profileId == null)
- profileId = ScannerConfigProfileManager.NULL_PROFILE_ID;
- scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(null), el, profileId);
- }
+ }
}
}
@@ -283,12 +272,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
//load user-defined macros
userDefinedMacros = new StorableMacros(configElement);
- }*/else if(configElement.getName().equals(DISCOVERY_INFO)){
- String profileId = getScannerConfigDiscoveryProfileId();
- if(profileId == null)
- profileId = ScannerConfigProfileManager.NULL_PROFILE_ID;
- scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(getParentResourceInfo(), null, null), configElement, profileId);
- }
+ }*/
}
String rebuild = PropertyManager.getInstance().getProperty(this, REBUILD_STATE);
@@ -356,9 +340,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
}
isRcTypeBasedDiscovery = toolChain.isRcTypeBasedDiscovery;
- if(toolChain.scannerConfigInfo != null){
- scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(folderInfo, null, null), toolChain.scannerConfigInfo, ScannerConfigProfileManager.NULL_PROFILE_ID);
- }
supportsManagedBuild = toolChain.supportsManagedBuild;
@@ -885,10 +866,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
if(isRcTypeBasedDiscovery != null)
element.setAttribute(RESOURCE_TYPE_BASED_DISCOVERY, isRcTypeBasedDiscovery.toString());
- if(scannerConfigInfo != null){
- ICStorageElement cfgInfoEl = element.createChild(DISCOVERY_INFO);
- ScannerConfigInfoFactory2.serialize(scannerConfigInfo, cfgInfoEl);
- }
saveRebuildState();
// I am clean now
@@ -2602,29 +2579,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IBuildPropert
}
}
- public IScannerConfigBuilderInfo2 setScannerConfigBuilderInfo(IScannerConfigBuilderInfo2 info){
- IScannerConfigBuilderInfo2 oldInfo = scannerConfigInfo;
- scannerConfigInfo = info;
- return oldInfo;
- }
-
- public IScannerConfigBuilderInfo2 getScannerConfigBuilderInfoElement(boolean searchSuper){
- if(scannerConfigInfo == null){
- if(superClass != null && searchSuper){
- return ((ToolChain)superClass).getScannerConfigBuilderInfoElement(true);
- }
- return null;
- }
- return scannerConfigInfo;
- }
-
- public IScannerConfigBuilderInfo2 getScannerConfigBuilderInfo(){
- return getScannerConfigBuilderInfoElement(true);
- }
-
public boolean hasScannerConfigSettings(){
- if(getScannerConfigBuilderInfoElement(true) != null)
- return true;
if(getScannerConfigDiscoveryProfileId() != null)
return true;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
index d5c8e8832a7..b440124a416 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigInfoFactory2;
import org.eclipse.cdt.core.model.ILanguageDescriptor;
import org.eclipse.cdt.core.model.LanguageManager;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@@ -37,6 +38,7 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener;
import org.eclipse.cdt.managedbuilder.internal.core.InputType;
@@ -101,6 +103,11 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
ManagedProject mProj = (ManagedProject)info.getManagedProject();
mProj.applyConfiguration((Configuration)appliedCfg.getConfiguration());
writeManagedProjectInfo(des.getProjectDescription(), mProj);
+ try {
+ CfgScannerConfigInfoFactory2.save(des.getProjectDescription(), baseDescription.getProjectDescription());
+ } catch (CoreException e){
+ ManagedBuilderCorePlugin.log(e);
+ }
info.setValid(true);
return appliedCfg;
@@ -139,8 +146,11 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
if(des.isPreferenceConfiguration())
return createPreferences(des, base);
+ IManagedBuildInfo info = getBuildInfo(des);
+ ManagedProject mProj = (ManagedProject)info.getManagedProject();
+
Configuration cfg = (Configuration)((BuildConfigurationData)base).getConfiguration();
- Configuration newCfg = new Configuration((ManagedProject)cfg.getManagedProject(), cfg, des.getId(), true, true, false);
+ Configuration newCfg = new Configuration(mProj, cfg, des.getId(), true, true, false);
newCfg.setConfigurationDescription(des);
newCfg.setName(des.getName());
if(!newCfg.getId().equals(cfg.getId())){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProfileInfoProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProfileInfoProvider.java
index ab12b7bded2..e7a3fbf0428 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProfileInfoProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProfileInfoProvider.java
@@ -14,9 +14,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
+import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject;
@@ -61,14 +62,14 @@ public class ProfileInfoProvider {
// private IResource fResource;
// private IPath fRcPath;
private IProject fProject;
- private InfoContext fContext;
- private IDiscoveredPathManager fMngr;
+ private CfgInfoContext fContext;
+ private CfgDiscoveredPathManager fMngr;
public ProfileInfoProvider(BuildLanguageData lData){
fLlanguageData = lData;
IResourceInfo rcInfo = lData.getTool().getParentResourceInfo();
- fContext = new InfoContext(rcInfo, lData.getTool(), lData.getInputType());
- fMngr = ManagedBuilderCorePlugin.getDefault().getDiscoveryManager();
+ fContext = new CfgInfoContext(rcInfo, lData.getTool(), lData.getInputType());
+ fMngr = CfgDiscoveredPathManager.getInstance();
IResource rc = rcInfo.getParent().getOwner();
fProject = rc != null ? rc.getProject() : null;
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProjectConverter.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProjectConverter.java
index 53cd3a6c7be..5af28dfac83 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProjectConverter.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ProjectConverter.java
@@ -19,6 +19,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.ICDescriptorOperation;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
@@ -31,11 +34,9 @@ import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.ICProjectConverter;
import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator;
import org.eclipse.cdt.core.settings.model.util.PathEntryTranslator.ReferenceSettingsInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.make.core.IMakeTarget;
+import org.eclipse.cdt.make.core.IMakeTargetManager;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
@@ -47,10 +48,21 @@ import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject;
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+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;
public class ProjectConverter implements ICProjectConverter {
private final static String OLD_MAKE_BUILDER_ID = "org.eclipse.cdt.make.core.makeBuilder"; //$NON-NLS-1$
@@ -63,6 +75,8 @@ public class ProjectConverter implements ICProjectConverter {
private final static String OLD_PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$
private final static String OLD_DISCOVERY_NATURE_ID = "org.eclipse.cdt.make.core.ScannerConfigNature"; //$NON-NLS-1$
private final static String OLD_DISCOVERY_BUILDER_ID = "org.eclipse.cdt.make.core.ScannerConfigBuilder"; //$NON-NLS-1$
+ private final static String OLD_MAKE_TARGET_BUIDER_ID = "org.eclipse.cdt.make.MakeTargetBuilder"; //$NON-NLS-1$
+ private final static String NEW_MAKE_TARGET_BUIDER_ID = "org.eclipse.cdt.build.MakeTargetBuilder"; //$NON-NLS-1$
public boolean canConvertProject(IProject project, String oldOwnerId, ICProjectDescription oldDes) {
@@ -91,15 +105,22 @@ public class ProjectConverter implements ICProjectConverter {
CoreModel model = CoreModel.getDefault();
ICProjectDescription newDes = null;
IManagedBuildInfo info = null;
- boolean adjustBinErrParsers = false;
+ String[] binErrParserIds = null;
+// boolean convertMakeTargetInfo = false;
if(natureSet.contains(OLD_MNG_NATURE_ID)){
newDes = model.createProjectDescription(project, false);
info = convertManagedBuildInfo(project, newDes);
} else if(natureSet.contains(OLD_MAKE_NATURE_ID)){
- adjustBinErrParsers = true;
newDes = oldDes;
ICConfigurationDescription des = newDes.getConfigurations()[0];
+ ICConfigExtensionReference refs[] = des.get(OLD_BINARY_PARSER_ID);
+ if(refs.length != 0){
+ binErrParserIds = new String[refs.length];
+ for(int i = 0; i < refs.length; i++){
+ binErrParserIds[i] = refs[i].getID();
+ }
+ }
info = ManagedBuildManager.createBuildInfo(project);
ManagedProject mProj = new ManagedProject(newDes);
info.setManagedProject(mProj);
@@ -133,6 +154,7 @@ public class ProjectConverter implements ICProjectConverter {
makeBuilderCmd = cmd;
iter.remove();
changeEDes = true;
+// convertMakeTargetInfo = true;
} else if(OLD_DISCOVERY_BUILDER_ID.equals(cmd.getBuilderName())){
iter.remove();
changeEDes = true;
@@ -148,18 +170,20 @@ public class ProjectConverter implements ICProjectConverter {
if(makeBuilderCmd != null)
loadBuilderSettings(cfg, makeBuilderCmd);
- loadDiscoveryOptions(cfgDes, cfg);
+// loadDiscoveryOptions(cfgDes, cfg);
loadPathEntryInfo(project, cfgDes, data);
- if(adjustBinErrParsers){
- ICConfigExtensionReference refs[] = cfgDes.get(OLD_ERROR_PARSER_ID);
- String ids[] = idsFromRefs(refs);
- data.getTargetPlatformData().setBinaryParserIds(ids);
-
- refs = cfgDes.get(OLD_ERROR_PARSER_ID);
- ids = idsFromRefs(refs);
- data.getBuildData().setErrorParserIDs(ids);
+ if(binErrParserIds != null){
+ data.getTargetPlatformData().setBinaryParserIds(binErrParserIds);
+ cfgDes.get(OLD_BINARY_PARSER_ID);
+// ICConfigExtensionReference refs[] = cfgDes.get(OLD_BINARY_PARSER_ID);
+// String ids[] = idsFromRefs(refs);
+// data.getTargetPlatformData().setBinaryParserIds(ids);
+//
+// refs = cfgDes.get(OLD_ERROR_PARSER_ID);
+// ids = idsFromRefs(refs);
+// data.getBuildData().setErrorParserIDs(ids);
}
try {
@@ -168,6 +192,14 @@ public class ProjectConverter implements ICProjectConverter {
}
}
+// if(convertMakeTargetInfo){
+// try {
+// convertMakeTargetInfo(project, newDes, null);
+// } catch (CoreException e){
+// ManagedBuilderCorePlugin.log(e);
+// }
+// }
+
if(changeEDes){
cmds = (ICommand[])list.toArray(new ICommand[list.size()]);
eDes.setBuildSpec(cmds);
@@ -185,6 +217,73 @@ public class ProjectConverter implements ICProjectConverter {
return newDes;
}
+ private static void convertMakeTargetInfo(final IProject project, ICProjectDescription des, IProgressMonitor monitor) throws CoreException{
+ if(monitor == null)
+ monitor = new NullProgressMonitor();
+
+ CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(project, des, new ICDescriptorOperation(){
+
+ public void execute(ICDescriptor descriptor,
+ IProgressMonitor monitor) throws CoreException {
+ final IMakeTargetManager mngr = MakeCorePlugin.getDefault().getTargetManager();
+
+ project.accept(new IResourceVisitor(){
+
+ public boolean visit(IResource resource)
+ throws CoreException {
+ if(resource.getType() == IResource.FILE)
+ return false;
+
+ try {
+ IContainer cr = (IContainer)resource;
+ IMakeTarget targets[] = mngr.getTargets(cr);
+ for(int i = 0; i < targets.length; i++){
+ IMakeTarget t = targets[i];
+ if(!OLD_MAKE_TARGET_BUIDER_ID.equals(t.getTargetBuilderID()))
+ continue;
+
+ IMakeTarget newT = mngr.createTarget(project, t.getName(), NEW_MAKE_TARGET_BUIDER_ID);
+ copySettings(t, newT);
+ mngr.removeTarget(t);
+ mngr.addTarget(newT);
+ }
+ } catch ( CoreException e){
+ ManagedBuilderCorePlugin.log(e);
+ }
+ return true;
+ }
+
+ });
+ }
+
+ }, monitor);
+ }
+
+ private static void copySettings(IMakeTarget fromTarget, IMakeTarget toTarget) throws CoreException{
+ toTarget.setAppendEnvironment(fromTarget.appendEnvironment());
+ toTarget.setAppendProjectEnvironment(fromTarget.appendProjectEnvironment());
+
+ toTarget.setBuildAttribute(IMakeTarget.BUILD_LOCATION, fromTarget.getBuildAttribute(IMakeTarget.BUILD_LOCATION, null));
+ toTarget.setBuildAttribute(IMakeTarget.BUILD_COMMAND, fromTarget.getBuildAttribute(IMakeTarget.BUILD_COMMAND, null));
+ toTarget.setBuildAttribute(IMakeTarget.BUILD_ARGUMENTS, fromTarget.getBuildAttribute(IMakeTarget.BUILD_ARGUMENTS, null));
+ toTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET, fromTarget.getBuildAttribute(IMakeTarget.BUILD_TARGET, null));
+
+ Map fromMap = fromTarget.getEnvironment();
+ if(fromMap != null)
+ toTarget.setEnvironment(new HashMap(fromMap));
+
+// toTarget.setErrorParsers(fromTarget.getErrorParsers());
+
+ toTarget.setRunAllBuilders(fromTarget.runAllBuilders());
+
+ toTarget.setStopOnError(fromTarget.isStopOnError());
+
+ toTarget.setUseDefaultBuildCmd(fromTarget.isDefaultBuildCmd());
+
+ toTarget.setContainer(fromTarget.getContainer());
+
+ }
+
private void loadPathEntryInfo(IProject project, ICConfigurationDescription des, CConfigurationData data){
try {
ICStorageElement el = des.getStorage(OLD_PATH_ENTRY_ID, false);
@@ -242,30 +341,156 @@ public class ProjectConverter implements ICProjectConverter {
return ids;
}
- private void loadDiscoveryOptions(ICConfigurationDescription des, IConfiguration cfg){
- try {
- ICStorageElement discoveryStorage = des.getStorage(OLD_DISCOVERY_MODULE_ID, false);
- if(discoveryStorage != null){
- Configuration config = (Configuration)cfg;
- IScannerConfigBuilderInfo2 scannerConfigInfo = ScannerConfigInfoFactory2.create(new InfoContext(cfg), discoveryStorage, ScannerConfigProfileManager.NULL_PROFILE_ID);
- config.setPerRcTypeDiscovery(false);
- config.setScannerConfigInfo(scannerConfigInfo);
- des.removeStorage(OLD_DISCOVERY_MODULE_ID);
+// private void loadDiscoveryOptions(ICConfigurationDescription des, IConfiguration cfg){
+// try {
+// ICStorageElement discoveryStorage = des.getStorage(OLD_DISCOVERY_MODULE_ID, false);
+// if(discoveryStorage != null){
+// Configuration config = (Configuration)cfg;
+// IScannerConfigBuilderInfo2 scannerConfigInfo = ScannerConfigInfoFactory2.create(new CfgInfoContext(cfg), discoveryStorage, ScannerConfigProfileManager.NULL_PROFILE_ID);
+// config.setPerRcTypeDiscovery(false);
+// config.setScannerConfigInfo(scannerConfigInfo);
+// des.removeStorage(OLD_DISCOVERY_MODULE_ID);
+// }
+// } catch (CoreException e) {
+// ManagedBuilderCorePlugin.log(e);
+// }
+//
+//
+// }
+
+ private void loadBuilderSettings(IConfiguration cfg, ICommand cmd){
+ Builder builder = (Builder)BuilderFactory.createBuilderFromCommand(cfg, cmd);
+ if(builder.getCommand() != null && builder.getCommand().length() != 0){
+ String[] errParserIds = builder.getCustomizedErrorParserIds();
+ builder.setCustomizedErrorParserIds(null);
+ ((ToolChain)cfg.getToolChain()).setBuilder((Builder)builder);
+ if(errParserIds != null && errParserIds.length != 0){
+ cfg.setErrorParserList(errParserIds);
}
+ }
+ }
+
+ private static boolean convertOldStdMakeToNewStyle(final IProject project, boolean checkOnly, IProgressMonitor monitor, boolean throwExceptions) throws CoreException {
+ try {
+ ICDescriptor dr = CCorePlugin.getDefault().getCProjectDescription(project, false);
+ if(dr == null){
+ if(throwExceptions)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the specified project is not an CDT project"));
+ return false;
+ }
+
+ if(!MakeCorePlugin.MAKE_PROJECT_ID.equals(dr.getProjectOwner().getID())){
+ if(throwExceptions)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the specified project is not an old style make project, the owner ID is " + dr.getProjectOwner().getID()));
+ return false;
+ }
+
+ ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
+ ICConfigurationDescription cfgs[] = des.getConfigurations();
+ if(cfgs.length != 1){
+ if(throwExceptions)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the specified project is not an old style project: the number of configurations is " + cfgs.length));
+ return false;
+ }
+
+ if(!CCorePlugin.DEFAULT_PROVIDER_ID.equals(cfgs[0].getBuildSystemId())){
+ if(throwExceptions)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the specified project is not an old style project: the number of configurations is " + cfgs.length));
+ return false;
+ }
+
+ final IProjectDescription eDes = project.getDescription();
+ String natureIds[] = eDes.getNatureIds();
+ Set set = new HashSet(Arrays.asList(natureIds));
+ if(!set.contains(OLD_MAKE_NATURE_ID)){
+ if(throwExceptions)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the specified project is not an old style make project: nature IDs are " + natureIds.toString()));
+ return false;
+ }
+
+ if(!checkOnly){
+ ProjectConverter instance = new ProjectConverter();
+ ICProjectDescription oldDes = CCorePlugin.getDefault().getProjectDescription(project);
+ if(!instance.canConvertProject(project, MakeCorePlugin.MAKE_PROJECT_ID, oldDes)){
+ if(throwExceptions)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the specified project can not be converted"));
+ return false;
+ }
+
+ final ICProjectDescription newDes = instance.convertProject(project, eDes, MakeCorePlugin.MAKE_PROJECT_ID, oldDes);
+ if(newDes == null){
+ if(throwExceptions)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the project conversion failed"));
+ return false;
+ }
+
+ final IWorkspace wsp = ResourcesPlugin.getWorkspace();
+ wsp.run(new IWorkspaceRunnable(){
+
+ public void run(IProgressMonitor monitor)
+ throws CoreException {
+ project.setDescription(eDes, monitor);
+ CCorePlugin.getDefault().setProjectDescription(project, newDes);
+ Job job = new Job("targets conversion"){
+
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project);
+ convertMakeTargetInfo(project, des, monitor);
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+
+ };
+
+ job.setRule(wsp.getRoot());
+ job.schedule();
+ }
+
+ }, wsp.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
+ }
+ return true;
+ } catch (CoreException e) {
+ if(throwExceptions)
+ throw e;
+ ManagedBuilderCorePlugin.log(e);
+ }
+ if(throwExceptions)
+ throw new CoreException(new Status(IStatus.ERROR,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ "the project conversion failed due to unknown reason"));
+ return false;
+ }
+
+ public static boolean isOldStyleMakeProject(IProject project){
+ try {
+ return convertOldStdMakeToNewStyle(project, true, null, false);
} catch (CoreException e) {
ManagedBuilderCorePlugin.log(e);
}
-
-
+ return false;
}
-
- private void loadBuilderSettings(IConfiguration cfg, ICommand cmd){
- IBuilder builder = BuilderFactory.createBuilderFromCommand(cfg, cmd);
- if(builder.getCommand() != null && builder.getCommand().length() != 0){
- ((ToolChain)cfg.getToolChain()).setBuilder((Builder)builder);
- }
+
+ public static void convertOldStdMakeToNewStyle(IProject project, IProgressMonitor monitor) throws CoreException{
+ convertOldStdMakeToNewStyle(project, false, monitor, true);
}
-
+
private IManagedBuildInfo convertManagedBuildInfo(IProject project, ICProjectDescription newDes){
IManagedBuildInfo info = ManagedBuildManager.getBuildInfoLegacy(project);
if(info != null && info.isValid()){
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java
index b6bb3df6e6c..777b3c7f44e 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java
@@ -14,8 +14,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
+import org.eclipse.core.resources.IProject;
/**
* Implementation class for gathering the built-in compiler settings for
@@ -24,7 +26,7 @@ import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
* @since 2.0
*/
public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoCollector {
-
+ private IProject fProject;
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map)
*/
@@ -36,7 +38,7 @@ public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoColl
// List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
// This method will be called by the parser each time there is a new value
- List translatedIncludes = CygpathTranslator.translateIncludePaths(getProject(), includes);
+ List translatedIncludes = CygpathTranslator.translateIncludePaths(fProject, includes);
Iterator pathIter = translatedIncludes.listIterator();
while (pathIter.hasNext()) {
String convertedPath = (String) pathIter.next();
@@ -62,5 +64,13 @@ public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoColl
super.contributeToScannerConfig(resource, scannerInfo);
}
// }
-
+ public void setProject(IProject project) {
+ fProject = project;
+ super.setProject(project);
+ }
+
+ public void setInfoContext(InfoContext context) {
+ fProject = context.getProject();
+ super.setInfoContext(context);
+ }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
index 638b43084a9..bde2fb42842 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/ManagedBuildCPathEntryContainer.java
@@ -17,6 +17,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.Vector;
+import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IMacroEntry;
import org.eclipse.cdt.core.model.IPathEntry;
@@ -25,7 +26,6 @@ import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
-import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil;
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -190,7 +190,7 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
if (scdProfileId != null) {
// See if we can load a dynamic resolver
//FIXME:
- InfoContext context = ScannerConfigUtil.createContextForProject(project);
+ InfoContext context = CfgScannerConfigProfileManager.createDefaultContext(project);
profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(project, context, scdProfileId);
collector = profileInstance.createScannerInfoCollector();
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/PreferenceInitializer.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/PreferenceInitializer.java
deleted file mode 100644
index cb7c42ea155..00000000000
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/newmake/internal/core/PreferenceInitializer.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 QNX Software Systems 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:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.newmake.internal.core;
-
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
-import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
-import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-
-
-public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- public void initializeDefaultPreferences() {
-/* IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, true);
- try {
- info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "make"); //$NON-NLS-1$
- info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, ""); //$NON-NLS-1$
- info.setStopOnError(false);
- info.setUseDefaultBuildCmd(true);
- info.setAutoBuildEnable(false);
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "all"); //$NON-NLS-1$
- info.setIncrementalBuildEnable(true);
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, "all"); //$NON-NLS-1$
- info.setFullBuildEnable(true);
- info.setCleanBuildEnable(true);
- info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, "clean"); //$NON-NLS-1$
- info.setAppendEnvironment(true);
- info.setErrorParsers(CCorePlugin.getDefault().getAllErrorParsersIDs());
- } catch (CoreException e) {
- }
- MakeCorePlugin.getDefault().getPluginPreferences().setDefault(CCorePlugin.PREF_BINARY_PARSER, CCorePlugin.PLUGIN_ID + ".ELF"); //$NON-NLS-1$
-*/
- // default plugin preferences for scanner configuration discovery
- IScannerConfigBuilderInfo scInfo = ManagedBuilderCorePlugin.createScannerConfigBuildInfo(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(), ScannerConfigBuilder.BUILDER_ID, true);
- try {
- scInfo.setAutoDiscoveryEnabled(true);
- scInfo.setMakeBuilderConsoleParserEnabled(true);
- scInfo.setESIProviderCommandEnabled(true);
- scInfo.setUseDefaultESIProviderCmd(true);
- scInfo.setESIProviderCommand(new Path("gcc")); //$NON-NLS-1$
- scInfo.setESIProviderArguments("-E -P -v -dD ${plugin_state_location}/${specs_file}"); //$NON-NLS-1$
- scInfo.setESIProviderConsoleParserId(ManagedBuilderCorePlugin.GCC_SPECS_CONSOLE_PARSER_ID);
- scInfo.setMakeBuilderConsoleParserId(ManagedBuilderCorePlugin.GCC_SCANNER_INFO_CONSOLE_PARSER_ID);
- scInfo.setSIProblemGenerationEnabled(true);
- } catch (CoreException e) {
- }
-
- // default plugin preferences for new scanner configuration discovery
- IScannerConfigBuilderInfo2 scInfo2 = ScannerConfigProfileManager.
- createScannerConfigBuildInfo2(ManagedBuilderCorePlugin.getDefault().getPluginPreferences(),
- ScannerConfigProfileManager.NULL_PROFILE_ID, true);
- scInfo2.setAutoDiscoveryEnabled(true);
- scInfo2.setProblemReportingEnabled(true);
- scInfo2.setSelectedProfileId(ScannerConfigProfileManager.DEFAULT_SI_PROFILE_ID);
- scInfo2.setBuildOutputFileActionEnabled(false);
- scInfo2.setBuildOutputFilePath(""); //$NON-NLS-1$
- scInfo2.setBuildOutputParserEnabled(true);
- String providerId = "specsFile"; //$NON-NLS-1$
- scInfo2.setProviderOpenFilePath(providerId, "");//$NON-NLS-1$
- scInfo2.setProviderRunCommand(providerId, "gcc"); //$NON-NLS-1$
- scInfo2.setProviderRunArguments(providerId, "-E -P -v -dD ${plugin_state_location}/${specs_file}");//$NON-NLS-1$
- scInfo2.setProviderOutputParserEnabled(providerId, true);
- scInfo2.setProblemReportingEnabled(true);
- try {
- scInfo2.save();
- }
- catch (CoreException e) {
- }
-
- // Store default for makefile
-// ManagedBuilderCorePlugin.getDefault().getPluginPreferences().setDefault(MakeCorePluginMigration.MAKEFILE_STYLE, "GNU"); //$NON-NLS-1$
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
index b4d0f9f1199..74628469be0 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
@@ -53,3 +53,7 @@ CDTToolchainProperty.name=C/C++ ToolChain edit
CDTVariablesProperty.name=C/C++ Build variables
BuildCfgMenu.label=Build configurations
+
+WizardConvertMakeProject.name=Convert to a C/C++ Make Project
+WizardConvertMakeProject.description=Convert to a C/C++ Project which uses a simple makefile
+
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index 310e3255a21..c68fe799cdf 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -51,6 +51,34 @@
Create a new C project
+
+
+ %WizardConvertMakeProject.description
+
+
+
+
+
+
+ %WizardConvertMakeProject.description
+
+
+
+
-
-
+