mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Moved implementations of deprecated methods from to the IValue interface
Change-Id: I2002d5d3c60d66f15c47a8014f39333291a49a2f
This commit is contained in:
parent
b97bdab9f9
commit
a98b07b8d3
7 changed files with 14 additions and 96 deletions
|
@ -352,7 +352,7 @@ public class BaseTestCase extends TestCase {
|
|||
|
||||
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
|
||||
assertNotNull("Expected object of " + clazz.getName() + " but got a null value", o);
|
||||
assertTrue("Expected "+clazz.getName()+" but got "+o.getClass().getName(), clazz.isInstance(o));
|
||||
assertTrue("Expected " + clazz.getName() + " but got " + o.getClass().getName(), clazz.isInstance(o));
|
||||
for (Class c : cs) {
|
||||
assertNotNull("Expected object of " + c.getName() + " but got a null value", o);
|
||||
assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
|
||||
|
@ -362,8 +362,8 @@ public class BaseTestCase extends TestCase {
|
|||
|
||||
protected static void assertValue(IValue value, long expectedValue) {
|
||||
assertNotNull(value);
|
||||
assertNotNull(value.numericalValue());
|
||||
assertEquals(expectedValue, value.numericalValue().longValue());
|
||||
assertTrue(value.numberValue() instanceof Long);
|
||||
assertEquals(expectedValue, value.numberValue().longValue());
|
||||
}
|
||||
|
||||
protected static void assertVariableValue(IVariable var, long expectedValue) {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -28,7 +29,10 @@ public interface IValue {
|
|||
* @deprecated Use numberValue() instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Long numericalValue();
|
||||
default Long numericalValue() {
|
||||
Number num = numberValue();
|
||||
return num instanceof Long ? (Long) num : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value as a number, or {@code null} if it is not possible.
|
||||
|
@ -78,14 +82,18 @@ public interface IValue {
|
|||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
@Deprecated
|
||||
char[] getInternalExpression();
|
||||
public default char[] getInternalExpression() {
|
||||
return CharArrayUtils.EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Returns an empty array.
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
@Deprecated
|
||||
IBinding[] getUnknownBindings();
|
||||
public default IBinding[] getUnknownBindings() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this value consists of sub-values, set the sub-value at the given position to the given new value.
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
|
@ -156,11 +155,6 @@ public final class CStringValue implements IValue {
|
|||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long numericalValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number numberValue() {
|
||||
return null;
|
||||
|
@ -220,18 +214,6 @@ public final class CStringValue implements IValue {
|
|||
return CharArrayUtils.equals(getSignature(), rhs.getSignature());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public char[] getInternalExpression() {
|
||||
return CharArrayUtils.EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public IBinding[] getUnknownBindings() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubValue(int position, ICPPEvaluation newValue) {
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
|
@ -46,11 +45,6 @@ public final class CompositeValue implements IValue {
|
|||
this.values = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long numericalValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number numberValue() {
|
||||
return null;
|
||||
|
@ -69,18 +63,6 @@ public final class CompositeValue implements IValue {
|
|||
return new char[]{};
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public char[] getInternalExpression() {
|
||||
return CharArrayUtils.EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public IBinding[] getUnknownBindings() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numberOfSubValues() {
|
||||
return values.length;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
|
@ -31,11 +30,6 @@ public class DependentValue implements IValue {
|
|||
fEvaluation = evaluation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long numericalValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Number numberValue() {
|
||||
return null;
|
||||
|
@ -54,18 +48,6 @@ public class DependentValue implements IValue {
|
|||
return fSignature;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public char[] getInternalExpression() {
|
||||
return CharArrayUtils.EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public IBinding[] getUnknownBindings() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buf) throws CoreException {
|
||||
buf.putShort(ITypeMarshalBuffer.DEPENDENT_VALUE);
|
||||
|
|
|
@ -10,7 +10,6 @@ package org.eclipse.cdt.internal.core.dom.parser;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
|
@ -32,11 +31,6 @@ public final class FloatingPointValue implements IValue {
|
|||
return new FloatingPointValue(toCharArray(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long numericalValue() {
|
||||
return null; // not a Long
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number numberValue() {
|
||||
return parseDouble(fFixedValue);
|
||||
|
@ -139,18 +133,6 @@ public final class FloatingPointValue implements IValue {
|
|||
return CharArrayUtils.equals(getSignature(), rhs.getSignature());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public char[] getInternalExpression() {
|
||||
return CharArrayUtils.EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public IBinding[] getUnknownBindings() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubValue(int position, ICPPEvaluation newValue) {
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.util.Arrays;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
|
@ -71,11 +70,6 @@ public class IntegralValue implements IValue {
|
|||
fFixedValue = fixedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long numericalValue() {
|
||||
return (Long) numberValue(); // IntegralValue.numberValue() always returns a Long
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Number numberValue() {
|
||||
return parseLong(fFixedValue);
|
||||
|
@ -91,18 +85,6 @@ public class IntegralValue implements IValue {
|
|||
return fFixedValue;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public char[] getInternalExpression() {
|
||||
return CharArrayUtils.EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public IBinding[] getUnknownBindings() {
|
||||
return IBinding.EMPTY_BINDING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buf) throws CoreException {
|
||||
if (UNKNOWN == this) {
|
||||
|
|
Loading…
Add table
Reference in a new issue