mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
New Scanner Config Discovery 'framework' in preparation for per file SC discovery. Currently implemented: Per project profiles for standard make and managed builders.
This commit is contained in:
parent
e7a9587ad8
commit
66d9c39ea6
61 changed files with 5091 additions and 4088 deletions
|
@ -21,6 +21,6 @@ epScannerConfigBuilder.name=Scanner Configuration Builder
|
||||||
extensionExternalScannerInfoProvider.name=C/C++ External Scanner Info Provider Extension
|
extensionExternalScannerInfoProvider.name=C/C++ External Scanner Info Provider Extension
|
||||||
epDefaultExternalScannerInfoProvider.name=Default External Scanner Info Provider
|
epDefaultExternalScannerInfoProvider.name=Default External Scanner Info Provider
|
||||||
|
|
||||||
extensionScannerInfoConsoleParser.name=C/C++ Scanner Info Console Parser Extension
|
extensionScannerInfoConsoleParser.name=GNU C/C++ Scanner Info Console Parser Extension
|
||||||
epGCCCommandLineParser.name=GNU C/C++ Scanner Info Parser
|
epGCCCommandLineParser.name=GNU C/C++ Scanner Info Parser
|
||||||
epGCCSpecsParser.name=GNU C/C++ Compiler Specs Parser
|
epGCCSpecsParser.name=GNU C/C++ Compiler Specs Parser
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
|
|
||||||
|
|
||||||
<extension-point id="MakeTargetBuilder" name="%extensionTargetBuilder.name" schema="schema/MakeTargetBuilder.exsd"/>
|
<extension-point id="MakeTargetBuilder" name="%extensionTargetBuilder.name" schema="schema/MakeTargetBuilder.exsd"/>
|
||||||
<extension-point id="ExternalScannerInfoProvider" name="%extensionExternalScannerInfoProvider.name" schema="schema/ExternalScannerInfoProvider.exsd"/>
|
<extension-point id="ScannerConfigurationDiscoveryProfile" name="%extensionScannerConfigurationDiscoveryProfile.name" schema="schema/ScannerConfigurationDiscoveryProfile.exsd"/>
|
||||||
<extension-point id="ScannerInfoConsoleParser" name="%extensionScannerInfoConsoleParser.name" schema="schema/ScannerInfoConsoleParser.exsd"/>
|
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
id="MakeScannerProvider"
|
id="MakeScannerProvider"
|
||||||
|
@ -106,42 +105,6 @@
|
||||||
</run>
|
</run>
|
||||||
</builder>
|
</builder>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
|
||||||
id="DefaultExternalScannerInfoProvider"
|
|
||||||
name="%epDefaultExternalScannerInfoProvider.name"
|
|
||||||
point="org.eclipse.cdt.make.core.ExternalScannerInfoProvider">
|
|
||||||
<externalScannerInfoProvider>
|
|
||||||
<run
|
|
||||||
class="org.eclipse.cdt.make.internal.core.scannerconfig.DefaultExternalScannerInfoProvider">
|
|
||||||
<parameter
|
|
||||||
name="defaultCommand"
|
|
||||||
value="gcc">
|
|
||||||
</parameter>
|
|
||||||
<parameter
|
|
||||||
name="defaultAttributes"
|
|
||||||
value="-E -P -v -dD ${plugin_state_location}/${specs_file}">
|
|
||||||
</parameter>
|
|
||||||
</run>
|
|
||||||
</externalScannerInfoProvider>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
id="GCCScannerInfoConsoleParser"
|
|
||||||
name="%epGCCCommandLineParser.name"
|
|
||||||
point="org.eclipse.cdt.make.core.ScannerInfoConsoleParser">
|
|
||||||
<scannerInfoConsoleParser
|
|
||||||
commandId="makeBuilder"
|
|
||||||
class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerInfoConsoleParser">
|
|
||||||
</scannerInfoConsoleParser>
|
|
||||||
</extension>
|
|
||||||
<extension
|
|
||||||
id="GCCSpecsConsoleParser"
|
|
||||||
name="%epGCCSpecsParser.name"
|
|
||||||
point="org.eclipse.cdt.make.core.ScannerInfoConsoleParser">
|
|
||||||
<scannerInfoConsoleParser
|
|
||||||
commandId="externalScannerInfoProvider"
|
|
||||||
class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser">
|
|
||||||
</scannerInfoConsoleParser>
|
|
||||||
</extension>
|
|
||||||
<extension
|
<extension
|
||||||
id="DiscoveredScannerInfoProvider"
|
id="DiscoveredScannerInfoProvider"
|
||||||
point="org.eclipse.cdt.core.ScannerInfoProvider">
|
point="org.eclipse.cdt.core.ScannerInfoProvider">
|
||||||
|
@ -162,5 +125,22 @@
|
||||||
point="org.eclipse.core.runtime.preferences">
|
point="org.eclipse.core.runtime.preferences">
|
||||||
<initializer class="org.eclipse.cdt.make.internal.core.PreferenceInitializer"/>
|
<initializer class="org.eclipse.cdt.make.internal.core.PreferenceInitializer"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
id="GCCStandardMakePerProjectProfile"
|
||||||
|
name="GNU C/C++ Scanner Info per project profile"
|
||||||
|
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
||||||
|
<scannerInfoCollector class="org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector"/>
|
||||||
|
<buildOutputProvider>
|
||||||
|
<open/>
|
||||||
|
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerInfoConsoleParser"/>
|
||||||
|
</buildOutputProvider>
|
||||||
|
<scannerInfoProvider providerId="specsFile">
|
||||||
|
<run
|
||||||
|
command="gcc"
|
||||||
|
arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}"
|
||||||
|
class="org.eclipse.cdt.make.internal.core.scannerconfig2.GCCSpecsRunSIProvider"/>
|
||||||
|
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/>
|
||||||
|
</scannerInfoProvider>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -1,137 +0,0 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
<!-- Schema file written by PDE -->
|
|
||||||
<schema targetNamespace="org.eclipse.cdt.make.core">
|
|
||||||
<annotation>
|
|
||||||
<appInfo>
|
|
||||||
<meta.schema plugin="org.eclipse.cdt.make.core" id="ExternalScannerInfoProvider" name="C/C++ Scanner Info Provider"/>
|
|
||||||
</appInfo>
|
|
||||||
<documentation>
|
|
||||||
This extension point is used to plug in particular compiler scanner info provider.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
<element name="extension">
|
|
||||||
<complexType>
|
|
||||||
<sequence>
|
|
||||||
<element ref="externalScannerInfoProvider" minOccurs="1" maxOccurs="unbounded"/>
|
|
||||||
</sequence>
|
|
||||||
<attribute name="point" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="id" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="name" type="string">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="externalScannerInfoProvider">
|
|
||||||
<complexType>
|
|
||||||
<sequence>
|
|
||||||
<element ref="run"/>
|
|
||||||
</sequence>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="run">
|
|
||||||
<complexType>
|
|
||||||
<sequence>
|
|
||||||
<element ref="parameter" minOccurs="0" maxOccurs="unbounded"/>
|
|
||||||
</sequence>
|
|
||||||
<attribute name="class" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
A fully qualified name of the Java class that implements <samp>org.eclipse.cdt.make.core.scannerconfig.ICompilerScannerInfoProvider</samp> interface.
|
|
||||||
</documentation>
|
|
||||||
<appInfo>
|
|
||||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.make.core.scannerconfig.ISpecsBuilder"/>
|
|
||||||
</appInfo>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<element name="parameter">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Parameters passed to the compiler scanner info provider.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
<complexType>
|
|
||||||
<attribute name="name" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Name of a parameter.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="value" type="string" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Value of a parameter.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
|
||||||
</element>
|
|
||||||
|
|
||||||
<annotation>
|
|
||||||
<appInfo>
|
|
||||||
<meta.section type="since"/>
|
|
||||||
</appInfo>
|
|
||||||
<documentation>
|
|
||||||
[Enter the first release in which this extension point appears.]
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
<annotation>
|
|
||||||
<appInfo>
|
|
||||||
<meta.section type="examples"/>
|
|
||||||
</appInfo>
|
|
||||||
<documentation>
|
|
||||||
[Enter extension point usage example here.]
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
<annotation>
|
|
||||||
<appInfo>
|
|
||||||
<meta.section type="apiInfo"/>
|
|
||||||
</appInfo>
|
|
||||||
<documentation>
|
|
||||||
Plug-ins that want to extend this extension point must implement <samp>org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider</samp> interface.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
<annotation>
|
|
||||||
<appInfo>
|
|
||||||
<meta.section type="implementation"/>
|
|
||||||
</appInfo>
|
|
||||||
<documentation>
|
|
||||||
org.eclipse.cdt.make.core plugin provides default implementation of the GNU C/C++ compiler specs scanner info provider.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
<annotation>
|
|
||||||
<appInfo>
|
|
||||||
<meta.section type="copyright"/>
|
|
||||||
</appInfo>
|
|
||||||
<documentation>
|
|
||||||
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
|
|
||||||
</schema>
|
|
|
@ -0,0 +1,227 @@
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!-- Schema file written by PDE -->
|
||||||
|
<schema targetNamespace="org.eclipse.cdt.make.core">
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.schema plugin="org.eclipse.cdt.make.core" id="ScannerConfigurationDiscoveryProfile" name="Scanner Configuration Discovery Profile"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
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>
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<element name="extension">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Definition of a profile:
|
||||||
|
- A scanner info collector
|
||||||
|
- A make build output parser
|
||||||
|
- A number of external scanner info providers
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<element ref="scannerInfoCollector"/>
|
||||||
|
<element ref="buildOutputProvider" minOccurs="0" maxOccurs="1"/>
|
||||||
|
<element ref="scannerInfoProvider" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
</sequence>
|
||||||
|
<attribute name="point" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="id" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Profile id.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="name" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
The name of the profile will be presented to the user.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="scannerInfoCollector">
|
||||||
|
<complexType>
|
||||||
|
<attribute name="class" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Java class that implements IScannerInfoCollector interface.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="scannerInfoConsoleParser">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Make build output or external scanner info provider output parser.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<attribute name="class" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Java class that implements IScannerInfoConsoleParser interface.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.make.core.IScannerInfoConsoleParser"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="buildOutputProvider">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Build output provider is make build or/and build output file.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<element ref="open" minOccurs="0" maxOccurs="1"/>
|
||||||
|
<element ref="scannerInfoConsoleParser"/>
|
||||||
|
</sequence>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="scannerInfoProvider">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Either a command with arguments whose output will provide scanner information or a file that contains the scanner info.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<sequence>
|
||||||
|
<choice>
|
||||||
|
<element ref="run"/>
|
||||||
|
<element ref="open"/>
|
||||||
|
</choice>
|
||||||
|
<element ref="scannerInfoConsoleParser"/>
|
||||||
|
</sequence>
|
||||||
|
<attribute name="providerId" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
An id of the specific provider.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="run">
|
||||||
|
<complexType>
|
||||||
|
<attribute name="class" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
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.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="command" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
A command to run. Example: <samp>gcc</samp>.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="arguments" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Arguments for the command. Example: <samp>-E -P -v -dD</samp>.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<element name="open">
|
||||||
|
<complexType>
|
||||||
|
<attribute name="class" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
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.
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.make.core.scannerconfig.IESIFileReader"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="file" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
A file containing a make build output or scanner information in some other form.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="since"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
3.0
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="examples"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
[Enter extension point usage example here.]
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="apiInfo"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
[Enter API information here.]
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="implementation"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
<samp>org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile</samp>
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
<annotation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.section type="copyright"/>
|
||||||
|
</appInfo>
|
||||||
|
<documentation>
|
||||||
|
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
|
||||||
|
</schema>
|
|
@ -189,7 +189,7 @@ public class MakeBuilder extends ACBuilder {
|
||||||
OutputStream stderr = epm.getOutputStream();
|
OutputStream stderr = epm.getOutputStream();
|
||||||
// Sniff console output for scanner info
|
// Sniff console output for scanner info
|
||||||
ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getMakeBuilderOutputSniffer(
|
ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getMakeBuilderOutputSniffer(
|
||||||
stdout, stderr, getProject(), workingDirectory, this);
|
stdout, stderr, getProject(), workingDirectory, null, this, null);
|
||||||
OutputStream consoleOut = (sniffer == null ? stdout : sniffer.getOutputStream());
|
OutputStream consoleOut = (sniffer == null ? stdout : sniffer.getOutputStream());
|
||||||
OutputStream consoleErr = (sniffer == null ? stderr : sniffer.getErrorStream());
|
OutputStream consoleErr = (sniffer == null ? stderr : sniffer.getErrorStream());
|
||||||
Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory);
|
Process p = launcher.execute(buildCommand, buildArguments, env, workingDirectory);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
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.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
|
|
@ -92,12 +92,11 @@ public class DiscoveredScannerInfoProvider extends ScannerProvider {
|
||||||
// session
|
// session
|
||||||
scannerInfo = (DiscoveredScannerInfo)project.getSessionProperty(scannerInfoProperty);
|
scannerInfo = (DiscoveredScannerInfo)project.getSessionProperty(scannerInfoProperty);
|
||||||
|
|
||||||
// this will convert user info
|
|
||||||
org.eclipse.cdt.make.core.MakeScannerInfo makeScannerInfo = org.eclipse.cdt.make.core.MakeScannerProvider.getDefault().getMakeScannerInfo(
|
|
||||||
project, cacheInfo);
|
|
||||||
|
|
||||||
if (scannerInfo == null) {
|
if (scannerInfo == null) {
|
||||||
scannerInfo = new DiscoveredScannerInfo(project);
|
scannerInfo = new DiscoveredScannerInfo(project);
|
||||||
|
// this will convert user info
|
||||||
|
org.eclipse.cdt.make.core.MakeScannerInfo makeScannerInfo = org.eclipse.cdt.make.core.MakeScannerProvider.getDefault().getMakeScannerInfo(
|
||||||
|
project, cacheInfo);
|
||||||
scannerInfo.setUserScannerInfo(makeScannerInfo);
|
scannerInfo.setUserScannerInfo(makeScannerInfo);
|
||||||
|
|
||||||
// migrate to new C Path Entries
|
// migrate to new C Path Entries
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
**********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.core.scannerconfig;
|
package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
|
|
||||||
import java.util.List;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,19 +19,19 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public interface IExternalScannerInfoProvider {
|
public interface IExternalScannerInfoProvider {
|
||||||
/**
|
/**
|
||||||
* Invokes a C/C++ compiler with target specific options to generate
|
* Invokes a provider to generate scanner info.
|
||||||
* compiler scanner info.
|
*
|
||||||
*
|
* @param monitor
|
||||||
* @param monitor
|
* @param resource project - current project being built
|
||||||
* @param current project - current project being built
|
* @param providerId - id of the provider
|
||||||
* @param buildInfo - settings for ScannerConfigBuilder
|
* @param buildInfo - settings for ScannerConfigBuilder
|
||||||
* @param targetSpecificOptions - array of options affecting compiler specs
|
* @param collector - scanner info collector for the resource (project)
|
||||||
* @param collector - scanner info collector, for StdMake projects - ScannerInfoCollector
|
*/
|
||||||
*/
|
public boolean invokeProvider(IProgressMonitor monitor,
|
||||||
public boolean invokeProvider(IProgressMonitor monitor,
|
IResource resource,
|
||||||
IProject currentProject,
|
String providerId,
|
||||||
IScannerConfigBuilderInfo buildInfo,
|
IScannerConfigBuilderInfo2 buildInfo,
|
||||||
List targetSpecificOptions,
|
IScannerInfoCollector collector);
|
||||||
IScannerInfoCollector collector);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the buildInfo.
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
void store() throws CoreException;
|
||||||
|
/**
|
||||||
|
* Persist the buildInfo.
|
||||||
|
* It is expected that buildInfo was previously stored.
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
void save() throws CoreException;
|
||||||
|
}
|
|
@ -1,43 +1,45 @@
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
**********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.core.scannerconfig;
|
package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for scanner info collector.
|
* Interface for scanner info collector.
|
||||||
* Used by scanner info console parsers.
|
* Used by scanner info console parsers.
|
||||||
|
* Eclipse independent.
|
||||||
*
|
*
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public interface IScannerInfoCollector {
|
public interface IScannerInfoCollector {
|
||||||
// for a list of target specific options i.e. -pthread, -ansi, -no_
|
|
||||||
public static Integer TARGET_SPECIFIC_OPTION = new Integer(1) ;
|
|
||||||
public static Integer IMACROS = new Integer(2);
|
|
||||||
public static Integer COMPILER_VERSION_INFO = new Integer(3);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contribute to resource's scanner configuration
|
* Contribute to resource's scanner configuration
|
||||||
*
|
*
|
||||||
* @param resource
|
* @param resource - if used from within Eclipse it is expected that resource is a
|
||||||
* @param includes
|
* member of <code>org.eclipse.core.resources.IResource</code> hierarchy.
|
||||||
* @param symbols
|
* If used outside of Eclipse then resource is expected to be a
|
||||||
* @param extraInfo - a map of key - list pairs, where key is the type of extra info
|
* <code>java.io.File<code> 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,...
|
* i.e. target specific options or imacros commands,...
|
||||||
*/
|
*/
|
||||||
public void contributeToScannerConfig(IResource resource,
|
public void contributeToScannerConfig(Object resource, Map scannerInfo);
|
||||||
List includes,
|
|
||||||
List symbols,
|
/**
|
||||||
Map extraInfo);
|
* 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);
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.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;
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Answers a map of collected defines that the the compiler uses by default.
|
||||||
|
// * The symbols are defined in the map as a (macro, value) pair as follows
|
||||||
|
// * <p><p><code>-DFOO</code> will be stored as ("FOO","")
|
||||||
|
// * <p><code>-DFOO=BAR</code> will be stored as ("FOO","BAR")
|
||||||
|
// * <p><p>Duplicates will not be stored in the map and any whitespaces in
|
||||||
|
// * the macro or value will be trimmed out.
|
||||||
|
// *
|
||||||
|
// * @return a <code>Map</code> of defined symbols and values
|
||||||
|
// */
|
||||||
|
// public Map getDefinedSymbols();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Answers a <code>List</code> of unique built-in includes paths that have been
|
||||||
|
// * collected for the receiver. The paths are stored as <code>String</code> in the proper
|
||||||
|
// * format for the host tools.
|
||||||
|
// *
|
||||||
|
// * @return a <code>List</code> of built-in compiler include search paths.
|
||||||
|
// */
|
||||||
|
// public List getIncludePaths();
|
||||||
|
|
||||||
|
}
|
|
@ -18,14 +18,18 @@ import org.eclipse.core.resources.IProject;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public interface IScannerInfoConsoleParser {
|
public interface IScannerInfoConsoleParser {
|
||||||
|
/**
|
||||||
|
* Get a utility object to be initialized
|
||||||
|
*/
|
||||||
|
public IScannerInfoConsoleParserUtility getUtility();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional one time initialization of a console parser.
|
* Optional one time initialization of a console parser.
|
||||||
*
|
*
|
||||||
* @param project
|
* @param project
|
||||||
* @param util - utility functions for file and path management
|
|
||||||
* @param collector - scanner info collector
|
* @param collector - scanner info collector
|
||||||
*/
|
*/
|
||||||
public void startup(IProject project, IScannerInfoConsoleParserUtility util, IScannerInfoCollector collector);
|
public void startup(IProject project, IScannerInfoCollector collector);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse one line of output.
|
* Parse one line of output.
|
||||||
|
|
|
@ -10,10 +10,9 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.make.core.scannerconfig;
|
package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
|
|
||||||
import java.util.List;
|
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common work required by the scanner info console parsers
|
* Common work required by the scanner info console parsers
|
||||||
|
@ -21,12 +20,5 @@ import org.eclipse.core.resources.IResource;
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
*/
|
*/
|
||||||
public interface IScannerInfoConsoleParserUtility {
|
public interface IScannerInfoConsoleParserUtility {
|
||||||
// Problem marker related
|
public void initialize(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator);
|
||||||
public void generateMarker(IResource file, int lineNumber, String desc, int severity, String varName);
|
|
||||||
public boolean reportProblems();
|
|
||||||
// File path management
|
|
||||||
public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir);
|
|
||||||
public IFile findFile(String fileName);
|
|
||||||
public List translateRelativePaths(IFile file, String fileName, List includes);
|
|
||||||
public String normalizePath(String path);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,16 @@
|
||||||
package org.eclipse.cdt.make.core.scannerconfig;
|
package org.eclipse.cdt.make.core.scannerconfig;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.resources.ACBuilder;
|
import org.eclipse.cdt.core.resources.ACBuilder;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.jobs.SCJobsUtil;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,21 +42,42 @@ public class ScannerConfigBuilder extends ACBuilder {
|
||||||
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
|
||||||
// If auto discovery is disabled, do nothing
|
// If auto discovery is disabled, do nothing
|
||||||
boolean autodiscoveryEnabled;
|
boolean autodiscoveryEnabled;
|
||||||
|
boolean autodiscoveryEnabled2;
|
||||||
|
IScannerConfigBuilderInfo2 buildInfo2 = null;
|
||||||
try {
|
try {
|
||||||
IScannerConfigBuilderInfo buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(getProject(), BUILDER_ID);
|
// IScannerConfigBuilderInfo buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(getProject(), BUILDER_ID);
|
||||||
autodiscoveryEnabled = buildInfo.isAutoDiscoveryEnabled();
|
// autodiscoveryEnabled = buildInfo.isAutoDiscoveryEnabled();
|
||||||
|
//
|
||||||
|
// if (autodiscoveryEnabled) {
|
||||||
|
// monitor.beginTask("ScannerConfigBuilder.Invoking_Builder", 100); //$NON-NLS-1$
|
||||||
|
// monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
|
||||||
|
// getProject().getName());
|
||||||
|
// ScannerInfoCollector.getInstance().updateScannerConfiguration(getProject(), new SubProgressMonitor(monitor, 100));
|
||||||
|
// }
|
||||||
|
|
||||||
|
buildInfo2 = ScannerConfigProfileManager.createScannerConfigBuildInfo2(getProject());
|
||||||
|
autodiscoveryEnabled2 = buildInfo2.isAutoDiscoveryEnabled();
|
||||||
|
|
||||||
|
if (autodiscoveryEnabled2) {
|
||||||
|
monitor.beginTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), 100); //$NON-NLS-1$
|
||||||
|
monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
|
||||||
|
getProject().getName());
|
||||||
|
|
||||||
|
// get scanner info from all external providers
|
||||||
|
SCJobsUtil.getProviderScannerInfo(getProject(), buildInfo2, new SubProgressMonitor(monitor, 70));
|
||||||
|
|
||||||
|
// update and persist scanner configuration
|
||||||
|
SCJobsUtil.updateScannerConfiguration(getProject(), buildInfo2, new SubProgressMonitor(monitor, 30));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
// builder not installed or disabled
|
// builder not installed or disabled
|
||||||
autodiscoveryEnabled = false;
|
autodiscoveryEnabled = false;
|
||||||
|
autodiscoveryEnabled2 = false;
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autodiscoveryEnabled) {
|
|
||||||
monitor.beginTask("ScannerConfigBuilder.Invoking_Builder", 100); //$NON-NLS-1$
|
|
||||||
monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") + //$NON-NLS-1$
|
|
||||||
getProject().getName());
|
|
||||||
ScannerInfoCollector.getInstance().updateScannerConfiguration(getProject(), new SubProgressMonitor(monitor, 100));
|
|
||||||
}
|
|
||||||
return getProject().getReferencedProjects();
|
return getProject().getReferencedProjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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 INCLUDE_PATHS = new ScannerInfoTypes(1);
|
||||||
|
public static final ScannerInfoTypes SYMBOL_DEFINITIONS = new ScannerInfoTypes(2);
|
||||||
|
public static final ScannerInfoTypes TARGET_SPECIFIC_OPTION = new ScannerInfoTypes(3) ;
|
||||||
|
public static final ScannerInfoTypes COMPILER_VERSION_INFO = new ScannerInfoTypes(4);
|
||||||
|
public static final ScannerInfoTypes COMPILER_COMMAND = new ScannerInfoTypes(5); // CCommandDSC
|
||||||
|
|
||||||
|
private final int _enum;
|
||||||
|
|
||||||
|
private ScannerInfoTypes(int val) {
|
||||||
|
_enum = val;
|
||||||
|
}
|
||||||
|
public final int toInt() {
|
||||||
|
return _enum;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,9 @@ import org.eclipse.cdt.make.core.IMakeBuilderInfo;
|
||||||
import org.eclipse.cdt.make.core.MakeBuilder;
|
import org.eclipse.cdt.make.core.MakeBuilder;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
|
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.core.scannerconfig.ScannerConfigBuilder;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||||
|
@ -59,6 +61,28 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default plugin preferences for new scanner configuration discovery
|
||||||
|
IScannerConfigBuilderInfo2 scInfo2 = ScannerConfigProfileManager.
|
||||||
|
createScannerConfigBuildInfo2(MakeCorePlugin.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.store();
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
}
|
||||||
|
|
||||||
// Store default for makefile
|
// Store default for makefile
|
||||||
MakeCorePlugin.getDefault().getPluginPreferences().setDefault(MakeCorePlugin.MAKEFILE_STYLE, "GNU"); //$NON-NLS-1$
|
MakeCorePlugin.getDefault().getPluginPreferences().setDefault(MakeCorePlugin.MAKEFILE_STYLE, "GNU"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,300 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM - Initial API and implementation
|
|
||||||
**********************************************************************/
|
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
|
||||||
|
|
||||||
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.CCProjectNature;
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
|
||||||
import org.eclipse.cdt.core.CommandLauncher;
|
|
||||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
|
||||||
import org.eclipse.cdt.core.resources.IConsole;
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
|
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
|
||||||
import org.eclipse.cdt.make.internal.core.StreamMonitor;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerConfigUtil;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
|
||||||
import org.eclipse.core.resources.IMarker;
|
|
||||||
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.SubProgressMonitor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default external scanner info provider.
|
|
||||||
* Runs an external command (i.e. gcc -c -v) and parses an output for scanner info.
|
|
||||||
*
|
|
||||||
* @author vhirsl
|
|
||||||
*/
|
|
||||||
public class DefaultExternalScannerInfoProvider implements IExternalScannerInfoProvider, IMarkerGenerator {
|
|
||||||
|
|
||||||
private static final String EXTERNAL_SI_PROVIDER_ERROR = "ExternalScannerInfoProvider.Provider_Error"; //$NON-NLS-1$
|
|
||||||
private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = MakeCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
|
|
||||||
private static final String LANG_ENV_VAR = "LANG"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private IPath fWorkingDirectory;
|
|
||||||
private IPath fCompileCommand;
|
|
||||||
private String[] fCompileArguments;
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider#invokeProvider(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.resources.IProject, org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo, java.util.List, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector)
|
|
||||||
*/
|
|
||||||
public boolean invokeProvider(IProgressMonitor monitor,
|
|
||||||
IProject currentProject,
|
|
||||||
IScannerConfigBuilderInfo buildInfo,
|
|
||||||
List targetSpecificOptions,
|
|
||||||
IScannerInfoCollector collector) {
|
|
||||||
if (targetSpecificOptions == null) {
|
|
||||||
targetSpecificOptions = new ArrayList();
|
|
||||||
}
|
|
||||||
if (!initialize(currentProject, buildInfo)) {
|
|
||||||
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 file and TSO
|
|
||||||
String[] compileArguments = fCompileArguments;
|
|
||||||
if (buildInfo.isDefaultESIProviderCmd()) {
|
|
||||||
// consider TSO only if default command
|
|
||||||
compileArguments = prepareArguments(targetSpecificOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
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, buildInfo, collector);
|
|
||||||
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);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param currentProject
|
|
||||||
* @param buildInfo
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
private boolean initialize(IProject currentProject, IScannerConfigBuilderInfo buildInfo) {
|
|
||||||
boolean rc = false;
|
|
||||||
|
|
||||||
fWorkingDirectory = currentProject.getLocation();
|
|
||||||
String targetFile = "dummy"; //$NON-NLS-1$
|
|
||||||
try {
|
|
||||||
if (currentProject.hasNature(CCProjectNature.CC_NATURE_ID)) {
|
|
||||||
targetFile = GCCScannerConfigUtil.CPP_SPECS_FILE;
|
|
||||||
}
|
|
||||||
else if (currentProject.hasNature(CProjectNature.C_NATURE_ID)) {
|
|
||||||
targetFile = GCCScannerConfigUtil.C_SPECS_FILE;
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
//TODO VMIR better error handling
|
|
||||||
MakeCorePlugin.log(e.getStatus());
|
|
||||||
}
|
|
||||||
IPath path2File = MakeCorePlugin.getWorkingDirectory().append(targetFile);
|
|
||||||
if (!path2File.toFile().exists()) {
|
|
||||||
GCCScannerConfigUtil.createSpecs();
|
|
||||||
}
|
|
||||||
fCompileCommand = buildInfo.getESIProviderCommand();
|
|
||||||
if (fCompileCommand != null) {
|
|
||||||
fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(buildInfo.getESIProviderArguments(), "\"");//$NON-NLS-1$
|
|
||||||
for (int i = 0; i < fCompileArguments.length; ++i) {
|
|
||||||
fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{plugin_state_location\\}", //$NON-NLS-1$
|
|
||||||
MakeCorePlugin.getWorkingDirectory().toString());
|
|
||||||
fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{specs_file\\}", targetFile); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
rc = true;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tso - target specific options
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String[] prepareArguments(List tso) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
private String[] setEnvironment(CommandLauncher launcher) {
|
|
||||||
// Set the environmennt, some scripts may need the CWD var to be set.
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (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) {
|
|
||||||
try {
|
|
||||||
IMarker[] cur = 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 == lineNumber && sev == mapMarkerSeverity(severity) && mesg.equals(errorDesc)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IMarker marker = file.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER);
|
|
||||||
marker.setAttribute(IMarker.LOCATION, lineNumber);
|
|
||||||
marker.setAttribute(IMarker.MESSAGE, errorDesc);
|
|
||||||
marker.setAttribute(IMarker.SEVERITY, mapMarkerSeverity(severity));
|
|
||||||
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
|
|
||||||
marker.setAttribute(IMarker.CHAR_START, -1);
|
|
||||||
marker.setAttribute(IMarker.CHAR_END, -1);
|
|
||||||
if (errorVar != null) {
|
|
||||||
marker.setAttribute(ICModelMarker.C_MODEL_MARKER_VARIABLE, errorVar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,6 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
|
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.make.core.MakeProjectNature;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ScannerConfigBuilderInfo variant
|
* Creates a ScannerConfigBuilderInfo variant
|
||||||
|
@ -47,6 +48,10 @@ public class ScannerConfigInfoFactory {
|
||||||
static final String ESI_PROVIDER_ARGUMENTS = PREFIX + ".esiProviderArguments"; //$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 ESI_PROVIDER_PARSER_ID = PREFIX + ".esiProviderParserId"; //$NON-NLS-1$
|
||||||
static final String SI_PROBLEM_GENERATION_ENABLED = PREFIX + ".siProblemGenerationEnabled"; //$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$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -169,7 +174,7 @@ public class ScannerConfigInfoFactory {
|
||||||
if (isDefaultESIProviderCmd()) {
|
if (isDefaultESIProviderCmd()) {
|
||||||
String attributes = getESIProviderParameter("defaultAttributes"); //$NON-NLS-1$
|
String attributes = getESIProviderParameter("defaultAttributes"); //$NON-NLS-1$
|
||||||
if (attributes == null) {
|
if (attributes == null) {
|
||||||
attributes = "-E -P -v -dD ${plugin_state_location}/{specs_file}"; //$NON-NLS-1$
|
attributes = "-E -P -v -dD ${plugin_state_location}/${specs_file}"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
@ -222,6 +227,24 @@ public class ScannerConfigInfoFactory {
|
||||||
putString(SI_PROBLEM_GENERATION_ENABLED, Boolean.toString(enabled));
|
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) {
|
protected boolean getBoolean(String property) {
|
||||||
return Boolean.valueOf(getString(property)).booleanValue();
|
return Boolean.valueOf(getString(property)).booleanValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.make.core.scannerconfig;
|
package org.eclipse.cdt.make.internal.core.scannerconfig;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -51,8 +51,8 @@ public final class ScannerConfigUtil {
|
||||||
String value = null;
|
String value = null;
|
||||||
int index = symbol.indexOf("="); //$NON-NLS-1$
|
int index = symbol.indexOf("="); //$NON-NLS-1$
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
key = getSymbolKey(symbol);
|
key = symbol.substring(0, index).trim();
|
||||||
value = getSymbolValue(symbol);
|
value = symbol.substring(index + 1).trim();
|
||||||
} else {
|
} else {
|
||||||
key = symbol.trim();
|
key = symbol.trim();
|
||||||
}
|
}
|
||||||
|
@ -123,8 +123,8 @@ public final class ScannerConfigUtil {
|
||||||
String value = null;
|
String value = null;
|
||||||
int index = symbol.indexOf("="); //$NON-NLS-1$
|
int index = symbol.indexOf("="); //$NON-NLS-1$
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
key = symbol.substring(0, index).trim();
|
key = getSymbolKey(symbol);
|
||||||
value = symbol.substring(index + 1).trim();
|
value = getSymbolValue(symbol);
|
||||||
} else {
|
} else {
|
||||||
key = symbol.trim();
|
key = symbol.trim();
|
||||||
}
|
}
|
||||||
|
@ -272,13 +272,8 @@ public final class ScannerConfigUtil {
|
||||||
String[] tokens = line.split(quoteStyle);
|
String[] tokens = line.split(quoteStyle);
|
||||||
for (int i = 0; i < tokens.length; ++i) {
|
for (int i = 0; i < tokens.length; ++i) {
|
||||||
if (i % 2 == 0) { // even tokens need further tokenization
|
if (i % 2 == 0) { // even tokens need further tokenization
|
||||||
String[] sTokens = tokens[i].split("\\s"); //$NON-NLS-1$
|
String[] sTokens = tokens[i].split("\\s+"); //$NON-NLS-1$
|
||||||
// remove empty strings
|
for (int j = 0; j < sTokens.length; allTokens.add(sTokens[j++]));
|
||||||
for (int j = 0; j < sTokens.length; ++j) {
|
|
||||||
if (sTokens[j].length() > 0) {
|
|
||||||
allTokens.add(sTokens[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
allTokens.add(tokens[i]);
|
allTokens.add(tokens[i]);
|
|
@ -1,444 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-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 org.eclipse.cdt.core.CCProjectNature;
|
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
|
||||||
import org.eclipse.cdt.make.core.MakeProjectNature;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
|
||||||
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.ISafeRunnable;
|
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton object that collects scanner config updates from ScannerInfoParser
|
|
||||||
* and updates scanner config when the project's build is done.
|
|
||||||
*
|
|
||||||
* @author vhirsl
|
|
||||||
*/
|
|
||||||
public class ScannerInfoCollector implements IScannerInfoCollector {
|
|
||||||
|
|
||||||
// Singleton
|
|
||||||
private static ScannerInfoCollector instance = new ScannerInfoCollector();
|
|
||||||
private Map discoveredIncludes;
|
|
||||||
private Map discoveredSymbols;
|
|
||||||
private Map discoveredTSO; // target specific options
|
|
||||||
// cumulative values
|
|
||||||
private Map sumDiscoveredIncludes;
|
|
||||||
private Map sumDiscoveredSymbols;
|
|
||||||
// private Map sumDiscoveredTSO; // target specific options
|
|
||||||
|
|
||||||
private IProject currentProject; // project being built
|
|
||||||
|
|
||||||
private ScannerInfoCollector() {
|
|
||||||
discoveredIncludes = new HashMap();
|
|
||||||
discoveredSymbols = new HashMap();
|
|
||||||
discoveredTSO = new HashMap();
|
|
||||||
|
|
||||||
sumDiscoveredIncludes = new HashMap();
|
|
||||||
sumDiscoveredSymbols = new HashMap();
|
|
||||||
// sumDiscoveredTSO = new HashMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ScannerInfoCollector getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(org.eclipse.core.resources.IResource, java.util.List, java.util.List, java.util.Map)
|
|
||||||
*/
|
|
||||||
public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) {
|
|
||||||
IProject project;
|
|
||||||
if (resource == null || (project = resource.getProject()) == null) {
|
|
||||||
TraceUtil.outputError("IScannerInfoCollector.contributeToScannerConfig : ", "resource or project is null"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (project.hasNature(MakeProjectNature.NATURE_ID) && // limits to StandardMake projects
|
|
||||||
(project.hasNature(CProjectNature.C_NATURE_ID) ||
|
|
||||||
project.hasNature(CCProjectNature.CC_NATURE_ID))) {
|
|
||||||
|
|
||||||
String projectName = project.getName();
|
|
||||||
contribute(projectName, discoveredIncludes, includes, true);
|
|
||||||
contribute(projectName, discoveredSymbols, symbols, false);
|
|
||||||
contribute(projectName,
|
|
||||||
discoveredTSO,
|
|
||||||
(extraInfo == null) ? null : (List) extraInfo.get(IScannerInfoCollector.TARGET_SPECIFIC_OPTION),
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param project
|
|
||||||
* @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(String projectName, Map discovered, List delta, boolean ordered) {
|
|
||||||
if (delta == null || delta.isEmpty())
|
|
||||||
return false;
|
|
||||||
List projectDiscovered = (List) discovered.get(projectName);
|
|
||||||
if (projectDiscovered == null) {
|
|
||||||
projectDiscovered = new ArrayList(delta);
|
|
||||||
discovered.put(projectName, projectDiscovered);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return addItemsWithOrder(delta, projectDiscovered, ordered);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds new items to the already accumulated ones preserving order
|
|
||||||
*
|
|
||||||
* @param includes - items to be added
|
|
||||||
* @param sumIncludes - previously accumulated items
|
|
||||||
* @param ordered - to preserve order or append at the end
|
|
||||||
* @return boolean - true if added
|
|
||||||
*/
|
|
||||||
private boolean addItemsWithOrder(List includes, List sumIncludes, 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param project
|
|
||||||
* @param monitor
|
|
||||||
*/
|
|
||||||
private void updateScannerConfig(IProject project, IProgressMonitor monitor) throws CoreException {
|
|
||||||
IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
|
||||||
monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
|
|
||||||
if (pathInfo != null) {
|
|
||||||
String projectName = project.getName();
|
|
||||||
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
|
|
||||||
if (scannerConfigNeedsUpdate(pathInfo)) {
|
|
||||||
monitor.worked(50);
|
|
||||||
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + projectName); //$NON-NLS-1$
|
|
||||||
try {
|
|
||||||
// update scanner configuration
|
|
||||||
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo);
|
|
||||||
monitor.worked(50);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
MakeCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
monitor.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare discovered include paths and symbol definitions with the ones from scanInfo.
|
|
||||||
*
|
|
||||||
* @param scanInfo
|
|
||||||
* @param projectName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean scannerConfigNeedsUpdate(IDiscoveredPathInfo discPathInfo) {
|
|
||||||
List includes = (List) discoveredIncludes.get(discPathInfo.getProject().getName());
|
|
||||||
List symbols = (List) discoveredSymbols.get(discPathInfo.getProject().getName());
|
|
||||||
|
|
||||||
boolean addedIncludes = includePathsNeedUpdate(discPathInfo, includes);
|
|
||||||
boolean addedSymbols = definedSymbolsNeedUpdate(discPathInfo, symbols);
|
|
||||||
|
|
||||||
return (addedIncludes | addedSymbols);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare include paths with already discovered.
|
|
||||||
*
|
|
||||||
* @param discPathInfo
|
|
||||||
* @param projectName
|
|
||||||
* @param includes
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean includePathsNeedUpdate(IDiscoveredPathInfo discPathInfo, List includes) {
|
|
||||||
boolean addedIncludes = false;
|
|
||||||
String projectName = discPathInfo.getProject().getName();
|
|
||||||
if (includes != null) {
|
|
||||||
// Step 1. Add discovered scanner config to the existing discovered scanner config
|
|
||||||
// add the includes from the latest discovery
|
|
||||||
List sumIncludes = (List) sumDiscoveredIncludes.get(projectName);
|
|
||||||
if (sumIncludes == null) {
|
|
||||||
sumIncludes = new ArrayList(includes);
|
|
||||||
sumDiscoveredIncludes.put(projectName, sumIncludes);
|
|
||||||
addedIncludes = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
addedIncludes = addItemsWithOrder(includes, sumIncludes, true);
|
|
||||||
}
|
|
||||||
// try to translate cygpaths to absolute paths
|
|
||||||
List finalSumIncludes = translateIncludePaths(sumIncludes);
|
|
||||||
|
|
||||||
// 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(finalSumIncludes, persistedKeyList, 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);
|
|
||||||
|
|
||||||
// Step 5. Invalidate discovered include paths
|
|
||||||
discoveredIncludes.put(projectName, null);
|
|
||||||
}
|
|
||||||
return addedIncludes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compare symbol definitions with already discovered.
|
|
||||||
*
|
|
||||||
* @param discPathInfo
|
|
||||||
* @param projectName
|
|
||||||
* @param symbols
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean definedSymbolsNeedUpdate(IDiscoveredPathInfo discPathInfo, List symbols) {
|
|
||||||
boolean addedSymbols = false;
|
|
||||||
String projectName = discPathInfo.getProject().getName();
|
|
||||||
if (symbols != null) {
|
|
||||||
// Step 1. Add discovered scanner config to the existing discovered scanner config
|
|
||||||
// add the symbols from the latest discovery
|
|
||||||
Map sumSymbols = (Map) sumDiscoveredSymbols.get(projectName);
|
|
||||||
if (sumSymbols == null) {
|
|
||||||
sumSymbols = new LinkedHashMap();
|
|
||||||
sumDiscoveredSymbols.put(projectName, sumSymbols);
|
|
||||||
}
|
|
||||||
addedSymbols = ScannerConfigUtil.scAddSymbolsList2SymbolEntryMap(sumSymbols, symbols, 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, sumSymbols);
|
|
||||||
|
|
||||||
// Step 4. Set resulting scanner config
|
|
||||||
discPathInfo.setSymbolMap(candidateSymbols);
|
|
||||||
|
|
||||||
// Step 5. Invalidate discovered symbol definitions
|
|
||||||
discoveredSymbols.put(projectName, null);
|
|
||||||
}
|
|
||||||
return addedSymbols;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param sumIncludes
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List translateIncludePaths(List 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()) {
|
|
||||||
String translatedPath = includePath;
|
|
||||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
|
||||||
translatedPath = new CygpathTranslator(currentProject, includePath).run();
|
|
||||||
}
|
|
||||||
if (translatedPath != null) {
|
|
||||||
if (!translatedPath.equals(includePath)) {
|
|
||||||
// Check if the translated path exists
|
|
||||||
IPath transPath = new Path(translatedPath);
|
|
||||||
if (transPath.toFile().exists()) {
|
|
||||||
translatedIncludePaths.add(translatedPath);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
TraceUtil.outputError("CygpathTranslator unable to translate path: ",//$NON-NLS-1$
|
|
||||||
includePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
translatedIncludePaths.add(includePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return translatedIncludePaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call ESI provider to get scanner info
|
|
||||||
*
|
|
||||||
* @param project
|
|
||||||
* @param tso
|
|
||||||
* @param monitor
|
|
||||||
*/
|
|
||||||
private void getProviderScannerInfo(final IProject project,
|
|
||||||
final List tso,
|
|
||||||
final IProgressMonitor monitor) {
|
|
||||||
// get IScannerConfigBuilderInfo
|
|
||||||
IScannerConfigBuilderInfo info;
|
|
||||||
try {
|
|
||||||
info = MakeCorePlugin.createScannerConfigBuildInfo(
|
|
||||||
project, ScannerConfigBuilder.BUILDER_ID);
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
info = MakeCorePlugin.createScannerConfigBuildInfo(
|
|
||||||
MakeCorePlugin.getDefault().getPluginPreferences(),
|
|
||||||
ScannerConfigBuilder.BUILDER_ID, false);
|
|
||||||
}
|
|
||||||
if (info.isESIProviderCommandEnabled()) {
|
|
||||||
final IScannerConfigBuilderInfo buildInfo = info;
|
|
||||||
final IExternalScannerInfoProvider esiProvider = MakeCorePlugin.getDefault().
|
|
||||||
getExternalScannerInfoProvider(MakeCorePlugin.DEFAULT_EXTERNAL_SI_PROVIDER_ID);
|
|
||||||
if (esiProvider != null) {
|
|
||||||
ISafeRunnable runnable = new ISafeRunnable() {
|
|
||||||
public void run() {
|
|
||||||
esiProvider.invokeProvider(monitor, project, buildInfo, tso, ScannerInfoCollector.getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleException(Throwable exception) {
|
|
||||||
MakeCorePlugin.log(exception);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Platform.run(runnable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param project
|
|
||||||
* @param monitor
|
|
||||||
*/
|
|
||||||
public synchronized void updateScannerConfiguration(IProject project, IProgressMonitor monitor) throws CoreException {
|
|
||||||
if (monitor == null) {
|
|
||||||
monitor = new NullProgressMonitor();
|
|
||||||
}
|
|
||||||
currentProject = project;
|
|
||||||
String projectName = project.getName();
|
|
||||||
// check TSO for the project
|
|
||||||
monitor.beginTask("", 100); //$NON-NLS-1$
|
|
||||||
getProviderScannerInfo(project, (List) discoveredTSO.get(projectName), new SubProgressMonitor(monitor, 60));
|
|
||||||
updateScannerConfig(project, new SubProgressMonitor(monitor, 40));
|
|
||||||
|
|
||||||
// delete discovered scanner config
|
|
||||||
discoveredIncludes.put(projectName, null);
|
|
||||||
discoveredSymbols.put(projectName, null);
|
|
||||||
discoveredTSO.put(projectName, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete all discovered paths for the project
|
|
||||||
*
|
|
||||||
* @param project
|
|
||||||
*/
|
|
||||||
public void deleteAllPaths(IProject project) {
|
|
||||||
if (project != null) {
|
|
||||||
sumDiscoveredIncludes.put(project.getName(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete all discovered symbols for the project
|
|
||||||
*
|
|
||||||
* @param project
|
|
||||||
*/
|
|
||||||
public void deleteAllSymbols(IProject project) {
|
|
||||||
if (project != null) {
|
|
||||||
sumDiscoveredSymbols.put(project.getName(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a specific include path
|
|
||||||
*
|
|
||||||
* @param project
|
|
||||||
* @param path
|
|
||||||
*/
|
|
||||||
public void deletePath(IProject project, String path) {
|
|
||||||
if (project != null) {
|
|
||||||
List sumIncludes = (List) sumDiscoveredIncludes.get(project.getName());
|
|
||||||
if (sumIncludes != null) {
|
|
||||||
sumIncludes.remove(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a specific symbol definition
|
|
||||||
*
|
|
||||||
* @param project
|
|
||||||
* @param path
|
|
||||||
*/
|
|
||||||
public void deleteSymbol(IProject project, String symbol) {
|
|
||||||
if (project != null) {
|
|
||||||
Map sumSymbols = (Map) sumDiscoveredSymbols.get(project.getName());
|
|
||||||
if (sumSymbols != null) {
|
|
||||||
// remove it from the Map of SymbolEntries
|
|
||||||
ScannerConfigUtil.removeSymbolEntryValue(symbol, sumSymbols);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,12 +14,13 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.ScannerInfoConsoleParserUtility;
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -32,45 +33,55 @@ import org.eclipse.core.runtime.IPath;
|
||||||
*/
|
*/
|
||||||
public class ScannerInfoConsoleParserFactory {
|
public class ScannerInfoConsoleParserFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser
|
* Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser
|
||||||
* and a utility.
|
* and a utility.
|
||||||
*
|
*
|
||||||
* @param outputStream
|
* @param outputStream
|
||||||
* @param currentProject
|
* @param errorStream
|
||||||
* @param markerGenerator
|
* @param currentProject
|
||||||
* @param scBuildInfo
|
* @param providerId
|
||||||
* @param collector - scanner info collector
|
* @param scBuildInfo
|
||||||
* @return ConsoleOutputSniffer
|
* @param markerGenerator
|
||||||
*/
|
* @return ConsoleOutputSniffer
|
||||||
public static ConsoleOutputSniffer getESIProviderOutputSniffer(
|
*/
|
||||||
OutputStream outputStream,
|
public static ConsoleOutputSniffer getESIProviderOutputSniffer(
|
||||||
OutputStream errorStream,
|
OutputStream outputStream,
|
||||||
IProject currentProject,
|
OutputStream errorStream,
|
||||||
IScannerConfigBuilderInfo scBuildInfo,
|
IProject currentProject,
|
||||||
IScannerInfoCollector collector) {
|
String providerId,
|
||||||
if (scBuildInfo.isESIProviderCommandEnabled()) {
|
IScannerConfigBuilderInfo2 scBuildInfo,
|
||||||
// get the ESIProvider console parser
|
IMarkerGenerator markerGenerator) {
|
||||||
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
|
if (scBuildInfo.isProviderOutputParserEnabled(providerId)) {
|
||||||
getScannerInfoConsoleParser(scBuildInfo.getESIProviderConsoleParserId());
|
// get the ESIProvider console parser
|
||||||
// initialize it with the utility
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
clParser.startup(currentProject, null /*new ScannerInfoConsoleParserUtility(
|
getSCProfileInstance(currentProject, scBuildInfo.getSelectedProfileId());
|
||||||
currentProject, null, markerGenerator)*/, collector);
|
IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId);
|
||||||
// create an output stream sniffer
|
// initialize the utility object
|
||||||
return new ConsoleOutputSniffer(outputStream, errorStream, new
|
IScannerInfoConsoleParserUtility util = clParser.getUtility();
|
||||||
IScannerInfoConsoleParser[] {clParser});
|
if (util != null) {
|
||||||
}
|
util.initialize(currentProject, currentProject.getLocation(), markerGenerator);
|
||||||
return null;
|
}
|
||||||
}
|
IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
|
||||||
|
clParser.startup(currentProject, collector);
|
||||||
|
// create an output stream sniffer
|
||||||
|
return new ConsoleOutputSniffer(outputStream, errorStream, new
|
||||||
|
IScannerInfoConsoleParser[] {clParser});
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser
|
* Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser
|
||||||
* and a utility.
|
* and a utility.
|
||||||
*
|
*
|
||||||
* @param outputStream
|
* @param outputStream
|
||||||
|
* @param errorStream
|
||||||
* @param currentProject
|
* @param currentProject
|
||||||
* @param workingDirectory
|
* @param workingDirectory
|
||||||
|
* @param buildInfo
|
||||||
* @param markerGenerator
|
* @param markerGenerator
|
||||||
|
* @param IScannerInfoCollector2
|
||||||
* @return ConsoleOutputSniffer
|
* @return ConsoleOutputSniffer
|
||||||
*/
|
*/
|
||||||
public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
|
public static ConsoleOutputSniffer getMakeBuilderOutputSniffer(
|
||||||
|
@ -78,30 +89,40 @@ public class ScannerInfoConsoleParserFactory {
|
||||||
OutputStream errorStream,
|
OutputStream errorStream,
|
||||||
IProject currentProject,
|
IProject currentProject,
|
||||||
IPath workingDirectory,
|
IPath workingDirectory,
|
||||||
IMarkerGenerator markerGenerator) {
|
IScannerConfigBuilderInfo2 scBuildInfo,
|
||||||
|
IMarkerGenerator markerGenerator,
|
||||||
|
IScannerInfoCollector collector) {
|
||||||
try {
|
try {
|
||||||
// get the SC builder settings
|
// get the SC builder settings
|
||||||
if (currentProject.hasNature(ScannerConfigNature.NATURE_ID)) {
|
if (currentProject.hasNature(ScannerConfigNature.NATURE_ID)) {
|
||||||
IScannerConfigBuilderInfo scBuildInfo;
|
if (scBuildInfo == null) {
|
||||||
try {
|
try {
|
||||||
scBuildInfo = MakeCorePlugin.
|
scBuildInfo = ScannerConfigProfileManager.
|
||||||
createScannerConfigBuildInfo(currentProject, ScannerConfigBuilder.BUILDER_ID);
|
createScannerConfigBuildInfo2(currentProject);
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
// builder not installed or disabled
|
// builder not installed or disabled
|
||||||
scBuildInfo = null;
|
}
|
||||||
}
|
}
|
||||||
if (scBuildInfo != null &&
|
if (scBuildInfo != null &&
|
||||||
scBuildInfo.isAutoDiscoveryEnabled() &&
|
scBuildInfo.isAutoDiscoveryEnabled() &&
|
||||||
scBuildInfo.isMakeBuilderConsoleParserEnabled()) {
|
scBuildInfo.isBuildOutputParserEnabled()) {
|
||||||
// get the make builder console parser
|
// get the make builder console parser
|
||||||
IScannerInfoConsoleParser clParser = MakeCorePlugin.getDefault().
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
getScannerInfoConsoleParser(scBuildInfo.getMakeBuilderConsoleParserId());
|
getSCProfileInstance(currentProject, scBuildInfo.getSelectedProfileId());
|
||||||
// initialize it with the utility
|
IScannerInfoConsoleParser clParser = profileInstance.createBuildOutputParser();
|
||||||
clParser.startup(currentProject, new ScannerInfoConsoleParserUtility(
|
if (collector == null) {
|
||||||
currentProject, workingDirectory,
|
collector = profileInstance.getScannerInfoCollector();
|
||||||
scBuildInfo.isSIProblemGenerationEnabled() ? markerGenerator : null),
|
}
|
||||||
ScannerInfoCollector.getInstance());
|
|
||||||
|
// initialize the utility object
|
||||||
|
IScannerInfoConsoleParserUtility util = clParser.getUtility();
|
||||||
|
if (util != null) {
|
||||||
|
util.initialize(currentProject, workingDirectory,
|
||||||
|
scBuildInfo.isProblemReportingEnabled() ?
|
||||||
|
markerGenerator : null);
|
||||||
|
}
|
||||||
|
clParser.startup(currentProject, collector);
|
||||||
// create an output stream sniffer
|
// create an output stream sniffer
|
||||||
return new ConsoleOutputSniffer(outputStream, errorStream, new
|
return new ConsoleOutputSniffer(outputStream, errorStream, new
|
||||||
IScannerInfoConsoleParser[] {clParser});
|
IScannerInfoConsoleParser[] {clParser});
|
||||||
|
|
|
@ -14,9 +14,11 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.ScannerInfoConsoleParserUtility;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -37,18 +39,25 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
|
||||||
private final static char[] matchingChars = {'`', '\'', '\"'};
|
private final static char[] matchingChars = {'`', '\'', '\"'};
|
||||||
|
|
||||||
private IProject fProject = null;
|
private IProject fProject = null;
|
||||||
private IScannerInfoConsoleParserUtility fUtil = null;
|
private ScannerInfoConsoleParserUtility fUtil = null;
|
||||||
private IScannerInfoCollector fCollector = null;
|
private IScannerInfoCollector fCollector = null;
|
||||||
|
|
||||||
private boolean bMultiline = false;
|
private boolean bMultiline = false;
|
||||||
private String sMultiline = ""; //$NON-NLS-1$
|
private String sMultiline = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector)
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#getUtility()
|
||||||
*/
|
*/
|
||||||
public void startup(IProject project, IScannerInfoConsoleParserUtility util, IScannerInfoCollector collector) {
|
public IScannerInfoConsoleParserUtility getUtility() {
|
||||||
|
fUtil = new ScannerInfoConsoleParserUtility();
|
||||||
|
return fUtil;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility, org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes)
|
||||||
|
*/
|
||||||
|
public void startup(IProject project, IScannerInfoCollector collector) {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
fUtil = util;
|
|
||||||
fCollector = collector;
|
fCollector = collector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,9 +120,7 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
|
||||||
|
|
||||||
while (I.hasNext()) {
|
while (I.hasNext()) {
|
||||||
token = (String) I.next();
|
token = (String) I.next();
|
||||||
if (token.equals("-mwin32") || //$NON-NLS-1$
|
if (token.startsWith("-m") || //$NON-NLS-1$
|
||||||
token.equals("-mno-win32") || //$NON-NLS-1$
|
|
||||||
token.equals("-mno-cygwin") || //$NON-NLS-1$
|
|
||||||
token.equals("-ansi") || //$NON-NLS-1$
|
token.equals("-ansi") || //$NON-NLS-1$
|
||||||
token.equals("-nostdinc") || //$NON-NLS-1$
|
token.equals("-nostdinc") || //$NON-NLS-1$
|
||||||
token.equals("-posix") || //$NON-NLS-1$
|
token.equals("-posix") || //$NON-NLS-1$
|
||||||
|
@ -171,9 +178,11 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
|
||||||
}
|
}
|
||||||
// Contribute discovered includes and symbols to the ScannerInfoCollector
|
// Contribute discovered includes and symbols to the ScannerInfoCollector
|
||||||
if (translatedIncludes.size() > 0 || symbols.size() > 0) {
|
if (translatedIncludes.size() > 0 || symbols.size() > 0) {
|
||||||
Map extraInfo = new HashMap();
|
Map scannerInfo = new HashMap();
|
||||||
extraInfo.put(IScannerInfoCollector.TARGET_SPECIFIC_OPTION, targetSpecificOptions);
|
scannerInfo.put(ScannerInfoTypes.INCLUDE_PATHS, translatedIncludes);
|
||||||
fCollector.contributeToScannerConfig(project, translatedIncludes, symbols, extraInfo);
|
scannerInfo.put(ScannerInfoTypes.SYMBOL_DEFINITIONS, symbols);
|
||||||
|
scannerInfo.put(ScannerInfoTypes.TARGET_SPECIFIC_OPTION, targetSpecificOptions);
|
||||||
|
fCollector.contributeToScannerConfig(project, scannerInfo);
|
||||||
|
|
||||||
TraceUtil.outputTrace("Discovered scanner info for file \'" + fileName + '\'', //$NON-NLS-1$
|
TraceUtil.outputTrace("Discovered scanner info for file \'" + fileName + '\'', //$NON-NLS-1$
|
||||||
"Include paths", includes, translatedIncludes, "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$
|
"Include paths", includes, translatedIncludes, "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -184,7 +193,7 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line
|
* @param line
|
||||||
* @return
|
* @return list of tokens
|
||||||
*/
|
*/
|
||||||
private List tokenize(String line) {
|
private List tokenize(String line) {
|
||||||
List rv = new ArrayList(2);
|
List rv = new ArrayList(2);
|
||||||
|
@ -361,4 +370,5 @@ public class GCCScannerInfoConsoleParser implements IScannerInfoConsoleParser {
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,12 @@ package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.TraceUtil;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
|
@ -40,11 +42,17 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
|
||||||
private List includes = new ArrayList();
|
private List includes = new ArrayList();
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector)
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#getUtility()
|
||||||
*/
|
*/
|
||||||
public void startup(IProject project, IScannerInfoConsoleParserUtility util, IScannerInfoCollector collector) {
|
public IScannerInfoConsoleParserUtility getUtility() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser#startup(org.eclipse.core.resources.IProject, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector)
|
||||||
|
*/
|
||||||
|
public void startup(IProject project, IScannerInfoCollector collector) {
|
||||||
this.fProject = project;
|
this.fProject = project;
|
||||||
this.fUtil = util;
|
|
||||||
this.fCollector = collector;
|
this.fCollector = collector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,18 +93,18 @@ public class GCCSpecsConsoleParser implements IScannerInfoConsoleParser {
|
||||||
includes.add(line);
|
includes.add(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown()
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParser#shutdown()
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
fCollector.contributeToScannerConfig(fProject, includes, symbols, new HashMap());
|
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$
|
TraceUtil.outputTrace("Scanner info from \'specs\' file", //$NON-NLS-1$
|
||||||
"Include paths", includes, new ArrayList(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$);
|
"Include paths", includes, new ArrayList(), "Defined symbols", symbols); //$NON-NLS-1$ //$NON-NLS-2$);
|
||||||
if (fUtil != null) {
|
|
||||||
fUtil.reportProblems();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.IScannerConfigBuilderInfo2;
|
||||||
|
import org.eclipse.cdt.make.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 String inputFileName;
|
||||||
|
|
||||||
|
private IResource resource;
|
||||||
|
private IScannerConfigBuilderInfo2 buildInfo;
|
||||||
|
private boolean rc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param project
|
||||||
|
* @param buildInfo
|
||||||
|
*/
|
||||||
|
public BuildOutputReaderJob(IProject project, IScannerConfigBuilderInfo2 buildInfo) {
|
||||||
|
super(JOB_NAME);
|
||||||
|
this.resource = project;
|
||||||
|
this.buildInfo = buildInfo;
|
||||||
|
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());
|
||||||
|
|
||||||
|
boolean rc = SCJobsUtil.readBuildOutputFile(project, buildInfo, new SubProgressMonitor(monitor, 70));
|
||||||
|
rc |= SCJobsUtil.getProviderScannerInfo(project, buildInfo, new SubProgressMonitor(monitor, 20));
|
||||||
|
if (rc) {
|
||||||
|
rc = SCJobsUtil.updateScannerConfiguration(project, buildInfo, new SubProgressMonitor(monitor, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor.done();
|
||||||
|
return (rc == true) ? Status.OK_STATUS : Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,171 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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 java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
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.internal.core.scannerconfig2.SCProfileInstance;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class for build and job related functionality
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public class SCJobsUtil {
|
||||||
|
private static class RC {
|
||||||
|
public RC(boolean init) {
|
||||||
|
rc = init;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the rc.
|
||||||
|
*/
|
||||||
|
public boolean get() {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param rc The rc to set.
|
||||||
|
*/
|
||||||
|
public void set(boolean rc) {
|
||||||
|
this.rc = rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return rc ? "true" : "false"; //$NON-NLS-1$ //$$NON-NLS-2$
|
||||||
|
}
|
||||||
|
private boolean rc;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Call ESI providers to get scanner info
|
||||||
|
*
|
||||||
|
* @param collector
|
||||||
|
* @param buildInfo
|
||||||
|
* @param monitor
|
||||||
|
*/
|
||||||
|
public static boolean getProviderScannerInfo(final IProject project,
|
||||||
|
final IScannerConfigBuilderInfo2 buildInfo,
|
||||||
|
final IProgressMonitor monitor) {
|
||||||
|
final RC rc = new RC(false);
|
||||||
|
// get the collector
|
||||||
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
|
getSCProfileInstance(project, buildInfo.getSelectedProfileId());
|
||||||
|
final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
|
||||||
|
|
||||||
|
List providerIds = buildInfo.getProviderIdList();
|
||||||
|
for (int i = 0; i < providerIds.size(); ++i) {
|
||||||
|
final String providerId = (String) providerIds.get(i);
|
||||||
|
if (buildInfo.isProviderOutputParserEnabled(providerId)) {
|
||||||
|
final IExternalScannerInfoProvider esiProvider = profileInstance.
|
||||||
|
createExternalScannerInfoProvider(providerId);
|
||||||
|
if (esiProvider != null) {
|
||||||
|
ISafeRunnable runnable = new ISafeRunnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
esiProvider.invokeProvider(monitor, project, providerId, buildInfo, collector);
|
||||||
|
rc.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleException(Throwable exception) {
|
||||||
|
rc.set(false);
|
||||||
|
MakeCorePlugin.log(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
Platform.run(runnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rc.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update and persist scanner configuration
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
* @param buildInfo
|
||||||
|
* @param monitor
|
||||||
|
*/
|
||||||
|
public static boolean updateScannerConfiguration(IProject project,
|
||||||
|
IScannerConfigBuilderInfo2 buildInfo,
|
||||||
|
final IProgressMonitor monitor) {
|
||||||
|
final RC rc = new RC(false);
|
||||||
|
// get the collector
|
||||||
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
|
getSCProfileInstance(project, buildInfo.getSelectedProfileId());
|
||||||
|
IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
|
||||||
|
if (collector instanceof IScannerInfoCollector2) {
|
||||||
|
final IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
|
||||||
|
ISafeRunnable runnable = new ISafeRunnable() {
|
||||||
|
|
||||||
|
public void run() throws Exception {
|
||||||
|
collector2.updateScannerConfiguration(monitor);
|
||||||
|
rc.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleException(Throwable exception) {
|
||||||
|
rc.set(false);
|
||||||
|
MakeCorePlugin.log(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
Platform.run(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param project
|
||||||
|
* @param buildInfo
|
||||||
|
* @param monitor
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean readBuildOutputFile(final IProject project,
|
||||||
|
final IScannerConfigBuilderInfo2 buildInfo,
|
||||||
|
final IProgressMonitor monitor) {
|
||||||
|
final RC rc = new RC(false);
|
||||||
|
// get the collector
|
||||||
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
|
getSCProfileInstance(project, buildInfo.getSelectedProfileId());
|
||||||
|
final IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
|
||||||
|
final IExternalScannerInfoProvider esiProvider = profileInstance.
|
||||||
|
createBuildOutputProvider();
|
||||||
|
|
||||||
|
if (buildInfo.isBuildOutputFileActionEnabled()) {
|
||||||
|
ISafeRunnable runnable = new ISafeRunnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
esiProvider.invokeProvider(monitor, project, null, buildInfo, collector);
|
||||||
|
rc.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleException(Throwable exception) {
|
||||||
|
rc.set(false);
|
||||||
|
MakeCorePlugin.log(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
Platform.run(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,213 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-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) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -52,7 +52,13 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
|
||||||
private List fNameConflicts;
|
private List fNameConflicts;
|
||||||
private Vector fDirectoryStack;
|
private Vector fDirectoryStack;
|
||||||
|
|
||||||
public ScannerInfoConsoleParserUtility(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) {
|
private boolean fInitialized = false;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParserUtility#initialize(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IPath, org.eclipse.cdt.core.IMarkerGenerator)
|
||||||
|
*/
|
||||||
|
public void initialize(IProject project, IPath workingDirectory, IMarkerGenerator markerGenerator) {
|
||||||
|
fInitialized = true;
|
||||||
fProject = project;
|
fProject = project;
|
||||||
fMarkerGenerator = markerGenerator;
|
fMarkerGenerator = markerGenerator;
|
||||||
fBaseDirectory = fProject.getLocation();
|
fBaseDirectory = fProject.getLocation();
|
||||||
|
@ -77,10 +83,9 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#reportProblems()
|
|
||||||
*/
|
|
||||||
public boolean reportProblems() {
|
public boolean reportProblems() {
|
||||||
|
if (!fInitialized)
|
||||||
|
return false;
|
||||||
boolean reset = false;
|
boolean reset = false;
|
||||||
for (Iterator iter = fErrors.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = fErrors.iterator(); iter.hasNext(); ) {
|
||||||
Problem problem = (Problem) iter.next();
|
Problem problem = (Problem) iter.next();
|
||||||
|
@ -251,7 +256,7 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
|
||||||
return fNameConflicts.contains(path.lastSegment());
|
return fNameConflicts.contains(path.lastSegment());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IPath getWorkingDirectory() {
|
public IPath getWorkingDirectory() {
|
||||||
if (fDirectoryStack.size() != 0) {
|
if (fDirectoryStack.size() != 0) {
|
||||||
return (IPath) fDirectoryStack.lastElement();
|
return (IPath) fDirectoryStack.lastElement();
|
||||||
}
|
}
|
||||||
|
@ -300,9 +305,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
|
||||||
return fDirectoryStack.size();
|
return fDirectoryStack.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#changeMakeDirectory(java.lang.String, int, boolean)
|
|
||||||
*/
|
|
||||||
public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir) {
|
public void changeMakeDirectory(String dir, int dirLevel, boolean enterDir) {
|
||||||
if (enterDir) {
|
if (enterDir) {
|
||||||
/* Sometimes make screws up the output, so
|
/* Sometimes make screws up the output, so
|
||||||
|
@ -319,9 +321,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#translateRelativePaths(org.eclipse.core.resources.IFile, java.lang.String, java.util.List)
|
|
||||||
*/
|
|
||||||
public List translateRelativePaths(IFile file, String fileName, List includes) {
|
public List translateRelativePaths(IFile file, String fileName, List includes) {
|
||||||
List translatedIncludes = new ArrayList(includes.size());
|
List translatedIncludes = new ArrayList(includes.size());
|
||||||
for (Iterator i = includes.iterator(); i.hasNext(); ) {
|
for (Iterator i = includes.iterator(); i.hasNext(); ) {
|
||||||
|
@ -380,9 +379,6 @@ public class ScannerInfoConsoleParserUtility implements IScannerInfoConsoleParse
|
||||||
return translatedIncludes;
|
return translatedIncludes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.internal.core.scannerconfig.IScannerInfoConsoleParserUtility#normalizePath(java.lang.String)
|
|
||||||
*/
|
|
||||||
public String normalizePath(String path) {
|
public String normalizePath(String path) {
|
||||||
int column = path.indexOf(':');
|
int column = path.indexOf(':');
|
||||||
if (column > 0) {
|
if (column > 0) {
|
||||||
|
|
|
@ -10,8 +10,12 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.make.internal.core.scannerconfig.util;
|
package org.eclipse.cdt.make.internal.core.scannerconfig.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tracebility related utility functions
|
* Tracebility related utility functions
|
||||||
|
@ -21,6 +25,18 @@ import java.util.List;
|
||||||
public class TraceUtil {
|
public class TraceUtil {
|
||||||
public static final String EOL = System.getProperty("line.separator"); //$NON-NLS-1$
|
public static final String EOL = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||||
public static boolean SCANNER_CONFIG = false;
|
public static boolean SCANNER_CONFIG = false;
|
||||||
|
private static LogWriter logger = null;
|
||||||
|
|
||||||
|
static {
|
||||||
|
logger = new LogWriter(MakeCorePlugin.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() {
|
public static boolean isTracing() {
|
||||||
return SCANNER_CONFIG;
|
return SCANNER_CONFIG;
|
||||||
|
@ -77,4 +93,74 @@ public class TraceUtil {
|
||||||
System.out.println("Error: " + string + line); //$NON-NLS-1$
|
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 ***");
|
||||||
|
logger.writeln();
|
||||||
|
for (Iterator k = directoryCommandListMap.keySet().iterator(); k.hasNext(); ) {
|
||||||
|
String dir = (String) k.next();
|
||||||
|
logger.writeln(title + dir + ":");
|
||||||
|
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 ***");
|
||||||
|
logger.writeln();
|
||||||
|
logger.writeln(title);
|
||||||
|
logger.writeln(" Number of directories visited: " + Integer.toString(workingDirsN));
|
||||||
|
logger.writeln(" Number of generic commands: " + Integer.toString(commandsN));
|
||||||
|
logger.writeln(" Number of compiled files: " + Integer.toString(filesN));
|
||||||
|
logger.flushLog();
|
||||||
|
}
|
||||||
|
catch (IOException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param trace : String
|
||||||
|
*/
|
||||||
|
public static void metricsTrace(String trace) {
|
||||||
|
try {
|
||||||
|
logger.writeln();
|
||||||
|
logger.writeln(" *** NEW METRICS TRACE 2 ***");
|
||||||
|
logger.writeln();
|
||||||
|
logger.writeln(trace);
|
||||||
|
logger.flushLog();
|
||||||
|
}
|
||||||
|
catch (IOException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,223 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
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.resources.IConsole;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
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.internal.core.MakeMessages;
|
||||||
|
import org.eclipse.cdt.make.internal.core.StreamMonitor;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.ConsoleOutputSniffer;
|
||||||
|
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.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
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 = MakeCorePlugin.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, 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() {
|
||||||
|
fWorkingDirectory = resource.getProject().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.
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,158 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.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.make.core.IMakeBuilderInfo;
|
||||||
|
import org.eclipse.cdt.make.core.MakeBuilder;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
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.internal.core.scannerconfig.ConsoleOutputSniffer;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
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 = MakeCorePlugin.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, cos;
|
||||||
|
try {
|
||||||
|
ostream = console.getOutputStream();
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
ostream = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get build location
|
||||||
|
IPath buildDirectory = null;
|
||||||
|
try {
|
||||||
|
IMakeBuilderInfo makeInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
|
||||||
|
if (!makeInfo.getBuildLocation().isEmpty()) {
|
||||||
|
IResource res = project.getParent().findMember(makeInfo.getBuildLocation());
|
||||||
|
if (res instanceof IContainer && res.exists()) {
|
||||||
|
buildDirectory = res.getLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (buildDirectory == null) {
|
||||||
|
buildDirectory = project.getLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.
|
||||||
|
getMakeBuilderOutputSniffer(ostream, null, project, 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) {
|
||||||
|
MakeCorePlugin.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));
|
||||||
|
// 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) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
ostream.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ostream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitor.done();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerConfigUtil;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
IPath path2File = MakeCorePlugin.getWorkingDirectory().append(targetFile);
|
||||||
|
if (!path2File.toFile().exists()) {
|
||||||
|
GCCScannerConfigUtil.createSpecs();
|
||||||
|
}
|
||||||
|
// 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$
|
||||||
|
MakeCorePlugin.getWorkingDirectory().toString());
|
||||||
|
fCompileArguments[i] = fCompileArguments[i].replaceAll("\\$\\{specs_file\\}", targetFile); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
//TODO VMIR better error handling
|
||||||
|
MakeCorePlugin.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,440 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.CCProjectNature;
|
||||||
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.MakeProjectNature;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
|
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.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.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New per project scanner info collector
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public class PerProjectSICollector implements IScannerInfoCollector2 {
|
||||||
|
private IProject project;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
MakeCorePlugin.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();
|
||||||
|
}
|
||||||
|
// check TSO for the project
|
||||||
|
updateScannerConfig(monitor);
|
||||||
|
scPersisted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param monitor
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
private void updateScannerConfig(IProgressMonitor monitor) throws CoreException {
|
||||||
|
IDiscoveredPathInfo pathInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
||||||
|
monitor.beginTask(MakeMessages.getString("ScannerInfoCollector.Processing"), 100); //$NON-NLS-1$
|
||||||
|
if (pathInfo != null) {
|
||||||
|
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Processing")); //$NON-NLS-1$
|
||||||
|
if (scannerConfigNeedsUpdate(pathInfo)) {
|
||||||
|
monitor.worked(50);
|
||||||
|
monitor.subTask(MakeMessages.getString("ScannerInfoCollector.Updating") + project.getName()); //$NON-NLS-1$
|
||||||
|
try {
|
||||||
|
// update scanner configuration
|
||||||
|
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(pathInfo);
|
||||||
|
monitor.worked(50);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare discovered include paths and symbol definitions with the ones from scanInfo.
|
||||||
|
*
|
||||||
|
* @param scanInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean scannerConfigNeedsUpdate(IDiscoveredPathInfo 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(IDiscoveredPathInfo 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 = translateIncludePaths(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(IDiscoveredPathInfo 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sumIncludes
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List translateIncludePaths(List 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()) {
|
||||||
|
String translatedPath = includePath;
|
||||||
|
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||||
|
translatedPath = new CygpathTranslator(project, includePath).run();
|
||||||
|
}
|
||||||
|
if (translatedPath != null) {
|
||||||
|
if (!translatedPath.equals(includePath)) {
|
||||||
|
// Check if the translated path exists
|
||||||
|
IPath transPath = new Path(translatedPath);
|
||||||
|
if (transPath.toFile().exists()) {
|
||||||
|
translatedIncludePaths.add(translatedPath);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TraceUtil.outputError("CygpathTranslator unable to translate path: ",//$NON-NLS-1$
|
||||||
|
includePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
translatedIncludePaths.add(includePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return translatedIncludePaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all discovered paths for the project
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
public void deleteAllPaths(IProject project) {
|
||||||
|
if (project != null && project.equals(this.project)) {
|
||||||
|
sumDiscoveredIncludes.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all discovered symbols for the project
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
*/
|
||||||
|
public void deleteAllSymbols(IProject project) {
|
||||||
|
if (project != null && project.equals(this.project)) {
|
||||||
|
sumDiscoveredSymbols.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a specific include path
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
* @param path
|
||||||
|
*/
|
||||||
|
public void deletePath(IProject project, String path) {
|
||||||
|
if (project != null && project.equals(this.project)) {
|
||||||
|
sumDiscoveredIncludes.remove(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a specific symbol definition
|
||||||
|
*
|
||||||
|
* @param project
|
||||||
|
* @param path
|
||||||
|
*/
|
||||||
|
public void deleteSymbol(IProject project, String symbol) {
|
||||||
|
if (project != null && project.equals(this.project)) {
|
||||||
|
// remove it from the Map of SymbolEntries
|
||||||
|
ScannerConfigUtil.removeSymbolEntryValue(symbol, sumDiscoveredSymbols);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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 org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||||
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
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) {
|
||||||
|
try {
|
||||||
|
IMarker[] cur = 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 == lineNumber && sev == mapMarkerSeverity(severity) && mesg.equals(errorDesc)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IMarker marker = file.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER);
|
||||||
|
marker.setAttribute(IMarker.LOCATION, lineNumber);
|
||||||
|
marker.setAttribute(IMarker.MESSAGE, errorDesc);
|
||||||
|
marker.setAttribute(IMarker.SEVERITY, mapMarkerSeverity(severity));
|
||||||
|
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
|
||||||
|
marker.setAttribute(IMarker.CHAR_START, -1);
|
||||||
|
marker.setAttribute(IMarker.CHAR_END, -1);
|
||||||
|
if (errorVar != null) {
|
||||||
|
marker.setAttribute(ICModelMarker.C_MODEL_MARKER_VARIABLE, errorVar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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 org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2;
|
||||||
|
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.ScannerInfoConsoleParser;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfile.ScannerInfoProvider;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiated scanner config profile
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public class SCProfileInstance {
|
||||||
|
private IProject project;
|
||||||
|
private ScannerConfigProfile profile;
|
||||||
|
private IScannerInfoCollector collector;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public SCProfileInstance(IProject project, ScannerConfigProfile profile) {
|
||||||
|
this.project = project;
|
||||||
|
this.profile = profile;
|
||||||
|
instantiate();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void instantiate() {
|
||||||
|
// create collector object
|
||||||
|
collector = (IScannerInfoCollector) profile.getScannerInfoCollectorElement().createScannerInfoCollector();
|
||||||
|
if (collector instanceof IScannerInfoCollector2) {
|
||||||
|
((IScannerInfoCollector2) collector).setProject(project);
|
||||||
|
}
|
||||||
|
// all other objects are created on request
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ScannerConfigProfile getProfile() {
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a single scannerInfoCollector object
|
||||||
|
*/
|
||||||
|
public IScannerInfoCollector getScannerInfoCollector() {
|
||||||
|
return collector;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,886 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
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.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 abstract class Store implements IScannerConfigBuilderInfo2 {
|
||||||
|
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 Map profileOptionsMap; // (profileId, options)
|
||||||
|
static class ProfileOptions {
|
||||||
|
protected boolean buildOutputFileActionEnabled;
|
||||||
|
protected String buildOutputFilePath = EMPTY_STRING;
|
||||||
|
protected boolean buildOutputParserEnabled;
|
||||||
|
protected Map providerOptionsMap; // {providerId, options}
|
||||||
|
static class ProviderOptions {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
// 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
|
||||||
|
*/
|
||||||
|
private static class BuildProperty extends Store {
|
||||||
|
private static boolean sIsDirty = false;
|
||||||
|
private IProject project;
|
||||||
|
private String profileId;
|
||||||
|
|
||||||
|
BuildProperty(IProject project, String profileId) {
|
||||||
|
super();
|
||||||
|
this.project = project;
|
||||||
|
this.profileId = profileId;
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load()
|
||||||
|
*/
|
||||||
|
protected void load() {
|
||||||
|
ICDescriptor descriptor;
|
||||||
|
int loaded = 0; // if everything is successfully loaded the value should be at least 2
|
||||||
|
try {
|
||||||
|
descriptor = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
||||||
|
for (Node sc = descriptor.getProjectData(SCANNER_CONFIG).getFirstChild();
|
||||||
|
sc != null; sc = sc.getNextSibling()) {
|
||||||
|
if (sc.getNodeName().equals(SC_AUTODISCOVERY)) {
|
||||||
|
autoDiscoveryEnabled = Boolean.valueOf(
|
||||||
|
((Element)sc).getAttribute(ENABLED)).booleanValue();
|
||||||
|
selectedProfile = (profileId == ScannerConfigProfileManager.NULL_PROFILE_ID)
|
||||||
|
? ((Element)sc).getAttribute(SELECTED_PROFILE_ID)
|
||||||
|
: profileId;
|
||||||
|
problemReportingEnabled = Boolean.valueOf(
|
||||||
|
((Element)sc).getAttribute(PROBLEM_REPORTING_ENABLED)).booleanValue();
|
||||||
|
++loaded;
|
||||||
|
}
|
||||||
|
else if (sc.getNodeName().equals(PROFILE)) {
|
||||||
|
//if (selectedProfile.equals(((Element)sc).getAttribute(ID))) {
|
||||||
|
load(sc);
|
||||||
|
++loaded;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (loaded < 2) {
|
||||||
|
// No ScannerConfigDiscovery entry, try old project location - .project
|
||||||
|
if (!migrateScannerConfigBuildInfo(ScannerConfigProfileManager.PER_PROJECT_PROFILE_ID)) {
|
||||||
|
// disable autodiscovery
|
||||||
|
autoDiscoveryEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param profileId
|
||||||
|
*/
|
||||||
|
private boolean migrateScannerConfigBuildInfo(String profileId) {
|
||||||
|
boolean rc = true;
|
||||||
|
try {
|
||||||
|
IScannerConfigBuilderInfo oldInfo = MakeCorePlugin.
|
||||||
|
createScannerConfigBuildInfo(project, 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;
|
||||||
|
store();
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
catch (CoreException e) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
rc = false;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param profile
|
||||||
|
*/
|
||||||
|
private void load(Node profile) {
|
||||||
|
if (profileOptionsMap == null) {
|
||||||
|
profileOptionsMap = new LinkedHashMap(1);
|
||||||
|
}
|
||||||
|
ProfileOptions po = new ProfileOptions();
|
||||||
|
String profileId = ((Element)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());
|
||||||
|
|
||||||
|
for (Node child = profile.getFirstChild();
|
||||||
|
child != null;
|
||||||
|
child = child.getNextSibling()) {
|
||||||
|
// buildOutputProvider element
|
||||||
|
if (BUILD_OUTPUT_PROVIDER.equals(child.getNodeName())) {
|
||||||
|
for (Node grandchild = child.getFirstChild();
|
||||||
|
grandchild != null;
|
||||||
|
grandchild = grandchild.getNextSibling()) {
|
||||||
|
|
||||||
|
if (OPEN_ACTION.equals(grandchild.getNodeName())) {
|
||||||
|
po.buildOutputFileActionEnabled = Boolean.valueOf(
|
||||||
|
((Element)grandchild).getAttribute(ENABLED)).booleanValue();
|
||||||
|
po.buildOutputFilePath = ((Element)grandchild).getAttribute(FILE_PATH);
|
||||||
|
}
|
||||||
|
else if (PARSER.equals(grandchild.getNodeName())) {
|
||||||
|
po.buildOutputParserEnabled = Boolean.valueOf(
|
||||||
|
((Element)grandchild).getAttribute(ENABLED)).booleanValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (SCANNER_INFO_PROVIDER.equals(child.getNodeName())) {
|
||||||
|
String providerId = ((Element)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();
|
||||||
|
|
||||||
|
for (Node grandchild = child.getFirstChild();
|
||||||
|
grandchild != null;
|
||||||
|
grandchild = grandchild.getNextSibling()) {
|
||||||
|
// action
|
||||||
|
if (RUN_ACTION.equals(grandchild.getNodeName())) {
|
||||||
|
ppo.providerRunUseDefault = Boolean.valueOf(
|
||||||
|
((Element)grandchild).getAttribute(USE_DEFAULT)).booleanValue();
|
||||||
|
ppo.providerRunCommand = ((Element)grandchild).getAttribute(COMMAND);
|
||||||
|
ppo.providerRunArguments = ((Element)grandchild).getAttribute(ARGUMENTS);
|
||||||
|
}
|
||||||
|
else if (OPEN_ACTION.equals(grandchild.getNodeName())) {
|
||||||
|
ppo.providerOpenFilePath = ((Element)grandchild).getAttribute(FILE_PATH);
|
||||||
|
}
|
||||||
|
// parser
|
||||||
|
else if (PARSER.equals(grandchild.getNodeName())) {
|
||||||
|
ppo.providerOutputParserEnabled = Boolean.valueOf(
|
||||||
|
((Element)grandchild).getAttribute(ENABLED)).booleanValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++providerCounter;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// mismatch - error
|
||||||
|
// TODO Vmir define error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#store()
|
||||||
|
*/
|
||||||
|
public void store() throws CoreException {
|
||||||
|
if (isDirty) {
|
||||||
|
synchronized (BuildProperty.class) {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
Element autod = doc.createElement(SC_AUTODISCOVERY);
|
||||||
|
sc.appendChild(autod);
|
||||||
|
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();
|
||||||
|
Element profile = doc.createElement(PROFILE);
|
||||||
|
profile.setAttribute(ID, profileId);
|
||||||
|
store(profile, (ProfileOptions) profileOptionsMap.get(profileId));
|
||||||
|
sc.appendChild(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
isDirty = false;
|
||||||
|
sIsDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param profile element
|
||||||
|
* @param profile options
|
||||||
|
*/
|
||||||
|
private void store(Element profile, ProfileOptions po) {
|
||||||
|
Element child, grandchild;
|
||||||
|
Document doc = profile.getOwnerDocument();
|
||||||
|
// buildOutputProvider element
|
||||||
|
child = doc.createElement(BUILD_OUTPUT_PROVIDER);
|
||||||
|
grandchild = doc.createElement(OPEN_ACTION);
|
||||||
|
grandchild.setAttribute(ENABLED, Boolean.toString(po.buildOutputFileActionEnabled));
|
||||||
|
grandchild.setAttribute(FILE_PATH, po.buildOutputFilePath);
|
||||||
|
child.appendChild(grandchild);
|
||||||
|
grandchild = doc.createElement(PARSER);
|
||||||
|
grandchild.setAttribute(ENABLED, Boolean.toString(po.buildOutputParserEnabled));
|
||||||
|
child.appendChild(grandchild);
|
||||||
|
profile.appendChild(child);
|
||||||
|
// 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 = doc.createElement(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 = doc.createElement(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 = doc.createElement(OPEN_ACTION);
|
||||||
|
grandchild.setAttribute(FILE_PATH, ppo.providerOpenFilePath);
|
||||||
|
}
|
||||||
|
child.appendChild(grandchild);
|
||||||
|
// parser
|
||||||
|
grandchild = doc.createElement(PARSER);
|
||||||
|
grandchild.setAttribute(ENABLED, Boolean.toString(ppo.providerOutputParserEnabled));
|
||||||
|
child.appendChild(grandchild);
|
||||||
|
profile.appendChild(child);
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
synchronized (BuildProperty.class) {
|
||||||
|
if (sIsDirty) {
|
||||||
|
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project, true);
|
||||||
|
descriptor.saveProjectData();
|
||||||
|
sIsDirty = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preferences
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
private static class Preference extends Store {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#load()
|
||||||
|
*/
|
||||||
|
protected void load() {
|
||||||
|
autoDiscoveryEnabled = getBoolean(SCANNER_CONFIG_AUTODISCOVERY_ENABLED);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigInfoFactory2.Store#store()
|
||||||
|
*/
|
||||||
|
public 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) {
|
||||||
|
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 {
|
||||||
|
// Nothing to do here
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IScannerConfigBuilderInfo2 create(IProject project, String profileId) throws CoreException {
|
||||||
|
return new ScannerConfigInfoFactory2.BuildProperty(project, profileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IScannerConfigBuilderInfo2 create(Preferences prefs, String profileId, boolean useDefaults) {
|
||||||
|
return new ScannerConfigInfoFactory2.Preference(prefs, profileId, useDefaults);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,305 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
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) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
MakeCorePlugin.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() {
|
||||||
|
String[] empty = new String[0];
|
||||||
|
IExtensionPoint extension = Platform.getExtensionRegistry().
|
||||||
|
getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
|
||||||
|
if (extension != null) {
|
||||||
|
IExtension[] extensions = extension.getExtensions();
|
||||||
|
List rProfileIds = new ArrayList(extensions.length);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the scannerInfoProviders.
|
||||||
|
*/
|
||||||
|
public ScannerInfoProvider getScannerInfoProviderElement(String providerId) {
|
||||||
|
return (ScannerInfoProvider) scannerInfoProviders.get(providerId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,188 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
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 {
|
||||||
|
public static final String SI_PROFILE_SIMPLE_ID = "ScannerConfigurationDiscoveryProfile"; //$NON-NLS-1$
|
||||||
|
public static final String PER_PROJECT_PROFILE_ID = MakeCorePlugin.getUniqueIdentifier() + ".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$
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getProfileId(IProject project) {
|
||||||
|
String profileId;
|
||||||
|
IScannerConfigBuilderInfo2 buildInfo = null;
|
||||||
|
try {
|
||||||
|
buildInfo = createScannerConfigBuildInfo2(project);
|
||||||
|
profileId = buildInfo.getSelectedProfileId();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
MakeCorePlugin.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.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param profileId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SCProfileInstance getSCProfileInstance(String profileId) {
|
||||||
|
SCProfileInstance profileInstance = null;
|
||||||
|
if (profileId != NULL_PROFILE_ID) {
|
||||||
|
profileInstance = new SCProfileInstance(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List getProfileIds() {
|
||||||
|
if (profileIds == null) {
|
||||||
|
profileIds = new ArrayList();
|
||||||
|
IExtensionPoint extension = Platform.getExtensionRegistry().
|
||||||
|
getExtensionPoint(MakeCorePlugin.PLUGIN_ID, ScannerConfigProfileManager.SI_PROFILE_SIMPLE_ID);
|
||||||
|
if (extension != null) {
|
||||||
|
IExtension[] extensions = extension.getExtensions();
|
||||||
|
List rProfileIds = new ArrayList(extensions.length);
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project, String profileId) throws CoreException {
|
||||||
|
return ScannerConfigInfoFactory2.create(project, profileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use stored selectedProfile
|
||||||
|
* @param project
|
||||||
|
* @return
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public static IScannerConfigBuilderInfo2 createScannerConfigBuildInfo2(IProject project) throws CoreException {
|
||||||
|
return ScannerConfigInfoFactory2.create(project, ScannerConfigProfileManager.NULL_PROFILE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -67,3 +67,5 @@ IncludeSymbolProperties.name=C/C++ Include Paths & Symbols
|
||||||
ProjectPathProperties.name=C/C++ Project Paths
|
ProjectPathProperties.name=C/C++ Project Paths
|
||||||
|
|
||||||
DiscoveredScannerInfoContainer.name=Discovered scanner configuration container
|
DiscoveredScannerInfoContainer.name=Discovered scanner configuration container
|
||||||
|
|
||||||
|
GCCPerProjectProfile.name=GCC per project scanner info profile
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<import plugin="org.eclipse.cdt.make.core"/>
|
<import plugin="org.eclipse.cdt.make.core"/>
|
||||||
<import plugin="org.eclipse.core.runtime"/>
|
<import plugin="org.eclipse.core.runtime"/>
|
||||||
</requires>
|
</requires>
|
||||||
|
<extension-point id="DiscoveryProfilePage" name="%discoveryProfilePage.name" schema="schema/DiscoveryProfilePage.exsd"/>
|
||||||
|
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
|
@ -526,4 +527,11 @@
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.core.runtime.preferences">
|
point="org.eclipse.core.runtime.preferences">
|
||||||
<initializer class="org.eclipse.cdt.make.internal.ui.MakeUIPreferenceInitializer"/>
|
<initializer class="org.eclipse.cdt.make.internal.ui.MakeUIPreferenceInitializer"/>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.cdt.make.ui.DiscoveryProfilePage">
|
||||||
|
<profilePage
|
||||||
|
class="org.eclipse.cdt.make.ui.dialogs.GCCPerProjectSCDProfilePage"
|
||||||
|
name="%GCCPerProjectProfile.name"
|
||||||
|
profileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||||
</extension></plugin>
|
</extension></plugin>
|
||||||
|
|
|
@ -1,19 +1,24 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<!-- Schema file written by PDE -->
|
<!-- Schema file written by PDE -->
|
||||||
<schema targetNamespace="org.eclipse.cdt.make.core">
|
<schema targetNamespace="org.eclipse.cdt.make.ui">
|
||||||
<annotation>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.schema plugin="org.eclipse.cdt.make.core" id="ScannerInfoConsoleParser" name="%extensionScannerInfoConsoleParser.name"/>
|
<meta.schema plugin="org.eclipse.cdt.make.ui" id="DiscoveryProfilePage" name="Scanner configuration discovery profile options page"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
[Enter description of this extension point.]
|
A
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
<element name="extension">
|
<element name="extension">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
An extension to define implementation of a SCD profile options page.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<sequence>
|
<sequence>
|
||||||
<element ref="scannerInfoConsoleParser"/>
|
<element ref="profilePage" minOccurs="1" maxOccurs="unbounded"/>
|
||||||
</sequence>
|
</sequence>
|
||||||
<attribute name="point" type="string" use="required">
|
<attribute name="point" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
|
@ -22,7 +27,7 @@
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="id" type="string" use="required">
|
<attribute name="id" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
||||||
|
@ -34,37 +39,42 @@
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
||||||
</documentation>
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute translatable="true"/>
|
||||||
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="scannerInfoConsoleParser">
|
<element name="profilePage">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Element defines a class that implements SCD profile options page for a profile with specified id.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<attribute name="commandId" use="default" value="all">
|
<attribute name="name" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
Id of the command the console parser is associated with. Can be 'all', 'makeBuilder' or 'externalScannerInfoProvider'.
|
Page name.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="profileId" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Associated profile id.
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
<simpleType>
|
|
||||||
<restriction base="string">
|
|
||||||
<enumeration value="all">
|
|
||||||
</enumeration>
|
|
||||||
<enumeration value="makeBuilder">
|
|
||||||
</enumeration>
|
|
||||||
<enumeration value="externalScannerInfoProvider">
|
|
||||||
</enumeration>
|
|
||||||
</restriction>
|
|
||||||
</simpleType>
|
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="class" type="string" use="required">
|
<attribute name="class" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
Java class that implements IScannerInfoConsoleParser interface.
|
A class that extends <samp>AbstractDiscoveryPage</samp> abstract class.
|
||||||
</documentation>
|
</documentation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.make.core.IScannerInfoConsoleParser"/>
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryPage"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
|
@ -70,34 +70,6 @@ ErrorParserBlock.label.missingBuilderInformation=Builder is missing or disabled
|
||||||
BuildTarget.target.group_label=Make Target
|
BuildTarget.target.group_label=Make Target
|
||||||
BuildTarget.target.label=Make Target:
|
BuildTarget.target.label=Make Target:
|
||||||
|
|
||||||
|
|
||||||
# String constants for the build include path and preprocessor symbols
|
|
||||||
BuildPathInfoBlock.label=Paths and Symbols
|
|
||||||
BuildPathInfoBlock.paths=Include paths:
|
|
||||||
BuildPathInfoBlock.symbols=Defined symbols:
|
|
||||||
BuildPathInfoBlock.browse.path=New Include Path
|
|
||||||
BuildPathInfoBlock.browse.path.edit=Edit Include Path
|
|
||||||
BuildPathInfoBlock.browse.path.label=Path:
|
|
||||||
BuildPathInfoBlock.browse.symbol=New Defined Symbol
|
|
||||||
BuildPathInfoBlock.browse.symbol.edit=Edit Defined Symbol
|
|
||||||
BuildPathInfoBlock.browse.symbol.label=Symbol:
|
|
||||||
BuildPathInfoBlock.scGroup.label=Automated discovery of paths and symbols
|
|
||||||
BuildPathInfoBlock.scGroup.enabled.label=Automate discovery of paths and symbols
|
|
||||||
BuildPathInfoBlock.scGroup.options.label=Options...
|
|
||||||
|
|
||||||
BuildPropertyCommon.label.title=Enter Value
|
|
||||||
BuildPropertyCommon.label.new=New...
|
|
||||||
BuildPropertyCommon.label.edit=Edit...
|
|
||||||
BuildPropertyCommon.label.remove=Remove
|
|
||||||
BuildPropertyCommon.label.up=Move Up
|
|
||||||
BuildPropertyCommon.label.down=Move Down
|
|
||||||
BuildPropertyCommon.label.editVar=Edit
|
|
||||||
BuildPropertyCommon.label.addVar=Add
|
|
||||||
BuildPropertyCommon.label.message=Value:
|
|
||||||
BuildPropertyCommon.label.browse=Browse...
|
|
||||||
BuildPropertyCommon.label.configs=Defined configurations:
|
|
||||||
BuildPropertyCommon.label.manage=Manage...
|
|
||||||
|
|
||||||
MakeTargetsPreferencePage.buildTargetInBackground.label=Build make targets in background.
|
MakeTargetsPreferencePage.buildTargetInBackground.label=Build make targets in background.
|
||||||
|
|
||||||
MakeDocumentProvider.exception.createElementInfo=Error creating element.
|
MakeDocumentProvider.exception.createElementInfo=Error creating element.
|
||||||
|
@ -245,10 +217,13 @@ ManageDefinedSymbolsDialog.discoveredGroup.title=Discovered symbol definitions
|
||||||
# --- ScannerConfigOptionsDialog ---
|
# --- ScannerConfigOptionsDialog ---
|
||||||
ScannerConfigOptionsDialog.title=Discovery Options
|
ScannerConfigOptionsDialog.title=Discovery Options
|
||||||
ScannerConfigOptionsDialog.description=Set the scanner configuration discovery options for this project
|
ScannerConfigOptionsDialog.description=Set the scanner configuration discovery options for this project
|
||||||
|
ScannerConfigOptionsDialog.label.missingBuilderInformation=Builder is missing or disabled on project.
|
||||||
|
ScannerConfigOptionsDialog.scGroup.label=Automated discovery of paths and symbols
|
||||||
|
ScannerConfigOptionsDialog.scGroup.enabled.label=Automate discovery of paths and symbols
|
||||||
|
ScannerConfigOptionsDialog.scGroup.selectedProfile.label=Discovery profile:
|
||||||
ScannerConfigOptionsDialog.siBuilder.parser.group_label=Build output parser options
|
ScannerConfigOptionsDialog.siBuilder.parser.group_label=Build output parser options
|
||||||
ScannerConfigOptionsDialog.siBuilder.parser.enable.label=Enable build output parser
|
ScannerConfigOptionsDialog.siBuilder.parser.enable.label=Enable build output parser
|
||||||
ScannerConfigOptionsDialog.siBuilder.parser.label=Make build output parser:
|
ScannerConfigOptionsDialog.siBuilder.parser.label=Make build output parser:
|
||||||
ScannerConfigOptionsDialog.label.missingBuilderInformation=Builder is missing or disabled on project.
|
|
||||||
ScannerConfigOptionsDialog.siProvider.cmd.group_label=Generate scanner info command options
|
ScannerConfigOptionsDialog.siProvider.cmd.group_label=Generate scanner info command options
|
||||||
ScannerConfigOptionsDialog.siProvider.cmd.enable.label=Enable generate scanner info command
|
ScannerConfigOptionsDialog.siProvider.cmd.enable.label=Enable generate scanner info command
|
||||||
ScannerConfigOptionsDialog.siProvider.cmd.use_default=Use default
|
ScannerConfigOptionsDialog.siProvider.cmd.use_default=Use default
|
||||||
|
@ -258,6 +233,25 @@ ScannerConfigOptionsDialog.siProvider.cmd.error_message=Must enter a 'generate s
|
||||||
ScannerConfigOptionsDialog.siProblem.group.label=Discovery problem reporting
|
ScannerConfigOptionsDialog.siProblem.group.label=Discovery problem reporting
|
||||||
ScannerConfigOptionsDialog.siProblem.generation.enable.label=Report path detection problems
|
ScannerConfigOptionsDialog.siProblem.generation.enable.label=Report path detection problems
|
||||||
|
|
||||||
|
ScannerConfigOptionsDialog.title=Discovery Options
|
||||||
|
ScannerConfigOptionsDialog.description=Set the scanner configuration discovery options for this project
|
||||||
|
ScannerConfigOptionsDialog.scGroup.label=Automated discovery of paths and symbols
|
||||||
|
ScannerConfigOptionsDialog.scGroup.enabled.button=Automate discovery of paths and symbols
|
||||||
|
ScannerConfigOptionsDialog.scGroup.problemReporting.enabled.button=Report path detection problems
|
||||||
|
ScannerConfigOptionsDialog.scGroup.selectedProfile.combo=Discovery profile:
|
||||||
|
ScannerConfigOptionsDialog.boProvider.group.label=Discovery profile options
|
||||||
|
ScannerConfigOptionsDialog.boProvider.parser.enabled.button=Enable build output scanner info discovery
|
||||||
|
ScannerConfigOptionsDialog.boProvider.open.label=Load build output from file
|
||||||
|
ScannerConfigOptionsDialog.boProvider.browse.button=Browse...
|
||||||
|
ScannerConfigOptionsDialog.boProvider.browse.openFileDialog=Build output file:
|
||||||
|
ScannerConfigOptionsDialog.boProvider.load.button=Load
|
||||||
|
ScannerConfigOptionsDialog.siProvider.parser.enabled.button=Enable generate scanner info command
|
||||||
|
ScannerConfigOptionsDialog.siProvider.command.label=Compiler invocation command
|
||||||
|
ScannerConfigOptionsDialog.siProvider.browse.button=Browse...
|
||||||
|
ScannerConfigOptionsDialog.siProvider.browse.runCommandDialog='gcc' command:
|
||||||
|
ScannerConfigOptionsDialog.siProvider.command.errorMessage=Must enter compiler invocation command
|
||||||
|
ScannerConfigOptionsDialog.apply.progressMessage=Setting scanner configuration discovery options...
|
||||||
|
|
||||||
# --- DiscoveredScannerConfigurationContainerPage ---
|
# --- DiscoveredScannerConfigurationContainerPage ---
|
||||||
DiscoveredScannerConfigurationContainerPage.title=Edit container
|
DiscoveredScannerConfigurationContainerPage.title=Edit container
|
||||||
DiscoveredScannerConfigurationContainerPage.description=Manage discovered scanner configuration
|
DiscoveredScannerConfigurationContainerPage.description=Manage discovered scanner configuration
|
||||||
|
|
|
@ -0,0 +1,199 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
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 AbstractDiscoveryPage {
|
||||||
|
private Map fProfilePageMap = null;
|
||||||
|
|
||||||
|
// Composite parent provided by the block.
|
||||||
|
private Composite fCompositeParent;
|
||||||
|
private ICOptionPage fCurrentPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a profile page only on request
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
protected static class DiscoveryProfilePageConfiguration {
|
||||||
|
|
||||||
|
ICOptionPage page;
|
||||||
|
IConfigurationElement fElement;
|
||||||
|
|
||||||
|
public DiscoveryProfilePageConfiguration(IConfigurationElement element) {
|
||||||
|
fElement = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICOptionPage getPage() throws CoreException {
|
||||||
|
if (page == null) {
|
||||||
|
page = (ICOptionPage) 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("profilePage")) { //$NON-NLS-1$
|
||||||
|
String id = infos[i].getAttribute("profileId"); //$NON-NLS-1$
|
||||||
|
fProfilePageMap.put(id, new DiscoveryProfilePageConfiguration(infos[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 Binary Parser.
|
||||||
|
*/
|
||||||
|
protected void handleDiscoveryProfileChanged() {
|
||||||
|
if (getCompositeParent() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String profileId = getCurrentProfileId();
|
||||||
|
ICOptionPage page = getDiscoveryProfilePage(profileId);
|
||||||
|
if (page != null) {
|
||||||
|
if (page.getControl() == null) {
|
||||||
|
Composite parent = getCompositeParent();
|
||||||
|
page.setContainer(getContainer());
|
||||||
|
page.createControl(parent);
|
||||||
|
parent.layout(true);
|
||||||
|
} else {
|
||||||
|
page.setVisible(false);
|
||||||
|
}
|
||||||
|
page.setVisible(true);
|
||||||
|
}
|
||||||
|
setCurrentPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICOptionPage getCurrentPage() {
|
||||||
|
return fCurrentPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setCurrentPage(ICOptionPage page) {
|
||||||
|
fCurrentPage = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#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 ICOptionPage 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();
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.make.core.MakeCorePlugin;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
|
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.Preferences;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO Provide description
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public abstract class AbstractDiscoveryPage extends AbstractCOptionPage {
|
||||||
|
|
||||||
|
private Preferences fPrefs;
|
||||||
|
private IScannerConfigBuilderInfo2 fBuildInfo;
|
||||||
|
private boolean fInitialized = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public AbstractDiscoveryPage() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param title
|
||||||
|
*/
|
||||||
|
public AbstractDiscoveryPage(String title) {
|
||||||
|
super(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param title
|
||||||
|
* @param image
|
||||||
|
*/
|
||||||
|
public AbstractDiscoveryPage(String title, ImageDescriptor image) {
|
||||||
|
super(title, image);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the fPrefs.
|
||||||
|
*/
|
||||||
|
protected Preferences getPrefs() {
|
||||||
|
return fPrefs;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the fBuildInfo.
|
||||||
|
*/
|
||||||
|
protected IScannerConfigBuilderInfo2 getBuildInfo() {
|
||||||
|
return fBuildInfo;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return Returns the fInitialized.
|
||||||
|
*/
|
||||||
|
protected boolean isInitialized() {
|
||||||
|
return fInitialized;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param initialized The fInitialized to set.
|
||||||
|
*/
|
||||||
|
protected void setInitialized(boolean initialized) {
|
||||||
|
fInitialized = initialized;
|
||||||
|
}
|
||||||
|
/* (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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create build info based on project properties
|
||||||
|
* @param project
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IScannerConfigBuilderInfo2 createBuildInfo(IProject project) {
|
||||||
|
IScannerConfigBuilderInfo2 bi = null;
|
||||||
|
if (project != null) {
|
||||||
|
try {
|
||||||
|
bi = ScannerConfigProfileManager.createScannerConfigBuildInfo2(project);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// disabled builder... just log it
|
||||||
|
MakeCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bi = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
|
||||||
|
}
|
||||||
|
return bi;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create build info based on preferences
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected IScannerConfigBuilderInfo2 createBuildInfo() {
|
||||||
|
IScannerConfigBuilderInfo2 bi = null;
|
||||||
|
// Populate with the default values
|
||||||
|
if (getContainer().getProject() != null) {
|
||||||
|
// get the preferences
|
||||||
|
bi = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, false);
|
||||||
|
} else {
|
||||||
|
// get the defaults
|
||||||
|
bi = ScannerConfigProfileManager.createScannerConfigBuildInfo2(fPrefs, true);
|
||||||
|
}
|
||||||
|
return bi;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,489 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Rational Software - Initial API and implementation
|
|
||||||
* QNX Software Systems - Move to Make plugin
|
|
||||||
***********************************************************************/
|
|
||||||
package org.eclipse.cdt.make.ui.dialogs;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
|
||||||
import org.eclipse.cdt.make.core.MakeProjectNature;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
|
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
|
||||||
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
|
|
||||||
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
|
||||||
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.core.runtime.Preferences;
|
|
||||||
import org.eclipse.jface.dialogs.IInputValidator;
|
|
||||||
import org.eclipse.jface.dialogs.InputDialog;
|
|
||||||
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.FontData;
|
|
||||||
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.Control;
|
|
||||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
|
||||||
import org.eclipse.swt.widgets.Group;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.List;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.help.WorkbenchHelp;
|
|
||||||
|
|
||||||
public class BuildPathInfoBlock extends AbstractCOptionPage {
|
|
||||||
private static final int PROJECT_LIST_MULTIPLIER = 15;
|
|
||||||
private static final int INITIAL_LIST_WIDTH = 60;
|
|
||||||
|
|
||||||
private static final String PREF_SYMBOLS = "ScannerSymbols"; //$NON-NLS-1$
|
|
||||||
private static final String PREF_INCLUDES = "ScannerIncludes"; //$NON-NLS-1$
|
|
||||||
private static final String PREFIX = "BuildPathInfoBlock"; //$NON-NLS-1$
|
|
||||||
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
|
||||||
private static final String PATHS = PREFIX + ".paths"; //$NON-NLS-1$
|
|
||||||
private static final String SYMBOLS = PREFIX + ".symbols"; //$NON-NLS-1$
|
|
||||||
private static final String MANAGE = "BuildPropertyCommon.label.manage"; //$NON-NLS-1$
|
|
||||||
private static final String SC_GROUP_LABEL = PREFIX + ".scGroup.label"; //$NON-NLS-1$
|
|
||||||
private static final String SC_ENABLED_LABEL = PREFIX + ".scGroup.enabled.label"; //$NON-NLS-1$
|
|
||||||
private static final String SC_OPTIONS_LABEL = PREFIX + ".scGroup.options.label"; //$NON-NLS-1$
|
|
||||||
private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private Button scEnabledButton;
|
|
||||||
private Button scOptionsButton;
|
|
||||||
private List pathList;
|
|
||||||
private List symbolList;
|
|
||||||
private Composite pathButtonComp;
|
|
||||||
private Button managePathsButton;
|
|
||||||
private Composite symbolButtonComp;
|
|
||||||
private Button manageSymbolsButton;
|
|
||||||
|
|
||||||
private ScannerConfigOptionsDialog scOptionsDialog;
|
|
||||||
private ManageIncludePathsDialog manageIncludesDialog;
|
|
||||||
private ManageDefinedSymbolsDialog manageSymbolsDialog;
|
|
||||||
|
|
||||||
private boolean needsSCNature = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class add a "browse" button to the selection to be used for the path
|
|
||||||
*/
|
|
||||||
static class SelectPathInputDialog extends InputDialog {
|
|
||||||
public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue, IInputValidator validator) {
|
|
||||||
super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createButtonsForButtonBar(Composite parent) {
|
|
||||||
super.createButtonsForButtonBar(parent);
|
|
||||||
Button browse = createButton(parent, 3, MakeUIPlugin.getResourceString("BuildPathInfoBlock.button.browse"), true); //$NON-NLS-1$
|
|
||||||
browse.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent ev) {
|
|
||||||
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
|
|
||||||
String currentName = getText().getText();
|
|
||||||
if(currentName != null && currentName.trim().length() != 0) {
|
|
||||||
dialog.setFilterPath(currentName);
|
|
||||||
}
|
|
||||||
String dirname = dialog.open();
|
|
||||||
if(dirname != null) {
|
|
||||||
getText().setText(dirname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public BuildPathInfoBlock() {
|
|
||||||
super(MakeUIPlugin.getResourceString(LABEL));
|
|
||||||
setDescription(MakeUIPlugin.getResourceString("BuildPathInfoBlock.description")); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPathListButtons(Composite parent) {
|
|
||||||
// Create a ManageIncludePathsDialog
|
|
||||||
if (manageIncludesDialog == null) {
|
|
||||||
manageIncludesDialog = new ManageIncludePathsDialog(getShell(), getContainer());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a composite for the buttons
|
|
||||||
pathButtonComp = ControlFactory.createComposite(parent, 1);
|
|
||||||
((GridData) pathButtonComp.getLayoutData()).verticalAlignment = GridData.BEGINNING;
|
|
||||||
((GridData) pathButtonComp.getLayoutData()).grabExcessHorizontalSpace = false;
|
|
||||||
pathButtonComp.setFont(parent.getFont());
|
|
||||||
|
|
||||||
// Add the buttons
|
|
||||||
managePathsButton = ControlFactory.createPushButton(pathButtonComp, MakeUIPlugin.getResourceString(MANAGE));
|
|
||||||
managePathsButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleManagePaths();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
managePathsButton.setFont(parent.getFont());
|
|
||||||
managePathsButton.setLayoutData(new GridData());
|
|
||||||
SWTUtil.setButtonDimensionHint(managePathsButton);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handleManagePaths() {
|
|
||||||
if (manageIncludesDialog.open() == Window.OK) {
|
|
||||||
pathList.setItems(manageIncludesDialog.getManagedIncludes());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPathListControl(Composite parent, int numColumns) {
|
|
||||||
// Create the list
|
|
||||||
pathList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
|
||||||
|
|
||||||
// Make it occupy the first 2 columns
|
|
||||||
GridData gd = new GridData(GridData.FILL_BOTH);
|
|
||||||
gd.grabExcessHorizontalSpace = true;
|
|
||||||
gd.horizontalSpan = numColumns - 1;
|
|
||||||
gd.heightHint = getDefaultFontHeight(pathList, PROJECT_LIST_MULTIPLIER);
|
|
||||||
gd.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
|
|
||||||
pathList.setLayoutData(gd);
|
|
||||||
pathList.setFont(parent.getFont());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the defualt widget height for the supplied control.
|
|
||||||
* @return int
|
|
||||||
* @param control - the control being queried about fonts
|
|
||||||
* @param lines - the number of lines to be shown on the table.
|
|
||||||
*/
|
|
||||||
private static int getDefaultFontHeight(Control control, int lines) {
|
|
||||||
FontData[] viewerFontData = control.getFont().getFontData();
|
|
||||||
int fontHeight = 10;
|
|
||||||
|
|
||||||
//If we have no font data use our guess
|
|
||||||
if (viewerFontData.length > 0)
|
|
||||||
fontHeight = viewerFontData[0].getHeight();
|
|
||||||
return lines * fontHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createSymbolListButtons(Composite parent) {
|
|
||||||
// Create a ManageDefinedSymbolsDialog
|
|
||||||
if (manageSymbolsDialog == null) {
|
|
||||||
manageSymbolsDialog = new ManageDefinedSymbolsDialog(getShell(), getContainer());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a composite for the buttons
|
|
||||||
symbolButtonComp = ControlFactory.createComposite(parent, 1);
|
|
||||||
((GridData) symbolButtonComp.getLayoutData()).verticalAlignment = GridData.BEGINNING;
|
|
||||||
((GridData) symbolButtonComp.getLayoutData()).grabExcessHorizontalSpace = false;
|
|
||||||
symbolButtonComp.setFont(parent.getFont());
|
|
||||||
|
|
||||||
// Add the Manage button
|
|
||||||
manageSymbolsButton = ControlFactory.createPushButton(symbolButtonComp, MakeUIPlugin.getResourceString(MANAGE));
|
|
||||||
manageSymbolsButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleManageSymbols();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
manageSymbolsButton.setFont(parent.getFont());
|
|
||||||
manageSymbolsButton.setLayoutData(new GridData());
|
|
||||||
SWTUtil.setButtonDimensionHint(manageSymbolsButton);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void handleManageSymbols() {
|
|
||||||
if (manageSymbolsDialog.open() == Window.OK) {
|
|
||||||
symbolList.setItems(manageSymbolsDialog.getManagedSymbols());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createSymbolListControl(Composite parent, int numColumns) {
|
|
||||||
// Create the list
|
|
||||||
symbolList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
|
||||||
|
|
||||||
// Make it occupy the first n-1 columns
|
|
||||||
GridData gd = new GridData(GridData.FILL_BOTH);
|
|
||||||
gd.horizontalSpan = numColumns - 1;
|
|
||||||
gd.grabExcessHorizontalSpace = true;
|
|
||||||
gd.heightHint = getDefaultFontHeight(pathList, PROJECT_LIST_MULTIPLIER);
|
|
||||||
gd.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
|
|
||||||
symbolList.setLayoutData(gd);
|
|
||||||
symbolList.setFont(parent.getFont());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#doRun(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IProgressMonitor)
|
|
||||||
*/
|
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
|
||||||
if (monitor == null) {
|
|
||||||
monitor = new NullProgressMonitor();
|
|
||||||
}
|
|
||||||
// First store scanner config options
|
|
||||||
if (scOptionsDialog.isInitialized()) {
|
|
||||||
try {
|
|
||||||
scOptionsDialog.performApply(monitor);
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
// builder was disabled while scOptionsDialog was initialized
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IProject project = getContainer().getProject();
|
|
||||||
if (project != null) {
|
|
||||||
// Store the paths and symbols
|
|
||||||
monitor.beginTask(MakeUIPlugin.getResourceString("BuildPathInfoBlock.monitor.settingScannerInfo"), 3); //$NON-NLS-1$
|
|
||||||
IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
|
||||||
boolean changed = manageIncludesDialog.saveTo(info);
|
|
||||||
monitor.worked(1);
|
|
||||||
changed |= manageSymbolsDialog.saveTo(info);
|
|
||||||
monitor.worked(1);
|
|
||||||
if (changed) {
|
|
||||||
MakeCorePlugin.getDefault().getDiscoveryManager().updateDiscoveredInfo(info);
|
|
||||||
}
|
|
||||||
monitor.done();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setIncludes(MakeCorePlugin.getDefault().getPluginPreferences());
|
|
||||||
setSymbols(MakeCorePlugin.getDefault().getPluginPreferences());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void performDefaults() {
|
|
||||||
// First restore scanner config options
|
|
||||||
scOptionsDialog.performDefaults();
|
|
||||||
scEnabledButton.setSelection(scOptionsDialog.isScannerConfigDiscoveryEnabled());
|
|
||||||
handleScannerConfigEnable();
|
|
||||||
|
|
||||||
pathList.removeAll();
|
|
||||||
symbolList.removeAll();
|
|
||||||
// if (getContainer().getProject() != null) {
|
|
||||||
// pathList.setItems(getIncludes(MakeCorePlugin.getDefault().getPluginPreferences()));
|
|
||||||
// symbolList.setItems(getSymbols(MakeCorePlugin.getDefault().getPluginPreferences()));
|
|
||||||
// }
|
|
||||||
manageIncludesDialog.restore();
|
|
||||||
manageSymbolsDialog.restore();
|
|
||||||
getContainer().updateContainer();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setSymbols(Preferences prefs) {
|
|
||||||
prefs.setValue(PREF_SYMBOLS, stringArrayToString(getSymbolListContents()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setIncludes(Preferences prefs) {
|
|
||||||
prefs.setValue(PREF_INCLUDES, stringArrayToString(getPathListContents()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String stringArrayToString(String[] strings) {
|
|
||||||
StringBuffer buf = new StringBuffer();
|
|
||||||
for (int i = 0; i < strings.length; i++) {
|
|
||||||
buf.append(strings[i]).append(';');
|
|
||||||
}
|
|
||||||
return buf.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
static String[] getSymbols(Preferences prefs) {
|
|
||||||
String syms = prefs.getString(PREF_SYMBOLS);
|
|
||||||
return parseStringToList(syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
static String[] getIncludes(Preferences prefs) {
|
|
||||||
String syms = prefs.getString(PREF_INCLUDES);
|
|
||||||
return parseStringToList(syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String[] parseStringToList(String syms) {
|
|
||||||
if (syms != null && syms.length() > 0) {
|
|
||||||
StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
|
|
||||||
ArrayList list = new ArrayList(tok.countTokens());
|
|
||||||
while (tok.hasMoreElements()) {
|
|
||||||
list.add(tok.nextToken());
|
|
||||||
}
|
|
||||||
return (String[]) list.toArray(new String[list.size()]);
|
|
||||||
}
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#getControl(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
public void createControl(Composite parent) {
|
|
||||||
// Create the composite control for the tab
|
|
||||||
int tabColumns = 3;
|
|
||||||
Font font = parent.getFont();
|
|
||||||
Composite composite = ControlFactory.createComposite(parent, tabColumns);
|
|
||||||
((GridLayout) composite.getLayout()).makeColumnsEqualWidth = false;
|
|
||||||
composite.setFont(font);
|
|
||||||
GridData gd;
|
|
||||||
setControl(composite);
|
|
||||||
|
|
||||||
WorkbenchHelp.setHelp(getControl(), IMakeHelpContextIds.MAKE_PATH_SYMBOL_SETTINGS);
|
|
||||||
|
|
||||||
// Create a group for scanner config discovery
|
|
||||||
createScannerConfigControls(composite, tabColumns);
|
|
||||||
|
|
||||||
// Create a label for the include paths control
|
|
||||||
Label paths = ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString(PATHS));
|
|
||||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
||||||
gd.horizontalSpan = tabColumns;
|
|
||||||
gd.grabExcessHorizontalSpace = false;
|
|
||||||
paths.setLayoutData(gd);
|
|
||||||
paths.setFont(font);
|
|
||||||
|
|
||||||
//Create the list and button controls
|
|
||||||
createPathListControl(composite, tabColumns);
|
|
||||||
createPathListButtons(composite);
|
|
||||||
|
|
||||||
// Create a label for the symbols control
|
|
||||||
Label symbols = ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString(SYMBOLS));
|
|
||||||
gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
||||||
gd.horizontalSpan = tabColumns;
|
|
||||||
gd.grabExcessHorizontalSpace = false;
|
|
||||||
symbols.setLayoutData(gd);
|
|
||||||
symbols.setFont(font);
|
|
||||||
|
|
||||||
// Create list and button controls for symbols
|
|
||||||
createSymbolListControl(composite, tabColumns);
|
|
||||||
createSymbolListButtons(composite);
|
|
||||||
|
|
||||||
setListContents();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void 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; // an old project
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
showMissingBuilder = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a ScannerConfigOptionsDialog
|
|
||||||
if (scOptionsDialog == null) {
|
|
||||||
if (needsSCNature) {
|
|
||||||
// create a temporary dialog
|
|
||||||
scOptionsDialog = new ScannerConfigOptionsDialog(getContainer());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scOptionsDialog = new ScannerConfigOptionsDialog(getShell(), getContainer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Group scGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SC_GROUP_LABEL), numColumns);
|
|
||||||
scGroup.setFont(parent.getFont());
|
|
||||||
((GridData) scGroup.getLayoutData()).grabExcessHorizontalSpace = false;
|
|
||||||
((GridData) scGroup.getLayoutData()).horizontalSpan = numColumns;
|
|
||||||
((GridData) scGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
|
|
||||||
((GridLayout) scGroup.getLayout()).marginWidth = 7;
|
|
||||||
|
|
||||||
if ((!needsSCNature && !scOptionsDialog.isInitialized())) {
|
|
||||||
ControlFactory.createLabel(scGroup, MakeUIPlugin.getResourceString(MISSING_BUILDER_MSG));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add checkbox
|
|
||||||
scEnabledButton = ControlFactory.createCheckBox(scGroup, MakeUIPlugin.getResourceString(SC_ENABLED_LABEL));
|
|
||||||
scEnabledButton.setFont(parent.getFont());
|
|
||||||
((GridData) scEnabledButton.getLayoutData()).horizontalSpan = 2;
|
|
||||||
((GridData) scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
|
|
||||||
// VMIR* old projects will have discovery disabled by default
|
|
||||||
scEnabledButton.setSelection(needsSCNature ? false : scOptionsDialog.isScannerConfigDiscoveryEnabled());
|
|
||||||
scEnabledButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleScannerConfigEnable();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Add Options... button
|
|
||||||
scOptionsButton = ControlFactory.createPushButton(scGroup, MakeUIPlugin.getResourceString(SC_OPTIONS_LABEL));
|
|
||||||
scOptionsButton.setFont(parent.getFont());
|
|
||||||
((GridData) scOptionsButton.getLayoutData()).grabExcessHorizontalSpace = false;
|
|
||||||
SWTUtil.setButtonDimensionHint(scOptionsButton);
|
|
||||||
scOptionsButton.setEnabled(scEnabledButton.getSelection());
|
|
||||||
scOptionsButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
scOptionsDialog.open();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// handleScannerConfigEnable(); Only if true in VMIR*
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles scanner configuration discovery selection change
|
|
||||||
*/
|
|
||||||
protected void handleScannerConfigEnable() {
|
|
||||||
boolean enable = scEnabledButton.getSelection();
|
|
||||||
scOptionsButton.setEnabled(enable);
|
|
||||||
if (enable && needsSCNature) {
|
|
||||||
// first install the SC nature
|
|
||||||
try {
|
|
||||||
ScannerConfigNature.addScannerConfigNature(getContainer().getProject());
|
|
||||||
// create the real dialog
|
|
||||||
scOptionsDialog = new ScannerConfigOptionsDialog(getShell(), getContainer());
|
|
||||||
needsSCNature = false;
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
MakeCorePlugin.log(e.getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scOptionsDialog.setScannerConfigDiscoveryEnabled(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getPathListContents() {
|
|
||||||
return pathList.getItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getSymbolListContents() {
|
|
||||||
return symbolList.getItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.ui.wizards.IWizardTab#isValid()
|
|
||||||
*/
|
|
||||||
public boolean isValid() {
|
|
||||||
// Info on this page is not critical
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setListContents() {
|
|
||||||
IProject project = getContainer().getProject();
|
|
||||||
if (project != null) {
|
|
||||||
// IScannerInfo info = CCorePlugin.getDefault().getScannerInfoProvider(project).getScannerInformation(project);
|
|
||||||
// if (info != null) {
|
|
||||||
// pathList.setItems(info.getIncludePaths());
|
|
||||||
// symbolList.setItems(info.getPreprocessorSymbols());
|
|
||||||
// }
|
|
||||||
try {
|
|
||||||
IDiscoveredPathInfo info = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(project);
|
|
||||||
pathList.setItems(ScannerConfigUtil.iPathArray2StringArray(info.getIncludePaths()));
|
|
||||||
LinkedHashMap discoveredSymbols = info.getSymbolMap();
|
|
||||||
ArrayList activeSymbols = new ArrayList();
|
|
||||||
activeSymbols.addAll(ScannerConfigUtil.scSymbolsSymbolEntryMap2List(discoveredSymbols, true));
|
|
||||||
symbolList.setItems((String[]) activeSymbols.toArray(new String[activeSymbols.size()]));
|
|
||||||
} catch (CoreException e) {
|
|
||||||
MakeCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// else {
|
|
||||||
// pathList.setItems(getIncludes(MakeCorePlugin.getDefault().getPluginPreferences()));
|
|
||||||
// symbolList.setItems(getSymbols(MakeCorePlugin.getDefault().getPluginPreferences()));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,16 +30,19 @@ 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.LayoutUtil;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
|
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.scannerconfig.util.SymbolEntry;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector;
|
||||||
|
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.MakeUIPlugin;
|
||||||
import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElement;
|
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.DiscoveredElementLabelProvider;
|
||||||
import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElementSorter;
|
import org.eclipse.cdt.make.internal.ui.scannerconfig.DiscoveredElementSorter;
|
||||||
import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
|
import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
|
@ -128,7 +131,8 @@ public class DiscoveredPathContainerPage extends WizardPage implements IPathEntr
|
||||||
fDiscoveredContainerList.setDialogFieldListener(adapter);
|
fDiscoveredContainerList.setDialogFieldListener(adapter);
|
||||||
fDiscoveredContainerList.setLabelText(MakeUIPlugin.getResourceString(CONTAINER_LIST_LABEL)); //$NON-NLS-1$
|
fDiscoveredContainerList.setLabelText(MakeUIPlugin.getResourceString(CONTAINER_LIST_LABEL)); //$NON-NLS-1$
|
||||||
|
|
||||||
fDiscoveredContainerList.setViewerSorter(new DiscoveredElementSorter());
|
fDiscoveredContainerList.setTreeExpansionLevel(2);
|
||||||
|
fDiscoveredContainerList.setViewerSorter(new DiscoveredElementSorter());
|
||||||
dirty = false;
|
dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,18 +567,23 @@ public class DiscoveredPathContainerPage extends WizardPage implements IPathEntr
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
Object[] children = parent.getChildren();
|
Object[] children = parent.getChildren();
|
||||||
if (elem.delete()) {
|
if (elem.delete()) {
|
||||||
|
// ScannerInfoCollector collector = ScannerInfoCollector.getInstance();
|
||||||
|
IProject project = fCProject.getProject();
|
||||||
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
|
getSCProfileInstance(project, ScannerConfigProfileManager.NULL_PROFILE_ID); // use selected profile for the project
|
||||||
|
PerProjectSICollector collector = (PerProjectSICollector) profileInstance.getScannerInfoCollector();
|
||||||
switch (elem.getEntryKind()) {
|
switch (elem.getEntryKind()) {
|
||||||
case DiscoveredElement.PATHS_GROUP:
|
case DiscoveredElement.PATHS_GROUP:
|
||||||
ScannerInfoCollector.getInstance().deleteAllPaths(fCProject.getProject());
|
collector.deleteAllPaths(project);
|
||||||
break;
|
break;
|
||||||
case DiscoveredElement.SYMBOLS_GROUP:
|
case DiscoveredElement.SYMBOLS_GROUP:
|
||||||
ScannerInfoCollector.getInstance().deleteAllSymbols(fCProject.getProject());
|
collector.deleteAllSymbols(project);
|
||||||
break;
|
break;
|
||||||
case DiscoveredElement.INCLUDE_PATH:
|
case DiscoveredElement.INCLUDE_PATH:
|
||||||
ScannerInfoCollector.getInstance().deletePath(fCProject.getProject(), elem.getEntry());
|
collector.deletePath(project, elem.getEntry());
|
||||||
break;
|
break;
|
||||||
case DiscoveredElement.SYMBOL_DEFINITION:
|
case DiscoveredElement.SYMBOL_DEFINITION:
|
||||||
ScannerInfoCollector.getInstance().deleteSymbol(fCProject.getProject(), elem.getEntry());
|
collector.deleteSymbol(project, elem.getEntry());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rc = true;
|
rc = true;
|
||||||
|
|
|
@ -1,50 +1,40 @@
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
* Copyright (c) 2004 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
**********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.make.ui.dialogs;
|
package org.eclipse.cdt.make.ui.dialogs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
|
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.MakeProjectNature;
|
import org.eclipse.cdt.make.core.MakeProjectNature;
|
||||||
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.core.scannerconfig.ScannerConfigNature;
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathContainer;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
|
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.ui.dialogs.ICOptionContainer;
|
||||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.Preferences;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -54,567 +44,311 @@ import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Combo;
|
import org.eclipse.swt.widgets.Combo;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Group;
|
import org.eclipse.swt.widgets.Group;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
|
||||||
import org.eclipse.ui.help.WorkbenchHelp;
|
import org.eclipse.ui.help.WorkbenchHelp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dialog to set scanner config discovery options
|
* A dialog to set scanner config discovery options.
|
||||||
*
|
*
|
||||||
* @author vhirsl
|
* @author vhirsl
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class DiscoveryOptionsBlock extends AbstractCOptionPage {
|
public class DiscoveryOptionsBlock extends AbstractDiscoveryOptionsBlock {
|
||||||
|
private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String PREFIX_BP = "BuildPathInfoBlock"; //$NON-NLS-1$
|
private static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
||||||
private static final String SC_GROUP_LABEL = PREFIX_BP + ".scGroup.label"; //$NON-NLS-1$
|
private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
|
||||||
private static final String SC_ENABLED_LABEL = PREFIX_BP + ".scGroup.enabled.label"; //$NON-NLS-1$
|
private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
|
||||||
private static final String MISSING_BUILDER_MSG = "ScannerConfigOptionsDialog.label.missingBuilderInformation"; //$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 static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
private Button scEnabledButton;
|
||||||
private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
|
private Button scProblemReportingEnabledButton;
|
||||||
private static final String DIALOG_DESCRIPTION = PREFIX + ".description"; //$NON-NLS-1$
|
private Combo profileComboBox;
|
||||||
private static final String SI_BUILD_PARSER_GROUP = PREFIX + ".siBuilder.parser.group_label"; //$NON-NLS-1$
|
private Composite profileComp;
|
||||||
private static final String ENABLE_SI_BUILD_PARSER = PREFIX + ".siBuilder.parser.enable.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_BUILD_PARSER_LABEL = PREFIX + ".siBuilder.parser.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_CMD_GROUP = PREFIX + ".siProvider.cmd.group_label"; //$NON-NLS-1$
|
|
||||||
private static final String ENABLE_SI_PROVIDER_COMMAND = PREFIX + ".siProvider.cmd.enable.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_CMD_USE_DEFAULT = PREFIX + ".siProvider.cmd.use_default"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_CMD_LABEL = PREFIX + ".siProvider.cmd.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_PARSER_LABEL = PREFIX + ".siProvider.parser.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_CMD_ERROR_MESSAGE = PREFIX + ".siProvider.cmd.error_message"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROBLEM_GROUP = PREFIX + ".siProblem.group.label"; //$NON-NLS-1$
|
|
||||||
private static final String ENABLE_SI_PROBLEM_GENERATION = PREFIX + ".siProblem.generation.enable.label"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private Button scEnabledButton;
|
private boolean needsSCNature = false;
|
||||||
private boolean needsSCNature = false;
|
private boolean fCreatePathContainer = false;
|
||||||
|
private boolean isValid = true;
|
||||||
|
|
||||||
private Button defESIProviderCommandButton;
|
/**
|
||||||
private Text esiProviderCommand;
|
*
|
||||||
private Button enableBuilderParserButton;
|
*/
|
||||||
private Combo makeBuilderSIParserComboBox;
|
public DiscoveryOptionsBlock() {
|
||||||
private Button enableProviderCommandButton;
|
super(MakeUIPlugin.getResourceString(DIALOG_TITLE));
|
||||||
private Combo esiProviderParserComboBox;
|
setDescription(MakeUIPlugin.getResourceString(DIALOG_DESCRIPTION));
|
||||||
private Button enableProblemGenerationButton;
|
}
|
||||||
|
|
||||||
private Preferences fPrefs;
|
/* (non-Javadoc)
|
||||||
private IScannerConfigBuilderInfo fBuildInfo;
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#setContainer(org.eclipse.cdt.ui.dialogs.ICOptionContainer)
|
||||||
private boolean fInitialized = false;
|
*/
|
||||||
private Map builderParsers = new HashMap();
|
public void setContainer(ICOptionContainer container) {
|
||||||
private String initialBuilderParserId = null;
|
super.setContainer(container);
|
||||||
private Map providerParsers = new HashMap();
|
if (container.getProject() == null) {
|
||||||
private String initialProviderParserId = null;
|
fCreatePathContainer = true;
|
||||||
private boolean fCreatePathContainer = false;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DiscoveryOptionsBlock() {
|
/* (non-Javadoc)
|
||||||
super(MakeUIPlugin.getResourceString(DIALOG_TITLE));
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||||
setDescription(MakeUIPlugin.getResourceString(DIALOG_DESCRIPTION));
|
*/
|
||||||
}
|
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);
|
||||||
|
|
||||||
/*
|
WorkbenchHelp.setHelp(getControl(), IMakeHelpContextIds.SCANNER_CONFIG_DISCOVERY_OPTIONS);
|
||||||
* (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();
|
// create a composite for general scanner config discovery options
|
||||||
IProject project = getContainer().getProject();
|
Composite scComp = ControlFactory.createComposite(composite, 1);
|
||||||
|
((GridLayout)scComp.getLayout()).marginHeight = 0;
|
||||||
|
((GridLayout)scComp.getLayout()).marginTop = 5;
|
||||||
|
scComp.setFont(font);
|
||||||
|
|
||||||
fInitialized = true;
|
// Create a group for scanner config discovery
|
||||||
if (project != null) {
|
if (createScannerConfigControls(scComp, tabColumns)) {
|
||||||
try {
|
// create a composite for discovery profile options
|
||||||
fBuildInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
|
profileComp = ControlFactory.createComposite(composite, 1);
|
||||||
} catch (CoreException e) {
|
// ((GridLayout)profileComp.getLayout()).marginHeight = 5;
|
||||||
// missing builder information (builder disabled or legacy project)
|
// ((GridLayout)profileComp.getLayout()).marginWidth = 5;
|
||||||
fInitialized = false;
|
// ((GridLayout)profileComp.getLayout()).verticalSpacing = 5;
|
||||||
fBuildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
|
profileComp.setFont(font);
|
||||||
}
|
GridData gd = (GridData) profileComp.getLayoutData();
|
||||||
} else {
|
gd.grabExcessHorizontalSpace = true;
|
||||||
fCreatePathContainer = true;
|
// gd.grabExcessVerticalSpace = true;
|
||||||
fBuildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
|
gd.horizontalAlignment = GridData.FILL;
|
||||||
}
|
gd.verticalAlignment = GridData.FILL;
|
||||||
retrieveSIConsoleParsers();
|
|
||||||
initialBuilderParserId = fBuildInfo.getMakeBuilderConsoleParserId(); //$NON-NLS-1$
|
|
||||||
initialProviderParserId = fBuildInfo.getESIProviderConsoleParserId(); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
// Must set the composite parent to super class.
|
||||||
* (non-Javadoc)
|
setCompositeParent(profileComp);
|
||||||
*
|
// fire a change event, to quick start.
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
handleDiscoveryProfileChanged();
|
||||||
*/
|
// enable controls depending on the state of auto discovery
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
enableAllControls();
|
||||||
if (!fInitialized && !needsSCNature) {
|
}
|
||||||
// Missing builder info on a non-legacy project
|
parent.layout(true);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
if (monitor == null) {
|
|
||||||
monitor = new NullProgressMonitor();
|
|
||||||
}
|
|
||||||
IWorkspace workspace = MakeUIPlugin.getWorkspace();
|
|
||||||
|
|
||||||
// To avoid multi-build
|
private boolean createScannerConfigControls(Composite parent, int numColumns) {
|
||||||
IWorkspaceRunnable operation = new IWorkspaceRunnable() {
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
if (showMissingBuilder || (!needsSCNature && !isInitialized())) {
|
||||||
IScannerConfigBuilderInfo buildInfo;
|
ControlFactory.createEmptySpace(parent);
|
||||||
IProject project = getContainer().getProject();
|
ControlFactory.createLabel(parent, MakeUIPlugin.getResourceString(MISSING_BUILDER_MSG));
|
||||||
if (project != null) {
|
return false;
|
||||||
if (needsSCNature) {
|
}
|
||||||
ScannerConfigNature.addScannerConfigNature(getContainer().getProject());
|
|
||||||
needsSCNature = false;
|
|
||||||
fCreatePathContainer = true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
// disabled builder... just log it
|
|
||||||
MakeCorePlugin.log(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (fCreatePathContainer) {
|
|
||||||
createDiscoveredPathContainer(project, monitor);
|
|
||||||
// create a new discovered scanner config store
|
|
||||||
MakeCorePlugin.getDefault().getDiscoveryManager().removeDiscoveredInfo(project);
|
|
||||||
fCreatePathContainer = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
buildInfo.setAutoDiscoveryEnabled(isScannerConfigDiscoveryEnabled());
|
Group scGroup = ControlFactory.createGroup(parent,
|
||||||
if (isScannerConfigDiscoveryEnabled()) {
|
MakeUIPlugin.getResourceString(SC_GROUP_LABEL), numColumns);
|
||||||
buildInfo.setMakeBuilderConsoleParserEnabled(isBuilderParserEnabled());
|
scGroup.setFont(parent.getFont());
|
||||||
if (isBuilderParserEnabled()) {
|
((GridData)scGroup.getLayoutData()).grabExcessHorizontalSpace = true;
|
||||||
buildInfo.setMakeBuilderConsoleParserId((String)builderParsers.get(makeBuilderSIParserComboBox.getText()));
|
((GridData)scGroup.getLayoutData()).horizontalSpan = numColumns;
|
||||||
}
|
((GridData)scGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
|
||||||
buildInfo.setESIProviderCommandEnabled(isProviderCommandEnabled());
|
|
||||||
if (isProviderCommandEnabled()) {
|
|
||||||
buildInfo.setUseDefaultESIProviderCmd(useDefaultESIProviderCmd());
|
|
||||||
if (!useDefaultESIProviderCmd()) {
|
|
||||||
storeSIProviderCommandLine(buildInfo);
|
|
||||||
}
|
|
||||||
buildInfo.setESIProviderConsoleParserId((String)providerParsers.get(esiProviderParserComboBox.getText()));
|
|
||||||
}
|
|
||||||
buildInfo.setSIProblemGenerationEnabled(isProblemGenerationEnabled());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (getContainer().getProject() != null) {
|
|
||||||
workspace.run(operation, monitor);
|
|
||||||
} else {
|
|
||||||
operation.run(monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
// Add main SCD checkbox
|
||||||
* (non-Javadoc)
|
scEnabledButton = ControlFactory.createCheckBox(scGroup,
|
||||||
*
|
MakeUIPlugin.getResourceString(SC_ENABLED_BUTTON));
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
scEnabledButton.setFont(parent.getFont());
|
||||||
*/
|
((GridData)scEnabledButton.getLayoutData()).horizontalSpan = numColumns;
|
||||||
public void performDefaults() {
|
((GridData)scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
|
||||||
if (!fInitialized && !needsSCNature) {
|
// VMIR* old projects will have discovery disabled by default
|
||||||
// Missing builder info on a non-legacy project
|
scEnabledButton.setSelection(needsSCNature ? false : getBuildInfo().isAutoDiscoveryEnabled());
|
||||||
return;
|
scEnabledButton.addSelectionListener(new SelectionAdapter() {
|
||||||
}
|
public void widgetSelected(SelectionEvent e) {
|
||||||
IScannerConfigBuilderInfo info;
|
enableAllControls();
|
||||||
// Populate with the default values
|
}
|
||||||
if (getContainer().getProject() != null) {
|
});
|
||||||
// get the preferences
|
// handleScannerConfigEnable(); Only if true in VMIR*
|
||||||
info = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
|
|
||||||
} else {
|
|
||||||
// get the defaults
|
|
||||||
info = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
setScannerConfigDiscoveryEnabled(info.isAutoDiscoveryEnabled());
|
// Add problem reporting checkbox
|
||||||
enableBuilderParserButton.setSelection(info.isMakeBuilderConsoleParserEnabled());
|
scProblemReportingEnabledButton = ControlFactory.createCheckBox(scGroup,
|
||||||
makeBuilderSIParserComboBox.setText(getParserName(builderParsers, info.getMakeBuilderConsoleParserId()));
|
MakeUIPlugin.getResourceString(SC_PROBLEM_REPORTING_ENABLED_BUTTON));
|
||||||
enableProviderCommandButton.setSelection(info.isESIProviderCommandEnabled());
|
scProblemReportingEnabledButton.setFont(parent.getFont());
|
||||||
defESIProviderCommandButton.setSelection(info.isDefaultESIProviderCmd());
|
((GridData)scProblemReportingEnabledButton.getLayoutData()).horizontalSpan = numColumns;
|
||||||
setESIProviderCommandFrom(info);
|
((GridData)scProblemReportingEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
|
||||||
esiProviderParserComboBox.setText(getParserName(providerParsers, info.getESIProviderConsoleParserId()));
|
scProblemReportingEnabledButton.setSelection(getBuildInfo().isProblemReportingEnabled());
|
||||||
|
|
||||||
enableAllControls();
|
// 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);
|
||||||
* @param parsers
|
|
||||||
* @param consoleParserId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getParserName(Map parsers, String consoleParserId) {
|
|
||||||
for (Iterator i = parsers.keySet().iterator(); i.hasNext();) {
|
|
||||||
String parserName = (String)i.next();
|
|
||||||
String parserId = (String)parsers.get(parserName);
|
|
||||||
if (parserId.equals(consoleParserId)) {
|
|
||||||
return parserName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return consoleParserId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
// fill the combobox and set the initial value
|
||||||
* (non-Javadoc)
|
for (Iterator items = getDiscoveryProfileIdList().iterator(); items.hasNext();) {
|
||||||
*
|
String profileId = (String)items.next();
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
String pageName = getDiscoveryProfileName(profileId);
|
||||||
*/
|
if (pageName != null) {
|
||||||
public void createControl(Composite parent) {
|
profileComboBox.add(pageName);
|
||||||
// Create the composite control for the tab
|
if (profileId.equals(getBuildInfo().getSelectedProfileId())) {
|
||||||
int tabColumns = 1;
|
profileComboBox.setText(pageName);
|
||||||
Font font = parent.getFont();
|
}
|
||||||
Composite composite = ControlFactory.createComposite(parent, tabColumns);
|
}
|
||||||
((GridLayout)composite.getLayout()).makeColumnsEqualWidth = false;
|
}
|
||||||
composite.setFont(font);
|
profileComboBox.setEnabled(scEnabledButton.getSelection());
|
||||||
setControl(composite);
|
|
||||||
|
|
||||||
WorkbenchHelp.setHelp(getControl(), IMakeHelpContextIds.SCANNER_CONFIG_DISCOVERY_OPTIONS);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a group for scanner config discovery
|
/**
|
||||||
if (createScannerConfigControls(composite, tabColumns)) {
|
*
|
||||||
createBuildOutputParserControls(composite);
|
*/
|
||||||
createAfterBuildCmdControls(composite);
|
private void enableAllControls() {
|
||||||
createProblemGenerationControls(composite);
|
boolean isSCDEnabled = scEnabledButton.getSelection();
|
||||||
// enable controls depending on the state of auto discovery
|
scProblemReportingEnabledButton.setEnabled(isSCDEnabled);
|
||||||
enableAllControls();
|
profileComboBox.setEnabled(isSCDEnabled);
|
||||||
}
|
profileComp.setVisible(isSCDEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* @param composite
|
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
||||||
*/
|
*/
|
||||||
private boolean createScannerConfigControls(Composite parent, int numColumns) {
|
public void setVisible(boolean visible) {
|
||||||
// Check if it is an old project
|
super.setVisible(visible);
|
||||||
IProject project = getContainer().getProject();
|
enableAllControls();
|
||||||
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 && !fInitialized)) {
|
/* (non-Javadoc)
|
||||||
ControlFactory.createEmptySpace(parent);
|
* @see org.eclipse.cdt.make.ui.dialogs.AbstractDiscoveryOptionsBlock#getCurrentProfileId()
|
||||||
ControlFactory.createLabel(parent, MakeUIPlugin.getResourceString(MISSING_BUILDER_MSG));
|
*/
|
||||||
return false;
|
protected String getCurrentProfileId() {
|
||||||
}
|
String selectedProfileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
|
||||||
|
String selectedProfileId = getDiscoveryProfileId(selectedProfileName);
|
||||||
|
return selectedProfileId;
|
||||||
|
}
|
||||||
|
|
||||||
Group scGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SC_GROUP_LABEL), numColumns);
|
/* (non-Javadoc)
|
||||||
scGroup.setFont(parent.getFont());
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
((GridData)scGroup.getLayoutData()).grabExcessHorizontalSpace = true;
|
*/
|
||||||
((GridData)scGroup.getLayoutData()).horizontalSpan = numColumns;
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
((GridData)scGroup.getLayoutData()).horizontalAlignment = GridData.FILL;
|
if (monitor == null) {
|
||||||
|
monitor = new NullProgressMonitor();
|
||||||
|
}
|
||||||
|
monitor.beginTask(MakeUIPlugin.getResourceString(SC_APPLY_PROGRESS_MESSAGE), 3);
|
||||||
|
|
||||||
// Add checkbox
|
// init buildInfo
|
||||||
scEnabledButton = ControlFactory.createCheckBox(scGroup, MakeUIPlugin.getResourceString(SC_ENABLED_LABEL));
|
final IProject project = getContainer().getProject();
|
||||||
scEnabledButton.setFont(parent.getFont());
|
// Create new build info in case of new C++ project wizard
|
||||||
((GridData)scEnabledButton.getLayoutData()).horizontalSpan = numColumns;
|
final IScannerConfigBuilderInfo2 buildInfo = createBuildInfo(project);
|
||||||
((GridData)scEnabledButton.getLayoutData()).grabExcessHorizontalSpace = true;
|
|
||||||
// VMIR* old projects will have discovery disabled by default
|
|
||||||
scEnabledButton.setSelection(needsSCNature ? false : fBuildInfo.isAutoDiscoveryEnabled());
|
|
||||||
scEnabledButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
enableAllControls();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// handleScannerConfigEnable(); Only if true in VMIR*
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (buildInfo != null) {
|
||||||
* Fills console parser maps
|
populateBuildInfo(buildInfo);
|
||||||
*/
|
buildInfo.store();
|
||||||
private void retrieveSIConsoleParsers() {
|
monitor.worked(1);
|
||||||
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.getUniqueIdentifier(),
|
|
||||||
MakeCorePlugin.SI_CONSOLE_PARSER_SIMPLE_ID);
|
|
||||||
if (ep != null) {
|
|
||||||
IExtension[] extensions = ep.getExtensions();
|
|
||||||
for (int i = 0; i < extensions.length; ++i) {
|
|
||||||
String parserId = extensions[i].getUniqueIdentifier();
|
|
||||||
String label = extensions[i].getLabel();
|
|
||||||
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
|
|
||||||
String commandId = elements[0].getAttribute("commandId"); //$NON-NLS-1$
|
|
||||||
if (commandId.equals("makeBuilder") || commandId.equals("all")) { //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
builderParsers.put(label, parserId);
|
|
||||||
}
|
|
||||||
if (commandId.equals("externalScannerInfoProvider") || commandId.equals("all")) { //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
providerParsers.put(label, parserId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createBuildOutputParserControls(Composite parent) {
|
if (scEnabledButton.getSelection()) {
|
||||||
// ControlFactory.insertSpace(parent, 1, 10);
|
getCurrentPage().performApply(monitor);
|
||||||
Group bopGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SI_BUILD_PARSER_GROUP), 2);
|
}
|
||||||
((GridLayout)bopGroup.getLayout()).marginHeight = 5;
|
monitor.worked(1);
|
||||||
((GridLayout)bopGroup.getLayout()).marginWidth = 5;
|
|
||||||
((GridData)bopGroup.getLayoutData()).verticalAlignment = GridData.FILL;
|
|
||||||
((GridData)bopGroup.getLayoutData()).horizontalSpan = 2;
|
|
||||||
|
|
||||||
enableBuilderParserButton = ControlFactory.createCheckBox(bopGroup, MakeUIPlugin.getResourceString(ENABLE_SI_BUILD_PARSER));
|
if (project != null) {
|
||||||
((GridData)enableBuilderParserButton.getLayoutData()).horizontalSpan = 2;
|
configureProject(project, monitor);
|
||||||
boolean enabledBuilderParser = fBuildInfo.isMakeBuilderConsoleParserEnabled();
|
ICDescriptorOperation op = new ICDescriptorOperation() {
|
||||||
enableBuilderParserButton.setSelection(enabledBuilderParser);
|
|
||||||
enableBuilderParserButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
|
||||||
makeBuilderSIParserComboBox.setEnabled(isBuilderParserEnabled());
|
buildInfo.save();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
Label label = ControlFactory.createLabel(bopGroup, MakeUIPlugin.getResourceString(SI_BUILD_PARSER_LABEL));
|
};
|
||||||
((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
|
CCorePlugin.getDefault().getCDescriptorManager().
|
||||||
|
runDescriptorOperation(project, op, monitor);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buildInfo.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
|
|
||||||
makeBuilderSIParserComboBox = new Combo(bopGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
|
private void configureProject(IProject project, IProgressMonitor monitor) throws CoreException {
|
||||||
|
if (monitor == null) {
|
||||||
|
monitor = new NullProgressMonitor();
|
||||||
|
}
|
||||||
|
monitor.beginTask(MakeUIPlugin.getResourceString(SC_APPLY_PROGRESS_MESSAGE), 3);
|
||||||
|
|
||||||
// fill the combobox and set the initial value
|
if (needsSCNature) {
|
||||||
for (Iterator items = builderParsers.keySet().iterator(); items.hasNext();) {
|
ScannerConfigNature.addScannerConfigNature(project);
|
||||||
String parser = (String)items.next();
|
needsSCNature = false;
|
||||||
makeBuilderSIParserComboBox.add(parser);
|
fCreatePathContainer = true;
|
||||||
if (initialBuilderParserId.equals(builderParsers.get(parser))) {
|
}
|
||||||
makeBuilderSIParserComboBox.setText(parser);
|
if (fCreatePathContainer) {
|
||||||
}
|
createDiscoveredPathContainer(project, monitor);
|
||||||
}
|
fCreatePathContainer = false;
|
||||||
makeBuilderSIParserComboBox.setEnabled(enabledBuilderParser);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAfterBuildCmdControls(Composite parent) {
|
/**
|
||||||
Group abcGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_GROUP), 2);
|
* @param project
|
||||||
((GridData)abcGroup.getLayoutData()).horizontalSpan = 2;
|
* @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);
|
||||||
|
}
|
||||||
|
|
||||||
enableProviderCommandButton = ControlFactory.createCheckBox(abcGroup,
|
private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo) {
|
||||||
MakeUIPlugin.getResourceString(ENABLE_SI_PROVIDER_COMMAND));
|
buildInfo.setAutoDiscoveryEnabled(scEnabledButton.getSelection());
|
||||||
((GridData)enableProviderCommandButton.getLayoutData()).horizontalSpan = 2;
|
String profileName = profileComboBox.getItem(profileComboBox.getSelectionIndex());
|
||||||
((GridData)enableProviderCommandButton.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
|
buildInfo.setSelectedProfileId(getDiscoveryProfileId(profileName));
|
||||||
boolean enabledProviderCommand = fBuildInfo.isESIProviderCommandEnabled();
|
buildInfo.setProblemReportingEnabled(scProblemReportingEnabledButton.getSelection());
|
||||||
enableProviderCommandButton.setSelection(enabledProviderCommand);
|
}
|
||||||
enableProviderCommandButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
/* (non-Javadoc)
|
||||||
defESIProviderCommandButton.setEnabled(isProviderCommandEnabled());
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
||||||
esiProviderCommand.setEnabled(isProviderCommandEnabled() && !useDefaultESIProviderCmd());
|
*/
|
||||||
esiProviderParserComboBox.setEnabled(isProviderCommandEnabled());
|
|
||||||
getContainer().updateContainer();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
createESIProviderCmdControls(abcGroup);
|
public void performDefaults() {
|
||||||
|
if (!isInitialized() && !needsSCNature) {
|
||||||
|
// Missing builder info on a non-legacy project
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IScannerConfigBuilderInfo2 buildInfo = createBuildInfo();
|
||||||
|
|
||||||
Label label = ControlFactory.createLabel(abcGroup, MakeUIPlugin.getResourceString(SI_PROVIDER_PARSER_LABEL));
|
restoreFromBuildinfo(buildInfo);
|
||||||
((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
|
enableAllControls();
|
||||||
|
|
||||||
esiProviderParserComboBox = new Combo(abcGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
|
getCurrentPage().performDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
// fill the combobox and set the initial value
|
private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
|
||||||
for (Iterator items = providerParsers.keySet().iterator(); items.hasNext();) {
|
scEnabledButton.setSelection(buildInfo.isAutoDiscoveryEnabled());
|
||||||
String parser = (String)items.next();
|
String profileId = buildInfo.getSelectedProfileId();
|
||||||
esiProviderParserComboBox.add(parser);
|
profileComboBox.setText(getDiscoveryProfileName(profileId));
|
||||||
if (initialProviderParserId.equals(providerParsers.get(parser))) {
|
scProblemReportingEnabledButton.setSelection(buildInfo.isProblemReportingEnabled());
|
||||||
esiProviderParserComboBox.setText(parser);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
defESIProviderCommandButton.setEnabled(enabledProviderCommand);
|
|
||||||
esiProviderCommand.setEnabled(enabledProviderCommand && !useDefaultESIProviderCmd());
|
|
||||||
esiProviderParserComboBox.setEnabled(enabledProviderCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createESIProviderCmdControls(Composite parent) {
|
|
||||||
defESIProviderCommandButton = ControlFactory.createCheckBox(parent,
|
|
||||||
MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_USE_DEFAULT));
|
|
||||||
defESIProviderCommandButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
esiProviderCommand.setEnabled(!useDefaultESIProviderCmd());
|
|
||||||
getContainer().updateContainer();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((GridData) (defESIProviderCommandButton.getLayoutData())).horizontalAlignment = GridData.FILL_HORIZONTAL;
|
|
||||||
((GridData) (defESIProviderCommandButton.getLayoutData())).horizontalSpan = 2;
|
|
||||||
Label label = ControlFactory.createLabel(parent, MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_LABEL));
|
|
||||||
((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
|
|
||||||
((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
|
|
||||||
esiProviderCommand = ControlFactory.createTextField(parent, SWT.SINGLE | SWT.BORDER);
|
|
||||||
((GridData) (esiProviderCommand.getLayoutData())).horizontalAlignment = GridData.FILL;
|
|
||||||
((GridData) (esiProviderCommand.getLayoutData())).grabExcessHorizontalSpace = true;
|
|
||||||
setESIProviderCommandFrom(fBuildInfo);
|
|
||||||
if (fBuildInfo.isDefaultESIProviderCmd()) {
|
|
||||||
esiProviderCommand.setEnabled(false);
|
|
||||||
}
|
|
||||||
esiProviderCommand.addListener(SWT.Modify, new Listener() {
|
|
||||||
|
|
||||||
public void handleEvent(Event e) {
|
|
||||||
getContainer().updateContainer();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
defESIProviderCommandButton.setSelection(fBuildInfo.isDefaultESIProviderCmd());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createProblemGenerationControls(Composite parent) {
|
|
||||||
Group problemGroup = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(SI_PROBLEM_GROUP), 2);
|
|
||||||
((GridData)problemGroup.getLayoutData()).horizontalSpan = 2;
|
|
||||||
|
|
||||||
enableProblemGenerationButton = ControlFactory.createCheckBox(problemGroup,
|
|
||||||
MakeUIPlugin.getResourceString(ENABLE_SI_PROBLEM_GENERATION));
|
|
||||||
((GridData)enableProblemGenerationButton.getLayoutData()).horizontalSpan = 2;
|
|
||||||
((GridData)enableProblemGenerationButton.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
|
|
||||||
boolean enabledProblemGeneration = fBuildInfo.isSIProblemGenerationEnabled();
|
|
||||||
enableProblemGenerationButton.setSelection(enabledProblemGeneration);
|
|
||||||
enableProblemGenerationButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
getContainer().updateContainer();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param buildInfo
|
|
||||||
*/
|
|
||||||
private void setESIProviderCommandFrom(IScannerConfigBuilderInfo buildInfo) {
|
|
||||||
IPath sCommand = buildInfo.getESIProviderCommand();
|
|
||||||
if (sCommand != null) {
|
|
||||||
StringBuffer cmd = new StringBuffer(sCommand.toOSString());
|
|
||||||
String args = buildInfo.getESIProviderArguments();
|
|
||||||
if (args != null && args.length() > 0) {
|
|
||||||
cmd.append(' ');
|
|
||||||
cmd.append(args);
|
|
||||||
}
|
|
||||||
esiProviderCommand.setText(cmd.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param enable
|
|
||||||
*/
|
|
||||||
private void enableAllControls() {
|
|
||||||
enableBuilderParserButton.setEnabled(isScannerConfigDiscoveryEnabled());
|
|
||||||
makeBuilderSIParserComboBox.setEnabled(isScannerConfigDiscoveryEnabled() && isBuilderParserEnabled());
|
|
||||||
enableProviderCommandButton.setEnabled(isScannerConfigDiscoveryEnabled());
|
|
||||||
defESIProviderCommandButton.setEnabled(isScannerConfigDiscoveryEnabled() && isProviderCommandEnabled());
|
|
||||||
esiProviderCommand.setEnabled(isScannerConfigDiscoveryEnabled() && isProviderCommandEnabled()
|
|
||||||
&& !useDefaultESIProviderCmd());
|
|
||||||
esiProviderParserComboBox.setEnabled(isScannerConfigDiscoveryEnabled() && isProviderCommandEnabled());
|
|
||||||
enableProblemGenerationButton.setEnabled(isScannerConfigDiscoveryEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean useDefaultESIProviderCmd() {
|
|
||||||
return defESIProviderCommandButton.getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSIProviderCommandLine() {
|
|
||||||
return esiProviderCommand.getText().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isBuilderParserEnabled() {
|
|
||||||
return enableBuilderParserButton.getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isProviderCommandEnabled() {
|
|
||||||
return enableProviderCommandButton.getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isProblemGenerationEnabled() {
|
|
||||||
return enableProblemGenerationButton.getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the state of scanner config discovery
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
private boolean isScannerConfigDiscoveryEnabled() {
|
|
||||||
return scEnabledButton.getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables or disables the scanner config discovery
|
|
||||||
*
|
|
||||||
* @param enabled
|
|
||||||
* (boolean)
|
|
||||||
*/
|
|
||||||
private void setScannerConfigDiscoveryEnabled(boolean enabled) {
|
|
||||||
scEnabledButton.setSelection(enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param buildInfo
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
private void storeSIProviderCommandLine(IScannerConfigBuilderInfo buildInfo) throws CoreException {
|
|
||||||
String esiProviderLine = getSIProviderCommandLine();
|
|
||||||
int start = 0;
|
|
||||||
int end = -1;
|
|
||||||
if (esiProviderLine.startsWith("\"")) { //$NON-NLS-1$
|
|
||||||
start = 1;
|
|
||||||
end = esiProviderLine.indexOf('"', 1);
|
|
||||||
} else {
|
|
||||||
end = esiProviderLine.indexOf(' ');
|
|
||||||
}
|
|
||||||
IPath path;
|
|
||||||
if (end == -1) {
|
|
||||||
path = new Path(esiProviderLine);
|
|
||||||
} else {
|
|
||||||
path = new Path(esiProviderLine.substring(start, end));
|
|
||||||
}
|
|
||||||
buildInfo.setESIProviderCommand(path);
|
|
||||||
String args = ""; //$NON-NLS-1$
|
|
||||||
if (end != -1) {
|
|
||||||
args = esiProviderLine.substring(end + 1);
|
|
||||||
}
|
|
||||||
buildInfo.setESIProviderArguments(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#isValid()
|
|
||||||
*/
|
|
||||||
public boolean isValid() {
|
|
||||||
if (fInitialized && isProviderCommandEnabled() && !useDefaultESIProviderCmd()) {
|
|
||||||
String cmd = getSIProviderCommandLine();
|
|
||||||
if (cmd == null || cmd.length() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
|
|
||||||
*/
|
|
||||||
public String getErrorMessage() {
|
|
||||||
if (!isValid()) {
|
|
||||||
return MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -0,0 +1,364 @@
|
||||||
|
/***********************************************************************
|
||||||
|
* Copyright (c) 2004 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.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
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 profile property/preference page
|
||||||
|
*
|
||||||
|
* @author vhirsl
|
||||||
|
*/
|
||||||
|
public class GCCPerProjectSCDProfilePage extends AbstractDiscoveryPage {
|
||||||
|
private static final int DEFAULT_HEIGHT = 160;
|
||||||
|
|
||||||
|
private static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
||||||
|
private static final String BO_PROVIDER_GROUP_LABEL = PREFIX + ".boProvider.group.label"; //$NON-NLS-1$
|
||||||
|
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) {
|
||||||
|
// Add the profile UI contribution.
|
||||||
|
Group profileGroup = ControlFactory.createGroup(parent,
|
||||||
|
MakeUIPlugin.getResourceString(BO_PROVIDER_GROUP_LABEL), 3);
|
||||||
|
|
||||||
|
GridData gd = (GridData) profileGroup.getLayoutData();
|
||||||
|
gd.grabExcessHorizontalSpace = true;
|
||||||
|
gd.horizontalAlignment = GridData.FILL;
|
||||||
|
// PixelConverter converter = new PixelConverter(parent);
|
||||||
|
// gd.heightHint = converter.convertHorizontalDLUsToPixels(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 = 3;
|
||||||
|
|
||||||
|
// text field
|
||||||
|
bopOpenFileText = ControlFactory.createTextField(profileGroup, SWT.SINGLE | SWT.BORDER);
|
||||||
|
bopOpenFileText.addModifyListener(new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
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 = bopOpenFileText.getText().trim();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
bopOpenFileText.setText(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
bopLoadButton.setEnabled(loadButtonInitialEnabled);
|
||||||
|
if (getContainer().getProject() == null) { // project properties
|
||||||
|
bopLoadButton.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
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(parent);
|
||||||
|
// set the shell variable; must be after setControl
|
||||||
|
//lock.acquire();
|
||||||
|
synchronized (lock) {
|
||||||
|
shell = getShell();
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
//lock.release();
|
||||||
|
initializeValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void handleModifyOpenFileText() {
|
||||||
|
String fileName = bopOpenFileText.getText().trim();
|
||||||
|
bopLoadButton.setEnabled(bopEnabledButton.getSelection() &&
|
||||||
|
fileName.length() > 0 &&
|
||||||
|
new File(fileName).exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected void handleModifyRunCommandText() {
|
||||||
|
String cmd = sipRunCommandText.getText().trim();
|
||||||
|
isValid = (cmd.length() > 0) ? true : false;
|
||||||
|
|
||||||
|
getContainer().updateContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void initializeValues() {
|
||||||
|
bopEnabledButton.setSelection(getBuildInfo().isBuildOutputParserEnabled());
|
||||||
|
bopOpenFileText.setText(getBuildInfo().getBuildOutputFilePath());
|
||||||
|
sipEnabledButton.setSelection(getBuildInfo().isProviderOutputParserEnabled(providerId));
|
||||||
|
sipRunCommandText.setText(getBuildInfo().getProviderRunCommand(providerId));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleBOPLoadFileButtonSelected() {
|
||||||
|
loadButtonInitialEnabled = false;
|
||||||
|
bopLoadButton.setEnabled(false);
|
||||||
|
|
||||||
|
// populate buildInfo to be used by the reader job
|
||||||
|
populateBuildInfo(getBuildInfo(), null);
|
||||||
|
IProject project = getContainer().getProject();
|
||||||
|
Job readerJob = new BuildOutputReaderJob(project, 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()) {
|
||||||
|
instance.bopLoadButton.setEnabled(instance.bopEnabledButton.getSelection());
|
||||||
|
}
|
||||||
|
loadButtonInitialEnabled = instance.bopEnabledButton.getSelection();//true;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
loadButtonInitialEnabled = instance.bopEnabledButton.getSelection();//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.ui.dialogs.AbstractCOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
|
IProject project = getContainer().getProject();
|
||||||
|
// Create new build info in case of new C++ project wizard
|
||||||
|
IScannerConfigBuilderInfo2 buildInfo = createBuildInfo(project);
|
||||||
|
|
||||||
|
if (buildInfo != null) {
|
||||||
|
populateBuildInfo(buildInfo, monitor);
|
||||||
|
buildInfo.store();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateBuildInfo(IScannerConfigBuilderInfo2 buildInfo, IProgressMonitor monitor) {
|
||||||
|
buildInfo.setBuildOutputFileActionEnabled(true);
|
||||||
|
buildInfo.setBuildOutputFilePath(bopOpenFileText.getText().trim());
|
||||||
|
buildInfo.setBuildOutputParserEnabled(bopEnabledButton.getSelection());
|
||||||
|
|
||||||
|
buildInfo.setProviderOutputParserEnabled(providerId, sipEnabledButton.getSelection());
|
||||||
|
buildInfo.setProviderRunCommand(providerId, sipRunCommandText.getText().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performDefaults()
|
||||||
|
*/
|
||||||
|
public void performDefaults() {
|
||||||
|
// Create buildInfo with defaults
|
||||||
|
IScannerConfigBuilderInfo2 buildInfo = createBuildInfo();
|
||||||
|
|
||||||
|
restoreFromBuildinfo(buildInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreFromBuildinfo(IScannerConfigBuilderInfo2 buildInfo) {
|
||||||
|
bopOpenFileText.setText(buildInfo.getBuildOutputFilePath());
|
||||||
|
bopEnabledButton.setSelection(buildInfo.isBuildOutputParserEnabled());
|
||||||
|
|
||||||
|
sipEnabledButton.setSelection(buildInfo.isProviderOutputParserEnabled(providerId));
|
||||||
|
sipRunCommandText.setText(buildInfo.getProviderRunCommand(providerId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,537 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-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.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigUtil;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.SymbolEntry;
|
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
|
||||||
import org.eclipse.cdt.make.internal.ui.MessageLine;
|
|
||||||
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.jface.dialogs.Dialog;
|
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.graphics.FontData;
|
|
||||||
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.Control;
|
|
||||||
import org.eclipse.swt.widgets.Group;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.List;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage defined symbols dialog
|
|
||||||
*
|
|
||||||
* @author vhirsl
|
|
||||||
*/
|
|
||||||
public class ManageDefinedSymbolsDialog extends Dialog {
|
|
||||||
private static final String PREF_SYMBOLS = "ScannerSymbols"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String PREFIX = "ManageDefinedSymbolsDialog"; //$NON-NLS-1$
|
|
||||||
private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
|
|
||||||
private static final String USER_GROUP = PREFIX + ".userGroup.title"; //$NON-NLS-1$
|
|
||||||
private static final String NEW = "BuildPropertyCommon.label.new"; //$NON-NLS-1$
|
|
||||||
private static final String EDIT = "BuildPropertyCommon.label.edit"; //$NON-NLS-1$
|
|
||||||
private static final String REMOVE = "BuildPropertyCommon.label.remove"; //$NON-NLS-1$
|
|
||||||
private static final String UP = "BuildPropertyCommon.label.up"; //$NON-NLS-1$
|
|
||||||
private static final String DOWN = "BuildPropertyCommon.label.down"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String BROWSE = "BuildPathInfoBlock.browse"; //$NON-NLS-1$
|
|
||||||
private static final String SYMBOL_TITLE = BROWSE + ".symbol"; //$NON-NLS-1$
|
|
||||||
private static final String EDIT_SYMBOL_TITLE = BROWSE + ".symbol.edit"; //$NON-NLS-1$
|
|
||||||
private static final String SYMBOL_LABEL = BROWSE + ".symbol.label"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String DISCOVERED_GROUP = PREFIX + ".discoveredGroup.title"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String DISC_COMMON_PREFIX = "ManageScannerConfigDialogCommon"; //$NON-NLS-1$
|
|
||||||
private static final String SELECTED_LABEL = DISC_COMMON_PREFIX + ".discoveredGroup.selected.label"; //$NON-NLS-1$
|
|
||||||
private static final String REMOVED_LABEL = DISC_COMMON_PREFIX + ".discoveredGroup.removed.label"; //$NON-NLS-1$
|
|
||||||
private static final String REMOVE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.remove.label"; //$NON-NLS-1$
|
|
||||||
private static final String RESTORE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.restore.label"; //$NON-NLS-1$
|
|
||||||
private static final String DELETE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.delete.label"; //$NON-NLS-1$
|
|
||||||
private static final String DELETE_ALL_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.deleteAll.label"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final int PROJECT_LIST_MULTIPLIER = 15;
|
|
||||||
private static final int INITIAL_LIST_WIDTH = 40;
|
|
||||||
|
|
||||||
private static final int ACTIVE = 0;
|
|
||||||
private static final int REMOVED = 1;
|
|
||||||
|
|
||||||
private static final int DO_REMOVE = 0;
|
|
||||||
private static final int DO_RESTORE = 1;
|
|
||||||
|
|
||||||
boolean alreadyCreated; // Set when dialog is created for the first time (vs. reopened)
|
|
||||||
private ArrayList returnSymbols;
|
|
||||||
private ArrayList deletedDiscoveredSymbols;
|
|
||||||
private LinkedHashMap discoveredSymbols;
|
|
||||||
private LinkedHashMap workingDiscoveredSymbols; // working copy of discoveredSymbols, until either OK or CANCEL is pressed
|
|
||||||
private boolean fDirty;
|
|
||||||
private boolean fWorkingDirty;
|
|
||||||
|
|
||||||
private ICOptionContainer fContainer;
|
|
||||||
private IProject fProject;
|
|
||||||
private Shell fShell;
|
|
||||||
private MessageLine fStatusLine;
|
|
||||||
|
|
||||||
private Group discoveredGroup;
|
|
||||||
private Label selectedLabel;
|
|
||||||
private Label removedLabel;
|
|
||||||
private List discActiveList;
|
|
||||||
private List discRemovedList;
|
|
||||||
private Button removeDiscSymbol;
|
|
||||||
private Button restoreDiscSymbol;
|
|
||||||
private Button deleteDiscSymbol;
|
|
||||||
private Button deleteAllDiscSymbols;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parentShell
|
|
||||||
*/
|
|
||||||
protected ManageDefinedSymbolsDialog(Shell parentShell, ICOptionContainer container) {
|
|
||||||
super(parentShell);
|
|
||||||
fShell = parentShell;
|
|
||||||
fContainer = container;
|
|
||||||
fProject = fContainer.getProject();
|
|
||||||
IDiscoveredPathInfo scanInfo;
|
|
||||||
if (fProject != null) {
|
|
||||||
try {
|
|
||||||
scanInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
scanInfo = new DiscoveredPathInfo(fProject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scanInfo = new DiscoveredPathInfo(fProject);
|
|
||||||
}
|
|
||||||
discoveredSymbols = scanInfo.getSymbolMap();
|
|
||||||
setDirty(false);
|
|
||||||
fDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
|
||||||
*/
|
|
||||||
protected void configureShell(Shell newShell) {
|
|
||||||
newShell.setText(getTitle(DIALOG_TITLE));
|
|
||||||
super.configureShell(newShell);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getTitle(String title) {
|
|
||||||
return MakeUIPlugin.getResourceString(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
protected Control createDialogArea(Composite parent) {
|
|
||||||
setDirty(false);
|
|
||||||
Composite composite = (Composite) super.createDialogArea(parent);
|
|
||||||
((GridLayout) composite.getLayout()).numColumns = 3;
|
|
||||||
initializeDialogUnits(composite);
|
|
||||||
|
|
||||||
// create message line
|
|
||||||
fStatusLine = new MessageLine(composite);
|
|
||||||
fStatusLine.setAlignment(SWT.LEFT);
|
|
||||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
||||||
gd.horizontalSpan = 3;
|
|
||||||
// gd.widthHint = convertWidthInCharsToPixels(50);
|
|
||||||
fStatusLine.setLayoutData(gd);
|
|
||||||
fStatusLine.setMessage(getTitle(DIALOG_TITLE));
|
|
||||||
|
|
||||||
createOptionsControls(composite);
|
|
||||||
createDiscoveredControls(composite);
|
|
||||||
|
|
||||||
setListContents();
|
|
||||||
discActiveList.select(0);
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
|
|
||||||
return composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void setListContents() {
|
|
||||||
workingDiscoveredSymbols = new LinkedHashMap(discoveredSymbols);
|
|
||||||
|
|
||||||
discActiveList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, ACTIVE));
|
|
||||||
discRemovedList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, REMOVED));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param discoveredPaths
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String[] getDiscDefinedSymbols(Map dSymbols, int type) {
|
|
||||||
ArrayList aSymbols = new ArrayList();
|
|
||||||
for (Iterator i = dSymbols.keySet().iterator(); i.hasNext(); ) {
|
|
||||||
String symbol = (String) i.next();
|
|
||||||
SymbolEntry values = (SymbolEntry) dSymbols.get(symbol);
|
|
||||||
java.util.List aValues = (type == ACTIVE ? values.getActiveRaw() : values.getRemovedRaw());
|
|
||||||
aSymbols.addAll(aValues);
|
|
||||||
}
|
|
||||||
return (String[]) aSymbols.toArray(new String[aSymbols.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getIncludes(Preferences prefs) {
|
|
||||||
String syms = prefs.getString(PREF_SYMBOLS);
|
|
||||||
return parseStringToList(syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] parseStringToList(String syms) {
|
|
||||||
if (syms != null && syms.length() > 0) {
|
|
||||||
StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
|
|
||||||
ArrayList list = new ArrayList(tok.countTokens());
|
|
||||||
while (tok.hasMoreElements()) {
|
|
||||||
list.add(tok.nextToken());
|
|
||||||
}
|
|
||||||
return (String[]) list.toArray(new String[list.size()]);
|
|
||||||
}
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createOptionsControls(Composite composite) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createDiscoveredControls(Composite composite) {
|
|
||||||
// Create group
|
|
||||||
discoveredGroup = ControlFactory.createGroup(composite, getTitle(DISCOVERED_GROUP), 3);
|
|
||||||
((GridData) discoveredGroup.getLayoutData()).horizontalSpan = 3;
|
|
||||||
((GridData) discoveredGroup.getLayoutData()).grabExcessHorizontalSpace = true;
|
|
||||||
|
|
||||||
// Create composite
|
|
||||||
// Composite c1 = ControlFactory.createComposite(discoveredGroup, 1);
|
|
||||||
Composite c1 = discoveredGroup;
|
|
||||||
|
|
||||||
// Create label Selected:
|
|
||||||
selectedLabel = ControlFactory.createLabel(c1, getTitle(SELECTED_LABEL));
|
|
||||||
((GridData) selectedLabel.getLayoutData()).horizontalSpan = 1;
|
|
||||||
|
|
||||||
// Add a dummy label
|
|
||||||
ControlFactory.createLabel(discoveredGroup, "");//$NON-NLS-1$
|
|
||||||
|
|
||||||
// Create label Removed:
|
|
||||||
removedLabel = ControlFactory.createLabel(c1, getTitle(REMOVED_LABEL));
|
|
||||||
((GridData) removedLabel.getLayoutData()).horizontalSpan = 1;
|
|
||||||
|
|
||||||
// Create list
|
|
||||||
discActiveList = new List(c1, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
|
||||||
discActiveList.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
discRemovedList.deselectAll();
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Make it occupy the first column
|
|
||||||
GridData gd = new GridData(GridData.FILL_BOTH);
|
|
||||||
gd.grabExcessHorizontalSpace = true;
|
|
||||||
gd.horizontalSpan = 1;
|
|
||||||
gd.heightHint = getDefaultFontHeight(discActiveList, PROJECT_LIST_MULTIPLIER);
|
|
||||||
gd.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
|
|
||||||
discActiveList.setLayoutData(gd);
|
|
||||||
|
|
||||||
// Create buttons
|
|
||||||
// Create a composite for the buttons
|
|
||||||
Composite pathButtonComp = ControlFactory.createComposite(discoveredGroup, 1);
|
|
||||||
|
|
||||||
// Add the buttons
|
|
||||||
removeDiscSymbol = ControlFactory.createPushButton(pathButtonComp, getTitle(REMOVE_DISCOVERED));
|
|
||||||
removeDiscSymbol.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleRemoveRestoreDiscSymbol(DO_REMOVE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
removeDiscSymbol.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(removeDiscSymbol);
|
|
||||||
|
|
||||||
restoreDiscSymbol = ControlFactory.createPushButton(pathButtonComp, getTitle(RESTORE_DISCOVERED));
|
|
||||||
restoreDiscSymbol.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleRemoveRestoreDiscSymbol(DO_RESTORE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
restoreDiscSymbol.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(restoreDiscSymbol);
|
|
||||||
|
|
||||||
Label sep = ControlFactory.createSeparator(pathButtonComp, 1);
|
|
||||||
|
|
||||||
deleteDiscSymbol = ControlFactory.createPushButton(pathButtonComp, getTitle(DELETE_DISCOVERED));
|
|
||||||
deleteDiscSymbol.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleDeleteDiscSymbol();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
deleteDiscSymbol.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(deleteDiscSymbol);
|
|
||||||
|
|
||||||
deleteAllDiscSymbols = ControlFactory.createPushButton(pathButtonComp, getTitle(DELETE_ALL_DISCOVERED));
|
|
||||||
deleteAllDiscSymbols.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleDeleteAllDiscSymbols();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
deleteAllDiscSymbols.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(deleteAllDiscSymbols);
|
|
||||||
|
|
||||||
// Create composite
|
|
||||||
// Composite c2 = ControlFactory.createComposite(discoveredGroup, 1);
|
|
||||||
Composite c2 = discoveredGroup;
|
|
||||||
|
|
||||||
// Create list
|
|
||||||
discRemovedList = new List(c2, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
|
||||||
discRemovedList.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
discActiveList.deselectAll();
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Make it occupy the first column
|
|
||||||
GridData gd2 = new GridData(GridData.FILL_BOTH);
|
|
||||||
gd2.grabExcessHorizontalSpace = true;
|
|
||||||
gd2.horizontalSpan = 1;
|
|
||||||
gd2.heightHint = getDefaultFontHeight(discRemovedList, PROJECT_LIST_MULTIPLIER);
|
|
||||||
gd2.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
|
|
||||||
discRemovedList.setLayoutData(gd2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleRemoveRestoreDiscSymbol(int type) {
|
|
||||||
if (workingDiscoveredSymbols != null) {
|
|
||||||
List discList = discRemovedList;
|
|
||||||
List discOtherList = discActiveList;
|
|
||||||
boolean newStatus = true; // active
|
|
||||||
if (type == DO_REMOVE) {
|
|
||||||
discList = discActiveList;
|
|
||||||
discOtherList = discRemovedList;
|
|
||||||
newStatus = false; // removed
|
|
||||||
}
|
|
||||||
|
|
||||||
int id = discList.getSelectionIndex();
|
|
||||||
if (id != -1) {
|
|
||||||
String symbol = discList.getItem(id);
|
|
||||||
String key = ScannerConfigUtil.getSymbolKey(symbol);
|
|
||||||
String value = ScannerConfigUtil.getSymbolValue(symbol);
|
|
||||||
// find it in the discoveredSymbols Map of SymbolEntries
|
|
||||||
SymbolEntry se = (SymbolEntry) workingDiscoveredSymbols.get(key);
|
|
||||||
if (se != null) {
|
|
||||||
se = new SymbolEntry(se); // deep copy
|
|
||||||
se.replace(value, newStatus);
|
|
||||||
workingDiscoveredSymbols.put(key, se);
|
|
||||||
// update UI
|
|
||||||
discActiveList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, ACTIVE));
|
|
||||||
discRemovedList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, REMOVED));
|
|
||||||
discOtherList.setSelection(discOtherList.indexOf(symbol));
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
setDirty(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//TODO VMIR generate an error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleDeleteDiscSymbol() {
|
|
||||||
deleteDiscSymbol(REMOVED);
|
|
||||||
deleteDiscSymbol(ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteDiscSymbol(int type) {
|
|
||||||
List discList = discRemovedList;
|
|
||||||
if (type == ACTIVE) {
|
|
||||||
discList = discActiveList;
|
|
||||||
}
|
|
||||||
int id = discList.getSelectionIndex();
|
|
||||||
if (id >= 0) {
|
|
||||||
String symbol = discList.getItem(id);
|
|
||||||
// add it to the deleted list
|
|
||||||
if (deletedDiscoveredSymbols == null) {
|
|
||||||
deletedDiscoveredSymbols = new ArrayList();
|
|
||||||
}
|
|
||||||
deletedDiscoveredSymbols.add(symbol);
|
|
||||||
|
|
||||||
// remove it from the Map of SymbolEntries
|
|
||||||
ScannerConfigUtil.removeSymbolEntryValue(symbol, workingDiscoveredSymbols);
|
|
||||||
|
|
||||||
int items = discList.getItemCount();
|
|
||||||
discList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, type));
|
|
||||||
if (items > 0) {
|
|
||||||
if (id >= items) {
|
|
||||||
id = items - 1;
|
|
||||||
}
|
|
||||||
discList.setSelection(id);
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
setDirty(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleDeleteAllDiscSymbols() {
|
|
||||||
ScannerInfoCollector.getInstance().deleteAllSymbols(fProject);
|
|
||||||
workingDiscoveredSymbols.clear();
|
|
||||||
discActiveList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, ACTIVE));
|
|
||||||
discRemovedList.setItems(getDiscDefinedSymbols(workingDiscoveredSymbols, REMOVED));
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
setDirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void enableDiscoveredButtons() {
|
|
||||||
discoveredGroup.setEnabled(fProject != null);
|
|
||||||
selectedLabel.setEnabled(fProject != null);
|
|
||||||
discActiveList.setEnabled(fProject != null);
|
|
||||||
removedLabel.setEnabled(fProject != null);
|
|
||||||
discRemovedList.setEnabled(fProject != null);
|
|
||||||
|
|
||||||
int activeItems = discActiveList.getItemCount();
|
|
||||||
int activeSeclection = discActiveList.getSelectionIndex();
|
|
||||||
int removedItems = discRemovedList.getItemCount();
|
|
||||||
int removedSelection = discRemovedList.getSelectionIndex();
|
|
||||||
// To maintain the proper TAB order of enabled buttons
|
|
||||||
if (activeItems > 0 && activeSeclection >= 0) {
|
|
||||||
removeDiscSymbol.setEnabled(activeItems > 0 && activeSeclection >= 0);
|
|
||||||
restoreDiscSymbol.setEnabled(removedItems > 0 && removedSelection >= 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
restoreDiscSymbol.setEnabled(removedItems > 0 && removedSelection >= 0);
|
|
||||||
removeDiscSymbol.setEnabled(activeItems > 0 && activeSeclection >= 0);
|
|
||||||
}
|
|
||||||
deleteDiscSymbol.setEnabled((activeItems > 0 && activeSeclection >= 0) ||
|
|
||||||
(removedItems > 0 && removedSelection >= 0));
|
|
||||||
deleteAllDiscSymbols.setEnabled(activeItems > 0 || removedItems > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the defualt widget height for the supplied control.
|
|
||||||
* @return int
|
|
||||||
* @param control - the control being queried about fonts
|
|
||||||
* @param lines - the number of lines to be shown on the table.
|
|
||||||
*/
|
|
||||||
private static int getDefaultFontHeight(Control control, int lines) {
|
|
||||||
FontData[] viewerFontData = control.getFont().getFontData();
|
|
||||||
int fontHeight = 10;
|
|
||||||
|
|
||||||
//If we have no font data use our guess
|
|
||||||
if (viewerFontData.length > 0)
|
|
||||||
fontHeight = viewerFontData[0].getHeight();
|
|
||||||
return lines * fontHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String[] getManagedSymbols() {
|
|
||||||
if (returnSymbols == null) {
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
return (String[]) returnSymbols.toArray(new String[returnSymbols.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
|
|
||||||
*/
|
|
||||||
protected void buttonPressed(int buttonId) {
|
|
||||||
if (IDialogConstants.OK_ID == buttonId) {
|
|
||||||
// Store discovered part
|
|
||||||
discoveredSymbols = workingDiscoveredSymbols;
|
|
||||||
// Return sum of user and active discovered paths
|
|
||||||
returnSymbols = new ArrayList(discActiveList.getItemCount());
|
|
||||||
returnSymbols.addAll(new ArrayList(Arrays.asList(discActiveList.getItems())));
|
|
||||||
|
|
||||||
fDirty = fWorkingDirty;
|
|
||||||
}
|
|
||||||
else if (IDialogConstants.CANCEL_ID == buttonId) {
|
|
||||||
deletedDiscoveredSymbols = null;
|
|
||||||
workingDiscoveredSymbols = null;
|
|
||||||
setDirty(false);
|
|
||||||
}
|
|
||||||
super.buttonPressed(buttonId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDirty(boolean dirty) {
|
|
||||||
fWorkingDirty = dirty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by BuildPathInfoBlock.performApply
|
|
||||||
* @param info
|
|
||||||
* @return boolean - true if changed
|
|
||||||
*/
|
|
||||||
public boolean saveTo(IDiscoveredPathInfo info) {
|
|
||||||
if (fDirty || (fProject == null && fContainer.getProject() != null)) {// New Standard Make project wizard
|
|
||||||
info.setSymbolMap(discoveredSymbols);
|
|
||||||
// remove deleted symbols from discovered SC
|
|
||||||
if (deletedDiscoveredSymbols != null) {
|
|
||||||
for (Iterator i = deletedDiscoveredSymbols.iterator(); i.hasNext(); ) {
|
|
||||||
ScannerInfoCollector.getInstance().deleteSymbol(fProject, (String) i.next());
|
|
||||||
}
|
|
||||||
deletedDiscoveredSymbols = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setDirty(false);
|
|
||||||
boolean rc = fDirty;
|
|
||||||
fDirty = false;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by BuildPathInfoBlock.performDefaults
|
|
||||||
*/
|
|
||||||
public void restore() {
|
|
||||||
if (fProject != null) {
|
|
||||||
// remove discovered symbols
|
|
||||||
ScannerInfoCollector.getInstance().deleteAllSymbols(fProject);
|
|
||||||
}
|
|
||||||
discoveredSymbols = new LinkedHashMap();
|
|
||||||
deletedDiscoveredSymbols = null;
|
|
||||||
fDirty = true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,598 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-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.LinkedHashMap;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.DiscoveredPathInfo;
|
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoCollector;
|
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
|
||||||
import org.eclipse.cdt.make.internal.ui.MessageLine;
|
|
||||||
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.jface.dialogs.Dialog;
|
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
|
||||||
import org.eclipse.swt.graphics.FontData;
|
|
||||||
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.Control;
|
|
||||||
import org.eclipse.swt.widgets.Group;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.List;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage include paths dialog
|
|
||||||
*
|
|
||||||
* @author vhirsl
|
|
||||||
*/
|
|
||||||
public class ManageIncludePathsDialog extends Dialog {
|
|
||||||
private static final String PREF_INCLUDES = "ScannerIncludes"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String PREFIX = "ManageIncludePathsDialog"; //$NON-NLS-1$
|
|
||||||
private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
|
|
||||||
private static final String USER_GROUP = PREFIX + ".userGroup.title"; //$NON-NLS-1$
|
|
||||||
private static final String NEW = "BuildPropertyCommon.label.new"; //$NON-NLS-1$
|
|
||||||
private static final String EDIT = "BuildPropertyCommon.label.edit"; //$NON-NLS-1$
|
|
||||||
private static final String REMOVE = "BuildPropertyCommon.label.remove"; //$NON-NLS-1$
|
|
||||||
private static final String UP = "BuildPropertyCommon.label.up"; //$NON-NLS-1$
|
|
||||||
private static final String DOWN = "BuildPropertyCommon.label.down"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String BROWSE = "BuildPathInfoBlock.browse"; //$NON-NLS-1$
|
|
||||||
private static final String PATH_TITLE = BROWSE + ".path"; //$NON-NLS-1$
|
|
||||||
private static final String EDIT_PATH_TITLE = BROWSE + ".path.edit"; //$NON-NLS-1$
|
|
||||||
private static final String PATH_LABEL = BROWSE + ".path.label"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String DISCOVERED_GROUP = PREFIX + ".discoveredGroup.title"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final String DISC_COMMON_PREFIX = "ManageScannerConfigDialogCommon"; //$NON-NLS-1$
|
|
||||||
private static final String SELECTED_LABEL = DISC_COMMON_PREFIX + ".discoveredGroup.selected.label"; //$NON-NLS-1$
|
|
||||||
private static final String REMOVED_LABEL = DISC_COMMON_PREFIX + ".discoveredGroup.removed.label"; //$NON-NLS-1$
|
|
||||||
private static final String UP_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.up.label"; //$NON-NLS-1$
|
|
||||||
private static final String DOWN_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.down.label"; //$NON-NLS-1$
|
|
||||||
private static final String REMOVE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.remove.label"; //$NON-NLS-1$
|
|
||||||
private static final String RESTORE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.restore.label"; //$NON-NLS-1$
|
|
||||||
private static final String DELETE_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.delete.label"; //$NON-NLS-1$
|
|
||||||
private static final String DELETE_ALL_DISCOVERED = DISC_COMMON_PREFIX + ".discoveredGroup.buttons.deleteAll.label"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static final int PROJECT_LIST_MULTIPLIER = 15;
|
|
||||||
private static final int INITIAL_LIST_WIDTH = 50;
|
|
||||||
|
|
||||||
private static final int ACTIVE = 0;
|
|
||||||
private static final int REMOVED = 1;
|
|
||||||
|
|
||||||
private static final int DO_REMOVE = 0;
|
|
||||||
private static final int DO_RESTORE = 1;
|
|
||||||
|
|
||||||
private static final int DISC_UP = 0;
|
|
||||||
private static final int DISC_DOWN = 1;
|
|
||||||
|
|
||||||
private ArrayList returnPaths;
|
|
||||||
private ArrayList deletedDiscoveredPaths;
|
|
||||||
private LinkedHashMap discoveredPaths;
|
|
||||||
private LinkedHashMap workingDiscoveredPaths; // working copy of discoveredPaths, until either OK or CANCEL is pressed
|
|
||||||
private boolean fDirty;
|
|
||||||
private boolean fWorkingDirty;
|
|
||||||
|
|
||||||
private ICOptionContainer fContainer;
|
|
||||||
private IProject fProject;
|
|
||||||
private Shell fShell;
|
|
||||||
private MessageLine fStatusLine;
|
|
||||||
|
|
||||||
private Group discoveredGroup;
|
|
||||||
private Label selectedLabel;
|
|
||||||
private Label removedLabel;
|
|
||||||
private List discActiveList;
|
|
||||||
private List discRemovedList;
|
|
||||||
private Button upDiscPath;
|
|
||||||
private Button downDiscPath;
|
|
||||||
private Button removeDiscPath;
|
|
||||||
private Button restoreDiscPath;
|
|
||||||
private Button deleteDiscPath;
|
|
||||||
private Button deleteAllDiscPaths;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parentShell
|
|
||||||
*/
|
|
||||||
protected ManageIncludePathsDialog(Shell parentShell, ICOptionContainer container) {
|
|
||||||
super(parentShell);
|
|
||||||
fShell = parentShell;
|
|
||||||
fContainer = container;
|
|
||||||
fProject = fContainer.getProject();
|
|
||||||
IDiscoveredPathInfo scanInfo;
|
|
||||||
if (fProject != null) {
|
|
||||||
try {
|
|
||||||
scanInfo = MakeCorePlugin.getDefault().getDiscoveryManager().getDiscoveredInfo(fProject);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
scanInfo = new DiscoveredPathInfo(fProject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scanInfo = new DiscoveredPathInfo(fProject);
|
|
||||||
}
|
|
||||||
discoveredPaths = scanInfo.getIncludeMap();
|
|
||||||
setDirty(false);
|
|
||||||
fDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
|
||||||
*/
|
|
||||||
protected void configureShell(Shell newShell) {
|
|
||||||
newShell.setText(getTitle(DIALOG_TITLE));
|
|
||||||
super.configureShell(newShell);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String getTitle(String title) {
|
|
||||||
return MakeUIPlugin.getResourceString(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
protected Control createDialogArea(Composite parent) {
|
|
||||||
Composite composite = (Composite) super.createDialogArea(parent);
|
|
||||||
((GridLayout) composite.getLayout()).numColumns = 3;
|
|
||||||
initializeDialogUnits(composite);
|
|
||||||
|
|
||||||
// create message line
|
|
||||||
fStatusLine = new MessageLine(composite);
|
|
||||||
fStatusLine.setAlignment(SWT.LEFT);
|
|
||||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
||||||
gd.horizontalSpan = 3;
|
|
||||||
// gd.widthHint = convertWidthInCharsToPixels(50);
|
|
||||||
fStatusLine.setLayoutData(gd);
|
|
||||||
fStatusLine.setMessage(getTitle(DIALOG_TITLE));
|
|
||||||
|
|
||||||
createOptionsControls(composite);
|
|
||||||
createDiscoveredControls(composite);
|
|
||||||
|
|
||||||
setListContents();
|
|
||||||
discActiveList.select(0);
|
|
||||||
discActiveList.setFocus();
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
|
|
||||||
return composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void setListContents() {
|
|
||||||
workingDiscoveredPaths = new LinkedHashMap(discoveredPaths);
|
|
||||||
|
|
||||||
discActiveList.setItems(getDiscIncludePaths(workingDiscoveredPaths, ACTIVE));
|
|
||||||
discRemovedList.setItems(getDiscIncludePaths(workingDiscoveredPaths, REMOVED));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param discoveredPaths
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private String[] getDiscIncludePaths(LinkedHashMap dPaths, int type) {
|
|
||||||
ArrayList aPaths = new ArrayList();
|
|
||||||
boolean compareValue = (type == ACTIVE ? false : true);
|
|
||||||
for (Iterator i = dPaths.keySet().iterator(); i.hasNext(); ) {
|
|
||||||
String path = (String) i.next();
|
|
||||||
if (((Boolean) dPaths.get(path)).booleanValue() == compareValue) {
|
|
||||||
aPaths.add(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (String[]) aPaths.toArray(new String[aPaths.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getIncludes(Preferences prefs) {
|
|
||||||
String syms = prefs.getString(PREF_INCLUDES);
|
|
||||||
return parseStringToList(syms);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] parseStringToList(String syms) {
|
|
||||||
if (syms != null && syms.length() > 0) {
|
|
||||||
StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
|
|
||||||
ArrayList list = new ArrayList(tok.countTokens());
|
|
||||||
while (tok.hasMoreElements()) {
|
|
||||||
list.add(tok.nextToken());
|
|
||||||
}
|
|
||||||
return (String[]) list.toArray(new String[list.size()]);
|
|
||||||
}
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createOptionsControls(Composite composite) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param composite
|
|
||||||
*/
|
|
||||||
private void createDiscoveredControls(Composite composite) {
|
|
||||||
// Create group
|
|
||||||
discoveredGroup = ControlFactory.createGroup(composite, getTitle(DISCOVERED_GROUP), 3);
|
|
||||||
((GridData) discoveredGroup.getLayoutData()).horizontalSpan = 3;
|
|
||||||
((GridData) discoveredGroup.getLayoutData()).grabExcessHorizontalSpace = true;
|
|
||||||
|
|
||||||
// Create label Selected:
|
|
||||||
selectedLabel = ControlFactory.createLabel(discoveredGroup, getTitle(SELECTED_LABEL));
|
|
||||||
((GridData) selectedLabel.getLayoutData()).horizontalSpan = 1;
|
|
||||||
|
|
||||||
// Add a dummy label
|
|
||||||
ControlFactory.createLabel(discoveredGroup, "");//$NON-NLS-1$
|
|
||||||
|
|
||||||
// Create label Removed:
|
|
||||||
removedLabel = ControlFactory.createLabel(discoveredGroup, getTitle(REMOVED_LABEL));
|
|
||||||
((GridData) removedLabel.getLayoutData()).horizontalSpan = 1;
|
|
||||||
|
|
||||||
// Create list
|
|
||||||
discActiveList = new List(discoveredGroup, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
|
||||||
discActiveList.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
discRemovedList.deselectAll();
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Make it occupy the first column
|
|
||||||
GridData gd = new GridData(GridData.FILL_BOTH);
|
|
||||||
gd.grabExcessHorizontalSpace = true;
|
|
||||||
gd.horizontalSpan = 1;
|
|
||||||
gd.heightHint = getDefaultFontHeight(discActiveList, PROJECT_LIST_MULTIPLIER);
|
|
||||||
gd.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
|
|
||||||
discActiveList.setLayoutData(gd);
|
|
||||||
|
|
||||||
// Create buttons
|
|
||||||
// Create a composite for the buttons
|
|
||||||
Composite pathButtonComp = ControlFactory.createComposite(discoveredGroup, 1);
|
|
||||||
|
|
||||||
// Add the buttons
|
|
||||||
upDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(UP_DISCOVERED));
|
|
||||||
upDiscPath.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleUpDownDiscPath(DISC_UP);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
upDiscPath.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(upDiscPath);
|
|
||||||
|
|
||||||
downDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(DOWN_DISCOVERED));
|
|
||||||
downDiscPath.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleUpDownDiscPath(DISC_DOWN);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
downDiscPath.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(downDiscPath);
|
|
||||||
|
|
||||||
removeDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(REMOVE_DISCOVERED));
|
|
||||||
removeDiscPath.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleRemoveRestoreDiscPath(DO_REMOVE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
removeDiscPath.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(removeDiscPath);
|
|
||||||
|
|
||||||
restoreDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(RESTORE_DISCOVERED));
|
|
||||||
restoreDiscPath.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleRemoveRestoreDiscPath(DO_RESTORE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
restoreDiscPath.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(restoreDiscPath);
|
|
||||||
|
|
||||||
Label sep = ControlFactory.createSeparator(pathButtonComp, 1);
|
|
||||||
|
|
||||||
deleteDiscPath = ControlFactory.createPushButton(pathButtonComp, getTitle(DELETE_DISCOVERED));
|
|
||||||
deleteDiscPath.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleDeleteDiscPath();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
deleteDiscPath.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(deleteDiscPath);
|
|
||||||
|
|
||||||
deleteAllDiscPaths = ControlFactory.createPushButton(pathButtonComp, getTitle(DELETE_ALL_DISCOVERED));
|
|
||||||
deleteAllDiscPaths.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
handleDeleteAllDiscPath();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
deleteAllDiscPaths.setEnabled(true);
|
|
||||||
SWTUtil.setButtonDimensionHint(deleteAllDiscPaths);
|
|
||||||
|
|
||||||
// Create list
|
|
||||||
discRemovedList = new List(discoveredGroup, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
|
|
||||||
discRemovedList.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
discActiveList.deselectAll();
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Make it occupy the first column
|
|
||||||
GridData gd2 = new GridData(GridData.FILL_BOTH);
|
|
||||||
gd2.grabExcessHorizontalSpace = true;
|
|
||||||
gd2.horizontalSpan = 1;
|
|
||||||
gd2.heightHint = getDefaultFontHeight(discRemovedList, PROJECT_LIST_MULTIPLIER);
|
|
||||||
gd2.widthHint = convertWidthInCharsToPixels(INITIAL_LIST_WIDTH);
|
|
||||||
discRemovedList.setLayoutData(gd2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param direction (DISC_UP or DISC_DOWN)
|
|
||||||
*/
|
|
||||||
protected void handleUpDownDiscPath(int direction) {
|
|
||||||
int delta = (direction == DISC_UP) ? -1 : 1;
|
|
||||||
List selectedList;
|
|
||||||
boolean removed;
|
|
||||||
int selectedSet;
|
|
||||||
if (discActiveList.getSelectionIndex() == -1) {
|
|
||||||
selectedList = discRemovedList;
|
|
||||||
removed = true;
|
|
||||||
selectedSet = REMOVED;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
selectedList = discActiveList;
|
|
||||||
removed = false;
|
|
||||||
selectedSet = ACTIVE;
|
|
||||||
}
|
|
||||||
int selectedItem = selectedList.getFocusIndex();
|
|
||||||
String selected = selectedList.getItem(selectedItem);
|
|
||||||
ArrayList pathKeyList = new ArrayList(workingDiscoveredPaths.keySet());
|
|
||||||
int curIndex = pathKeyList.indexOf(selected);
|
|
||||||
int otherIndex = curIndex + delta;
|
|
||||||
boolean found = false;
|
|
||||||
for (; otherIndex >= 0 && otherIndex < pathKeyList.size(); otherIndex+=delta) {
|
|
||||||
Boolean val = (Boolean) workingDiscoveredPaths.get(pathKeyList.get(otherIndex));
|
|
||||||
if (val != null && val.booleanValue() == removed) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) {
|
|
||||||
// swap the entries in the working copy
|
|
||||||
String temp = (String) pathKeyList.get(curIndex);
|
|
||||||
pathKeyList.add(curIndex, pathKeyList.get(otherIndex));
|
|
||||||
pathKeyList.add(otherIndex, temp);
|
|
||||||
|
|
||||||
LinkedHashMap newWorkingDiscoveredPaths = new LinkedHashMap(workingDiscoveredPaths.size());
|
|
||||||
for (Iterator i = pathKeyList.iterator(); i.hasNext(); ) {
|
|
||||||
String key = (String) i.next();
|
|
||||||
newWorkingDiscoveredPaths.put(key, workingDiscoveredPaths.get(key));
|
|
||||||
}
|
|
||||||
workingDiscoveredPaths = newWorkingDiscoveredPaths;
|
|
||||||
// update UI
|
|
||||||
selectedList.setItems(getDiscIncludePaths(workingDiscoveredPaths, selectedSet));
|
|
||||||
selectedList.setSelection(selectedItem + delta);
|
|
||||||
selectedList.setFocus();
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
setDirty(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleRemoveRestoreDiscPath(int type) {
|
|
||||||
if (workingDiscoveredPaths != null) {
|
|
||||||
List discList = discRemovedList;
|
|
||||||
List discOtherList = discActiveList;
|
|
||||||
boolean compareValue = true; // removed
|
|
||||||
if (type == DO_REMOVE) {
|
|
||||||
discList = discActiveList;
|
|
||||||
discOtherList = discRemovedList;
|
|
||||||
compareValue = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int id = discList.getSelectionIndex();
|
|
||||||
if (id != -1) {
|
|
||||||
String path = discList.getItem(id);
|
|
||||||
// find it in the discoveredPaths LinkedHashMap
|
|
||||||
Boolean value = (Boolean) workingDiscoveredPaths.get(path);
|
|
||||||
if (value != null) {
|
|
||||||
if (value.booleanValue() == compareValue) {
|
|
||||||
workingDiscoveredPaths.put(path, Boolean.valueOf(!compareValue));
|
|
||||||
// update UI
|
|
||||||
discActiveList.setItems(getDiscIncludePaths(workingDiscoveredPaths, ACTIVE));
|
|
||||||
discRemovedList.setItems(getDiscIncludePaths(workingDiscoveredPaths, REMOVED));
|
|
||||||
discOtherList.setSelection(discOtherList.indexOf(path));
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
setDirty(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleDeleteDiscPath() {
|
|
||||||
deleteDiscPath(REMOVED);
|
|
||||||
deleteDiscPath(ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param discList
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
private void deleteDiscPath(int type) {
|
|
||||||
List discList = discRemovedList;
|
|
||||||
if (type == ACTIVE) {
|
|
||||||
discList = discActiveList;
|
|
||||||
}
|
|
||||||
int id = discList.getSelectionIndex();
|
|
||||||
if (id >= 0) {
|
|
||||||
String path = discList.getItem(id);
|
|
||||||
// add it to the deleted list
|
|
||||||
if (deletedDiscoveredPaths == null) {
|
|
||||||
deletedDiscoveredPaths = new ArrayList();
|
|
||||||
}
|
|
||||||
deletedDiscoveredPaths.add(path);
|
|
||||||
|
|
||||||
workingDiscoveredPaths.remove(path);
|
|
||||||
discList.setItems(getDiscIncludePaths(workingDiscoveredPaths, type));
|
|
||||||
int items = discList.getItemCount();
|
|
||||||
if (items > 0) {
|
|
||||||
if (id >= items) {
|
|
||||||
id = items - 1;
|
|
||||||
}
|
|
||||||
discList.setSelection(id);
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
setDirty(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleDeleteAllDiscPath() {
|
|
||||||
ScannerInfoCollector.getInstance().deleteAllPaths(fProject);
|
|
||||||
workingDiscoveredPaths.clear();
|
|
||||||
discActiveList.setItems(getDiscIncludePaths(workingDiscoveredPaths, ACTIVE));
|
|
||||||
discRemovedList.setItems(getDiscIncludePaths(workingDiscoveredPaths, REMOVED));
|
|
||||||
enableDiscoveredButtons();
|
|
||||||
setDirty(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void enableDiscoveredButtons() {
|
|
||||||
discoveredGroup.setEnabled(fProject != null);
|
|
||||||
selectedLabel.setEnabled(fProject != null);
|
|
||||||
discActiveList.setEnabled(fProject != null);
|
|
||||||
removedLabel.setEnabled(fProject != null);
|
|
||||||
discRemovedList.setEnabled(fProject != null);
|
|
||||||
|
|
||||||
int activeItems = discActiveList.getItemCount();
|
|
||||||
int activeSelection = discActiveList.getSelectionIndex();
|
|
||||||
int removedItems = discRemovedList.getItemCount();
|
|
||||||
int removedSelection = discRemovedList.getSelectionIndex();
|
|
||||||
// To maintain the proper TAB order of enabled buttons
|
|
||||||
upDiscPath.setEnabled((activeItems > 0 && activeSelection > 0) ||
|
|
||||||
(removedItems > 0 && removedSelection > 0));
|
|
||||||
downDiscPath.setEnabled((activeItems > 0 && activeSelection >= 0 && activeSelection < activeItems-1) ||
|
|
||||||
(removedItems > 0 && removedSelection >= 0 && removedSelection < removedItems-1));
|
|
||||||
removeDiscPath.setEnabled(activeItems > 0 && activeSelection >= 0);
|
|
||||||
restoreDiscPath.setEnabled(removedItems > 0 && removedSelection >= 0);
|
|
||||||
deleteDiscPath.setEnabled((activeItems > 0 && activeSelection >= 0) ||
|
|
||||||
(removedItems > 0 && removedSelection >= 0));
|
|
||||||
deleteAllDiscPaths.setEnabled(activeItems > 0 || removedItems > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the defualt widget height for the supplied control.
|
|
||||||
* @return int
|
|
||||||
* @param control - the control being queried about fonts
|
|
||||||
* @param lines - the number of lines to be shown on the table.
|
|
||||||
*/
|
|
||||||
private static int getDefaultFontHeight(Control control, int lines) {
|
|
||||||
FontData[] viewerFontData = control.getFont().getFontData();
|
|
||||||
int fontHeight = 10;
|
|
||||||
|
|
||||||
//If we have no font data use our guess
|
|
||||||
if (viewerFontData.length > 0)
|
|
||||||
fontHeight = viewerFontData[0].getHeight();
|
|
||||||
return lines * fontHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String[] getManagedIncludes() {
|
|
||||||
if (returnPaths == null) {
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
return (String[]) returnPaths.toArray(new String[returnPaths.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
|
|
||||||
*/
|
|
||||||
protected void buttonPressed(int buttonId) {
|
|
||||||
if (IDialogConstants.OK_ID == buttonId) {
|
|
||||||
// Store discovered part
|
|
||||||
discoveredPaths = workingDiscoveredPaths;
|
|
||||||
// Return sum of user and active discovered paths
|
|
||||||
returnPaths = new ArrayList(discActiveList.getItemCount());
|
|
||||||
returnPaths.addAll(new ArrayList(Arrays.asList(discActiveList.getItems())));
|
|
||||||
|
|
||||||
fDirty = fWorkingDirty;
|
|
||||||
}
|
|
||||||
else if (IDialogConstants.CANCEL_ID == buttonId) {
|
|
||||||
deletedDiscoveredPaths = null;
|
|
||||||
workingDiscoveredPaths = null;
|
|
||||||
setDirty(false);
|
|
||||||
}
|
|
||||||
super.buttonPressed(buttonId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDirty(boolean dirty) {
|
|
||||||
fWorkingDirty = dirty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by BuildPathInfoBlock.performApply
|
|
||||||
* @param info
|
|
||||||
* @return boolean - true if changed
|
|
||||||
*/
|
|
||||||
public boolean saveTo(IDiscoveredPathInfo info) {
|
|
||||||
if (fDirty || (fProject == null && fContainer.getProject() != null)) {// New Standard Make project wizard
|
|
||||||
info.setIncludeMap(discoveredPaths);
|
|
||||||
// remove deleted paths from discovered SC
|
|
||||||
if (deletedDiscoveredPaths != null) {
|
|
||||||
for (Iterator i = deletedDiscoveredPaths.iterator(); i.hasNext(); ) {
|
|
||||||
ScannerInfoCollector.getInstance().deletePath(fProject, (String) i.next());
|
|
||||||
}
|
|
||||||
deletedDiscoveredPaths = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setDirty(false);
|
|
||||||
boolean rc = fDirty;
|
|
||||||
fDirty = false;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by BuildPathInfoBlock.performDefaults
|
|
||||||
*/
|
|
||||||
public void restore() {
|
|
||||||
if (fProject != null) {
|
|
||||||
// remove discovered paths
|
|
||||||
ScannerInfoCollector.getInstance().deleteAllPaths(fProject);
|
|
||||||
}
|
|
||||||
discoveredPaths = new LinkedHashMap();
|
|
||||||
deletedDiscoveredPaths = null;
|
|
||||||
fDirty = true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,576 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM - Initial API and implementation
|
|
||||||
**********************************************************************/
|
|
||||||
package org.eclipse.cdt.make.ui.dialogs;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigBuilder;
|
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
|
||||||
import org.eclipse.cdt.make.internal.ui.MessageLine;
|
|
||||||
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.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.Path;
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.Preferences;
|
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
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.Combo;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.widgets.Event;
|
|
||||||
import org.eclipse.swt.widgets.Group;
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
|
||||||
import org.eclipse.swt.widgets.Listener;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A dialog to set scanner config discovery options
|
|
||||||
*
|
|
||||||
* @author vhirsl
|
|
||||||
*/
|
|
||||||
public class ScannerConfigOptionsDialog extends Dialog {
|
|
||||||
private static final String PREFIX = "ScannerConfigOptionsDialog"; //$NON-NLS-1$
|
|
||||||
private static final String DIALOG_TITLE = PREFIX + ".title"; //$NON-NLS-1$
|
|
||||||
private static final String SI_BUILD_PARSER_GROUP = PREFIX + ".siBuilder.parser.group_label"; //$NON-NLS-1$
|
|
||||||
private static final String ENABLE_SI_BUILD_PARSER = PREFIX + ".siBuilder.parser.enable.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_BUILD_PARSER_LABEL = PREFIX + ".siBuilder.parser.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_CMD_GROUP = PREFIX + ".siProvider.cmd.group_label"; //$NON-NLS-1$
|
|
||||||
private static final String ENABLE_SI_PROVIDER_COMMAND = PREFIX + ".siProvider.cmd.enable.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_CMD_USE_DEFAULT = PREFIX + ".siProvider.cmd.use_default"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_CMD_LABEL = PREFIX + ".siProvider.cmd.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_PARSER_LABEL = PREFIX + ".siProvider.parser.label"; //$NON-NLS-1$
|
|
||||||
private static final String SI_PROVIDER_CMD_ERROR_MESSAGE = PREFIX + ".siProvider.cmd.error_message"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private MessageLine fStatusLine;
|
|
||||||
private Button defESIProviderCommandButton;
|
|
||||||
private Text esiProviderCommand;
|
|
||||||
private Button enableBuilderParserButton;
|
|
||||||
private Combo makeBuilderSIParserComboBox;
|
|
||||||
private Button enableProviderCommandButton;
|
|
||||||
private Combo esiProviderParserComboBox;
|
|
||||||
|
|
||||||
private ICOptionContainer fContainer;
|
|
||||||
private Preferences fPrefs;
|
|
||||||
private IScannerConfigBuilderInfo fBuildInfo;
|
|
||||||
private boolean fInitialized;
|
|
||||||
private Map builderParsers = new HashMap();
|
|
||||||
private String initialBuilderParserId = null;
|
|
||||||
private Map providerParsers = new HashMap();
|
|
||||||
private String initialProviderParserId = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Local store for Scanner Config discovery setting
|
|
||||||
*
|
|
||||||
* @author vhirsl
|
|
||||||
*/
|
|
||||||
protected class LocalStore implements IScannerConfigBuilderInfo {
|
|
||||||
private boolean fAutoDiscoveryEnabled;
|
|
||||||
private boolean fMakeBuilderConsoleParserEnabled;
|
|
||||||
private String fMakeBuilderConsoleParserId;
|
|
||||||
private boolean fESIProviderCommandEnabled;
|
|
||||||
private boolean fDefaultESIProviderCmd;
|
|
||||||
private IPath fESIProviderCommand;
|
|
||||||
private String fESIProviderArguments;
|
|
||||||
private String fESIProviderConsoleParserId;
|
|
||||||
private boolean fSIParserGenerationEnabled;
|
|
||||||
|
|
||||||
public LocalStore(IScannerConfigBuilderInfo info) {
|
|
||||||
try {
|
|
||||||
setAutoDiscoveryEnabled(info.isAutoDiscoveryEnabled());
|
|
||||||
setMakeBuilderConsoleParserEnabled(info.isMakeBuilderConsoleParserEnabled());
|
|
||||||
setMakeBuilderConsoleParserId(info.getMakeBuilderConsoleParserId());
|
|
||||||
setESIProviderCommandEnabled(info.isESIProviderCommandEnabled());
|
|
||||||
setUseDefaultESIProviderCmd(info.isDefaultESIProviderCmd());
|
|
||||||
setESIProviderCommand(info.getESIProviderCommand());
|
|
||||||
setESIProviderArguments(info.getESIProviderArguments());
|
|
||||||
setESIProviderConsoleParserId(info.getESIProviderConsoleParserId());
|
|
||||||
setSIProblemGenerationEnabled(info.isSIProblemGenerationEnabled());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAutoDiscoveryEnabled() {
|
|
||||||
return fAutoDiscoveryEnabled;
|
|
||||||
}
|
|
||||||
public void setAutoDiscoveryEnabled(boolean enabled) throws CoreException {
|
|
||||||
fAutoDiscoveryEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMakeBuilderConsoleParserEnabled() {
|
|
||||||
return fMakeBuilderConsoleParserEnabled;
|
|
||||||
}
|
|
||||||
public void setMakeBuilderConsoleParserEnabled(boolean enabled) throws CoreException {
|
|
||||||
fMakeBuilderConsoleParserEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMakeBuilderConsoleParserId() {
|
|
||||||
return fMakeBuilderConsoleParserId;
|
|
||||||
}
|
|
||||||
public void setMakeBuilderConsoleParserId(String parserId) throws CoreException {
|
|
||||||
fMakeBuilderConsoleParserId = new String(parserId);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isESIProviderCommandEnabled() {
|
|
||||||
return fESIProviderCommandEnabled;
|
|
||||||
}
|
|
||||||
public void setESIProviderCommandEnabled(boolean enabled) throws CoreException {
|
|
||||||
fESIProviderCommandEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDefaultESIProviderCmd() {
|
|
||||||
return fDefaultESIProviderCmd;
|
|
||||||
}
|
|
||||||
public void setUseDefaultESIProviderCmd(boolean on) throws CoreException {
|
|
||||||
fDefaultESIProviderCmd = on;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IPath getESIProviderCommand() {
|
|
||||||
return fESIProviderCommand;
|
|
||||||
}
|
|
||||||
public void setESIProviderCommand(IPath command) throws CoreException {
|
|
||||||
fESIProviderCommand = new Path(command.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getESIProviderArguments() {
|
|
||||||
return fESIProviderArguments;
|
|
||||||
}
|
|
||||||
public void setESIProviderArguments(String args) throws CoreException {
|
|
||||||
fESIProviderArguments = new String(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getESIProviderConsoleParserId() {
|
|
||||||
return fESIProviderConsoleParserId;
|
|
||||||
}
|
|
||||||
public void setESIProviderConsoleParserId(String parserId) throws CoreException {
|
|
||||||
fESIProviderConsoleParserId = new String(parserId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSIProblemGenerationEnabled() {
|
|
||||||
return fSIParserGenerationEnabled;
|
|
||||||
}
|
|
||||||
public void setSIProblemGenerationEnabled(boolean enabled) throws CoreException {
|
|
||||||
fSIParserGenerationEnabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A temporary page to retrieve SC options from preferences
|
|
||||||
* Not to be shown
|
|
||||||
*
|
|
||||||
* @param container
|
|
||||||
*/
|
|
||||||
ScannerConfigOptionsDialog(ICOptionContainer container) {
|
|
||||||
super(null);
|
|
||||||
fInitialized = false;
|
|
||||||
fContainer = container;
|
|
||||||
fPrefs = fContainer.getPreferences();
|
|
||||||
IScannerConfigBuilderInfo fInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
|
|
||||||
// Create local store
|
|
||||||
fBuildInfo = new LocalStore(fInfo);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param parentShell
|
|
||||||
* @param container
|
|
||||||
*/
|
|
||||||
ScannerConfigOptionsDialog(Shell parentShell, ICOptionContainer container) {
|
|
||||||
super(parentShell);
|
|
||||||
fInitialized = true;
|
|
||||||
fContainer = container;
|
|
||||||
IProject project = fContainer.getProject();
|
|
||||||
fPrefs = fContainer.getPreferences();
|
|
||||||
|
|
||||||
IScannerConfigBuilderInfo fInfo;
|
|
||||||
if (project != null) {
|
|
||||||
try {
|
|
||||||
fInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
fInitialized = false;
|
|
||||||
fInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
|
|
||||||
}
|
|
||||||
retrieveSIConsoleParsers();
|
|
||||||
initialBuilderParserId = fInfo.getMakeBuilderConsoleParserId(); //$NON-NLS-1$
|
|
||||||
initialProviderParserId = fInfo.getESIProviderConsoleParserId(); //$NON-NLS-1$
|
|
||||||
|
|
||||||
// Create local store
|
|
||||||
fBuildInfo = new LocalStore(fInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills console parser maps
|
|
||||||
*/
|
|
||||||
private void retrieveSIConsoleParsers() {
|
|
||||||
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(MakeCorePlugin.SI_CONSOLE_PARSER_SIMPLE_ID);
|
|
||||||
if (ep != null) {
|
|
||||||
IExtension[] extensions = ep.getExtensions();
|
|
||||||
for (int i = 0; i < extensions.length; ++i) {
|
|
||||||
String parserId = extensions[i].getUniqueIdentifier();
|
|
||||||
String label = extensions[i].getLabel();
|
|
||||||
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
|
|
||||||
String commandId = elements[0].getAttribute("commandId"); //$NON-NLS-1$
|
|
||||||
if (commandId.equals("makeBuilder") || commandId.equals("all")) { //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
builderParsers.put(label, parserId);
|
|
||||||
}
|
|
||||||
if (commandId.equals("externalScannerInfoProvider") || commandId.equals("all")) { //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
providerParsers.put(label, parserId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
|
||||||
*/
|
|
||||||
protected void configureShell(Shell newShell) {
|
|
||||||
newShell.setText(getTitle(DIALOG_TITLE));
|
|
||||||
super.configureShell(newShell);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return MakeUIPlugin resource string
|
|
||||||
*/
|
|
||||||
private String getTitle(String title) {
|
|
||||||
return MakeUIPlugin.getResourceString(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
protected Control createDialogArea(Composite parent) {
|
|
||||||
Composite composite = (Composite) super.createDialogArea(parent);
|
|
||||||
initializeDialogUnits(composite);
|
|
||||||
|
|
||||||
// create message line
|
|
||||||
fStatusLine = new MessageLine(composite);
|
|
||||||
fStatusLine.setAlignment(SWT.LEFT);
|
|
||||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
||||||
// gd.widthHint = convertWidthInCharsToPixels(50);
|
|
||||||
fStatusLine.setLayoutData(gd);
|
|
||||||
fStatusLine.setMessage(getTitle(DIALOG_TITLE));
|
|
||||||
|
|
||||||
createBuildOutputParserControls(composite);
|
|
||||||
createAfterBuildCmdControls(composite);
|
|
||||||
// enable controls depending on the state of auto discovery
|
|
||||||
enableAllControls();
|
|
||||||
|
|
||||||
return composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createBuildOutputParserControls(Composite parent) {
|
|
||||||
// ControlFactory.insertSpace(parent, 1, 10);
|
|
||||||
Group bopGroup = ControlFactory.createGroup(parent,
|
|
||||||
MakeUIPlugin.getResourceString(SI_BUILD_PARSER_GROUP), 2);
|
|
||||||
((GridLayout)bopGroup.getLayout()).marginHeight = 5;
|
|
||||||
((GridLayout)bopGroup.getLayout()).marginWidth = 5;
|
|
||||||
((GridData)bopGroup.getLayoutData()).verticalAlignment = GridData.FILL;
|
|
||||||
|
|
||||||
enableBuilderParserButton = ControlFactory.createCheckBox(bopGroup,
|
|
||||||
MakeUIPlugin.getResourceString(ENABLE_SI_BUILD_PARSER));
|
|
||||||
((GridData)enableBuilderParserButton.getLayoutData()).horizontalSpan = 2;
|
|
||||||
boolean enabledBuilderParser = fBuildInfo.isMakeBuilderConsoleParserEnabled();
|
|
||||||
enableBuilderParserButton.setSelection(enabledBuilderParser);
|
|
||||||
enableBuilderParserButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
makeBuilderSIParserComboBox.setEnabled(isBuilderParserEnabled());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Label label = ControlFactory.createLabel(bopGroup,
|
|
||||||
MakeUIPlugin.getResourceString(SI_BUILD_PARSER_LABEL));
|
|
||||||
((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
|
|
||||||
|
|
||||||
makeBuilderSIParserComboBox = new Combo(bopGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
||||||
|
|
||||||
// fill the combobox and set the initial value
|
|
||||||
Iterator items = builderParsers.keySet().iterator();
|
|
||||||
while (items.hasNext()) {
|
|
||||||
String parser = (String) items.next();
|
|
||||||
makeBuilderSIParserComboBox.add(parser);
|
|
||||||
if (initialBuilderParserId.equals(builderParsers.get(parser))) {
|
|
||||||
makeBuilderSIParserComboBox.setText(parser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
makeBuilderSIParserComboBox.setEnabled(enabledBuilderParser);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createAfterBuildCmdControls(Composite parent) {
|
|
||||||
Group abcGroup = ControlFactory.createGroup(parent,
|
|
||||||
MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_GROUP), 2);
|
|
||||||
((GridData)abcGroup.getLayoutData()).horizontalSpan = 2;
|
|
||||||
|
|
||||||
enableProviderCommandButton = ControlFactory.createCheckBox(abcGroup,
|
|
||||||
MakeUIPlugin.getResourceString(ENABLE_SI_PROVIDER_COMMAND));
|
|
||||||
((GridData)enableProviderCommandButton.getLayoutData()).horizontalSpan = 2;
|
|
||||||
((GridData)enableProviderCommandButton.getLayoutData()).horizontalAlignment = GridData.FILL_HORIZONTAL;
|
|
||||||
boolean enabledProviderCommand = fBuildInfo.isESIProviderCommandEnabled();
|
|
||||||
enableProviderCommandButton.setSelection(enabledProviderCommand);
|
|
||||||
enableProviderCommandButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
defESIProviderCommandButton.setEnabled(isProviderCommandEnabled());
|
|
||||||
esiProviderCommand.setEnabled(isProviderCommandEnabled() && !useDefaultESIProviderCmd());
|
|
||||||
esiProviderParserComboBox.setEnabled(isProviderCommandEnabled());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
createESIProviderCmdControls(abcGroup);
|
|
||||||
|
|
||||||
Label label = ControlFactory.createLabel(abcGroup,
|
|
||||||
MakeUIPlugin.getResourceString(SI_PROVIDER_PARSER_LABEL));
|
|
||||||
((GridData)label.getLayoutData()).grabExcessHorizontalSpace = false;
|
|
||||||
|
|
||||||
esiProviderParserComboBox = new Combo(abcGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
||||||
|
|
||||||
// fill the combobox and set the initial value
|
|
||||||
Iterator items = providerParsers.keySet().iterator();
|
|
||||||
while (items.hasNext()) {
|
|
||||||
String parser = (String) items.next();
|
|
||||||
esiProviderParserComboBox.add(parser);
|
|
||||||
if (initialProviderParserId.equals(providerParsers.get(parser))) {
|
|
||||||
esiProviderParserComboBox.setText(parser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
defESIProviderCommandButton.setEnabled(enabledProviderCommand);
|
|
||||||
esiProviderCommand.setEnabled(enabledProviderCommand && !useDefaultESIProviderCmd());
|
|
||||||
esiProviderParserComboBox.setEnabled(enabledProviderCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createESIProviderCmdControls(Composite parent) {
|
|
||||||
defESIProviderCommandButton = ControlFactory.createCheckBox(parent,
|
|
||||||
MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_USE_DEFAULT));
|
|
||||||
defESIProviderCommandButton.addSelectionListener(new SelectionAdapter() {
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
|
||||||
esiProviderCommand.setEnabled(!useDefaultESIProviderCmd());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((GridData) (defESIProviderCommandButton.getLayoutData())).horizontalAlignment = GridData.FILL_HORIZONTAL;
|
|
||||||
((GridData) (defESIProviderCommandButton.getLayoutData())).horizontalSpan = 2;
|
|
||||||
Label label = ControlFactory.createLabel(parent,
|
|
||||||
MakeUIPlugin.getResourceString(SI_PROVIDER_CMD_LABEL));
|
|
||||||
((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
|
|
||||||
((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
|
|
||||||
esiProviderCommand = ControlFactory.createTextField(parent, SWT.SINGLE | SWT.BORDER);
|
|
||||||
((GridData) (esiProviderCommand.getLayoutData())).horizontalAlignment = GridData.FILL;
|
|
||||||
((GridData) (esiProviderCommand.getLayoutData())).grabExcessHorizontalSpace = true;
|
|
||||||
IPath sCommand = fBuildInfo.getESIProviderCommand();
|
|
||||||
if (sCommand != null) {
|
|
||||||
StringBuffer cmd = new StringBuffer(sCommand.toOSString());
|
|
||||||
String args = fBuildInfo.getESIProviderArguments();
|
|
||||||
if (args != null && args.length() > 0) {
|
|
||||||
cmd.append(' ');
|
|
||||||
cmd.append(args);
|
|
||||||
}
|
|
||||||
esiProviderCommand.setText(cmd.toString());
|
|
||||||
}
|
|
||||||
if (fBuildInfo.isDefaultESIProviderCmd()) {
|
|
||||||
esiProviderCommand.setEnabled(false);
|
|
||||||
}
|
|
||||||
esiProviderCommand.addListener(SWT.Modify, new Listener() {
|
|
||||||
public void handleEvent(Event e) {
|
|
||||||
handleProviderCommandModify();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
defESIProviderCommandButton.setSelection(fBuildInfo.isDefaultESIProviderCmd());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected void handleProviderCommandModify() {
|
|
||||||
String newCommand = esiProviderCommand.getText().trim();
|
|
||||||
if (newCommand.length() == 0) {
|
|
||||||
fStatusLine.setErrorMessage(getTitle(SI_PROVIDER_CMD_ERROR_MESSAGE));
|
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fStatusLine.setErrorMessage(null);
|
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param enable
|
|
||||||
*/
|
|
||||||
private void enableAllControls() {
|
|
||||||
enableBuilderParserButton.setEnabled(true);
|
|
||||||
makeBuilderSIParserComboBox.setEnabled(isBuilderParserEnabled());
|
|
||||||
enableProviderCommandButton.setEnabled(true);
|
|
||||||
defESIProviderCommandButton.setEnabled(isProviderCommandEnabled());
|
|
||||||
esiProviderCommand.setEnabled(isProviderCommandEnabled() && !useDefaultESIProviderCmd());
|
|
||||||
esiProviderParserComboBox.setEnabled(isProviderCommandEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean useDefaultESIProviderCmd() {
|
|
||||||
return defESIProviderCommandButton.getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSIProviderCommandLine() {
|
|
||||||
return esiProviderCommand.getText().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isBuilderParserEnabled() {
|
|
||||||
return enableBuilderParserButton.getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isProviderCommandEnabled() {
|
|
||||||
return enableProviderCommandButton.getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the state of scanner config discovery
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public boolean isScannerConfigDiscoveryEnabled() {
|
|
||||||
return fBuildInfo.isAutoDiscoveryEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables or disables the scanner config discovery
|
|
||||||
*
|
|
||||||
* @param enabled (boolean)
|
|
||||||
*/
|
|
||||||
public void setScannerConfigDiscoveryEnabled(boolean enabled) {
|
|
||||||
try {
|
|
||||||
fBuildInfo.setAutoDiscoveryEnabled(enabled);
|
|
||||||
}
|
|
||||||
catch (CoreException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by BuildPathInfoBlock.performApply
|
|
||||||
*
|
|
||||||
* @param monitor
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
|
||||||
IProject project = fContainer.getProject();
|
|
||||||
IScannerConfigBuilderInfo buildInfo;
|
|
||||||
if (project != null) {
|
|
||||||
buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(project, ScannerConfigBuilder.BUILDER_ID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
buildInfo.setAutoDiscoveryEnabled(fBuildInfo.isAutoDiscoveryEnabled());
|
|
||||||
if (fBuildInfo.isAutoDiscoveryEnabled()) {
|
|
||||||
buildInfo.setMakeBuilderConsoleParserEnabled(fBuildInfo.isMakeBuilderConsoleParserEnabled());
|
|
||||||
if (fBuildInfo.isMakeBuilderConsoleParserEnabled()) {
|
|
||||||
buildInfo.setMakeBuilderConsoleParserId(fBuildInfo.getMakeBuilderConsoleParserId());
|
|
||||||
}
|
|
||||||
buildInfo.setESIProviderCommandEnabled(fBuildInfo.isESIProviderCommandEnabled());
|
|
||||||
if (fBuildInfo.isESIProviderCommandEnabled()) {
|
|
||||||
buildInfo.setUseDefaultESIProviderCmd(fBuildInfo.isDefaultESIProviderCmd());
|
|
||||||
if (!fBuildInfo.isDefaultESIProviderCmd()) {
|
|
||||||
buildInfo.setESIProviderCommand(fBuildInfo.getESIProviderCommand());
|
|
||||||
buildInfo.setESIProviderArguments(fBuildInfo.getESIProviderArguments());
|
|
||||||
}
|
|
||||||
buildInfo.setESIProviderConsoleParserId(fBuildInfo.getESIProviderConsoleParserId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param buildInfo
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
private void storeSIProviderCommandLine(IScannerConfigBuilderInfo buildInfo) throws CoreException {
|
|
||||||
String esiProviderLine = getSIProviderCommandLine();
|
|
||||||
int start = 0;
|
|
||||||
int end = -1;
|
|
||||||
if (esiProviderLine.startsWith("\"")) { //$NON-NLS-1$
|
|
||||||
start = 1;
|
|
||||||
end = esiProviderLine.indexOf('"', 1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
end = esiProviderLine.indexOf(' ');
|
|
||||||
}
|
|
||||||
IPath path;
|
|
||||||
if (end == -1) {
|
|
||||||
path = new Path(esiProviderLine);
|
|
||||||
} else {
|
|
||||||
path = new Path(esiProviderLine.substring(start, end));
|
|
||||||
}
|
|
||||||
buildInfo.setESIProviderCommand(path);
|
|
||||||
String args = ""; //$NON-NLS-1$
|
|
||||||
if (end != -1) {
|
|
||||||
args = esiProviderLine.substring(end + 1);
|
|
||||||
}
|
|
||||||
buildInfo.setESIProviderArguments(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by BuildPathInfoBlock.performDefaults
|
|
||||||
*/
|
|
||||||
public void performDefaults() {
|
|
||||||
IScannerConfigBuilderInfo buildInfo;
|
|
||||||
// Populate with the default values
|
|
||||||
if (fContainer.getProject() != null) {
|
|
||||||
// get the preferences
|
|
||||||
buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// get the defaults
|
|
||||||
buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(fPrefs, ScannerConfigBuilder.BUILDER_ID, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
fBuildInfo = new LocalStore(buildInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
|
||||||
*/
|
|
||||||
protected void okPressed() {
|
|
||||||
// Store UI values to the LocalStore
|
|
||||||
try {
|
|
||||||
fBuildInfo.setAutoDiscoveryEnabled(isScannerConfigDiscoveryEnabled());
|
|
||||||
fBuildInfo.setMakeBuilderConsoleParserEnabled(isBuilderParserEnabled());
|
|
||||||
fBuildInfo.setMakeBuilderConsoleParserId((String)builderParsers.get(makeBuilderSIParserComboBox.getText()));
|
|
||||||
fBuildInfo.setESIProviderCommandEnabled(isProviderCommandEnabled());
|
|
||||||
fBuildInfo.setUseDefaultESIProviderCmd(useDefaultESIProviderCmd());
|
|
||||||
storeSIProviderCommandLine(fBuildInfo);
|
|
||||||
fBuildInfo.setESIProviderConsoleParserId((String)providerParsers.get(esiProviderParserComboBox.getText()));
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
super.okPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if successfully initialized, false if not
|
|
||||||
*/
|
|
||||||
public boolean isInitialized() {
|
|
||||||
return fInitialized;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,12 +14,12 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerInfoConsoleParser;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCScannerInfoConsoleParser;
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scanner configuration console parser tests
|
* Scanner configuration console parser tests
|
||||||
|
@ -58,13 +58,20 @@ public class ScannerConfigConsoleParserTests extends TestCase {
|
||||||
* Only tests parsing of the imput (make build output)
|
* Only tests parsing of the imput (make build output)
|
||||||
*/
|
*/
|
||||||
public void testParsingIncludePaths() {
|
public void testParsingIncludePaths() {
|
||||||
final ArrayList sumIncludes = new ArrayList();
|
IScannerInfoCollector collector = new IScannerInfoCollector() {
|
||||||
// initialize it with the utility
|
private List sumIncludes = new ArrayList();
|
||||||
clParser.startup(null, null, new IScannerInfoCollector() {
|
public void contributeToScannerConfig(Object resource, Map scannerInfo) {
|
||||||
public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) {
|
sumIncludes.addAll((List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS));
|
||||||
sumIncludes.addAll(includes);
|
}
|
||||||
}
|
public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
|
||||||
});
|
if (type.equals(ScannerInfoTypes.INCLUDE_PATHS)) {
|
||||||
|
return sumIncludes;
|
||||||
|
}
|
||||||
|
return new ArrayList();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// initialize it with the utility
|
||||||
|
clParser.startup(null, collector);
|
||||||
|
|
||||||
clParser.processLine("gcc -I /dir/include -I C:\\dir\\include -ID:/dir/include -c test.c"); // absolute paths
|
clParser.processLine("gcc -I /dir/include -I C:\\dir\\include -ID:/dir/include -c test.c"); // absolute paths
|
||||||
clParser.processLine("gcc -I -I /dir2/include -c test.c"); // empty -I
|
clParser.processLine("gcc -I -I /dir2/include -c test.c"); // empty -I
|
||||||
|
@ -80,7 +87,8 @@ public class ScannerConfigConsoleParserTests extends TestCase {
|
||||||
clParser.processLine("/multiline\\");
|
clParser.processLine("/multiline\\");
|
||||||
clParser.processLine("/dir -c test.c"); // multiline
|
clParser.processLine("/dir -c test.c"); // multiline
|
||||||
|
|
||||||
assertTrue(sumIncludes.contains("/dir/include"));
|
List sumIncludes = collector.getCollectedScannerInfo(null, ScannerInfoTypes.INCLUDE_PATHS);
|
||||||
|
assertTrue(sumIncludes.contains("/dir/include"));
|
||||||
assertTrue(sumIncludes.contains("C:\\dir\\include"));
|
assertTrue(sumIncludes.contains("C:\\dir\\include"));
|
||||||
assertTrue(sumIncludes.contains("D:/dir/include"));
|
assertTrue(sumIncludes.contains("D:/dir/include"));
|
||||||
assertTrue(sumIncludes.contains("/dir2/include"));
|
assertTrue(sumIncludes.contains("/dir2/include"));
|
||||||
|
@ -108,13 +116,20 @@ public class ScannerConfigConsoleParserTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParsingSymbolDefinitions() {
|
public void testParsingSymbolDefinitions() {
|
||||||
final ArrayList sumSymbols = new ArrayList();
|
IScannerInfoCollector collector = new IScannerInfoCollector() {
|
||||||
|
private List sumSymbols = new ArrayList();
|
||||||
|
public void contributeToScannerConfig(Object resource, Map scannerInfo) {
|
||||||
|
sumSymbols.addAll((List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS));
|
||||||
|
}
|
||||||
|
public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
|
||||||
|
if (type.equals(ScannerInfoTypes.SYMBOL_DEFINITIONS)) {
|
||||||
|
return sumSymbols;
|
||||||
|
}
|
||||||
|
return new ArrayList();
|
||||||
|
}
|
||||||
|
};
|
||||||
// initialize it with the utility
|
// initialize it with the utility
|
||||||
clParser.startup(null, null, new IScannerInfoCollector() {
|
clParser.startup(null, collector);
|
||||||
public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) {
|
|
||||||
sumSymbols.addAll(symbols);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
clParser.processLine("gcc -DMACRO1 -D MACRO2=value2 -c test.c"); // simple definitions
|
clParser.processLine("gcc -DMACRO1 -D MACRO2=value2 -c test.c"); // simple definitions
|
||||||
clParser.processLine("gcc -D -DMACRO3 -c test.c"); // empty -D
|
clParser.processLine("gcc -D -DMACRO3 -c test.c"); // empty -D
|
||||||
|
@ -127,7 +142,8 @@ public class ScannerConfigConsoleParserTests extends TestCase {
|
||||||
clParser.processLine("-c test.c"); // multiline
|
clParser.processLine("-c test.c"); // multiline
|
||||||
clParser.processLine("gcc -D 'SUM(x, y) = (x) + (y)' -c test.c"); // more complex macro definition
|
clParser.processLine("gcc -D 'SUM(x, y) = (x) + (y)' -c test.c"); // more complex macro definition
|
||||||
|
|
||||||
assertTrue(sumSymbols.contains("MACRO1"));
|
List sumSymbols = collector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||||
|
assertTrue(sumSymbols.contains("MACRO1"));
|
||||||
assertTrue(sumSymbols.contains("MACRO2=value2"));
|
assertTrue(sumSymbols.contains("MACRO2=value2"));
|
||||||
assertTrue(sumSymbols.contains("MACRO3"));
|
assertTrue(sumSymbols.contains("MACRO3"));
|
||||||
assertTrue(sumSymbols.contains("MACRO4=value4"));
|
assertTrue(sumSymbols.contains("MACRO4=value4"));
|
||||||
|
@ -143,20 +159,27 @@ public class ScannerConfigConsoleParserTests extends TestCase {
|
||||||
assertTrue(sumSymbols.contains("MULTILINE=TRUE"));
|
assertTrue(sumSymbols.contains("MULTILINE=TRUE"));
|
||||||
assertTrue(sumSymbols.contains("SUM(x, y) = (x) + (y)"));
|
assertTrue(sumSymbols.contains("SUM(x, y) = (x) + (y)"));
|
||||||
assertTrue(sumSymbols.size() == 15);
|
assertTrue(sumSymbols.size() == 15);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParsingSymbolDefinitions_bug80271() {
|
public void testParsingSymbolDefinitions_bug80271() {
|
||||||
final ArrayList sumSymbols = new ArrayList();
|
IScannerInfoCollector collector = new IScannerInfoCollector() {
|
||||||
// initialize it with the utility
|
private List sumSymbols = new ArrayList();
|
||||||
clParser.startup(null, null, new IScannerInfoCollector() {
|
public void contributeToScannerConfig(Object resource, Map scannerInfo) {
|
||||||
public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) {
|
sumSymbols.addAll((List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS));
|
||||||
sumSymbols.addAll(symbols);
|
}
|
||||||
}
|
public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type) {
|
||||||
});
|
if (type.equals(ScannerInfoTypes.SYMBOL_DEFINITIONS)) {
|
||||||
|
return sumSymbols;
|
||||||
|
}
|
||||||
|
return new ArrayList();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// initialize it with the utility
|
||||||
|
clParser.startup(null, collector);
|
||||||
|
|
||||||
clParser.processLine("gcc -DMACRO1 -I ..\\inc -c ..\\source\\source.c"); // PR 80271
|
clParser.processLine("gcc -DMACRO1 -I ..\\inc -c ..\\source\\source.c"); // PR 80271
|
||||||
|
|
||||||
|
List sumSymbols = collector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||||
assertTrue(sumSymbols.contains("MACRO1"));
|
assertTrue(sumSymbols.contains("MACRO1"));
|
||||||
assertTrue(sumSymbols.size() == 1);
|
assertTrue(sumSymbols.size() == 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2005-01-24 Vladimir Hirsl
|
||||||
|
Updated managed build scanner info collector to use new interfaces introduced
|
||||||
|
for CDT 3.0.
|
||||||
|
|
||||||
2004-03-16 Tanya Wolff
|
2004-03-16 Tanya Wolff
|
||||||
Marked remaining strings untranslatable as they belong to the extensibility schema.
|
Marked remaining strings untranslatable as they belong to the extensibility schema.
|
||||||
|
|
||||||
|
|
|
@ -83,5 +83,18 @@
|
||||||
natureID="org.eclipse.cdt.managedbuilder.core.managedBuildNature"
|
natureID="org.eclipse.cdt.managedbuilder.core.managedBuildNature"
|
||||||
class="org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeProject"/>
|
class="org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeProject"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
id="GCCManagedMakePerProjectProfile"
|
||||||
|
name="GNU C/C++ managed make per project SCD profile"
|
||||||
|
point="org.eclipse.cdt.make.core.ScannerConfigurationDiscoveryProfile">
|
||||||
|
<scannerInfoCollector class="org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector"/>
|
||||||
|
<scannerInfoProvider providerId="specsFile">
|
||||||
|
<run
|
||||||
|
arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}"
|
||||||
|
command="gcc"
|
||||||
|
class="org.eclipse.cdt.make.internal.core.scannerconfig2.GCCSpecsRunSIProvider"/>
|
||||||
|
<scannerInfoConsoleParser class="org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser"/>
|
||||||
|
</scannerInfoProvider>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -16,9 +16,13 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
|
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.TraceUtil;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation class for gathering the built-in compiler settings for
|
* Implementation class for gathering the built-in compiler settings for
|
||||||
|
@ -28,7 +32,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
*
|
*
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class DefaultGCCScannerInfoCollector implements IManagedScannerInfoCollector {
|
public class DefaultGCCScannerInfoCollector implements IScannerInfoCollector2 {
|
||||||
protected Map definedSymbols;
|
protected Map definedSymbols;
|
||||||
protected static final String EQUALS = "="; //$NON-NLS-1$
|
protected static final String EQUALS = "="; //$NON-NLS-1$
|
||||||
protected List includePaths;
|
protected List includePaths;
|
||||||
|
@ -42,26 +46,32 @@ public class DefaultGCCScannerInfoCollector implements IManagedScannerInfoCollec
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(org.eclipse.core.resources.IResource, java.util.List, java.util.List, java.util.Map)
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map)
|
||||||
*/
|
*/
|
||||||
public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) {
|
public void contributeToScannerConfig(Object resource, Map scannerInfo) {
|
||||||
// This method will be called by the parser each time there is a new value
|
// check the resource
|
||||||
Iterator pathIter = includes.listIterator();
|
if (resource != null && resource instanceof IResource &&
|
||||||
while (pathIter.hasNext()) {
|
((IResource) resource).getProject() == project ) {
|
||||||
String path = (String) pathIter.next();
|
List includes = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
|
||||||
getIncludePaths().add(path);
|
List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||||
}
|
|
||||||
|
|
||||||
// Now add the macros
|
// This method will be called by the parser each time there is a new value
|
||||||
Iterator symbolIter = symbols.listIterator();
|
Iterator pathIter = includes.listIterator();
|
||||||
while (symbolIter.hasNext()) {
|
while (pathIter.hasNext()) {
|
||||||
// See if it has an equals
|
String path = (String) pathIter.next();
|
||||||
String[] macroTokens = ((String)symbolIter.next()).split(EQUALS);
|
getIncludePaths().add(path);
|
||||||
String macro = macroTokens[0].trim();
|
}
|
||||||
String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String();
|
|
||||||
getDefinedSymbols().put(macro, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Now add the macros
|
||||||
|
Iterator symbolIter = symbols.listIterator();
|
||||||
|
while (symbolIter.hasNext()) {
|
||||||
|
// See if it has an equals
|
||||||
|
String[] macroTokens = ((String)symbolIter.next()).split(EQUALS);
|
||||||
|
String macro = macroTokens[0].trim();
|
||||||
|
String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String();
|
||||||
|
getDefinedSymbols().put(macro, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -92,4 +102,57 @@ public class DefaultGCCScannerInfoCollector implements IManagedScannerInfoCollec
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2#updateScannerConfiguration(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public void updateScannerConfiguration(IProgressMonitor monitor) throws CoreException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (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;
|
||||||
|
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("DefaultGCCScannerInfoCollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
else if (type.equals(ScannerInfoTypes.INCLUDE_PATHS)) {
|
||||||
|
rv = getIncludePaths();
|
||||||
|
}
|
||||||
|
else if (type.equals(ScannerInfoTypes.SYMBOL_DEFINITIONS)) {
|
||||||
|
rv = new ArrayList();
|
||||||
|
Map symbols = getDefinedSymbols();
|
||||||
|
for (Iterator i = symbols.keySet().iterator(); i.hasNext(); ) {
|
||||||
|
String macro = (String) i.next();
|
||||||
|
String value = (String) symbols.get(macro);
|
||||||
|
if (value.length() > 0) {
|
||||||
|
rv.add(macro + EQUALS + value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv.add(macro);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = new ArrayList();
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
|
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CygpathTranslator;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
|
@ -25,32 +26,39 @@ import org.eclipse.core.resources.IResource;
|
||||||
*/
|
*/
|
||||||
public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoCollector {
|
public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoCollector {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(org.eclipse.core.resources.IResource, java.util.List, java.util.List, java.util.List)
|
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map)
|
||||||
*/
|
*/
|
||||||
public void contributeToScannerConfig(IResource resource, List includes, List symbols, Map extraInfo) {
|
public void contributeToScannerConfig(Object resource, Map scannerInfo) {
|
||||||
// This method will be called by the parser each time there is a new value
|
// check the resource
|
||||||
Iterator pathIter = includes.listIterator();
|
if (resource != null && resource instanceof IResource &&
|
||||||
while (pathIter.hasNext()) {
|
((IResource) resource).getProject() == project ) {
|
||||||
String path = (String) pathIter.next();
|
List includes = (List) scannerInfo.get(ScannerInfoTypes.INCLUDE_PATHS);
|
||||||
String convertedPath = convertPath(path);
|
List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||||
// On MinGW, there is no facility for converting paths
|
|
||||||
if (convertedPath.startsWith("/")) continue; //$NON-NLS-1$
|
|
||||||
// Add it if it is not a duplicate
|
|
||||||
if (!getIncludePaths().contains(convertedPath)){
|
|
||||||
getIncludePaths().add(convertedPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now add the macros
|
// This method will be called by the parser each time there is a new value
|
||||||
Iterator symbolIter = symbols.listIterator();
|
Iterator pathIter = includes.listIterator();
|
||||||
while (symbolIter.hasNext()) {
|
while (pathIter.hasNext()) {
|
||||||
// See if it has an equals
|
String path = (String) pathIter.next();
|
||||||
String[] macroTokens = ((String)symbolIter.next()).split(EQUALS);
|
String convertedPath = convertPath(path);
|
||||||
String macro = macroTokens[0].trim();
|
// On MinGW, there is no facility for converting paths
|
||||||
String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String();
|
if (convertedPath.startsWith("/")) continue; //$NON-NLS-1$
|
||||||
getDefinedSymbols().put(macro, value);
|
// Add it if it is not a duplicate
|
||||||
}
|
if (!getIncludePaths().contains(convertedPath)){
|
||||||
|
getIncludePaths().add(convertedPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now add the macros
|
||||||
|
Iterator symbolIter = symbols.listIterator();
|
||||||
|
while (symbolIter.hasNext()) {
|
||||||
|
// See if it has an equals
|
||||||
|
String[] macroTokens = ((String)symbolIter.next()).split(EQUALS);
|
||||||
|
String macro = macroTokens[0].trim();
|
||||||
|
String value = (macroTokens.length > 1) ? macroTokens[1].trim() : new String();
|
||||||
|
getDefinedSymbols().put(macro, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -24,14 +24,17 @@ import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
|
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
|
||||||
|
import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
|
import org.eclipse.cdt.managedbuilder.scannerconfig.IManagedScannerInfoCollector;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -52,6 +55,10 @@ import org.eclipse.core.runtime.Platform;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
|
// Managed make per project scanner configuration discovery profile
|
||||||
|
private static final String MM_PP_DISCOVERY_PROFILE_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".GCCManagedMakePerProjectProfile"; //$NON-NLS-1$
|
||||||
|
private static final String SPECS_FILE_PROVIDER = "specsFile"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$
|
private static final String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".ScannerConfigBuilder"; //$NON-NLS-1$
|
||||||
private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
|
private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||||
private static final String ERROR_HEADER = "PathEntryContainer error ["; //$NON-NLS-1$
|
private static final String ERROR_HEADER = "PathEntryContainer error ["; //$NON-NLS-1$
|
||||||
|
@ -161,27 +168,22 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void calculateEntriesDynamically(final IProject project, final IScannerInfoCollector collector) {
|
protected void calculateEntriesDynamically(final IProject project,
|
||||||
final IScannerConfigBuilderInfo buildInfo;
|
SCProfileInstance profileInstance,
|
||||||
buildInfo = MakeCorePlugin.createScannerConfigBuildInfo(
|
final IScannerInfoCollector collector) {
|
||||||
MakeCorePlugin.getDefault().getPluginPreferences(),
|
|
||||||
BUILDER_ID,
|
|
||||||
false);
|
|
||||||
|
|
||||||
// TODO Get the provider from the toolchain specification
|
// TODO Get the provider from the toolchain specification
|
||||||
final IExternalScannerInfoProvider esiProvider;
|
|
||||||
esiProvider = MakeCorePlugin.getDefault().getExternalScannerInfoProvider(MakeCorePlugin.DEFAULT_EXTERNAL_SI_PROVIDER_ID);
|
final IScannerConfigBuilderInfo2 buildInfo = ScannerConfigProfileManager.
|
||||||
|
createScannerConfigBuildInfo2(MakeCorePlugin.getDefault().getPluginPreferences(),
|
||||||
|
MM_PP_DISCOVERY_PROFILE_ID, false);
|
||||||
|
final IExternalScannerInfoProvider esiProvider = profileInstance.createExternalScannerInfoProvider(SPECS_FILE_PROVIDER);
|
||||||
|
|
||||||
// Set the arguments for the provider
|
// Set the arguments for the provider
|
||||||
Vector compilerArgs = new Vector();
|
|
||||||
String args = buildInfo.getESIProviderArguments();
|
|
||||||
IPath command = buildInfo.getESIProviderCommand();
|
|
||||||
final Vector buildArgs = compilerArgs;
|
|
||||||
|
|
||||||
ISafeRunnable runnable = new ISafeRunnable() {
|
ISafeRunnable runnable = new ISafeRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
IProgressMonitor monitor = new NullProgressMonitor();
|
IProgressMonitor monitor = new NullProgressMonitor();
|
||||||
esiProvider.invokeProvider(monitor, project, buildInfo, buildArgs, collector);
|
esiProvider.invokeProvider(monitor, project, SPECS_FILE_PROVIDER, buildInfo, collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
|
@ -210,13 +212,16 @@ public class ManagedBuildCPathEntryContainer implements IPathEntryContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we can load a dynamic resolver
|
// See if we can load a dynamic resolver
|
||||||
IManagedScannerInfoCollector collector = ManagedBuildManager.getScannerInfoCollector(defaultConfig);
|
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
|
||||||
if (collector != null) {
|
getSCProfileInstance(project, MM_PP_DISCOVERY_PROFILE_ID);
|
||||||
|
IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
|
||||||
|
|
||||||
|
if (collector instanceof IManagedScannerInfoCollector) {
|
||||||
|
IManagedScannerInfoCollector mCollector = (IManagedScannerInfoCollector) collector;
|
||||||
ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries collected dynamically"); //$NON-NLS-1$
|
ManagedBuildCPathEntryContainer.outputTrace(project.getName(), "Path entries collected dynamically"); //$NON-NLS-1$
|
||||||
collector.setProject(info.getOwner().getProject());
|
calculateEntriesDynamically((IProject)info.getOwner(), profileInstance, collector);
|
||||||
calculateEntriesDynamically((IProject)info.getOwner(), collector);
|
addIncludePaths(mCollector.getIncludePaths());
|
||||||
addIncludePaths(collector.getIncludePaths());
|
addDefinedSymbols(mCollector.getDefinedSymbols());
|
||||||
addDefinedSymbols(collector.getDefinedSymbols());
|
|
||||||
} else {
|
} else {
|
||||||
// If none supplied, use the built-ins
|
// If none supplied, use the built-ins
|
||||||
if (defaultConfig != null) {
|
if (defaultConfig != null) {
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2005-01-24 Vladimir Hirsl
|
||||||
|
SCD work for CDT 3.0
|
||||||
|
Better displaying of error messages in TabFolderOptionBlock.
|
||||||
|
* src/org/eclipse/cdt/ui/dialogs/TabFolderOptionsBlock.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/CUIMessages.properties
|
||||||
|
|
||||||
2005-01-24 Alain Magloire
|
2005-01-24 Alain Magloire
|
||||||
PR 83514 patch from Przemek
|
PR 83514 patch from Przemek
|
||||||
* src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
|
* src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
|
||||||
|
|
|
@ -23,6 +23,7 @@ CAnnotationHover.multipleMarkers=Multiple markers at this line
|
||||||
|
|
||||||
TabFolderOptionBlock.error=Error
|
TabFolderOptionBlock.error=Error
|
||||||
TabFolderOptionBlock.error.settingOptions=Error setting options
|
TabFolderOptionBlock.error.settingOptions=Error setting options
|
||||||
|
TabFolderOptionBlock.error.message=Error in {0} tab
|
||||||
|
|
||||||
BinaryParserBlock.binaryParser=Binary Parser:
|
BinaryParserBlock.binaryParser=Binary Parser:
|
||||||
BinaryParserBlock.button.up=Up
|
BinaryParserBlock.button.up=Up
|
||||||
|
|
|
@ -194,7 +194,13 @@ public abstract class TabFolderOptionBlock {
|
||||||
ICOptionPage tab = (ICOptionPage)iter.next();
|
ICOptionPage tab = (ICOptionPage)iter.next();
|
||||||
ok = tab.isValid();
|
ok = tab.isValid();
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
setErrorMessage(tab.getErrorMessage());
|
String errorMessage = tab.getErrorMessage();
|
||||||
|
if (!tab.getControl().isVisible()) {
|
||||||
|
setErrorMessage(CUIMessages.getFormattedString(
|
||||||
|
"TabFolderOptionBlock.error.message", tab.getTitle())); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
setErrorMessage(errorMessage);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue