mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Cosmetics.
This commit is contained in:
parent
1e824bb514
commit
1e3fc49c45
2 changed files with 33 additions and 23 deletions
|
@ -91,11 +91,12 @@ public class Value implements IValue {
|
|||
fResolvedUnknown= resolvedUnknowns;
|
||||
fMap= map;
|
||||
}
|
||||
|
||||
public void nextSeperator() throws UnknownValueException {
|
||||
final char[] expression = fExpression;
|
||||
final int len = expression.length;
|
||||
int idx = pos;
|
||||
while(idx < len) {
|
||||
while (idx < len) {
|
||||
if (expression[idx++] == SEPARATOR)
|
||||
break;
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ public class Value implements IValue {
|
|||
|
||||
private static class UnknownValueException extends Exception {}
|
||||
private static UnknownValueException UNKNOWN_EX= new UnknownValueException();
|
||||
private static int sUnique=0;
|
||||
private static int sUnique= 0;
|
||||
|
||||
private final char[] fExpression;
|
||||
private final ICPPUnknownBinding[] fUnknownBindings;
|
||||
|
@ -400,7 +401,8 @@ public class Value implements IValue {
|
|||
* Returns a {@code Number} for numerical values or a {@code String}, otherwise.
|
||||
* @throws UnknownValueException
|
||||
*/
|
||||
private static Object evaluate(IASTExpression e, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
|
||||
private static Object evaluate(IASTExpression e, Map<String, Integer> unknownSigs,
|
||||
List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
|
||||
if (maxdepth < 0 || e == null)
|
||||
throw UNKNOWN_EX;
|
||||
|
||||
|
@ -433,7 +435,8 @@ public class Value implements IValue {
|
|||
final IASTExpression pe = cexpr.getPositiveResultExpression();
|
||||
Object po= pe == null ? o : evaluate(pe, unknownSigs, unknowns, maxdepth);
|
||||
Object neg= evaluate(cexpr.getNegativeResultExpression(), unknownSigs, unknowns, maxdepth);
|
||||
return "" + CONDITIONAL_CHAR + SEPARATOR + o.toString() + SEPARATOR + po.toString() + SEPARATOR + neg.toString(); //$NON-NLS-1$
|
||||
return "" + CONDITIONAL_CHAR + SEPARATOR + o.toString() + SEPARATOR + po.toString() + //$NON-NLS-1$
|
||||
SEPARATOR + neg.toString();
|
||||
}
|
||||
if (e instanceof IASTIdExpression) {
|
||||
IBinding b= ((IASTIdExpression) e).getName().resolvePreBinding();
|
||||
|
@ -483,7 +486,8 @@ public class Value implements IValue {
|
|||
/**
|
||||
* Extract a value off a binding.
|
||||
*/
|
||||
private static Object evaluateBinding(IBinding b, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
|
||||
private static Object evaluateBinding(IBinding b, Map<String, Integer> unknownSigs,
|
||||
List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
|
||||
if (b instanceof IType) {
|
||||
throw UNKNOWN_EX;
|
||||
}
|
||||
|
@ -510,7 +514,8 @@ public class Value implements IValue {
|
|||
throw UNKNOWN_EX;
|
||||
}
|
||||
|
||||
private static Object createReference(ICPPUnknownBinding unknown, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns) {
|
||||
private static Object createReference(ICPPUnknownBinding unknown,
|
||||
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns) {
|
||||
String sig= getSignatureForUnknown(unknown);
|
||||
Integer idx= unknownSigs.get(sig);
|
||||
if (idx == null) {
|
||||
|
@ -521,7 +526,8 @@ public class Value implements IValue {
|
|||
return "" + REFERENCE_CHAR + idx.toString(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private static Object evaluateValue(IValue cv, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns) throws UnknownValueException {
|
||||
private static Object evaluateValue(IValue cv, Map<String, Integer> unknownSigs,
|
||||
List<ICPPUnknownBinding> unknowns) throws UnknownValueException {
|
||||
if (cv == Value.UNKNOWN)
|
||||
throw UNKNOWN_EX;
|
||||
|
||||
|
@ -564,7 +570,9 @@ public class Value implements IValue {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
private static Object evaluateUnaryExpression(IASTUnaryExpression ue, Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
|
||||
private static Object evaluateUnaryExpression(IASTUnaryExpression ue,
|
||||
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth)
|
||||
throws UnknownValueException {
|
||||
final int unaryOp= ue.getOperator();
|
||||
|
||||
if (unaryOp == IASTUnaryExpression.op_sizeof) {
|
||||
|
@ -626,7 +634,8 @@ public class Value implements IValue {
|
|||
}
|
||||
|
||||
private static Object evaluateBinaryExpression(IASTBinaryExpression be,
|
||||
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth) throws UnknownValueException {
|
||||
Map<String, Integer> unknownSigs, List<ICPPUnknownBinding> unknowns, int maxdepth)
|
||||
throws UnknownValueException {
|
||||
final Object o1= evaluate(be.getOperand1(), unknownSigs, unknowns, maxdepth);
|
||||
final Object o2= evaluate(be.getOperand2(), unknownSigs, unknowns, maxdepth);
|
||||
|
||||
|
@ -634,7 +643,8 @@ public class Value implements IValue {
|
|||
return combineBinary(op, o1, o2);
|
||||
}
|
||||
|
||||
private static Object combineBinary(final int op, final Object o1, final Object o2) throws UnknownValueException {
|
||||
private static Object combineBinary(final int op, final Object o1, final Object o2)
|
||||
throws UnknownValueException {
|
||||
if (o1 instanceof Number && o2 instanceof Number) {
|
||||
long v1= ((Number) o1).longValue();
|
||||
long v2= ((Number) o2).longValue();
|
||||
|
@ -721,7 +731,8 @@ public class Value implements IValue {
|
|||
return "" + BINARY_OP_CHAR + op + SEPARATOR + o1.toString() + SEPARATOR + o2.toString(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static IValue reevaluate(IValue val, int packOffset, IBinding[] resolvedUnknowns, ICPPTemplateParameterMap map, int maxdepth) {
|
||||
public static IValue reevaluate(IValue val, int packOffset, IBinding[] resolvedUnknowns,
|
||||
ICPPTemplateParameterMap map, int maxdepth) {
|
||||
try {
|
||||
Map<String, Integer> unknownSigs= new HashMap<String, Integer>();
|
||||
List<ICPPUnknownBinding> unknown= new ArrayList<ICPPUnknownBinding>();
|
||||
|
@ -783,7 +794,8 @@ public class Value implements IValue {
|
|||
}
|
||||
return po;
|
||||
}
|
||||
return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + po.toString() + SEPARATOR + neg.toString(); //$NON-NLS-1$
|
||||
return "" + CONDITIONAL_CHAR + SEPARATOR + cond.toString() + SEPARATOR + //$NON-NLS-1$
|
||||
po.toString() + SEPARATOR + neg.toString();
|
||||
case REFERENCE_CHAR:
|
||||
int num= parseNonNegative(buf, idx + 1);
|
||||
final IBinding[] resolvedUnknowns= reeval.fResolvedUnknown;
|
||||
|
@ -885,7 +897,7 @@ public class Value implements IValue {
|
|||
* Parses a long.
|
||||
*/
|
||||
private static long parseLong(char[] value, int offset) throws UnknownValueException {
|
||||
final long maxvalue= Long.MAX_VALUE/10;
|
||||
final long maxvalue= Long.MAX_VALUE / 10;
|
||||
final int len= value.length;
|
||||
boolean negative= false;
|
||||
long result = 0;
|
||||
|
@ -916,7 +928,7 @@ public class Value implements IValue {
|
|||
* Parses a long, returns <code>null</code> if not possible
|
||||
*/
|
||||
private static Long parseLong(char[] value) {
|
||||
final long maxvalue= Long.MAX_VALUE/10;
|
||||
final long maxvalue= Long.MAX_VALUE / 10;
|
||||
final int len= value.length;
|
||||
boolean negative= false;
|
||||
long result = 0;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Institute for Software - initial API and implementation
|
||||
* Institute for Software - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.rewrite.util;
|
||||
|
||||
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
|||
|
||||
/**
|
||||
* @author Emanuel Graf IFS
|
||||
*
|
||||
*/
|
||||
public class OffsetHelper {
|
||||
|
||||
|
@ -32,10 +31,11 @@ public class OffsetHelper {
|
|||
if (location instanceof IASTMacroExpansionLocation) {
|
||||
IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
|
||||
offset = macroLoc.asFileLocation().getNodeOffset();
|
||||
}else {
|
||||
} else {
|
||||
offset = location.asFileLocation().getNodeOffset();
|
||||
}
|
||||
if(offset < nodeStart) nodeStart = offset;
|
||||
if (offset < nodeStart)
|
||||
nodeStart = offset;
|
||||
}
|
||||
} else {
|
||||
nodeStart = node.getFileLocation().getNodeOffset();
|
||||
|
@ -55,14 +55,13 @@ public class OffsetHelper {
|
|||
IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
|
||||
fileOffset = macroLoc.asFileLocation().getNodeOffset();
|
||||
length = macroLoc.asFileLocation().getNodeLength();
|
||||
}else {
|
||||
} else {
|
||||
fileOffset = location.asFileLocation().getNodeOffset();
|
||||
length = location.asFileLocation().getNodeLength();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IASTFileLocation loc = node.getFileLocation();
|
||||
|
||||
fileOffset = loc.getNodeOffset();
|
||||
length = loc.getNodeLength();
|
||||
}
|
||||
|
@ -75,7 +74,7 @@ public class OffsetHelper {
|
|||
}
|
||||
|
||||
public static int getLengthIncludingComment(IASTNode node) {
|
||||
return OffsetHelper.getEndOffsetIncludingComments(node) - OffsetHelper.getOffsetIncludingComment(node);
|
||||
return getEndOffsetIncludingComments(node) - getOffsetIncludingComment(node);
|
||||
}
|
||||
|
||||
public static int getNodeOffset(ASTNode node) {
|
||||
|
@ -92,6 +91,5 @@ public class OffsetHelper {
|
|||
|
||||
public static int getEndingLineNumber(IASTNode node) {
|
||||
return node.getFileLocation().getEndingLineNumber();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue