### Eclipse Workspace Patch 1.0
#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 10 Mar 2006 07:23:32 -0000
@@ -19,6 +19,7 @@
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.model.addl_langs.IContributedModelBuilder;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IScannerInfo;
@@ -32,6 +33,7 @@
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.c.GCCParserExtensionConfiguration;
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
@@ -129,5 +131,9 @@
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset) {
return null;
}
-
+
+ public IContributedModelBuilder createModelBuilder(TranslationUnit tu) {
+ // JO -- 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 10 Mar 2006 07:23:32 -0000
@@ -19,6 +19,7 @@
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.model.addl_langs.IContributedModelBuilder;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IScannerInfo;
@@ -32,6 +33,7 @@
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
@@ -128,4 +130,9 @@
return null;
}
+
+ public IContributedModelBuilder createModelBuilder(TranslationUnit tu) {
+ // JO -- 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 10 Mar 2006 07:23:33 -0000
@@ -882,11 +882,13 @@
* @return
*/
public static IContentType getContentType(IProject project, String filename) {
+ // JO -- Always try in the workspace
// 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: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/META-INF/MANIFEST.MF,v
retrieving revision 1.8
diff -u -r1.8 MANIFEST.MF
--- META-INF/MANIFEST.MF 2 Feb 2006 21:27:14 -0000 1.8
+++ META-INF/MANIFEST.MF 10 Mar 2006 07:23:29 -0000
@@ -19,6 +19,7 @@
org.eclipse.cdt.core.formatter,
org.eclipse.cdt.core.index,
org.eclipse.cdt.core.model,
+ org.eclipse.cdt.core.model.addl_langs,
org.eclipse.cdt.core.parser,
org.eclipse.cdt.core.parser.ast,
org.eclipse.cdt.core.parser.ast.gcc,
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 10 Mar 2006 07:23:31 -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 10 Mar 2006 07:23:31 -0000
@@ -13,6 +13,7 @@
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.addl_langs.IContributedModelBuilder;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IStorage;
@@ -95,4 +96,13 @@
*/
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset);
+ /**
+ * Used to override the default model building behavior for a translation unit.
+ *
+ * @param tu the TranslationUnit
to be parsed (non-null
)
+ * @return an IModelBuilder
, which parses the given translation unit and
+ * returns the ICElement
s of its model, or null
+ * to parse using the default CDT model builder
+ */
+ public IContributedModelBuilder createModelBuilder(org.eclipse.cdt.internal.core.model.TranslationUnit tu);
}
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 10 Mar 2006 07:23:31 -0000
@@ -11,7 +11,11 @@
package org.eclipse.cdt.core.model;
+import java.util.ArrayList;
+
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.addl_langs.IContributedModelBuilder;
+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 +74,43 @@
}
return null;
}
+
+ public ArrayList/**/ getAllContentTypes() {
+ ArrayList/**/ 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 10 Mar 2006 07:23:32 -0000
@@ -14,6 +14,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
@@ -31,6 +32,7 @@
import org.eclipse.cdt.core.model.IUsing;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.model.addl_langs.IContributedModelBuilder;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -279,7 +281,7 @@
return location;
}
- protected IFile getFile() {
+ public IFile getFile() {
IResource res = getResource();
if (res instanceof IFile) {
return (IFile)res;
@@ -580,10 +582,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 +605,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 +636,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 +719,20 @@
}
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 CElementInfo
object associated with the translation unit
+ *
+ * @param wasSuccessful
+ * @throws CModelException
+ */
+ public void setIsStructureKnown(boolean wasSuccessful) {
+ try {
+ this.getElementInfo().setIsStructureKnown(wasSuccessful);
+ } catch (CModelException e) {
+ ;
+ }
+ }
}
Index: model/org/eclipse/cdt/core/model/addl_langs/IContributedCElement.java
===================================================================
RCS file: model/org/eclipse/cdt/core/model/addl_langs/IContributedCElement.java
diff -N model/org/eclipse/cdt/core/model/addl_langs/IContributedCElement.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/core/model/addl_langs/IContributedCElement.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,40 @@
+package org.eclipse.cdt.core.model.addl_langs;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * Additions to the ICElement
hierarchy provided by
+ * contributed languages.
+ *
+ * @author Jeff Overbey
+ */
+public interface IContributedCElement extends ICElement {
+ /**
+ * @return an ImageDescriptor
for displaying alongside the
+ * element in the Outline (or similar view)
+ *
+ * The return type is Object
for now so that we don't
+ * have JFace as a dependency.
+ *
+ * Note...
+ *
+ * In the ICElement
hierarchy, icons are determined by a
+ * giant case
statement in
+ * CElementImageProvider#getBaseImageDescriptor
. Since
+ * case
statements based on types are bad (and error-prone)
+ * and we prefer to have everything in one place, we simply ask each
+ * FortranElement
to tell us what its pictorial
+ * representation is. Yeah, if you want to argue that this is user interface
+ * stuff, it's in the wrong place... but for us, the chances are much higher
+ * that we will change the hierarchy than change the icons, so putting
+ * everything in one place is a better move.
+ *
+ * To make this work, at the top of
+ * CElementImageProvider#getBaseImageDescriptor
, I added
+ * these lines:
+ * if (celement instanceof FortranElement)
+ * return ((FortranElement)celement).getBaseImageDescriptor();
+ *
+ */
+ public abstract Object getBaseImageDescriptor();
+}
Index: model/org/eclipse/cdt/core/model/addl_langs/IContributedModelBuilder.java
===================================================================
RCS file: model/org/eclipse/cdt/core/model/addl_langs/IContributedModelBuilder.java
diff -N model/org/eclipse/cdt/core/model/addl_langs/IContributedModelBuilder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/core/model/addl_langs/IContributedModelBuilder.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,26 @@
+package org.eclipse.cdt.core.model.addl_langs;
+
+/**
+ * Interface supported by model builders for contributed languages.
+ *
+ * Model builders parse a TranslationUnit
(i.e., a file) and
+ * return a hierarchy of ICElement
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
+ * IAdditionalLanguage#createModelBuilder
, which will presumably
+ * pass that information on to the model builder constructor.
+ *
+ * @author Jeff Overbey
+ */
+public interface IContributedModelBuilder {
+ /**
+ * Callback used when a TranslationUnit
needs to be parsed.
+ *
+ * The translation unit to parse is given to
+ * ILanguage#createModelBuilder
, which will presumably
+ * pass it on to the model builder constructor.
+ */
+ public abstract void parse(boolean quickParseMode) throws Exception;
+}
#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 10 Mar 2006 07:23:36 -0000
@@ -19,12 +19,13 @@
import org.eclipse.cdt.core.model.ICProject;
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;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.addl_langs.IContributedCElement;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.ui.CElementImageDescriptor;
@@ -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) {
+ // JO -- Allow contributed languages to provide icons for their extensions to the ICElement hierarchy
+ if (celement instanceof IContributedCElement)
+ return (ImageDescriptor)((IContributedCElement)celement).getBaseImageDescriptor();
+
int type = celement.getElementType();
switch (type) {
case ICElement.C_VCONTAINER: