1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-08-27 05:48:09 +00:00
parent da074afa86
commit d3fcfea8f1
6 changed files with 110 additions and 98 deletions

View file

@ -33,11 +33,11 @@ import org.eclipse.core.runtime.PlatformObject;
*/
public class CEnumerator extends PlatformObject implements IEnumerator {
public static class CEnumeratorProblem extends ProblemBinding implements IEnumerator {
public CEnumeratorProblem( IASTNode node, int id, char[] arg ) {
super( node, id, arg );
public CEnumeratorProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
public IType getType() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public IValue getValue() {
return Value.UNKNOWN;
@ -46,21 +46,23 @@ public class CEnumerator extends PlatformObject implements IEnumerator {
private final IASTName enumeratorName;
public CEnumerator( IASTEnumerator enumtor ){
public CEnumerator(IASTEnumerator enumtor) {
this.enumeratorName = enumtor.getName();
enumeratorName.setBinding( this );
enumeratorName.setBinding(this);
}
public IASTNode getPhysicalNode(){
public IASTNode getPhysicalNode() {
return enumeratorName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
public String getName() {
return enumeratorName.toString();
}
public char[] getNameCharArray(){
public char[] getNameCharArray() {
return enumeratorName.toCharArray();
}
@ -68,7 +70,7 @@ public class CEnumerator extends PlatformObject implements IEnumerator {
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
public IScope getScope() {
return CVisitor.getContainingScope( enumeratorName.getParent() );
return CVisitor.getContainingScope(enumeratorName.getParent());
}
/* (non-Javadoc)

View file

@ -24,14 +24,15 @@ import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
*/
public class CField extends CVariable implements IField {
public static class CFieldProblem extends CVariable.CVariableProblem implements IField {
public CFieldProblem( IASTNode node, int id, char[] arg ) {
super( node, id, arg );
public CFieldProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
public ICompositeType getCompositeTypeOwner() throws DOMException {
throw new DOMException(this);
}
}
/**
* @param name
*/
@ -43,5 +44,4 @@ public class CField extends CVariable implements IField {
ICCompositeTypeScope scope = (ICCompositeTypeScope) getScope();
return scope.getCompositeType();
}
}

View file

@ -29,24 +29,26 @@ import org.eclipse.core.runtime.PlatformObject;
public class CLabel extends PlatformObject implements ILabel {
public static class CLabelProblem extends ProblemBinding implements ILabel {
public CLabelProblem( IASTNode node, int id, char[] arg ) {
super( node, id, arg );
public CLabelProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
public IASTLabelStatement getLabelStatement() throws DOMException{
throw new DOMException( this );
public IASTLabelStatement getLabelStatement() throws DOMException {
throw new DOMException(this);
}
}
private final IASTName labelStatement;
public CLabel( IASTName statement ){
public CLabel(IASTName statement) {
labelStatement = statement;
statement.setBinding( this );
statement.setBinding(this);
}
public IASTNode getPhysicalNode(){
public IASTNode getPhysicalNode() {
return labelStatement;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ILabel#getLabelStatement()
*/
@ -60,7 +62,8 @@ public class CLabel extends PlatformObject implements ILabel {
public String getName() {
return labelStatement.toString();
}
public char[] getNameCharArray(){
public char[] getNameCharArray() {
return labelStatement.toCharArray();
}
@ -68,7 +71,7 @@ public class CLabel extends PlatformObject implements ILabel {
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
public IScope getScope() {
return CVisitor.getContainingScope( labelStatement.getParent() );
return CVisitor.getContainingScope(labelStatement.getParent());
}
public ILinkage getLinkage() {

View file

@ -39,34 +39,34 @@ import org.eclipse.core.runtime.PlatformObject;
*/
public class CParameter extends PlatformObject implements IParameter {
public static class CParameterProblem extends ProblemBinding implements IParameter {
public CParameterProblem( IASTNode node, int id, char[] arg ) {
super( node, id, arg );
public CParameterProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
public IType getType() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isStatic() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isExtern() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isAuto() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isRegister() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public IValue getInitialValue() {
return null;
}
}
private IASTName [] declarations;
private IASTName[] declarations;
private IType type = null;
public CParameter( IASTName parameterName ){
this.declarations = new IASTName [] { parameterName };
public CParameter(IASTName parameterName) {
this.declarations = new IASTName[] { parameterName };
}
/* (non-Javadoc)
@ -74,22 +74,21 @@ public class CParameter extends PlatformObject implements IParameter {
*/
public IType getType() {
if ( type == null && declarations[0].getParent() instanceof IASTDeclarator)
type = CVisitor.createType( (IASTDeclarator)declarations[0].getParent() );
if (type == null && declarations[0].getParent() instanceof IASTDeclarator)
type = CVisitor.createType((IASTDeclarator)declarations[0].getParent());
return type;
}
private IASTName getPrimaryDeclaration(){
if( declarations != null ){
for( int i = 0; i < declarations.length && declarations[i] != null; i++ ){
private IASTName getPrimaryDeclaration() {
if (declarations != null) {
for (int i = 0; i < declarations.length && declarations[i] != null; i++) {
IASTNode node = declarations[i].getParent();
while( !(node instanceof IASTDeclaration) )
while (!(node instanceof IASTDeclaration))
node = node.getParent();
if( node.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER ||
node instanceof IASTFunctionDefinition )
{
if (node.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER ||
node instanceof IASTFunctionDefinition) {
return declarations[i];
}
}
@ -103,13 +102,14 @@ public class CParameter extends PlatformObject implements IParameter {
*/
public String getName() {
IASTName name = getPrimaryDeclaration();
if( name != null )
if (name != null)
return name.toString();
return CVisitor.EMPTY_STRING;
}
public char[] getNameCharArray(){
public char[] getNameCharArray() {
IASTName name = getPrimaryDeclaration();
if( name != null )
if (name != null)
return name.toCharArray();
return CVisitor.EMPTY_CHAR_ARRAY;
}
@ -119,19 +119,19 @@ public class CParameter extends PlatformObject implements IParameter {
*/
public IScope getScope() {
//IASTParameterDeclaration or IASTSimpleDeclaration
for( int i = 0; i < declarations.length; i++ ){
for (int i = 0; i < declarations.length; i++) {
IASTNode parent = declarations[i].getParent();
if( parent instanceof ICASTKnRFunctionDeclarator ){
if (parent instanceof ICASTKnRFunctionDeclarator) {
parent = parent.getParent();
return ((IASTCompoundStatement)((IASTFunctionDefinition)parent).getBody()).getScope();
return ((IASTCompoundStatement)((IASTFunctionDefinition) parent).getBody()).getScope();
}
IASTNode fdtorNode = parent.getParent().getParent();
if (fdtorNode instanceof IASTFunctionDeclarator) {
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator)fdtorNode;
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) fdtorNode;
parent = fdtor.getParent();
if( parent instanceof IASTFunctionDefinition ) {
return ((IASTCompoundStatement)((IASTFunctionDefinition)parent).getBody()).getScope();
if (parent instanceof IASTFunctionDefinition) {
return ((IASTCompoundStatement)((IASTFunctionDefinition) parent).getBody()).getScope();
}
}
}
@ -150,7 +150,7 @@ public class CParameter extends PlatformObject implements IParameter {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic()
*/
public boolean isStatic(){
public boolean isStatic() {
return false;
}
@ -165,14 +165,14 @@ public class CParameter extends PlatformObject implements IParameter {
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
*/
public boolean isAuto() {
return hasStorageClass( IASTDeclSpecifier.sc_auto );
return hasStorageClass(IASTDeclSpecifier.sc_auto);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
*/
public boolean isRegister() {
return hasStorageClass( IASTDeclSpecifier.sc_register );
return hasStorageClass(IASTDeclSpecifier.sc_register);
}
public boolean hasStorageClass(int storage) {

View file

@ -51,38 +51,38 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
super(node, id, arg);
}
public IField findField(String name) throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public IScope getCompositeScope() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public IField[] getFields() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public int getKey() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isAnonymous() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
}
private IASTName [] declarations = null;
private IASTName[] declarations = null;
private IASTName definition;
private boolean checked;
private ICompositeType typeInIndex;
public CStructure( IASTName name ){
if( name.getPropertyInParent() == IASTCompositeTypeSpecifier.TYPE_NAME )
public CStructure(IASTName name) {
if (name.getPropertyInParent() == IASTCompositeTypeSpecifier.TYPE_NAME) {
definition = name;
else {
} else {
declarations = new IASTName[] { name };
}
name.setBinding( this );
name.setBinding(this);
}
public IASTNode getPhysicalNode(){
return ( definition != null ) ? (IASTNode)definition : (IASTNode)declarations[0];
public IASTNode getPhysicalNode() {
return (definition != null) ? (IASTNode)definition : (IASTNode)declarations[0];
}
private void checkForDefinition() {
@ -112,13 +112,13 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
public String getName() {
if( definition != null )
if (definition != null)
return definition.toString();
return declarations[0].toString();
}
public char[] getNameCharArray() {
if( definition != null )
if (definition != null)
return definition.toCharArray();
return declarations[0].toCharArray();
@ -128,9 +128,9 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
public IScope getScope() throws DOMException {
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ( ( definition != null ) ? (IASTNode)definition.getParent() : declarations[0].getParent() );
IScope scope = CVisitor.getContainingScope( declSpec );
while( scope instanceof ICCompositeTypeScope ){
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ((definition != null) ? (IASTNode)definition.getParent() : declarations[0].getParent());
IScope scope = CVisitor.getContainingScope(declSpec);
while(scope instanceof ICCompositeTypeScope) {
scope = scope.getParent();
}
return scope;
@ -148,7 +148,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
}
ICASTCompositeTypeSpecifier compSpec = (ICASTCompositeTypeSpecifier) definition.getParent();
IField[] fields = collectFields(compSpec, null);
return (IField[]) ArrayUtil.trim( IField.class, fields );
return (IField[]) ArrayUtil.trim(IField.class, fields);
}
private IField[] collectFields(ICASTCompositeTypeSpecifier compSpec, IField[] fields) {
@ -197,7 +197,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
*/
public int getKey() {
return ( definition != null ) ? ((IASTCompositeTypeSpecifier)definition.getParent()).getKey()
return (definition != null) ? ((IASTCompositeTypeSpecifier)definition.getParent()).getKey()
: ((IASTElaboratedTypeSpecifier)declarations[0].getParent()).getKind();
}
@ -223,11 +223,11 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
}
@Override
public Object clone(){
public Object clone() {
IType t = null;
try {
t = (IType) super.clone();
} catch ( CloneNotSupportedException e ) {
} catch (CloneNotSupportedException e) {
//not going to happen
}
return t;

View file

@ -41,36 +41,36 @@ import org.eclipse.core.runtime.PlatformObject;
*/
public class CVariable extends PlatformObject implements IInternalVariable, ICInternalBinding {
public static class CVariableProblem extends ProblemBinding implements IVariable {
public CVariableProblem( IASTNode node, int id, char[] arg ) {
super( node, id, arg );
public CVariableProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
public IType getType() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isStatic() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isExtern() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isAuto() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public boolean isRegister() throws DOMException {
throw new DOMException( this );
throw new DOMException(this);
}
public IValue getInitialValue() {
return null;
}
}
private IASTName [] declarations = null;
private IASTName[] declarations = null;
private IType type = null;
public CVariable( IASTName name ){
declarations = new IASTName [] { name };
public CVariable(IASTName name) {
declarations = new IASTName[] { name };
}
public IASTNode getPhysicalNode(){
public IASTNode getPhysicalNode() {
return declarations[0];
}
@ -95,7 +95,8 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
public String getName() {
return declarations[0].toString();
}
public char[]getNameCharArray(){
public char[] getNameCharArray() {
return declarations[0].toCharArray();
}
@ -104,62 +105,68 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
*/
public IScope getScope() {
IASTDeclarator declarator = (IASTDeclarator) declarations[0].getParent();
return CVisitor.getContainingScope( declarator.getParent() );
return CVisitor.getContainingScope(declarator.getParent());
}
public boolean isStatic() {
return hasStorageClass(IASTDeclSpecifier.sc_static);
}
public boolean hasStorageClass( int storage){
if( declarations == null )
public boolean hasStorageClass(int storage) {
if (declarations == null)
return false;
for( int i = 0; i < declarations.length && declarations[i] != null; i++ ){
for (int i = 0; i < declarations.length && declarations[i] != null; i++) {
final IASTName name = declarations[i];
IASTNode parent = name.getParent();
while( !(parent instanceof IASTDeclaration) )
while (!(parent instanceof IASTDeclaration))
parent = parent.getParent();
if( parent instanceof IASTSimpleDeclaration ){
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier();
if( declSpec.getStorageClass() == storage ) {
if (parent instanceof IASTSimpleDeclaration) {
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
if (declSpec.getStorageClass() == storage) {
return true;
}
}
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
*/
public boolean isExtern() {
return hasStorageClass( IASTDeclSpecifier.sc_extern);
return hasStorageClass(IASTDeclSpecifier.sc_extern);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
*/
public boolean isAuto() {
return hasStorageClass( IASTDeclSpecifier.sc_auto);
return hasStorageClass(IASTDeclSpecifier.sc_auto);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
*/
public boolean isRegister() {
return hasStorageClass( IASTDeclSpecifier.sc_register);
return hasStorageClass(IASTDeclSpecifier.sc_register);
}
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
public IASTNode[] getDeclarations() {
public IASTNode[] getDeclarations() {
return declarations;
}
public IASTNode getDefinition() {
public IASTNode getDefinition() {
return getPhysicalNode();
}
public IBinding getOwner() throws DOMException {
public IBinding getOwner() throws DOMException {
if (declarations == null || declarations.length == 0)
return null;