[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
A fix for bug 36379: The parser to set Line information when scanning as
well.
-----Original Message-----
From: Amer, Hoda [mailto:hamer@xxxxxxxxxxxx]
Sent: Thursday, April 17, 2003 11:49 AM
To: 'cdt-patch@xxxxxxxxxxx'
Subject: [cdt-patch] Fix for bug 36604 : NPE in CModelBuilder for given
input
Fix for bug 36604 : NPE in CModelBuilder for given input
Thanks
Hoda
Index: model/org/eclipse/cdt/core/model/ICElement.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java,v
retrieving revision 1.7
diff -u -r1.7 ICElement.java
--- model/org/eclipse/cdt/core/model/ICElement.java 11 Apr 2003 14:36:51 -0000 1.7
+++ model/org/eclipse/cdt/core/model/ICElement.java 17 Apr 2003 18:22:23 -0000
@@ -294,4 +294,14 @@
* exception occurs while accessing its corresponding resource
*/
boolean isStructureKnown() throws CModelException;
+ /**
+ * Returns the start line of the CElement
+ * @return
+ */
+ int getStartLine();
+ /**
+ * Returns the end line of the CElement
+ * @return
+ */
+ int getEndLine();
}
Index: parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.14
diff -u -r1.14 CModelBuilder.java
--- parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 17 Apr 2003 13:41:43 -0000 1.14
+++ parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 17 Apr 2003 18:22:23 -0000
@@ -228,6 +228,8 @@
// set position
element.setIdPos(inclusion.getNameOffset(), inclusion.getNameLength());
element.setPos(inclusion.getStartingOffset(), inclusion.getTotalLength());
+ // set the element lines
+ element.setLines(inclusion.getTopLine(), inclusion.getBottomLine());
this.newElements.put(element, element.getElementInfo());
return element;
}
@@ -240,6 +242,8 @@
// set position
element.setIdPos(macro.getNameOffset(), macro.getNameLength());
element.setPos(macro.getStartingOffset(), macro.getTotalLength());
+ // set the element lines
+ element.setLines(macro.getTopLine(), macro.getBottomLine());
this.newElements.put(element, element.getElementInfo());
return element;
}
@@ -258,6 +262,8 @@
}
element.setPos(nsDef.getStartingOffset(), nsDef.getTotalLength());
element.setTypeName(nsDef.getStartToken().getImage());
+ // set the element lines
+ element.setLines(nsDef.getTopLine(), nsDef.getBottomLine());
this.newElements.put(element, element.getElementInfo());
return element;
@@ -284,6 +290,8 @@
}
element.setPos(enumSpecifier.getStartingOffset(), enumSpecifier.getTotalLength());
element.setTypeName(enumSpecifier.getStartToken().getImage());
+ // set the element lines
+ element.setLines(enumSpecifier.getTopLine(), enumSpecifier.getBottomLine());
this.newElements.put(element, element.getElementInfo());
return element;
@@ -296,6 +304,8 @@
// set enumerator position
element.setIdPos(enumDef.getName().getStartOffset(), enumDef.getName().length());
element.setPos(enumDef.getStartingOffset(), enumDef.getTotalLength());
+ // set the element lines
+ element.setLines(enumDef.getTopLine(), enumDef.getBottomLine());
this.newElements.put(element, element.getElementInfo());
return element;
@@ -345,6 +355,8 @@
}
element.setTypeName( type );
element.setPos(classSpecifier.getStartingOffset(), classSpecifier.getTotalLength());
+ // set the element lines
+ element.setLines(classSpecifier.getTopLine(), classSpecifier.getBottomLine());
this.newElements.put(element, element.getElementInfo());
return element;
@@ -366,13 +378,19 @@
// set positions
element.setIdPos(domName.getStartOffset(), domName.length());
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
+ // set the element lines
+ element.setLines(simpleDeclaration.getTopLine(), simpleDeclaration.getBottomLine());
this.newElements.put(element, element.getElementInfo());
return element;
}
protected VariableDeclaration createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
- String variableName = declarator.getName().toString();
+ Name domName = ( declarator.getDeclarator() != null ) ?
+ declarator.getDeclarator().getName() :
+ declarator.getName();
+
+ String variableName = domName.toString();
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
VariableDeclaration element = null;
@@ -403,15 +421,21 @@
parent.addChild( element );
// set position
- element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
+ element.setIdPos( domName.getStartOffset(), domName.length() );
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
+ // set the element lines
+ element.setLines(simpleDeclaration.getTopLine(), simpleDeclaration.getBottomLine());
this.newElements.put(element, element.getElementInfo());
return element;
}
protected FunctionDeclaration createFunctionSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator, ParameterDeclarationClause pdc, boolean isTemplate){
- String declaratorName = declarator.getName().toString();
+ Name domName = ( declarator.getDeclarator() != null ) ?
+ declarator.getDeclarator().getName() :
+ declarator.getName();
+
+ String declaratorName = domName.toString();
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
// getParameterTypes
List parameterList = pdc.getDeclarations();
@@ -482,8 +506,11 @@
parent.addChild( element );
// hook up the offsets
- element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
+ element.setIdPos( domName.getStartOffset(), domName.length() );
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
+ // set the element lines
+ element.setLines(simpleDeclaration.getTopLine(), simpleDeclaration.getBottomLine());
+
this.newElements.put(element, element.getElementInfo());
return element;
}
@@ -504,10 +531,14 @@
|| ( parent instanceof INamespace ))
{
element = new VariableDeclaration(parent, declaratorName);
- }
+ } else if( parent instanceof IStructure){
+ Field newElement = new Field(parent, declaratorName);
+ newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
+ element = newElement;
+ }
+
StringBuffer typeName = new StringBuffer();
typeName.append(getType(simpleDeclaration, declarator));
- typeName.append("(*)");
if(parameterTypes.length > 0){
typeName.append("(");
int i = 0;
@@ -532,6 +563,9 @@
// hook up the offsets
element.setIdPos( declarator.getDeclarator().getName().getStartOffset(), declarator.getDeclarator().getName().length() );
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
+ // set the element lines
+ element.setLines(simpleDeclaration.getTopLine(), simpleDeclaration.getBottomLine());
+
this.newElements.put(element, element.getElementInfo());
return element;
}
@@ -589,6 +623,10 @@
type.append(getDeclarationType(declaration));
// add pointerr or reference from declarator if any
type.append(getDeclaratorPointerOperation(declarator));
+ // pointer to function or array of functions
+ if(declarator.getDeclarator() != null)
+ type.append("(*)");
+ // arrays
type.append(getDeclaratorArrayQualifiers(declarator));
return type.toString();
}