mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 11:15:38 +02:00
Cosmetics.
This commit is contained in:
parent
bd0e88a3e2
commit
090345f405
9 changed files with 1158 additions and 1170 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2012 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* John Cortell - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.alltests;
|
package org.eclipse.cdt.alltests;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
|
|
@ -40,9 +40,6 @@ import org.eclipse.core.runtime.content.IContentType;
|
||||||
* @author dsteffle
|
* @author dsteffle
|
||||||
*/
|
*/
|
||||||
public class DOMSearchUtil {
|
public class DOMSearchUtil {
|
||||||
private static final IASTName[] BLANK_NAME_ARRAY = new IASTName[0];
|
|
||||||
// private static final IASTName[] EMPTY_NAME_LIST = BLANK_NAME_ARRAY;
|
|
||||||
|
|
||||||
public static final int DECLARATIONS = 1;
|
public static final int DECLARATIONS = 1;
|
||||||
public static final int DEFINITIONS = 2;
|
public static final int DEFINITIONS = 2;
|
||||||
public static final int DECLARATIONS_DEFINITIONS = 3;
|
public static final int DECLARATIONS_DEFINITIONS = 3;
|
||||||
|
@ -135,7 +132,7 @@ public class DOMSearchUtil {
|
||||||
IASTTranslationUnit tu = searchName.getTranslationUnit();
|
IASTTranslationUnit tu = searchName.getTranslationUnit();
|
||||||
|
|
||||||
if (tu == null) {
|
if (tu == null) {
|
||||||
return BLANK_NAME_ARRAY;
|
return IASTName.EMPTY_NAME_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBinding binding = searchName.resolveBinding();
|
IBinding binding = searchName.resolveBinding();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
* Copyright (c) 2004, 2013 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
*/
|
*/
|
||||||
public interface ICPPFunctionScope extends ICPPScope {
|
public interface ICPPFunctionScope extends ICPPScope {
|
||||||
/**
|
/**
|
||||||
* Get the scope representing the function body. returns null if there is no
|
* Returns the scope representing the function body, or {@code null} if there is no
|
||||||
* function definition
|
* function definition.
|
||||||
*
|
*
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,18 +20,18 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
*/
|
*/
|
||||||
public interface IASTInternalScope extends IScope {
|
public interface IASTInternalScope extends IScope {
|
||||||
/**
|
/**
|
||||||
* Return the physical IASTNode that this scope was created for
|
* Returns the physical IASTNode that this scope was created for
|
||||||
*/
|
*/
|
||||||
public IASTNode getPhysicalNode();
|
public IASTNode getPhysicalNode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This adds an IBinding to the scope. It is primarily used by the parser to add
|
* Adds an IBinding to the scope. It is primarily used by the parser to add
|
||||||
* implicit IBindings to the scope (such as GCC built-in functions).
|
* implicit IBindings to the scope (such as GCC built-in functions).
|
||||||
*/
|
*/
|
||||||
public void addBinding(IBinding binding);
|
public void addBinding(IBinding binding);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an IASTName to be cached in this scope
|
* Adds an IASTName to be cached in this scope
|
||||||
*/
|
*/
|
||||||
public void addName(IASTName name);
|
public void addName(IASTName name);
|
||||||
|
|
||||||
|
@ -47,5 +47,4 @@ public interface IASTInternalScope extends IScope {
|
||||||
* node from the cache.
|
* node from the cache.
|
||||||
*/
|
*/
|
||||||
public void removeNestedFromCache(IASTNode container);
|
public void removeNestedFromCache(IASTNode container);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
* Scope of a function, containing labels.
|
* Scope of a function, containing labels.
|
||||||
*/
|
*/
|
||||||
public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
|
|
||||||
private CharArrayObjectMap<IBinding> labels = CharArrayObjectMap.emptyMap();
|
private CharArrayObjectMap<IBinding> labels = CharArrayObjectMap.emptyMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,9 +51,6 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
return EScopeKind.eLocal;
|
return EScopeKind.eLocal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#addBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addBinding(IBinding binding) {
|
public void addBinding(IBinding binding) {
|
||||||
//3.3.4 only labels have function scope
|
//3.3.4 only labels have function scope
|
||||||
|
@ -67,16 +63,10 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
labels.put(binding.getNameCharArray(), binding);
|
labels.put(binding.getNameCharArray(), binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[])
|
|
||||||
*/
|
|
||||||
public IBinding getBinding(IASTName name) {
|
public IBinding getBinding(IASTName name) {
|
||||||
return labels.get(name.getLookupKey());
|
return labels.get(name.getLookupKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IBinding[] find(String name) {
|
public IBinding[] find(String name) {
|
||||||
char[] n = name.toCharArray();
|
char[] n = name.toCharArray();
|
||||||
|
@ -106,9 +96,6 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
return CPPVisitor.getContainingNonTemplateScope(name);
|
return CPPVisitor.getContainingNonTemplateScope(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope#getBodyScope()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IScope getBodyScope() {
|
public IScope getBodyScope() {
|
||||||
IASTFunctionDeclarator fnDtor = (IASTFunctionDeclarator) getPhysicalNode();
|
IASTFunctionDeclarator fnDtor = (IASTFunctionDeclarator) getPhysicalNode();
|
||||||
|
@ -121,9 +108,6 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IName getScopeName() {
|
public IName getScopeName() {
|
||||||
IASTNode node = getPhysicalNode();
|
IASTNode node = getPhysicalNode();
|
||||||
|
|
|
@ -375,10 +375,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinding createBinding(IASTGotoStatement gotoStatement) {
|
private static IBinding createBinding(IASTGotoStatement gotoStatement) {
|
||||||
ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(gotoStatement.getName());
|
|
||||||
IASTName name = gotoStatement.getName();
|
IASTName name = gotoStatement.getName();
|
||||||
IBinding binding;
|
ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(name);
|
||||||
binding = functionScope.getBinding(name, false);
|
IBinding binding = functionScope.getBinding(name, false);
|
||||||
if (binding == null || !(binding instanceof ILabel)) {
|
if (binding == null || !(binding instanceof ILabel)) {
|
||||||
binding = new CPPLabel(name);
|
binding = new CPPLabel(name);
|
||||||
ASTInternal.addName(functionScope, name);
|
ASTInternal.addName(functionScope, name);
|
||||||
|
@ -388,10 +387,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinding createBinding(IASTLabelStatement labelStatement) {
|
private static IBinding createBinding(IASTLabelStatement labelStatement) {
|
||||||
ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(labelStatement.getName());
|
|
||||||
IASTName name = labelStatement.getName();
|
IASTName name = labelStatement.getName();
|
||||||
IBinding binding;
|
ICPPFunctionScope functionScope = (ICPPFunctionScope) getContainingScope(name);
|
||||||
binding = functionScope.getBinding(name, false);
|
IBinding binding = functionScope.getBinding(name, false);
|
||||||
if (binding == null || !(binding instanceof ILabel)) {
|
if (binding == null || !(binding instanceof ILabel)) {
|
||||||
binding = new CPPLabel(name);
|
binding = new CPPLabel(name);
|
||||||
ASTInternal.addName(functionScope, name);
|
ASTInternal.addName(functionScope, name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue