1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-21 15:23:59 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-11-30 14:45:01 -08:00
parent 0f13c1b8f1
commit 372f3ef066
34 changed files with 498 additions and 536 deletions

View file

@ -25,7 +25,6 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
/**
* @author bnicolle
*
*/
public class IStructureTests extends IntegratedCModelTest {
/**
@ -229,10 +228,8 @@ public class IStructureTests extends IntegratedCModelTest {
try {
myElementUnion = tu.getElement("testUnion1");
myElementNonUnion = tu.getElement("testStruct1");
}
catch( CModelException c )
{
assertNotNull("CModelException thrown",c);
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElementUnion);
assertTrue(myElementUnion.getElementType() == ICElement.C_UNION);
@ -246,6 +243,7 @@ public class IStructureTests extends IntegratedCModelTest {
assertNotNull(myStructNonUnion);
assertFalse(myStructNonUnion.isUnion());
}
public void testIsStruct() throws CModelException {
ITranslationUnit tu = getTU();
ICElement myElementStruct = null;
@ -253,10 +251,8 @@ public class IStructureTests extends IntegratedCModelTest {
try {
myElementStruct = tu.getElement("testStruct1");
myElementNonStruct = tu.getElement("testClass1");
}
catch( CModelException c )
{
assertNotNull("CModelException thrown",c);
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElementStruct);
assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT);
@ -278,10 +274,8 @@ public class IStructureTests extends IntegratedCModelTest {
try {
myElementClass = tu.getElement("testClass1");
myElementNonClass = tu.getElement("testStruct1");
}
catch( CModelException c )
{
assertNotNull("CModelException thrown",c);
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElementClass);
assertTrue(myElementClass.getElementType() == ICElement.C_CLASS);
@ -303,10 +297,8 @@ public class IStructureTests extends IntegratedCModelTest {
try {
myElementAbstract = tu.getElement("testClass4Abstract");
myElementNonAbstract = tu.getElement("testClass1");
}
catch( CModelException c )
{
assertNotNull("CModelException thrown",c);
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElementAbstract);
assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS);
@ -333,10 +325,8 @@ public class IStructureTests extends IntegratedCModelTest {
IStructure myStructDerived = (IStructure) myElementDerived;
assertNotNull(myStructDerived);
myBaseTypes = myStructDerived.getSuperClassesNames();
}
catch( CModelException c )
{
assertNotNull("CModelException thrown",c);
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
String[] myExpectedBaseTypes = {
@ -372,10 +362,8 @@ public class IStructureTests extends IntegratedCModelTest {
ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]);
assertEquals("Failed on " + i, myExpectedAccessControl[i], myAccessControl);
}
}
catch( CModelException c )
{
assertNotNull("CModelException thrown",c);
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
}
@ -399,10 +387,8 @@ public class IStructureTests extends IntegratedCModelTest {
ICElement myElement = null;
try {
myElement = tu.getElement("testAnonymousStructObject1");
}
catch( CModelException c )
{
assertNotNull("CModelException thrown",c);
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElement);
assertEquals(ICElement.C_VARIABLE, myElement.getElementType());
@ -413,10 +399,8 @@ public class IStructureTests extends IntegratedCModelTest {
ICElement myElement = null;
try {
myElement = tu.getElement("testStruct8");
}
catch( CModelException c )
{
assertNotNull("CModelException thrown",c);
} catch (CModelException e) {
assertNotNull("CModelException thrown", e);
}
assertNotNull(myElement);
IStructure myIStruct = (IStructure) myElement;

View file

@ -8,10 +8,6 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*
* Created on Jun 3, 2003
* by bnicolle
*/
package org.eclipse.cdt.core.model.tests;
import java.io.FileInputStream;
@ -33,18 +29,13 @@ import org.eclipse.core.runtime.Path;
/**
* @author bnicolle
*
*/
public abstract class IntegratedCModelTest extends BaseTestCase {
private ICProject fCProject;
private IFile sourceFile;
private NullProgressMonitor monitor;
private boolean structuralParse = false;
/**
*
*/
public IntegratedCModelTest() {
super();
}
@ -113,5 +104,4 @@ public abstract class IntegratedCModelTest extends BaseTestCase {
public void setStructuralParse(boolean structuralParse) {
this.structuralParse = structuralParse;
}
}

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.core.parser.util;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@ -42,9 +43,7 @@ public class ObjectMap extends ObjectTable<Object> {
@Override
final public void clear() {
super.clear();
for(int i = 0; i < valueTable.length; i++) {
valueTable[i] = null;
}
Arrays.fill(valueTable, null);
}
@Override

View file

@ -417,8 +417,9 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
copy.fForContentAssist = fForContentAssist;
copy.fOriginatingTranslationUnit = fOriginatingTranslationUnit;
for (IASTDeclaration declaration : getDeclarations())
for (IASTDeclaration declaration : getDeclarations()) {
copy.addDeclaration(declaration == null ? null : declaration.copy(style));
}
copy.setOffsetAndLength(this);
}

View file

@ -263,7 +263,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
if (image.length > 1 && image[0] == 'L')
return Value.create(ExpressionEvaluator.getChar(image, 2));
return Value.create(ExpressionEvaluator.getChar(image, 1));
} catch (EvalException e1) {
} catch (EvalException e) {
return Value.UNKNOWN;
}
}
@ -271,7 +271,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
private IValue createIntValue() {
try {
return Value.create(ExpressionEvaluator.getNumber(getValue()));
} catch (EvalException e1) {
} catch (EvalException e) {
return Value.UNKNOWN;
}
}

View file

@ -19,5 +19,4 @@ public class CPPConstructor extends CPPMethod implements ICPPConstructor {
public CPPConstructor(ICPPASTFunctionDeclarator declarator) {
super(declarator);
}
}

View file

@ -28,7 +28,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
private final ICPPTemplateArgument[] fArguments;
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap,
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
super(orig, owner, argMap, type, exceptionSpecs);
fArguments = args;
}

View file

@ -29,8 +29,7 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
*/
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
implements ICPPFunctionTemplate, ICPPInternalTemplate {
private ObjectMap instances = null;
private ObjectMap instances;
public CPPFunctionTemplateSpecialization(ICPPFunction original, ICPPClassType owner, ICPPTemplateParameterMap argumentMap, ICPPFunctionType type, IType[] exceptionSpecs) {
super(original, owner, argumentMap, type, exceptionSpecs);

View file

@ -23,13 +23,11 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
*/
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap,
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
super(orig, owner, tpmap, args, type, exceptionSpecs);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
*/
@Override
public int getVisibility() {
return ((ICPPMethod) getTemplateDefinition()).getVisibility();
@ -40,17 +38,11 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
return (ICPPClassType) getOwner();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
*/
@Override
public boolean isVirtual() {
return ((ICPPMethod) getTemplateDefinition()).isVirtual();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isPureVirtual()
*/
@Override
public boolean isPureVirtual() {
return ((ICPPMethod) getTemplateDefinition()).isPureVirtual();
@ -61,9 +53,6 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
return ((ICPPMethod) getTemplateDefinition()).isExplicit();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
*/
@Override
public boolean isDestructor() {
char[] name = getNameCharArray();

View file

@ -3041,8 +3041,10 @@ public class CPPSemantics {
if (type == null)
return null;
ICPPEvaluation[] args = {new EvalFixed(type, LVALUE, Value.UNKNOWN),
((ICPPASTExpression) expr.getOperand()).getEvaluation()};
ICPPEvaluation[] args = {
new EvalFixed(type, LVALUE, Value.UNKNOWN),
((ICPPASTExpression) expr.getOperand()).getEvaluation()
};
return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
}

View file

@ -118,7 +118,6 @@ public class EvalFunctionCall extends CPPEvaluation {
if (overload != null)
return ExpressionTypes.typeFromFunctionCall(overload);
final ICPPEvaluation arg0 = fArguments[0];
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
if (t instanceof ICPPClassType) {

View file

@ -176,7 +176,8 @@ public class EvalMemberAccess extends CPPEvaluation {
*/
ICPPEvaluation[] args= { new EvalFixed(type, LVALUE, Value.UNKNOWN) };
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType, OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
ICPPFunction op= CPPSemantics.findOverloadedOperator(point, args, classType,
OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
if (op == null)
break;

View file

@ -73,9 +73,9 @@ public class ExpressionEvaluator {
if (LA() == IToken.tQUESTION) {
consume();
long r2 = expression();
if (LA() == IToken.tCOLON)
if (LA() == IToken.tCOLON) {
consume();
else {
} else {
throw new EvalException(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION, null);
}
long r3 = conditionalExpression();
@ -139,12 +139,13 @@ public class ExpressionEvaluator {
for (int t = LA(); t == IToken.tEQUAL || t == IToken.tNOTEQUAL; t = LA()) {
consume();
long r2 = relationalExpression();
if (t == IToken.tEQUAL)
if (t == IToken.tEQUAL) {
r1 = (r1 == r2) ? 1 : 0;
else
} else {
// t == tNOTEQUAL
r1 = (r1 != r2) ? 1 : 0;
}
}
return r1;
}
@ -179,12 +180,13 @@ public class ExpressionEvaluator {
for (int t = LA(); t == IToken.tSHIFTL || t == IToken.tSHIFTR; t = LA()) {
consume();
long r2 = additiveExpression();
if (t == IToken.tSHIFTL)
if (t == IToken.tSHIFTL) {
r1 = r1 << r2;
else
} else {
// t == tSHIFTR
r1 = r1 >> r2;
}
}
return r1;
}
@ -193,12 +195,13 @@ public class ExpressionEvaluator {
for (int t = LA(); t == IToken.tPLUS || t == IToken.tMINUS; t = LA()) {
consume();
long r2 = multiplicativeExpression();
if (t == IToken.tPLUS)
if (t == IToken.tPLUS) {
r1 = r1 + r2;
else
} else {
// t == tMINUS
r1 = r1 - r2;
}
}
return r1;
}
@ -207,13 +210,14 @@ public class ExpressionEvaluator {
for (int t = LA(); t == IToken.tSTAR || t == IToken.tDIV || t == IToken.tMOD; t = LA()) {
consume();
long r2 = unaryExpression();
if (t == IToken.tSTAR)
if (t == IToken.tSTAR) {
r1 = r1 * r2;
else if (r2 != 0) {
if (t == IToken.tDIV)
} else if (r2 != 0) {
if (t == IToken.tDIV) {
r1 = r1 / r2;
else
} else {
r1 = r1 % r2; //tMOD
}
} else {
throw new EvalException(IProblem.SCANNER_DIVIDE_BY_ZERO, null);
}

View file

@ -31,7 +31,6 @@ import org.eclipse.core.runtime.CoreException;
* Binding for a function parameter in the index.
*/
final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
private static final int FLAG_OFFSET = NEXT_PARAM + Database.PTR_SIZE;
@SuppressWarnings("hiding")
@ -138,7 +137,6 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
return getNodeType();
}
@Override
public void delete(PDOMLinkage linkage) throws CoreException {
PDOMCParameter p= this;
@ -193,7 +191,6 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
return defValue;
}
@Override
public boolean isExtern() {
return false;

View file

@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
* Result of instantiating a class template.
*/
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
/**

View file

@ -42,20 +42,18 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
private static final short ANNOT_IS_DELETED = 9;
/**
* Offset of total number of function parameters (relative to the
* beginning of the record).
* Offset of total number of function parameters (relative to the beginning of the record).
*/
private static final int NUM_PARAMS = PDOMCPPBinding.RECORD_SIZE;
/**
* Offset of pointer to the first parameter of this function (relative to
* the beginning of the record).
* Offset of pointer to the first parameter of this function (relative to the beginning of the record).
*/
private static final int FIRST_PARAM = NUM_PARAMS + 4;
/**
* Offset of pointer to the function type record of this function (relative to
* the beginning of the record).
* Offset of pointer to the function type record of this function (relative to the beginning of the
* record).
*/
protected static final int FUNCTION_TYPE = FIRST_PARAM + Database.PTR_SIZE;
@ -86,7 +84,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
private int fRequiredArgCount = -1;
private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final.
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, boolean setTypes) throws CoreException, DOMException {
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function,
boolean setTypes) throws CoreException, DOMException {
super(linkage, parent, function.getNameCharArray());
Database db = getDB();
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
@ -376,8 +375,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
int mySM = a.getSignatureHash();
int otherSM = bb.getSignatureHash();
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
} catch(CoreException ce) {
CCorePlugin.log(ce);
} catch (CoreException e) {
CCorePlugin.log(e);
}
} else {
assert false;

View file

@ -98,7 +98,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
db.putRecPtr(record + FIRST_PARAM, 0);
PDOMCPPParameter origPar= null;
PDOMCPPParameterSpecialization next= null;
for (int i= length-1; i >= 0; --i) {
for (int i= length; --i >= 0;) {
// There may be fewer or less original parameters, because of parameter packs.
if (i < origAstParams.length - 1) {
// Normal case
@ -205,8 +205,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
if (fType == null) {
try {
fType= (ICPPFunctionType) getLinkage().loadType(record + FUNCTION_TYPE);
} catch(CoreException ce) {
CCorePlugin.log(ce);
} catch (CoreException e) {
CCorePlugin.log(e);
fType= new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED);
}
}

View file

@ -35,7 +35,6 @@ import org.eclipse.core.runtime.CoreException;
* Binding for a parameter of a c++ function in the index.
*/
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBinding {
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE;
private static final int ANNOTATIONS = NEXT_PARAM + Database.PTR_SIZE;
private static final int FLAGS = ANNOTATIONS + 1;
@ -48,6 +47,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
private static final byte FLAG_DEFAULT_VALUE = 0x1;
private final IType fType;
public PDOMCPPParameter(PDOMLinkage linkage, long record, IType type) {
super(linkage, record);
fType= type;

View file

@ -44,7 +44,7 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMCPPFunctionSpecialization parent, ICPPParameter astParam,
PDOMCPPParameter original, PDOMCPPParameterSpecialization next) throws CoreException {
super(linkage, parent, (ICPPSpecialization) astParam, original);
fType= null; // this constructor is used for adding parameters to the database, only.
fType= null; // This constructor is used for adding parameters to the database, only.
Database db = getDB();
db.putRecPtr(record + NEXT_PARAM, next == null ? 0 : next.getRecord());

View file

@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
* Binding for a c++ variable in the index, serves as a base class for fields.
*/
class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
private static final int TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE;
private static final int VALUE_OFFSET = TYPE_OFFSET + Database.TYPE_SIZE;
protected static final int ANNOTATIONS = VALUE_OFFSET + Database.VALUE_SIZE; // byte