Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 134341 Details for
Bug 267967
API - Symbol Context Resolver needs to be pluggable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Adds a new non-breaking extension point that allows contributions to the SymbolContextResolverFactory
patch.txt (text/plain), 18.39 KB, created by
Cameron Bateman
on 2009-05-04 18:45:46 EDT
(
hide
)
Description:
Adds a new non-breaking extension point that allows contributions to the SymbolContextResolverFactory
Filename:
MIME Type:
Creator:
Cameron Bateman
Created:
2009-05-04 18:45:46 EDT
Size:
18.39 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.jsf.common >Index: src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsf/components/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 AbstractDelegatingFactory.java >--- src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java 23 May 2007 16:48:00 -0000 1.3 >+++ src/org/eclipse/jst/jsf/context/AbstractDelegatingFactory.java 4 May 2009 22:44:17 -0000 >@@ -15,8 +15,8 @@ > import java.util.ArrayList; > import java.util.Arrays; > import java.util.Collections; >-import java.util.Iterator; > import java.util.List; >+import java.util.concurrent.CopyOnWriteArrayList; > > import org.eclipse.core.runtime.IAdaptable; > >@@ -26,85 +26,77 @@ > * Clients may extend this class. > * > * @author cbateman >- * >+ * > */ >-public abstract class AbstractDelegatingFactory implements IDelegatingFactory { >+public abstract class AbstractDelegatingFactory implements IDelegatingFactory >+{ >+ >+ /* instance attributes */ > >- /* instance attributes */ >- >- /** >- * the list of registered factory delegates >- */ >- protected final List<IAdaptable> _delegates; >- >- private final List<Class> _supportedDelegates; >- >- /** >- * @param supportedDelegateTypes -- populates the list of classes used >- * by the isValidDelegate contract >- */ >- protected AbstractDelegatingFactory(Class[] supportedDelegateTypes) >- { >- _delegates = new ArrayList<IAdaptable>(); >- >- final List<Class> supportedTypes = new ArrayList<Class>(); >- supportedTypes.addAll(Arrays.asList(supportedDelegateTypes)); >- _supportedDelegates = Collections.unmodifiableList(supportedTypes); >- } >- >- /** >- * @see org.eclipse.jst.jsf.context.IDelegatingFactory#addFactoryDelegate(org.eclipse.core.runtime.IAdaptable) >- */ >- public final void addFactoryDelegate(IAdaptable delegate) >- { >- synchronized(_delegates) >- { >- >- if (!_delegates.contains(delegate) >- && isValidDelegate(delegate)) >- { >- _delegates.add(delegate); >- } >- } >- } >- >- /** >- * @see org.eclipse.jst.jsf.context.IDelegatingFactory#removeFactoryDelegate(org.eclipse.core.runtime.IAdaptable) >- */ >- public final boolean removeFactoryDelegate(IAdaptable delegate) >- { >- synchronized(_delegates) >- { >- return _delegates.remove(delegate); >- } >- } >- >- /** >- * @see org.eclipse.jst.jsf.context.IDelegatingFactory#getValidDelegateTypes() >- */ >- public final List<Class> getValidDelegateTypes() >- { >- return _supportedDelegates; >- } >- >- /** >- * @see org.eclipse.jst.jsf.context.IDelegatingFactory#isValidDelegate(org.eclipse.core.runtime.IAdaptable) >- */ >- public final boolean isValidDelegate(IAdaptable delegate) >- { >- for (final Iterator<Class> it = _supportedDelegates.iterator(); it.hasNext();) >- { >- final Class clazz = it.next(); >- >- // if the delegate supports one of the valid delegate classes >- // via adaptation, then it is a valid delegate >- if (delegate.getAdapter(clazz) != null) >- { >- return true; >- } >- } >- >- // if no found, delegate is not supported >- return false; >- } >+ /** >+ * the list of registered factory delegates >+ */ >+ protected final CopyOnWriteArrayList<IAdaptable> _delegates; >+ >+ private final List<Class> _supportedDelegates; >+ >+ /** >+ * @param supportedDelegateTypes >+ * -- populates the list of classes used by the isValidDelegate >+ * contract >+ */ >+ protected AbstractDelegatingFactory(final Class[] supportedDelegateTypes) >+ { >+ _delegates = new CopyOnWriteArrayList<IAdaptable>(); >+ >+ final List<Class> supportedTypes = new ArrayList<Class>(); >+ supportedTypes.addAll(Arrays.asList(supportedDelegateTypes)); >+ _supportedDelegates = Collections.unmodifiableList(supportedTypes); >+ } >+ >+ /** >+ * @see org.eclipse.jst.jsf.context.IDelegatingFactory#addFactoryDelegate(org.eclipse.core.runtime.IAdaptable) >+ */ >+ public final void addFactoryDelegate(final IAdaptable delegate) >+ { >+ if (isValidDelegate(delegate)) >+ { >+ _delegates.addIfAbsent(delegate); >+ } >+ } >+ >+ /** >+ * @see org.eclipse.jst.jsf.context.IDelegatingFactory#removeFactoryDelegate(org.eclipse.core.runtime.IAdaptable) >+ */ >+ public final boolean removeFactoryDelegate(final IAdaptable delegate) >+ { >+ return _delegates.remove(delegate); >+ } >+ >+ /** >+ * @see org.eclipse.jst.jsf.context.IDelegatingFactory#getValidDelegateTypes() >+ */ >+ public final List<Class> getValidDelegateTypes() >+ { >+ return _supportedDelegates; >+ } >+ >+ /** >+ * @see org.eclipse.jst.jsf.context.IDelegatingFactory#isValidDelegate(org.eclipse.core.runtime.IAdaptable) >+ */ >+ public final boolean isValidDelegate(final IAdaptable delegate) >+ { >+ for (final Class clazz : _supportedDelegates) >+ { >+ // if the delegate supports one of the valid delegate classes >+ // via adaptation, then it is a valid delegate >+ if (delegate.getAdapter(clazz) != null) >+ { >+ return true; >+ } >+ } >+ >+ // if no found, delegate is not supported >+ return false; >+ } > } >#P org.eclipse.jst.jsf.core >Index: src/org/eclipse/jst/jsf/designtime/resolver/StructuredDocumentSymbolResolverFactory.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsf/components/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/resolver/StructuredDocumentSymbolResolverFactory.java,v >retrieving revision 1.4 >diff -u -r1.4 StructuredDocumentSymbolResolverFactory.java >--- src/org/eclipse/jst/jsf/designtime/resolver/StructuredDocumentSymbolResolverFactory.java 12 Feb 2008 07:57:34 -0000 1.4 >+++ src/org/eclipse/jst/jsf/designtime/resolver/StructuredDocumentSymbolResolverFactory.java 4 May 2009 22:44:18 -0000 >@@ -12,6 +12,7 @@ > > package org.eclipse.jst.jsf.designtime.resolver; > >+import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.jst.jsf.context.AbstractDelegatingFactory; > import org.eclipse.jst.jsf.context.IModelContext; > import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext; >@@ -23,13 +24,14 @@ > * Clients may not sub-class. > * > * @author cbateman >- * >+ * > */ > public final class StructuredDocumentSymbolResolverFactory extends >- AbstractDelegatingFactory implements IStructuredDocumentSymbolResolverFactory >+ AbstractDelegatingFactory implements >+ IStructuredDocumentSymbolResolverFactory > { > private static StructuredDocumentSymbolResolverFactory INSTANCE; >- >+ > /** > * @return the singleton factory instance > */ >@@ -38,46 +40,70 @@ > if (INSTANCE == null) > { > // no delegates supported >- INSTANCE = new StructuredDocumentSymbolResolverFactory(new Class[0]); >+ INSTANCE = new StructuredDocumentSymbolResolverFactory(new Class[] >+ { IStructuredDocumentSymbolResolverFactory.class }); > } >- >+ > return INSTANCE; > } >- >- private StructuredDocumentSymbolResolverFactory(Class[] supportedDelegateTypes) >+ >+ private StructuredDocumentSymbolResolverFactory( >+ Class[] supportedDelegateTypes) > { > super(supportedDelegateTypes); >+ for (final IAdaptable delegate : SymbolContextResolverReader >+ .getAllHandlers()) >+ { >+ addFactoryDelegate(delegate); >+ } > } > > /** > * @param context > * @return a new instance of symbol resolver for context > */ >- public ISymbolContextResolver getSymbolContextResolver(IModelContext context) { >- ISymbolContextResolver resolver = internalGetSymbolContextResolver(context); >- >+ public ISymbolContextResolver getSymbolContextResolver(IModelContext context) >+ { >+ ISymbolContextResolver resolver = delegateGetSymbolContextResolver(context); >+ > if (resolver == null) > { >- resolver = delegateGetSymbolContextResolver(context); >+ resolver = internalGetSymbolContextResolver(context); > } >- >+ > return resolver; > } >- >- private ISymbolContextResolver internalGetSymbolContextResolver(IModelContext context) >+ >+ private ISymbolContextResolver internalGetSymbolContextResolver( >+ IModelContext context) > { >- if (context instanceof IStructuredDocumentContext && >- ((IStructuredDocumentContext)context).getStructuredDocument() instanceof IStructuredDocument) >+ if (context instanceof IStructuredDocumentContext >+ && ((IStructuredDocumentContext) context) >+ .getStructuredDocument() instanceof IStructuredDocument) > { >- return new SymbolContextResolver((IStructuredDocumentContext) context); >+ return new SymbolContextResolver( >+ (IStructuredDocumentContext) context); > } >- >+ > return null; > } >- >- private ISymbolContextResolver delegateGetSymbolContextResolver(IModelContext context) >+ >+ private ISymbolContextResolver delegateGetSymbolContextResolver( >+ IModelContext context) > { >- // no delegates currently supported >+ for (final IAdaptable adaptable : _delegates) >+ { >+ final IStructuredDocumentSymbolResolverFactory delegateFactory = >+ (IStructuredDocumentSymbolResolverFactory) adaptable >+ .getAdapter(IStructuredDocumentSymbolResolverFactory.class); >+ ISymbolContextResolver symbolContextResolver = delegateFactory >+ .getSymbolContextResolver(context); >+ >+ if (symbolContextResolver != null) >+ { >+ return symbolContextResolver; >+ } >+ } > return null; > } > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsf/components/jsf/plugins/org.eclipse.jst.jsf.core/plugin.xml,v >retrieving revision 1.36 >diff -u -r1.36 plugin.xml >--- plugin.xml 30 Apr 2009 00:25:24 -0000 1.36 >+++ plugin.xml 4 May 2009 22:44:18 -0000 >@@ -13,6 +13,7 @@ > <extension-point id="viewhandler" name="%extension-point.name.6" schema="schema/viewhandler.exsd"/> > <extension-point id="customViewMapper" name="%extension-point.name.7" schema="schema/customViewMapper.exsd"/> > <extension-point id="jsfFacetConfiguration" name="%extension-point.name.11" schema="schema/jsfFacetConfiguration.exsd"/> >+ <extension-point id="symbolContextResolverFactory" name="%extension-point.name.12" schema="schema/symbolContextResolverFactory.exsd"/> > > <extension point="org.eclipse.emf.ecore.generated_package"> > <package >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsf/components/jsf/plugins/org.eclipse.jst.jsf.core/plugin.properties,v >retrieving revision 1.15 >diff -u -r1.15 plugin.properties >--- plugin.properties 27 Apr 2009 17:29:58 -0000 1.15 >+++ plugin.properties 4 May 2009 22:44:18 -0000 >@@ -42,3 +42,5 @@ > > noOpLibraryProviderWarning = Library configuration is disabled. Further classpath changes may be required later. > noOpLibraryProviderMessage = This facet requires JSF implementation library to be present on project classpath. By disabling library configuration, user takes on responsibility of configuring classpath appropriately via alternate means. >+ >+extension-point.name.12 = Symbol Context Resolver Factory Delegate >\ No newline at end of file >Index: schema/symbolContextResolverFactory.exsd >=================================================================== >RCS file: schema/symbolContextResolverFactory.exsd >diff -N schema/symbolContextResolverFactory.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/symbolContextResolverFactory.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,104 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.jst.jsf.core" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.jst.jsf.core" id="symbolContextResolverFactory" name="Symbol Context Resolver Factory Delegate"/> >+ </appInfo> >+ <documentation> >+ [Enter description of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> >+ <complexType> >+ <choice> >+ <element ref="symbolFactoryDelegate"/> >+ </choice> >+ <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="symbolFactoryDelegate"> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ PROVISIONAL API -- Subject to change >+ >+Use to add symbol factory delegates that get called before the SymbolContextResolver. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.jst.jsf.designtime.resolver.AbstractStructuredDocumentSymbolResolverFactory:org.eclipse.core.runtime.IAdaptable"/> >+ </appInfo> >+ </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> >Index: src/org/eclipse/jst/jsf/designtime/resolver/SymbolContextResolverReader.java >=================================================================== >RCS file: src/org/eclipse/jst/jsf/designtime/resolver/SymbolContextResolverReader.java >diff -N src/org/eclipse/jst/jsf/designtime/resolver/SymbolContextResolverReader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/jsf/designtime/resolver/SymbolContextResolverReader.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+package org.eclipse.jst.jsf.designtime.resolver; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; >+ >+/*package*/ class SymbolContextResolverReader >+{ >+ private static List<IAdaptable> _handlers = null; >+ >+ /** >+ * @return all available handers for the ext-pt. List is not >+ * modifiable >+ */ >+ public static synchronized List<IAdaptable> getAllHandlers() { >+ if (_handlers == null) { >+ _handlers = readAllHandlers(); >+ } >+ return Collections.unmodifiableList(_handlers); >+ } >+ >+ private static List<IAdaptable> readAllHandlers() >+ { >+ final List<IAdaptable> result = new ArrayList<IAdaptable>(); >+ final IExtensionPoint extensionPoint = Platform.getExtensionRegistry() >+ .getExtensionPoint(JSFCorePlugin.PLUGIN_ID, >+ "symbolContextResolverFactory"); //$NON-NLS-1$ >+ final IExtension[] extensions = extensionPoint.getExtensions(); >+ >+ for (final IExtension ext : extensions) >+ { >+ final IConfigurationElement[] elementEditElement = ext >+ .getConfigurationElements(); >+ >+ for (final IConfigurationElement configurationElement : elementEditElement) >+ { >+ final IConfigurationElement element = configurationElement; >+ if (element.getName().equals( >+ "symbolFactoryDelegate")) //$NON-NLS-1$ >+ { >+ try >+ { >+ final IAdaptable factory = (IAdaptable) configurationElement >+ .createExecutableExtension("class"); //$NON-NLS-1$ >+ if (factory != null) >+ { >+ result.add(factory); >+ } >+ >+ } catch (final CoreException e) >+ { >+ JSFCorePlugin.log("Problem loading element edit extension for "+element.toString(), e); //$NON-NLS-1$ >+ } >+ } >+ } >+ } >+ return result; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 267967
: 134341