1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

New ScannerInfoProvider extension point allowing providers to be associated with build commands in the project description.

This commit is contained in:
Doug Schaefer 2009-12-08 18:51:56 +00:00
parent cd837027a9
commit 673ce7a0a9
3 changed files with 156 additions and 3 deletions

View file

@ -579,6 +579,7 @@
schema="schema/templates.exsd"/> schema="schema/templates.exsd"/>
<extension-point id="templateProcessTypes" name="%templateProcessTypes.name" schema="schema/templateProcessTypes.exsd"/> <extension-point id="templateProcessTypes" name="%templateProcessTypes.name" schema="schema/templateProcessTypes.exsd"/>
<extension-point id="templateAssociations" name="%templateAssociations.name" schema="schema/templateAssociations.exsd"/> <extension-point id="templateAssociations" name="%templateAssociations.name" schema="schema/templateAssociations.exsd"/>
<extension-point id="ScannerInfoProvider2" name="Scanner Info Provider" schema="schema/ScannerInfoProvider2.exsd"/>
<extension <extension
point="org.eclipse.cdt.core.templateProcessTypes"> point="org.eclipse.cdt.core.templateProcessTypes">

View file

@ -0,0 +1,109 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="ScannerInfoProvider2" name="Scanner Info Provider"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="provider"/>
</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>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="provider">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.parser.IScannerInfoProvider"/>
</appInfo>
</annotation>
</attribute>
<attribute name="builder" type="string" use="required">
<annotation>
<documentation>
The id of the build command this scanner info provider provides for.
</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>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View file

@ -21,8 +21,6 @@ import java.util.HashSet;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager; import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.cdtvariables.IUserVarSupplier; import org.eclipse.cdt.core.cdtvariables.IUserVarSupplier;
import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.dom.IPDOMManager;
@ -55,6 +53,7 @@ import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory; import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager; import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -65,6 +64,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
@ -72,12 +72,15 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import com.ibm.icu.text.MessageFormat;
/** /**
* CCorePlugin is the life-cycle owner of the core plug-in, and starting point for access to many core APIs. * CCorePlugin is the life-cycle owner of the core plug-in, and starting point for access to many core APIs.
* *
@ -131,6 +134,10 @@ public class CCorePlugin extends Plugin {
public static final String DEFAULT_PROVIDER_ID = CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$ public static final String DEFAULT_PROVIDER_ID = CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$
public final static String SCANNER_INFO_PROVIDER2_NAME = "ScannerInfoProvider2"; //$NON-NLS-1$
public final static String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$
/** /**
* Name of the extension point for contributing a source code formatter * Name of the extension point for contributing a source code formatter
*/ */
@ -910,7 +917,43 @@ public class CCorePlugin extends Plugin {
} }
public IScannerInfoProvider getScannerInfoProvider(IProject project) { public IScannerInfoProvider getScannerInfoProvider(IProject project) {
return fNewCProjectDescriptionManager.getScannerInfoProviderProxy(project); IScannerInfoProvider provider = null;
try {
// Look up in session property for previously created provider
QualifiedName scannerInfoProviderName = new QualifiedName(PLUGIN_ID, SCANNER_INFO_PROVIDER2_NAME);
provider = (IScannerInfoProvider)project.getSessionProperty(scannerInfoProviderName);
if (provider != null)
return provider;
// Next search the extension registry to see if a provider is registered with a build command
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint(SCANNER_INFO_PROVIDER2);
if (point != null) {
IExtension[] exts = point.getExtensions();
for (IExtension ext : exts) {
IConfigurationElement[] elems = ext.getConfigurationElements();
for (IConfigurationElement elem : elems) {
String builder = elem.getAttribute("builder"); //$NON-NLS-1$
if (builder != null) {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (ICommand command : commands)
if (builder.equals(command.getBuilderName()))
provider = (IScannerInfoProvider)elem.createExecutableExtension("class"); //$NON-NLS-1$
}
}
}
}
// Default to the proxy
if (provider == null)
provider = fNewCProjectDescriptionManager.getScannerInfoProviderProxy(project);
project.setSessionProperty(scannerInfoProviderName, provider);
} catch (CoreException e) {
log(e);
}
return provider;
} }
/** /**