mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
2004-07-30 Alain Magloire
Add the Using-{directive,declaration} part of the Core Model. * model/org/eclipse/cdt/core/model/IUsing.java * model/org/eclipse/cdt/internal/core/model/CElement.java * model/org/eclipse/cdt/internal/core/model/CModelBuilder.java * model/org/eclipse/cdt/internal/core/model/Using.java
This commit is contained in:
parent
59d90063a3
commit
cfb6771929
5 changed files with 71 additions and 2 deletions
|
@ -1,3 +1,12 @@
|
|||
2004-07-30 Alain Magloire
|
||||
|
||||
Add the Using-{directive,declaration} part of the Core Model.
|
||||
|
||||
* model/org/eclipse/cdt/core/model/IUsing.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CElement.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
|
||||
* model/org/eclipse/cdt/internal/core/model/Using.java
|
||||
|
||||
2004-07-28 Tanya Wolff
|
||||
|
||||
Fix for PR 70161: Assembly untranslated in C++ File Types
|
||||
|
|
|
@ -13,4 +13,6 @@ public interface IUsing extends ICElement, ISourceManipulation, ISourceReference
|
|||
* This is a handle-only method.
|
||||
*/
|
||||
String getElementName();
|
||||
|
||||
boolean isDirective();
|
||||
}
|
||||
|
|
|
@ -330,6 +330,10 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
return "C_FIELD"; //$NON-NLS-1$
|
||||
case C_METHOD:
|
||||
return "C_METHOD"; //$NON-NLS-1$
|
||||
case C_NAMESPACE:
|
||||
return "C_NAMESPACE"; //$NON-NLS-1$
|
||||
case C_USING:
|
||||
return "C_USING"; //$NON-NLS-1$
|
||||
default:
|
||||
return "UNKNOWN"; //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifierOwner;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.StructuralParseCallback;
|
||||
|
@ -270,6 +272,14 @@ public class CModelBuilder {
|
|||
if(declaration instanceof IASTLinkageSpecification) {
|
||||
generateModelElements(parent, (IASTLinkageSpecification)declaration);
|
||||
}
|
||||
|
||||
if (declaration instanceof IASTUsingDirective) {
|
||||
createUsingDirective(parent, (IASTUsingDirective)declaration);
|
||||
}
|
||||
|
||||
if (declaration instanceof IASTUsingDeclaration) {
|
||||
createUsingDeclaration(parent, (IASTUsingDeclaration)declaration);
|
||||
}
|
||||
createSimpleElement(parent, declaration, false);
|
||||
}
|
||||
|
||||
|
@ -734,6 +744,40 @@ public class CModelBuilder {
|
|||
return element;
|
||||
}
|
||||
|
||||
private Using createUsingDirective(Parent parent, IASTUsingDirective usingDirDeclaration) throws CModelException{
|
||||
// create the element
|
||||
String name = usingDirDeclaration.getNamespaceName();
|
||||
|
||||
Using element = new Using( parent, name, true );
|
||||
|
||||
// add to parent
|
||||
parent.addChild(element);
|
||||
|
||||
// set positions
|
||||
//element.setIdPos(usingDirDeclaration.getNameOffset(), (usingDirective.getNameEndOffset() - usingDirDeclaration.getNameOffset()));
|
||||
element.setPos(usingDirDeclaration.getStartingOffset(), usingDirDeclaration.getEndingOffset() - usingDirDeclaration.getStartingOffset());
|
||||
element.setLines(usingDirDeclaration.getStartingLine(), usingDirDeclaration.getEndingLine() );
|
||||
this.newElements.put(element, element.getElementInfo());
|
||||
return element;
|
||||
}
|
||||
|
||||
private Using createUsingDeclaration(Parent parent, IASTUsingDeclaration usingDeclaration) throws CModelException{
|
||||
// create the element
|
||||
String name = usingDeclaration.usingTypeName();
|
||||
|
||||
Using element = new Using(parent, name, false);
|
||||
|
||||
// add to parent
|
||||
parent.addChild(element);
|
||||
|
||||
// set positions
|
||||
//element.setIdPos(usingDeclaration.getNameOffset(), (usingDeclaration.getNameEndOffset() - usingDeclaration.getNameOffset()));
|
||||
element.setPos(usingDeclaration.getStartingOffset(), usingDeclaration.getEndingOffset() - usingDeclaration.getStartingOffset());
|
||||
element.setLines(usingDeclaration.getStartingLine(), usingDeclaration.getEndingLine() );
|
||||
this.newElements.put(element, element.getElementInfo());
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the newElements.
|
||||
*/
|
||||
|
|
|
@ -14,14 +14,24 @@ package org.eclipse.cdt.internal.core.model;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IUsing;
|
||||
|
||||
public class Using extends SourceManipulation implements IUsing{
|
||||
public class Using extends SourceManipulation implements IUsing {
|
||||
|
||||
public Using(ICElement parent, String name) {
|
||||
boolean directive;
|
||||
|
||||
public Using(ICElement parent, String name, boolean isDirective) {
|
||||
super(parent, name, CElement.C_USING);
|
||||
directive = isDirective;
|
||||
}
|
||||
|
||||
protected CElementInfo createElementInfo () {
|
||||
return new SourceManipulationInfo(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IUsing#isDirective()
|
||||
*/
|
||||
public boolean isDirective() {
|
||||
return directive;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue