mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Code formatting.
This commit is contained in:
parent
4f541baeb7
commit
fc22e5fdce
10 changed files with 94 additions and 119 deletions
|
@ -33,14 +33,12 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbiguityParent {
|
public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbiguityParent {
|
||||||
|
|
||||||
private IASTInitializer initializer;
|
private IASTInitializer initializer;
|
||||||
private IASTName name;
|
private IASTName name;
|
||||||
private IASTDeclarator nestedDeclarator;
|
private IASTDeclarator nestedDeclarator;
|
||||||
private IASTPointerOperator[] pointerOps = null;
|
private IASTPointerOperator[] pointerOps = null;
|
||||||
private int pointerOpsPos= -1;
|
private int pointerOpsPos= -1;
|
||||||
|
|
||||||
|
|
||||||
public CASTDeclarator() {
|
public CASTDeclarator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +69,6 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
return initializer;
|
return initializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setInitializer(IASTInitializer initializer) {
|
public void setInitializer(IASTInitializer initializer) {
|
||||||
this.initializer = initializer;
|
this.initializer = initializer;
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
|
@ -114,26 +111,27 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR && nestedDeclarator == null) {
|
||||||
if( getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR &&
|
if (getParent() instanceof IASTDeclarator) {
|
||||||
nestedDeclarator == null )
|
|
||||||
{
|
|
||||||
if( getParent() instanceof IASTDeclarator )
|
|
||||||
{
|
|
||||||
IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent();
|
IASTDeclarator outermostDeclarator = (IASTDeclarator) getParent();
|
||||||
while (outermostDeclarator.getParent() instanceof IASTDeclarator)
|
while (outermostDeclarator.getParent() instanceof IASTDeclarator)
|
||||||
outermostDeclarator = (IASTDeclarator) outermostDeclarator.getParent();
|
outermostDeclarator = (IASTDeclarator) outermostDeclarator.getParent();
|
||||||
if( outermostDeclarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR )
|
if (outermostDeclarator.getPropertyInParent() != IASTTypeId.ABSTRACT_DECLARATOR &&
|
||||||
if( name != null ) if( !name.accept( action ) ) return false;
|
name != null && !name.accept(action)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
} else if (name != null && !name.accept(action)) {
|
||||||
if( name != null ) if( !name.accept( action ) ) return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nestedDeclarator != null && !nestedDeclarator.accept(action)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if( nestedDeclarator != null ) if( !nestedDeclarator.accept( action ) ) return false;
|
|
||||||
|
|
||||||
IASTPointerOperator[] ptrOps = getPointerOperators();
|
IASTPointerOperator[] ptrOps = getPointerOperators();
|
||||||
for (int i = 0; i < ptrOps.length; i++) {
|
for (int i = 0; i < ptrOps.length; i++) {
|
||||||
if( !ptrOps[i].accept( action ) ) return false;
|
if (!ptrOps[i].accept(action))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!postAccept(action))
|
if (!postAccept(action))
|
||||||
|
@ -153,24 +151,19 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRoleForName(IASTName n) {
|
public int getRoleForName(IASTName n) {
|
||||||
if( n == this.name )
|
if (n == this.name) {
|
||||||
{
|
|
||||||
IASTNode getParent = getParent();
|
IASTNode getParent = getParent();
|
||||||
boolean fnDtor = (this instanceof IASTFunctionDeclarator);
|
boolean fnDtor = (this instanceof IASTFunctionDeclarator);
|
||||||
if( getParent instanceof IASTDeclaration )
|
if (getParent instanceof IASTDeclaration) {
|
||||||
{
|
|
||||||
if (getParent instanceof IASTFunctionDefinition)
|
if (getParent instanceof IASTFunctionDefinition)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
if( getParent instanceof IASTSimpleDeclaration )
|
if (getParent instanceof IASTSimpleDeclaration) {
|
||||||
{
|
|
||||||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
||||||
int storage = sd.getDeclSpecifier().getStorageClass();
|
int storage = sd.getDeclSpecifier().getStorageClass();
|
||||||
if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef)
|
if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
|
|
||||||
if( storage == IASTDeclSpecifier.sc_extern ||
|
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) {
|
||||||
storage == IASTDeclSpecifier.sc_static )
|
|
||||||
{
|
|
||||||
return r_declaration;
|
return r_declaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,25 +172,22 @@ public class CASTDeclarator extends ASTNode implements IASTDeclarator, IASTAmbig
|
||||||
}
|
}
|
||||||
if (getParent instanceof IASTTypeId)
|
if (getParent instanceof IASTTypeId)
|
||||||
return r_reference;
|
return r_reference;
|
||||||
if( getParent instanceof IASTDeclarator )
|
if (getParent instanceof IASTDeclarator) {
|
||||||
{
|
|
||||||
IASTNode t = getParent;
|
IASTNode t = getParent;
|
||||||
while (t instanceof IASTDeclarator)
|
while (t instanceof IASTDeclarator)
|
||||||
t = t.getParent();
|
t = t.getParent();
|
||||||
if( t instanceof IASTDeclaration )
|
if (t instanceof IASTDeclaration) {
|
||||||
{
|
|
||||||
if (getParent instanceof IASTFunctionDefinition)
|
if (getParent instanceof IASTFunctionDefinition)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
if( getParent instanceof IASTSimpleDeclaration )
|
if (getParent instanceof IASTSimpleDeclaration) {
|
||||||
{
|
|
||||||
if (getInitializer() != null)
|
if (getInitializer() != null)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
||||||
int storage = sd.getDeclSpecifier().getStorageClass();
|
int storage = sd.getDeclSpecifier().getStorageClass();
|
||||||
if( storage == IASTDeclSpecifier.sc_extern ||
|
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) {
|
||||||
storage == IASTDeclSpecifier.sc_static)
|
|
||||||
return r_declaration;
|
return r_declaration;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return fnDtor ? r_declaration : r_definition;
|
return fnDtor ? r_declaration : r_definition;
|
||||||
}
|
}
|
||||||
if (t instanceof IASTTypeId)
|
if (t instanceof IASTTypeId)
|
||||||
|
|
|
@ -38,7 +38,6 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
|
||||||
private IASTPointerOperator[] pointerOps = null;
|
private IASTPointerOperator[] pointerOps = null;
|
||||||
private int pointerOpsPos= -1;
|
private int pointerOpsPos= -1;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTDeclarator() {
|
public CPPASTDeclarator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +92,6 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setName(IASTName name) {
|
public void setName(IASTName name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
@ -148,8 +146,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
|
||||||
public int getRoleForName(IASTName n) {
|
public int getRoleForName(IASTName n) {
|
||||||
IASTNode getParent = getParent();
|
IASTNode getParent = getParent();
|
||||||
boolean fnDtor = (this instanceof IASTFunctionDeclarator);
|
boolean fnDtor = (this instanceof IASTFunctionDeclarator);
|
||||||
if( getParent instanceof IASTDeclaration )
|
if (getParent instanceof IASTDeclaration) {
|
||||||
{
|
|
||||||
if (getParent instanceof IASTFunctionDefinition)
|
if (getParent instanceof IASTFunctionDefinition)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
if (getParent instanceof IASTSimpleDeclaration) {
|
if (getParent instanceof IASTSimpleDeclaration) {
|
||||||
|
@ -157,9 +154,7 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
|
||||||
if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef)
|
if (getInitializer() != null || storage == IASTDeclSpecifier.sc_typedef)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
|
|
||||||
if( storage == IASTDeclSpecifier.sc_extern ||
|
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_static) {
|
||||||
storage == IASTDeclSpecifier.sc_static )
|
|
||||||
{
|
|
||||||
return r_declaration;
|
return r_declaration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,25 +162,20 @@ public class CPPASTDeclarator extends ASTNode implements IASTDeclarator {
|
||||||
}
|
}
|
||||||
if (getParent instanceof IASTTypeId)
|
if (getParent instanceof IASTTypeId)
|
||||||
return r_reference;
|
return r_reference;
|
||||||
if( getParent instanceof IASTDeclarator )
|
if (getParent instanceof IASTDeclarator) {
|
||||||
{
|
|
||||||
IASTNode t = getParent;
|
IASTNode t = getParent;
|
||||||
while (t instanceof IASTDeclarator)
|
while (t instanceof IASTDeclarator)
|
||||||
t = t.getParent();
|
t = t.getParent();
|
||||||
if( t instanceof IASTDeclaration )
|
if (t instanceof IASTDeclaration) {
|
||||||
{
|
|
||||||
if (getParent instanceof IASTFunctionDefinition)
|
if (getParent instanceof IASTFunctionDefinition)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
if( getParent instanceof IASTSimpleDeclaration )
|
if (getParent instanceof IASTSimpleDeclaration) {
|
||||||
{
|
|
||||||
if (getInitializer() != null)
|
if (getInitializer() != null)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) getParent;
|
||||||
int storage = sd.getDeclSpecifier().getStorageClass();
|
int storage = sd.getDeclSpecifier().getStorageClass();
|
||||||
if( storage == IASTDeclSpecifier.sc_extern ||
|
if (storage == IASTDeclSpecifier.sc_extern || storage == IASTDeclSpecifier.sc_typedef ||
|
||||||
storage == IASTDeclSpecifier.sc_typedef ||
|
storage == IASTDeclSpecifier.sc_static) {
|
||||||
storage == IASTDeclSpecifier.sc_static )
|
|
||||||
{
|
|
||||||
return r_declaration;
|
return r_declaration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ public abstract class CPPTemplateParameter extends PlatformObject
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IASTNode node= declarations[0];
|
IASTNode node= declarations[0];
|
||||||
while (node instanceof ICPPASTTemplateParameter == false) {
|
while (!(node instanceof ICPPASTTemplateParameter)) {
|
||||||
if (node == null)
|
if (node == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
|
||||||
|
|
||||||
private ICPPClassScope fScope;
|
private ICPPClassScope fScope;
|
||||||
|
|
||||||
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, ICPPClassType classType)
|
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, ICPPClassType classType) throws CoreException {
|
||||||
throws CoreException {
|
|
||||||
super(pdom, parent, classType.getNameCharArray());
|
super(pdom, parent, classType.getNameCharArray());
|
||||||
|
|
||||||
setKind(classType);
|
setKind(classType);
|
||||||
|
@ -89,7 +88,6 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
|
||||||
return IIndexCPPBindingConstants.CPPCLASSTYPE;
|
return IIndexCPPBindingConstants.CPPCLASSTYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
|
||||||
if (newBinding instanceof ICPPClassType) {
|
if (newBinding instanceof ICPPClassType) {
|
||||||
|
@ -142,7 +140,6 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
|
||||||
list.accept(visitor);
|
list.accept(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private PDOMCPPBase getFirstBase() throws CoreException {
|
private PDOMCPPBase getFirstBase() throws CoreException {
|
||||||
int rec = pdom.getDB().getInt(record + FIRSTBASE);
|
int rec = pdom.getDB().getInt(record + FIRSTBASE);
|
||||||
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
|
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.eclipse.cdt.internal.core.browser.ASTTypeInfo;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class PDOMSearchQuery implements ISearchQuery {
|
public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
|
|
||||||
public static final int FIND_DECLARATIONS = 0x1;
|
public static final int FIND_DECLARATIONS = 0x1;
|
||||||
public static final int FIND_DEFINITIONS = 0x2;
|
public static final int FIND_DEFINITIONS = 0x2;
|
||||||
public static final int FIND_REFERENCES = 0x4;
|
public static final int FIND_REFERENCES = 0x4;
|
||||||
|
@ -155,10 +154,9 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
names.addAll(Arrays.asList(ast.getReferences(binding)));
|
names.addAll(Arrays.asList(ast.getReferences(binding)));
|
||||||
|
|
||||||
for (IASTName name : names) {
|
for (IASTName name : names) {
|
||||||
if ( ((flags & FIND_DECLARATIONS) != 0 && name.isDeclaration())
|
if (((flags & FIND_DECLARATIONS) != 0 && name.isDeclaration()) ||
|
||||||
|| ((flags & FIND_DEFINITIONS) != 0 && name.isDefinition())
|
((flags & FIND_DEFINITIONS) != 0 && name.isDefinition()) ||
|
||||||
|| ((flags & FIND_REFERENCES) != 0 && name.isReference())) {
|
((flags & FIND_REFERENCES) != 0 && name.isReference())) {
|
||||||
|
|
||||||
ASTTypeInfo typeInfo= ASTTypeInfo.create(name);
|
ASTTypeInfo typeInfo= ASTTypeInfo.create(name);
|
||||||
if (typeInfo != null) {
|
if (typeInfo != null) {
|
||||||
ITypeReference ref= typeInfo.getResolvedReference();
|
ITypeReference ref= typeInfo.getResolvedReference();
|
||||||
|
|
Loading…
Add table
Reference in a new issue