mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Patch for Hoda Amer adds:
- the support for namespaces in the NewModelBuilder. - an icon for extern variables. - a JUnit test case for core model elements, including namespaces. The enum_obj_gif should overwrite the existing file.
This commit is contained in:
parent
19805635c6
commit
d66e2dca22
10 changed files with 263 additions and 72 deletions
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +13,7 @@ import org.eclipse.cdt.core.model.IParent;
|
||||||
*/
|
*/
|
||||||
public interface ICElementWrapper {
|
public interface ICElementWrapper {
|
||||||
|
|
||||||
public IParent getElement();
|
public ICElement getElement();
|
||||||
public void setElement (IParent item);
|
public void setElement (ICElement item);
|
||||||
|
public IParent getParent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Apr 1, 2003
|
||||||
|
*
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
public class NamespaceWrapper implements ICElementWrapper{
|
||||||
|
private Name name;
|
||||||
|
private final IParent parent;
|
||||||
|
private ICElement element;
|
||||||
|
|
||||||
|
public NamespaceWrapper( IParent incoming)
|
||||||
|
{
|
||||||
|
this.parent= incoming;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name.
|
||||||
|
* @return Name
|
||||||
|
*/
|
||||||
|
public Name getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the parent.
|
||||||
|
* @return IParent
|
||||||
|
*/
|
||||||
|
public IParent getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name.
|
||||||
|
* @param name The name to set
|
||||||
|
*/
|
||||||
|
public void setName(Name name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.ICElementWrapper#getElement()
|
||||||
|
*/
|
||||||
|
public ICElement getElement() {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.ICElementWrapper#setElement(org.eclipse.cdt.core.model.IParent)
|
||||||
|
*/
|
||||||
|
public void setElement(ICElement item) {
|
||||||
|
element = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.internal.core.parser.IParserCallback;
|
import org.eclipse.cdt.internal.core.parser.IParserCallback;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||||
|
@ -136,13 +137,14 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
*/
|
*/
|
||||||
public Object simpleDeclarationBegin(Object container) {
|
public Object simpleDeclarationBegin(Object container) {
|
||||||
ICElementWrapper wrapper = (ICElementWrapper)container;
|
ICElementWrapper wrapper = (ICElementWrapper)container;
|
||||||
Object parent = wrapper.getElement();
|
// Assuming that the parent is the container's element
|
||||||
|
IParent parent = (IParent)wrapper.getElement();
|
||||||
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
|
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
|
||||||
|
result.setParent( parent );
|
||||||
|
// A special case to transfere the visibility
|
||||||
if( wrapper instanceof SimpleDeclarationWrapper ){
|
if( wrapper instanceof SimpleDeclarationWrapper ){
|
||||||
result.setParent( wrapper.getElement() );
|
|
||||||
result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
|
result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
|
||||||
} else if ( wrapper instanceof TranslationUnitWrapper )
|
}
|
||||||
result.setParent( (TranslationUnit)wrapper.getElement());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,8 +356,9 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
elem.setElementName( elementName );
|
elem.setElementName( elementName );
|
||||||
if( wrapper.getName() != null )
|
if( wrapper.getName() != null )
|
||||||
{
|
{
|
||||||
elem.setIdPos(wrapper.getName().getStartOffset(), wrapper.getName().length());
|
elem.setTypeName( wrapper.getClassKind().getImage() );
|
||||||
elem.setPos(wrapper.getName().getStartOffset(), wrapper.getName().length());
|
elem.setIdPos(wrapper.getName().getStartOffset(), elementName.length());
|
||||||
|
elem.setPos(wrapper.getName().getStartOffset(), elementName.length());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -549,21 +552,37 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object namespaceDefinitionBegin(Object container) {
|
public Object namespaceDefinitionBegin(Object container) {
|
||||||
// until Namespaces are made part of the code model, just return the container object
|
|
||||||
return container;
|
ICElementWrapper c = (ICElementWrapper)container;
|
||||||
|
NamespaceWrapper wrapper = new NamespaceWrapper((IParent)c.getElement());
|
||||||
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationId(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationId(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionId(Object namespace) {
|
public void namespaceDefinitionId(Object namespace) {
|
||||||
// until namespaceDefinitionBegin is updated to do more than return its container, do nothing
|
// set wrapper name to current name
|
||||||
|
NamespaceWrapper wrapper = (NamespaceWrapper)namespace;
|
||||||
|
wrapper.setName( currName );
|
||||||
|
|
||||||
|
// create the new element
|
||||||
|
String namespaceName = wrapper.getName().toString();
|
||||||
|
Parent realParent = (Parent)wrapper.getParent();
|
||||||
|
Namespace newNameSpace = new Namespace( (ICElement)realParent, namespaceName );
|
||||||
|
wrapper.setElement(newNameSpace);
|
||||||
|
realParent.addChild( newNameSpace );
|
||||||
|
|
||||||
|
// set the positions
|
||||||
|
newNameSpace.setIdPos(wrapper.getName().getStartOffset(), namespaceName.length());
|
||||||
|
newNameSpace.setPos(wrapper.getName().getStartOffset(), namespaceName.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationAbort(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationAbort(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionAbort(Object namespace) {
|
public void namespaceDefinitionAbort(Object namespace) {
|
||||||
|
namespace = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -3,7 +3,9 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.INamespace;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IStructure;
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
|
@ -17,7 +19,7 @@ import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
*/
|
*/
|
||||||
public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpecifier.Container, ICElementWrapper {
|
public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpecifier.Container, ICElementWrapper {
|
||||||
|
|
||||||
private IParent element = null;
|
private ICElement element = null;
|
||||||
private IParent parent = null;
|
private IParent parent = null;
|
||||||
|
|
||||||
private Name name = null;
|
private Name name = null;
|
||||||
|
@ -36,7 +38,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
* Returns the item.
|
* Returns the item.
|
||||||
* @return CElement
|
* @return CElement
|
||||||
*/
|
*/
|
||||||
public IParent getElement() {
|
public ICElement getElement() {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +46,8 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
* Sets the item.
|
* Sets the item.
|
||||||
* @param item The item to set
|
* @param item The item to set
|
||||||
*/
|
*/
|
||||||
public void setElement (IParent item) {
|
public void setElement (ICElement item) {
|
||||||
this.element = (IParent)item;
|
this.element = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +92,8 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
{
|
{
|
||||||
declaration = createField( parentElement, declaratorName );
|
declaration = createField( parentElement, declaratorName );
|
||||||
}
|
}
|
||||||
else if( parentElement instanceof ITranslationUnit )
|
else if(( parentElement instanceof ITranslationUnit )
|
||||||
|
|| ( parentElement instanceof INamespace ))
|
||||||
{
|
{
|
||||||
if(isExtern())
|
if(isExtern())
|
||||||
{
|
{
|
||||||
|
@ -112,10 +115,18 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
// this is a function or a method
|
// this is a function or a method
|
||||||
if( parentElement instanceof IStructure )
|
if( parentElement instanceof IStructure )
|
||||||
{
|
{
|
||||||
declaration = createMethodDeclaration( parentElement, declaratorName, parameters );
|
if (isFunctionDefinition())
|
||||||
|
{
|
||||||
|
declaration = createMethod( parentElement, declaratorName, parameters );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
declaration = createMethodDeclaration( parentElement, declaratorName, parameters );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( parentElement instanceof ITranslationUnit )
|
else if(( parentElement instanceof ITranslationUnit )
|
||||||
|
|| ( parentElement instanceof INamespace ))
|
||||||
{
|
{
|
||||||
if (isFunctionDefinition())
|
if (isFunctionDefinition())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,13 +18,13 @@ public class TranslationUnitWrapper implements ICElementWrapper {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.model.IWrapper#getElement()
|
* @see org.eclipse.cdt.internal.core.model.IWrapper#getElement()
|
||||||
*/
|
*/
|
||||||
public IParent getElement() {
|
public ICElement getElement() {
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.model.IWrapper#setElement(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.model.IWrapper#setElement(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void setElement(IParent item) {
|
public void setElement(ICElement item) {
|
||||||
unit = (TranslationUnit)item;
|
unit = (TranslationUnit)item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,4 +32,11 @@ public class TranslationUnitWrapper implements ICElementWrapper {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.ICElementWrapper#getParent()
|
||||||
|
*/
|
||||||
|
public IParent getParent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
package org.eclipse.cdt.core.model.tests;
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* 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:
|
||||||
|
* Rational Software - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.IField;
|
||||||
|
import org.eclipse.cdt.core.model.IMember;
|
||||||
|
import org.eclipse.cdt.core.model.IMethod;
|
||||||
|
import org.eclipse.cdt.core.model.INamespace;
|
||||||
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
|
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||||
|
import org.eclipse.cdt.testplugin.CProjectHelper;
|
||||||
|
import org.eclipse.cdt.testplugin.TestPluginLauncher;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
public class CModelElementsTests extends TestCase {
|
||||||
|
private ICProject fCProject;
|
||||||
|
private IFile headerFile;
|
||||||
|
private NullProgressMonitor monitor;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), WorkingCopyTests.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite();
|
||||||
|
suite.addTest(new CModelElementsTests("testCModelElements"));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CModelElementsTests(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
monitor = new NullProgressMonitor();
|
||||||
|
String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.ui.tests").find(new Path("/")).getFile();
|
||||||
|
|
||||||
|
fCProject= CProjectHelper.createCProject("TestProject1", "bin");
|
||||||
|
headerFile = fCProject.getProject().getFile("CModelElementsTest.h");
|
||||||
|
if (!headerFile.exists()) {
|
||||||
|
try{
|
||||||
|
FileInputStream fileIn = new FileInputStream(pluginRoot+ "model/org/eclipse/cdt/core/model/tests/resources/cfiles/CModelElementsTestStart.h");
|
||||||
|
headerFile.create(fileIn,false, monitor);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CCorePlugin.getDefault().setUseNewParser(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
CProjectHelper.delete(fCProject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCModelElements(){
|
||||||
|
TranslationUnit tu = new TranslationUnit(fCProject, headerFile);
|
||||||
|
// parse the translation unit to get the elements tree
|
||||||
|
tu.parse();
|
||||||
|
|
||||||
|
// tu ---> namespace MyPackage
|
||||||
|
ArrayList tuPackages = tu.getChildrenOfType(ICElement.C_NAMESPACE);
|
||||||
|
INamespace namespace = (INamespace) tuPackages.get(0);
|
||||||
|
assertEquals(namespace.getElementName(), new String("MyPackage"));
|
||||||
|
|
||||||
|
// MyPackage ---> class Hello
|
||||||
|
ArrayList nsClassChildren = namespace.getChildrenOfType(ICElement.C_CLASS);
|
||||||
|
IStructure classHello = (IStructure) nsClassChildren.get(0);
|
||||||
|
assertEquals(classHello.getElementName(), new String("Hello"));
|
||||||
|
|
||||||
|
// Hello --> int x
|
||||||
|
ArrayList helloFieldChildren = classHello.getChildrenOfType(ICElement.C_FIELD);
|
||||||
|
IField intX = (IField) helloFieldChildren.get(0);
|
||||||
|
assertEquals(intX.getElementName(), new String("x"));
|
||||||
|
int visibility = intX.getVisibility();
|
||||||
|
if (visibility != IMember.V_PROTECTED)
|
||||||
|
fail("visibility should be protected!");
|
||||||
|
|
||||||
|
|
||||||
|
// Hello ---> void setX(int X)
|
||||||
|
ArrayList helloMethodChildren = classHello.getChildrenOfType(ICElement.C_METHOD);
|
||||||
|
IMethod setX = (IMethod) helloMethodChildren.get(0);
|
||||||
|
assertEquals(setX.getElementName(), new String("setX"));
|
||||||
|
int setXNumOfParam = setX.getNumberOfParameters();
|
||||||
|
if(setXNumOfParam != 1)
|
||||||
|
fail("setX should have one parameter!");
|
||||||
|
String[] setXParamTypes = setX.getParameterTypes();
|
||||||
|
String firstParamType = setXParamTypes[0];
|
||||||
|
assertEquals(firstParamType, new String("int"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
namespace MyPackage{
|
||||||
|
class Hello{
|
||||||
|
protected:
|
||||||
|
int x;
|
||||||
|
void setX(int X){
|
||||||
|
x = X;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -251,6 +251,9 @@ public class CElementImageProvider {
|
||||||
case ICElement.C_FUNCTION:
|
case ICElement.C_FUNCTION:
|
||||||
return CPluginImages.DESC_OBJS_FUNCTION;
|
return CPluginImages.DESC_OBJS_FUNCTION;
|
||||||
|
|
||||||
|
case ICElement.C_VARIABLE_DECLARATION:
|
||||||
|
return CPluginImages.DESC_OBJS_VAR_DECLARARION;
|
||||||
|
|
||||||
case ICElement.C_FUNCTION_DECLARATION:
|
case ICElement.C_FUNCTION_DECLARATION:
|
||||||
return CPluginImages.DESC_OBJS_DECLARARION;
|
return CPluginImages.DESC_OBJS_DECLARARION;
|
||||||
|
|
||||||
|
@ -259,58 +262,12 @@ public class CElementImageProvider {
|
||||||
|
|
||||||
case ICElement.C_MACRO:
|
case ICElement.C_MACRO:
|
||||||
return CPluginImages.DESC_OBJS_MACRO;
|
return CPluginImages.DESC_OBJS_MACRO;
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImageDescriptor getCElementImageDescriptor(int type) {
|
case ICElement.C_NAMESPACE:
|
||||||
switch (type) {
|
|
||||||
case ICElement.C_VCONTAINER:
|
|
||||||
return CPluginImages.DESC_OBJS_CONTAINER;
|
return CPluginImages.DESC_OBJS_CONTAINER;
|
||||||
|
|
||||||
case ICElement.C_UNIT:
|
|
||||||
return CPluginImages.DESC_OBJS_TUNIT;
|
|
||||||
|
|
||||||
case ICElement.C_STRUCT:
|
|
||||||
return CPluginImages.DESC_OBJS_STRUCT;
|
|
||||||
|
|
||||||
case ICElement.C_CLASS:
|
|
||||||
return CPluginImages.DESC_OBJS_CLASS;
|
|
||||||
|
|
||||||
case ICElement.C_UNION:
|
|
||||||
return CPluginImages.DESC_OBJS_UNION;
|
|
||||||
|
|
||||||
case ICElement.C_TYPEDEF:
|
|
||||||
return CPluginImages.DESC_OBJS_TYPEDEF;
|
|
||||||
|
|
||||||
case ICElement.C_ENUMERATION:
|
|
||||||
return CPluginImages.DESC_OBJS_ENUMERATION;
|
|
||||||
|
|
||||||
case ICElement.C_ENUMERATOR:
|
|
||||||
return CPluginImages.DESC_OBJS_ENUMERATOR;
|
|
||||||
|
|
||||||
case ICElement.C_FIELD:
|
|
||||||
return CPluginImages.DESC_OBJS_PUBLIC_FIELD;
|
|
||||||
|
|
||||||
case ICElement.C_VARIABLE:
|
|
||||||
return CPluginImages.DESC_OBJS_FIELD;
|
|
||||||
|
|
||||||
case ICElement.C_METHOD: // assumed public
|
|
||||||
return CPluginImages.DESC_OBJS_PUBLIC_METHOD;
|
|
||||||
|
|
||||||
case ICElement.C_FUNCTION:
|
|
||||||
case ICElement.C_FUNCTION_DECLARATION:
|
|
||||||
return CPluginImages.DESC_OBJS_FUNCTION;
|
|
||||||
|
|
||||||
case ICElement.C_INCLUDE:
|
|
||||||
return CPluginImages.DESC_OBJS_INCLUDE;
|
|
||||||
|
|
||||||
case ICElement.C_MACRO:
|
|
||||||
return CPluginImages.DESC_OBJS_MACRO;
|
|
||||||
}
|
}
|
||||||
System.out.println("Unknown base object ype " + type);
|
return null;
|
||||||
return CPluginImages.DESC_OBJS_MACRO;
|
|
||||||
//return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class CPluginImages {
|
||||||
public static final String IMG_OBJS_PROTECTED_FIELD= NAME_PREFIX + "field_protected_obj.gif";
|
public static final String IMG_OBJS_PROTECTED_FIELD= NAME_PREFIX + "field_protected_obj.gif";
|
||||||
public static final String IMG_OBJS_PRIVATE_FIELD= NAME_PREFIX + "field_private_obj.gif";
|
public static final String IMG_OBJS_PRIVATE_FIELD= NAME_PREFIX + "field_private_obj.gif";
|
||||||
public static final String IMG_OBJS_DECLARATION= NAME_PREFIX + "cdeclaration_obj.gif";
|
public static final String IMG_OBJS_DECLARATION= NAME_PREFIX + "cdeclaration_obj.gif";
|
||||||
|
public static final String IMG_OBJS_VAR_DECLARATION= NAME_PREFIX + "var_declaration_obj.gif";
|
||||||
public static final String IMG_OBJS_INCLUDE= NAME_PREFIX + "include_obj.gif";
|
public static final String IMG_OBJS_INCLUDE= NAME_PREFIX + "include_obj.gif";
|
||||||
public static final String IMG_OBJS_MACRO= NAME_PREFIX + "define_obj.gif";
|
public static final String IMG_OBJS_MACRO= NAME_PREFIX + "define_obj.gif";
|
||||||
public static final String IMG_OBJS_TUNIT= NAME_PREFIX + "c_file_obj.gif";
|
public static final String IMG_OBJS_TUNIT= NAME_PREFIX + "c_file_obj.gif";
|
||||||
|
@ -90,6 +91,7 @@ public class CPluginImages {
|
||||||
public static final ImageDescriptor DESC_OBJS_PROTECTED_FIELD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_FIELD);
|
public static final ImageDescriptor DESC_OBJS_PROTECTED_FIELD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_FIELD);
|
||||||
public static final ImageDescriptor DESC_OBJS_PRIVATE_FIELD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_FIELD);
|
public static final ImageDescriptor DESC_OBJS_PRIVATE_FIELD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_FIELD);
|
||||||
public static final ImageDescriptor DESC_OBJS_DECLARARION= createManaged(T_OBJ, IMG_OBJS_DECLARATION);
|
public static final ImageDescriptor DESC_OBJS_DECLARARION= createManaged(T_OBJ, IMG_OBJS_DECLARATION);
|
||||||
|
public static final ImageDescriptor DESC_OBJS_VAR_DECLARARION= createManaged(T_OBJ, IMG_OBJS_VAR_DECLARATION);
|
||||||
public static final ImageDescriptor DESC_OBJS_INCLUDE= createManaged(T_OBJ, IMG_OBJS_INCLUDE);
|
public static final ImageDescriptor DESC_OBJS_INCLUDE= createManaged(T_OBJ, IMG_OBJS_INCLUDE);
|
||||||
public static final ImageDescriptor DESC_OBJS_MACRO= createManaged(T_OBJ, IMG_OBJS_MACRO);
|
public static final ImageDescriptor DESC_OBJS_MACRO= createManaged(T_OBJ, IMG_OBJS_MACRO);
|
||||||
public static final ImageDescriptor DESC_OBJS_TUNIT= createManaged(T_OBJ, IMG_OBJS_TUNIT);
|
public static final ImageDescriptor DESC_OBJS_TUNIT= createManaged(T_OBJ, IMG_OBJS_TUNIT);
|
||||||
|
|
|
@ -76,6 +76,7 @@ public class CElementLabelProvider extends LabelProvider {
|
||||||
name = fDecl.getSignature();
|
name = fDecl.getSignature();
|
||||||
break;
|
break;
|
||||||
case ICElement.C_STRUCT:
|
case ICElement.C_STRUCT:
|
||||||
|
case ICElement.C_UNION:
|
||||||
case ICElement.C_ENUMERATION:
|
case ICElement.C_ENUMERATION:
|
||||||
if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){
|
if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){
|
||||||
name = celem.getElementName();
|
name = celem.getElementName();
|
||||||
|
|
Loading…
Add table
Reference in a new issue