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 37020 Details for
Bug 133386
Photran-based patch for superficial multilanguage support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Revised patch (3/27/06)
cdt-multilang-patch-20060327.txt (text/plain), 18.02 KB, created by
Jeffrey Overbey
on 2006-03-27 16:12:46 EST
(
hide
)
Description:
Revised patch (3/27/06)
Filename:
MIME Type:
Creator:
Jeffrey Overbey
Created:
2006-03-27 16:12:46 EST
Size:
18.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.ui >Index: src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java,v >retrieving revision 1.4 >diff -u -r1.4 CElementImageProvider.java >--- src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java 22 Jul 2005 03:32:01 -0000 1.4 >+++ src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java 27 Mar 2006 21:03:05 -0000 >@@ -17,10 +17,11 @@ > import org.eclipse.cdt.core.model.IBinaryModule; > import org.eclipse.cdt.core.model.ICElement; > import org.eclipse.cdt.core.model.ICProject; >+import org.eclipse.cdt.core.model.IContributedCElement; > import org.eclipse.cdt.core.model.IDeclaration; > import org.eclipse.cdt.core.model.IField; >-import org.eclipse.cdt.core.model.ILibraryReference; > import org.eclipse.cdt.core.model.IIncludeReference; >+import org.eclipse.cdt.core.model.ILibraryReference; > import org.eclipse.cdt.core.model.IMethodDeclaration; > import org.eclipse.cdt.core.model.ISourceRoot; > import org.eclipse.cdt.core.model.ITemplate; >@@ -267,6 +268,10 @@ > * Returns an image descriptor for a C element. This is the base image, no overlays. > */ > public ImageDescriptor getBaseImageDescriptor(ICElement celement, int renderFlags) { >+ // Allow contributed languages to provide icons for their extensions to the ICElement hierarchy >+ if (celement instanceof IContributedCElement) >+ return (ImageDescriptor)((IContributedCElement)celement).getAdapter(ImageDescriptor.class); >+ > int type = celement.getElementType(); > switch (type) { > case ICElement.C_VCONTAINER: >#P org.eclipse.cdt.core >Index: parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java,v >retrieving revision 1.9 >diff -u -r1.9 GCCLanguage.java >--- parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java 24 Jan 2006 18:23:53 -0000 1.9 >+++ parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java 27 Mar 2006 21:03:07 -0000 >@@ -17,7 +17,9 @@ > import org.eclipse.cdt.core.dom.PDOM; > import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; > import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; >+import org.eclipse.cdt.core.model.IContributedModelBuilder; > import org.eclipse.cdt.core.model.ILanguage; >+import org.eclipse.cdt.core.model.ITranslationUnit; > import org.eclipse.cdt.core.model.IWorkingCopy; > import org.eclipse.cdt.core.parser.CodeReader; > import org.eclipse.cdt.core.parser.IScanner; >@@ -129,5 +131,9 @@ > public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset) { > return null; > } >- >+ >+ public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { >+ // Use the default CDT model builder >+ return null; >+ } > } >Index: parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java,v >retrieving revision 1.12 >diff -u -r1.12 GPPLanguage.java >--- parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java 24 Jan 2006 18:23:53 -0000 1.12 >+++ parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java 27 Mar 2006 21:03:07 -0000 >@@ -17,7 +17,9 @@ > import org.eclipse.cdt.core.dom.PDOM; > import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; > import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; >+import org.eclipse.cdt.core.model.IContributedModelBuilder; > import org.eclipse.cdt.core.model.ILanguage; >+import org.eclipse.cdt.core.model.ITranslationUnit; > import org.eclipse.cdt.core.model.IWorkingCopy; > import org.eclipse.cdt.core.parser.CodeReader; > import org.eclipse.cdt.core.parser.IScanner; >@@ -128,4 +130,9 @@ > return null; > } > >+ >+ public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { >+ // Use the default CDT model builder >+ return null; >+ } > } >Index: src/org/eclipse/cdt/core/CCorePlugin.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java,v >retrieving revision 1.88 >diff -u -r1.88 CCorePlugin.java >--- src/org/eclipse/cdt/core/CCorePlugin.java 25 Nov 2005 22:01:47 -0000 1.88 >+++ src/org/eclipse/cdt/core/CCorePlugin.java 27 Mar 2006 21:03:07 -0000 >@@ -882,11 +882,13 @@ > * @return > */ > public static IContentType getContentType(IProject project, String filename) { >+ // Always try in the workspace (for multi-language support) > // try with the project settings > if (project != null) { > try { > IContentTypeMatcher matcher = project.getContentTypeMatcher(); >- return matcher.findContentTypeFor(filename); >+ IContentType ct = matcher.findContentTypeFor(filename); >+ if (ct != null) return ct; > } catch (CoreException e) { > // ignore. > } >Index: model/org/eclipse/cdt/core/model/CoreModel.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java,v >retrieving revision 1.64 >diff -u -r1.64 CoreModel.java >--- model/org/eclipse/cdt/core/model/CoreModel.java 6 Jul 2005 02:20:16 -0000 1.64 >+++ model/org/eclipse/cdt/core/model/CoreModel.java 27 Mar 2006 21:03:07 -0000 >@@ -11,6 +11,8 @@ > package org.eclipse.cdt.core.model; > > >+import java.util.ArrayList; >+ > import org.eclipse.cdt.core.CCProjectNature; > import org.eclipse.cdt.core.CCorePlugin; > import org.eclipse.cdt.core.CProjectNature; >@@ -41,6 +43,7 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Plugin; > import org.eclipse.core.runtime.content.IContentType; > import org.eclipse.core.runtime.jobs.ISchedulingRule; > >@@ -185,13 +188,10 @@ > * @return String[] ids > */ > public static String[] getRegistedContentTypeIds() { >- return new String[] { >- CCorePlugin.CONTENT_TYPE_ASMSOURCE, >- CCorePlugin.CONTENT_TYPE_CHEADER, >- CCorePlugin.CONTENT_TYPE_CSOURCE, >- CCorePlugin.CONTENT_TYPE_CXXHEADER, >- CCorePlugin.CONTENT_TYPE_CXXSOURCE >- }; >+ ArrayList a = LanguageManager.getInstance().getAllContentTypes(); >+ String[] result = new String[a.size()]; >+ a.toArray(result); >+ return result; > } > > /** >@@ -201,17 +201,12 @@ > IContentType contentType = CCorePlugin.getContentType(project, name); > if (contentType != null) { > String id = contentType.getId(); >- if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) { >- return true; >- } else if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) { >- return true; >- } else if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) { >- return true; >- } else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) { >- return true; >- } else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) { >- return true; >- } >+ return CCorePlugin.CONTENT_TYPE_CHEADER.equals(id) >+ || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id) >+ || CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id) >+ || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id) >+ || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id) >+ || LanguageManager.getInstance().isContributedContentType(id); > } > return false; > } >@@ -239,13 +234,10 @@ > IContentType contentType = CCorePlugin.getContentType(project, name); > if (contentType != null) { > String id = contentType.getId(); >- if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id)) { >- return true; >- } else if (CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) { >- return true; >- } else if (CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id)) { >- return true; >- } >+ return CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id) >+ || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id) >+ || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id) >+ || LanguageManager.getInstance().isContributedContentType(id); > } > return false; > } >Index: model/org/eclipse/cdt/core/model/ILanguage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java,v >retrieving revision 1.3 >diff -u -r1.3 ILanguage.java >--- model/org/eclipse/cdt/core/model/ILanguage.java 24 Jan 2006 18:23:53 -0000 1.3 >+++ model/org/eclipse/cdt/core/model/ILanguage.java 27 Mar 2006 21:03:07 -0000 >@@ -95,4 +95,13 @@ > */ > public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset); > >+ /** >+ * Used to override the default model building behavior for a translation unit. >+ * >+ * @param tu the <code>ITranslationUnit</code> to be parsed (non-<code>null</code>) >+ * @return an <code>IModelBuilder</code>, which parses the given translation unit and >+ * returns the <code>ICElement</code>s of its model, or <code>null</code> >+ * to parse using the default CDT model builder >+ */ >+ public IContributedModelBuilder createModelBuilder(ITranslationUnit tu); > } >Index: model/org/eclipse/cdt/core/model/ITranslationUnit.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ITranslationUnit.java,v >retrieving revision 1.15 >diff -u -r1.15 ITranslationUnit.java >--- model/org/eclipse/cdt/core/model/ITranslationUnit.java 21 Dec 2005 21:01:27 -0000 1.15 >+++ model/org/eclipse/cdt/core/model/ITranslationUnit.java 27 Mar 2006 21:03:07 -0000 >@@ -12,7 +12,6 @@ > > import java.util.Map; > >-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; > import org.eclipse.cdt.internal.core.model.IBufferFactory; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -375,4 +374,12 @@ > * @return > */ > ILanguage getLanguage() throws CoreException; >+ >+ /** >+ * Used by contributed languages' model builders to indicate whether or >+ * not the parse of a translation unit was successful. >+ * >+ * @param wasSuccessful >+ */ >+ public void setIsStructureKnown(boolean wasSuccessful); > } >Index: model/org/eclipse/cdt/core/model/LanguageManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java,v >retrieving revision 1.1 >diff -u -r1.1 LanguageManager.java >--- model/org/eclipse/cdt/core/model/LanguageManager.java 21 Dec 2005 21:01:27 -0000 1.1 >+++ model/org/eclipse/cdt/core/model/LanguageManager.java 27 Mar 2006 21:03:07 -0000 >@@ -11,7 +11,10 @@ > > package org.eclipse.cdt.core.model; > >+import java.util.ArrayList; >+ > import org.eclipse.cdt.core.CCorePlugin; >+import org.eclipse.cdt.internal.core.model.TranslationUnit; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtension; >@@ -70,4 +73,43 @@ > } > return null; > } >+ >+ public ArrayList/*<String>*/ getAllContentTypes() { >+ ArrayList/*<String>*/ allTypes = new ArrayList(); >+ allTypes.add(CCorePlugin.CONTENT_TYPE_ASMSOURCE); >+ allTypes.add(CCorePlugin.CONTENT_TYPE_CHEADER); >+ allTypes.add(CCorePlugin.CONTENT_TYPE_CSOURCE); >+ allTypes.add(CCorePlugin.CONTENT_TYPE_CXXHEADER); >+ allTypes.add(CCorePlugin.CONTENT_TYPE_CXXSOURCE); >+ >+ IContentTypeManager manager = Platform.getContentTypeManager(); >+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, ILanguage.KEY); >+ IExtension[] extensions = point.getExtensions(); >+ for (int i = 0; i < extensions.length; ++i) { >+ IConfigurationElement[] languages = extensions[i].getConfigurationElements(); >+ for (int j = 0; j < languages.length; ++j) { >+ IConfigurationElement language = languages[j]; >+ IConfigurationElement[] contentTypes = language.getChildren("contentType"); //$NON-NLS-1$ >+ for (int k = 0; k < contentTypes.length; ++k) { >+ IContentType langContType = manager.getContentType(contentTypes[k].getAttribute("id")); //$NON-NLS-1$ >+ allTypes.add(langContType.getId()); >+ } >+ } >+ } >+ >+ return allTypes; >+ } >+ >+ public boolean isContributedContentType(String contentTypeId) { >+ return getAllContentTypes().contains(contentTypeId); >+ } >+ >+ public IContributedModelBuilder getContributedModelBuilderFor(TranslationUnit tu) { >+ try { >+ ILanguage lang = tu.getLanguage(); >+ return lang == null ? null : lang.createModelBuilder(tu); >+ } catch (CoreException e) { >+ return null; >+ } >+ } > } >Index: model/org/eclipse/cdt/internal/core/model/TranslationUnit.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java,v >retrieving revision 1.44 >diff -u -r1.44 TranslationUnit.java >--- model/org/eclipse/cdt/internal/core/model/TranslationUnit.java 18 Jan 2006 18:56:25 -0000 1.44 >+++ model/org/eclipse/cdt/internal/core/model/TranslationUnit.java 27 Mar 2006 21:03:07 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.cdt.core.model.CoreModel; > import org.eclipse.cdt.core.model.IBuffer; > import org.eclipse.cdt.core.model.ICElement; >+import org.eclipse.cdt.core.model.IContributedModelBuilder; > import org.eclipse.cdt.core.model.IInclude; > import org.eclipse.cdt.core.model.ILanguage; > import org.eclipse.cdt.core.model.INamespace; >@@ -279,7 +280,7 @@ > return location; > } > >- protected IFile getFile() { >+ public IFile getFile() { > IResource res = getResource(); > if (res instanceof IFile) { > return (IFile)res; >@@ -580,10 +581,22 @@ > /** > * Parse the buffer contents of this element. > */ >- private void parse(Map newElements){ >+ private void parse(Map newElements) { >+ boolean quickParseMode = ! (CCorePlugin.getDefault().useStructuralParseMode()); >+ IContributedModelBuilder mb = LanguageManager.getInstance().getContributedModelBuilderFor(this); >+ if (mb == null) { >+ parseUsingCModelBuilder(newElements, quickParseMode); >+ } else { >+ parseUsingContributedModelBuilder(mb, quickParseMode); >+ } >+ } >+ >+ /** >+ * Parse the buffer contents of this element. >+ */ >+ private void parseUsingCModelBuilder(Map newElements, boolean quickParseMode) { > try { > CModelBuilder modelBuilder = new CModelBuilder(this, newElements); >- boolean quickParseMode = ! (CCorePlugin.getDefault().useStructuralParseMode()); > modelBuilder.parse(quickParseMode); > } catch (Exception e) { > // use the debug log for this exception. >@@ -591,6 +604,15 @@ > } > } > >+ private void parseUsingContributedModelBuilder(IContributedModelBuilder mb, boolean quickParseMode) { >+ try { >+ mb.parse(quickParseMode); >+ } catch (Exception e) { >+ // use the debug log for this exception. >+ Util.debugLog( "Exception in contributed model builder", IDebugLogConstants.MODEL); //$NON-NLS-1$ >+ } >+ } >+ > public IProblemRequestor getProblemRequestor() { > return problemRequestor; > } >@@ -613,6 +635,7 @@ > CCorePlugin.CONTENT_TYPE_CSOURCE.equals(contentTypeId) > || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(contentTypeId) > || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(contentTypeId) >+ || LanguageManager.getInstance().isContributedContentType(contentTypeId) > ); > } > >@@ -695,4 +718,19 @@ > } > super.closing(info); > } >+ >+ /** >+ * Contributed languages' model builders need to be able to indicate whether or >+ * not the parse of a translation unit was successful without having access to >+ * the <code>CElementInfo</code> object associated with the translation unit >+ * >+ * @param wasSuccessful >+ */ >+ public void setIsStructureKnown(boolean wasSuccessful) { >+ try { >+ this.getElementInfo().setIsStructureKnown(wasSuccessful); >+ } catch (CModelException e) { >+ ; >+ } >+ } > } >Index: model/org/eclipse/cdt/core/model/IContributedModelBuilder.java >=================================================================== >RCS file: model/org/eclipse/cdt/core/model/IContributedModelBuilder.java >diff -N model/org/eclipse/cdt/core/model/IContributedModelBuilder.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/cdt/core/model/IContributedModelBuilder.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+package org.eclipse.cdt.core.model; >+ >+/** >+ * Interface supported by model builders for contributed languages. >+ * >+ * Model builders parse a <code>TranslationUnit</code> (i.e., a file) and >+ * return a hierarchy of <code>ICElement</code>s which represent the high-level >+ * structure of that file (what modules, classes, functions, and similar >+ * constructs are contained in it, and on what line(s) the definition occurs). >+ * >+ * The translation unit to parse and the initial element map are given to >+ * <code>IAdditionalLanguage#createModelBuilder</code>, which will presumably >+ * pass that information on to the model builder constructor. >+ * >+ * @author Jeff Overbey >+ */ >+public interface IContributedModelBuilder { >+ /** >+ * Callback used when a <code>TranslationUnit</code> needs to be parsed. >+ * >+ * The translation unit to parse is given to >+ * <code>ILanguage#createModelBuilder</code>, which will presumably >+ * pass it on to the model builder constructor. >+ */ >+ public abstract void parse(boolean quickParseMode) throws Exception; >+} >Index: model/org/eclipse/cdt/core/model/IContributedCElement.java >=================================================================== >RCS file: model/org/eclipse/cdt/core/model/IContributedCElement.java >diff -N model/org/eclipse/cdt/core/model/IContributedCElement.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/cdt/core/model/IContributedCElement.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,17 @@ >+package org.eclipse.cdt.core.model; >+ >+import org.eclipse.core.runtime.IAdaptable; >+ >+/** >+ * Additions to the <code>ICElement</code> hierarchy provided by >+ * contributed languages. >+ * >+ * Contributed elements are required to be adaptable to an >+ * <code>ImageDescriptor</code>. >+ * >+ * @author Jeff Overbey >+ * @see ICElement >+ * @see IAdaptable >+ */ >+public interface IContributedCElement extends ICElement { >+}
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
Flags:
bjorn.freeman-benson
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 133386
:
36996
| 37020