本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.TypeIds.T_JavaLangString方法的典型用法代码示例。如果您正苦于以下问题:Java TypeIds.T_JavaLangString方法的具体用法?Java TypeIds.T_JavaLangString怎么用?Java TypeIds.T_JavaLangString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.TypeIds
的用法示例。
在下文中一共展示了TypeIds.T_JavaLangString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConstantValue
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public Object getConstantValue() {
Constant c = this.binding.constant();
if (c == null || c == Constant.NotAConstant) return null;
switch (c.typeID()) {
case TypeIds.T_boolean:
return Boolean.valueOf(c.booleanValue());
case TypeIds.T_byte:
return new Byte(c.byteValue());
case TypeIds.T_char:
return new Character(c.charValue());
case TypeIds.T_double:
return new Double(c.doubleValue());
case TypeIds.T_float:
return new Float(c.floatValue());
case TypeIds.T_int:
return new Integer(c.intValue());
case TypeIds.T_long:
return new Long(c.longValue());
case TypeIds.T_short:
return new Short(c.shortValue());
case TypeIds.T_JavaLangString:
return c.stringValue();
}
return null;
}
示例2: checkNPE
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo, boolean checkString) {
// cannot override localVariableBinding because this would project o.m onto o when
// analyzing assignments
if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) {
LocalVariableBinding local = (LocalVariableBinding) this.binding;
if (local != null &&
(local.type.tagBits & TagBits.IsBaseType) == 0 &&
(checkString || local.type.id != TypeIds.T_JavaLangString)) {
if ((this.bits & ASTNode.IsNonNull) == 0) {
flowContext.recordUsingNullReference(scope, local, this,
FlowContext.MAY_NULL, flowInfo);
}
flowInfo.markAsComparedEqualToNonNull(local);
// from thereon it is set
if (flowContext.initsOnFinally != null) {
flowContext.initsOnFinally.markAsComparedEqualToNonNull(local);
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:21,代码来源:QualifiedNameReference.java
示例3: resolveConstantExpressionValue
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
Object resolveConstantExpressionValue(Expression expression) {
org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression);
if (node instanceof org.eclipse.jdt.internal.compiler.ast.Expression) {
org.eclipse.jdt.internal.compiler.ast.Expression compilerExpression = (org.eclipse.jdt.internal.compiler.ast.Expression) node;
Constant constant = compilerExpression.constant;
if (constant != null && constant != Constant.NotAConstant) {
switch (constant.typeID()) {
case TypeIds.T_int : return new Integer(constant.intValue());
case TypeIds.T_byte : return new Byte(constant.byteValue());
case TypeIds.T_short : return new Short(constant.shortValue());
case TypeIds.T_char : return new Character(constant.charValue());
case TypeIds.T_float : return new Float(constant.floatValue());
case TypeIds.T_double : return new Double(constant.doubleValue());
case TypeIds.T_boolean : return constant.booleanValue() ? Boolean.TRUE : Boolean.FALSE;
case TypeIds.T_long : return new Long(constant.longValue());
case TypeIds.T_JavaLangString : return constant.stringValue();
}
return null;
}
}
return null;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:23,代码来源:DefaultBindingResolver.java
示例4: calculateValue
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
/**
* Returns the actual value of the given Literal or Literal-like node.
*/
public static Object calculateValue(Expression e) {
if (e instanceof Literal) {
((Literal)e).computeConstant();
switch (e.constant.typeID()) {
case TypeIds.T_int: return e.constant.intValue();
case TypeIds.T_byte: return e.constant.byteValue();
case TypeIds.T_short: return e.constant.shortValue();
case TypeIds.T_char: return e.constant.charValue();
case TypeIds.T_float: return e.constant.floatValue();
case TypeIds.T_double: return e.constant.doubleValue();
case TypeIds.T_boolean: return e.constant.booleanValue();
case TypeIds.T_long: return e.constant.longValue();
case TypeIds.T_JavaLangString: return e.constant.stringValue();
default: return null;
}
} else if (e instanceof ClassLiteralAccess) {
return Eclipse.toQualifiedName(((ClassLiteralAccess)e).type.getTypeName());
} else if (e instanceof SingleNameReference) {
return new String(((SingleNameReference)e).token);
} else if (e instanceof QualifiedNameReference) {
String qName = Eclipse.toQualifiedName(((QualifiedNameReference)e).tokens);
int idx = qName.lastIndexOf('.');
return idx == -1 ? qName : qName.substring(idx+1);
}
return null;
}
示例5: getAnnotationMemberValue
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public static Object getAnnotationMemberValue(
MemberValuePair memberValuePair, Constant constant) {
if (constant == null) {
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
}
switch (constant.typeID()) {
case TypeIds.T_int:
memberValuePair.valueKind = IMemberValuePair.K_INT;
return new Integer(constant.intValue());
case TypeIds.T_byte:
memberValuePair.valueKind = IMemberValuePair.K_BYTE;
return new Byte(constant.byteValue());
case TypeIds.T_short:
memberValuePair.valueKind = IMemberValuePair.K_SHORT;
return new Short(constant.shortValue());
case TypeIds.T_char:
memberValuePair.valueKind = IMemberValuePair.K_CHAR;
return new Character(constant.charValue());
case TypeIds.T_float:
memberValuePair.valueKind = IMemberValuePair.K_FLOAT;
return new Float(constant.floatValue());
case TypeIds.T_double:
memberValuePair.valueKind = IMemberValuePair.K_DOUBLE;
return new Double(constant.doubleValue());
case TypeIds.T_boolean:
memberValuePair.valueKind = IMemberValuePair.K_BOOLEAN;
return Boolean.valueOf(constant.booleanValue());
case TypeIds.T_long:
memberValuePair.valueKind = IMemberValuePair.K_LONG;
return new Long(constant.longValue());
case TypeIds.T_JavaLangString:
memberValuePair.valueKind = IMemberValuePair.K_STRING;
return constant.stringValue();
default:
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
}
}
示例6: accept
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") // Need to cast Object _value to a List<AnnotationValue>
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
switch (_kind) {
case TypeIds.T_boolean:
return v.visitBoolean((Boolean)_value, p);
case TypeIds.T_byte:
return v.visitByte((Byte)_value, p);
case TypeIds.T_char:
return v.visitChar((Character)_value, p);
case TypeIds.T_double:
return v.visitDouble((Double)_value, p);
case TypeIds.T_float:
return v.visitFloat((Float)_value, p);
case TypeIds.T_int:
return v.visitInt((Integer)_value, p);
case TypeIds.T_JavaLangString:
return v.visitString((String)_value, p);
case TypeIds.T_long:
return v.visitLong((Long)_value, p);
case TypeIds.T_short:
return v.visitShort((Short)_value, p);
case T_EnumConstant:
return v.visitEnumConstant((VariableElement)_value, p);
case T_ClassObject:
return v.visitType((TypeMirror)_value, p);
case T_AnnotationMirror:
return v.visitAnnotation((AnnotationMirror)_value, p);
case T_ArrayType:
return v.visitArray((List<AnnotationValue>)_value, p);
default:
return null;
}
}
示例7: getConstantValue
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
@Override
public Object getConstantValue() {
VariableBinding variableBinding = (VariableBinding) _binding;
Constant constant = variableBinding.constant();
if (constant == null || constant == Constant.NotAConstant) return null;
TypeBinding type = variableBinding.type;
switch (type.id) {
case TypeIds.T_boolean:
return constant.booleanValue();
case TypeIds.T_byte:
return constant.byteValue();
case TypeIds.T_char:
return constant.charValue();
case TypeIds.T_double:
return constant.doubleValue();
case TypeIds.T_float:
return constant.floatValue();
case TypeIds.T_int:
return constant.intValue();
case TypeIds.T_JavaLangString:
return constant.stringValue();
case TypeIds.T_long:
return constant.longValue();
case TypeIds.T_short:
return constant.shortValue();
}
return null;
}
示例8: convertConstant
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
/**
* Converts a field constant from the compiler's representation
* to the Java Model constant representation (Number or String).
*/
protected static Object convertConstant(Constant constant) {
if (constant == null)
return null;
if (constant == Constant.NotAConstant) {
return null;
}
switch (constant.typeID()) {
case TypeIds.T_boolean :
return constant.booleanValue() ? Boolean.TRUE : Boolean.FALSE;
case TypeIds.T_byte :
return new Byte(constant.byteValue());
case TypeIds.T_char :
return new Character(constant.charValue());
case TypeIds.T_double :
return new Double(constant.doubleValue());
case TypeIds.T_float :
return new Float(constant.floatValue());
case TypeIds.T_int :
return new Integer(constant.intValue());
case TypeIds.T_long :
return new Long(constant.longValue());
case TypeIds.T_short :
return new Short(constant.shortValue());
case TypeIds.T_JavaLangString :
return constant.stringValue();
default :
return null;
}
}
示例9: getAnnotationMemberValue
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public static Object getAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant) {
if (constant == null) {
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
}
switch (constant.typeID()) {
case TypeIds.T_int :
memberValuePair.valueKind = IMemberValuePair.K_INT;
return new Integer(constant.intValue());
case TypeIds.T_byte :
memberValuePair.valueKind = IMemberValuePair.K_BYTE;
return new Byte(constant.byteValue());
case TypeIds.T_short :
memberValuePair.valueKind = IMemberValuePair.K_SHORT;
return new Short(constant.shortValue());
case TypeIds.T_char :
memberValuePair.valueKind = IMemberValuePair.K_CHAR;
return new Character(constant.charValue());
case TypeIds.T_float :
memberValuePair.valueKind = IMemberValuePair.K_FLOAT;
return new Float(constant.floatValue());
case TypeIds.T_double :
memberValuePair.valueKind = IMemberValuePair.K_DOUBLE;
return new Double(constant.doubleValue());
case TypeIds.T_boolean :
memberValuePair.valueKind = IMemberValuePair.K_BOOLEAN;
return Boolean.valueOf(constant.booleanValue());
case TypeIds.T_long :
memberValuePair.valueKind = IMemberValuePair.K_LONG;
return new Long(constant.longValue());
case TypeIds.T_JavaLangString :
memberValuePair.valueKind = IMemberValuePair.K_STRING;
return constant.stringValue();
default:
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
}
}
示例10: generateOptimizedStringConcatenation
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public void generateOptimizedStringConcatenation(BlockScope blockScope, CodeStream codeStream, int typeID) {
if (typeID == TypeIds.T_JavaLangString && this.constant != Constant.NotAConstant && this.constant.stringValue().length() == 0) {
return; // optimize str + ""
}
generateCode(blockScope, codeStream, true);
codeStream.invokeStringConcatenationAppendForType(typeID);
}
示例11: checkInternalNPE
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
private void checkInternalNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo, boolean checkString) {
if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) {
LocalVariableBinding local = (LocalVariableBinding) this.binding;
if (local != null &&
(local.type.tagBits & TagBits.IsBaseType) == 0 &&
(checkString || local.type.id != TypeIds.T_JavaLangString)) {
if ((this.bits & ASTNode.IsNonNull) == 0) {
flowContext.recordUsingNullReference(scope, local, this,
FlowContext.MAY_NULL, flowInfo);
}
flowInfo.markAsComparedEqualToNonNull(local);
// from thereon it is set
flowContext.markFinallyNullStatus(local, FlowInfo.NON_NULL);
}
}
if (this.otherBindings != null) {
if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.FIELD) {
// is the first field dereferenced annotated Nullable? If so, report immediately
checkNullableFieldDereference(scope, (FieldBinding) this.binding, this.sourcePositions[this.indexOfFirstFieldBinding-1]);
}
// look for annotated fields, they do not depend on flow context -> check immediately:
int length = this.otherBindings.length - 1; // don't check the last binding
for (int i = 0; i < length; i++) {
checkNullableFieldDereference(scope, this.otherBindings[i], this.sourcePositions[this.indexOfFirstFieldBinding+i]);
}
}
}
示例12: incorrectSwitchType
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public void incorrectSwitchType(Expression expression, TypeBinding testType) {
if (this.options.sourceLevel < ClassFileConstants.JDK1_7) {
if (testType.id == TypeIds.T_JavaLangString) {
this.handle(
IProblem.SwitchOnStringsNotBelow17,
new String[] {new String(testType.readableName())},
new String[] {new String(testType.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
} else {
if (this.options.sourceLevel < ClassFileConstants.JDK1_5 && testType.isEnum()) {
this.handle(
IProblem.SwitchOnEnumNotBelow15,
new String[] {new String(testType.readableName())},
new String[] {new String(testType.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
} else {
this.handle(
IProblem.IncorrectSwitchType,
new String[] {new String(testType.readableName())},
new String[] {new String(testType.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
}
} else {
this.handle(
IProblem.IncorrectSwitchType17,
new String[] {new String(testType.readableName())},
new String[] {new String(testType.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
}
示例13: hasSameValue
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
/**
* Returns true if both constants have the same type and the same actual value
* @param otherConstant
*/
public boolean hasSameValue(Constant otherConstant) {
if (this == otherConstant)
return true;
int typeID;
if ((typeID = typeID()) != otherConstant.typeID())
return false;
switch (typeID) {
case TypeIds.T_boolean:
return booleanValue() == otherConstant.booleanValue();
case TypeIds.T_byte:
return byteValue() == otherConstant.byteValue();
case TypeIds.T_char:
return charValue() == otherConstant.charValue();
case TypeIds.T_double:
return doubleValue() == otherConstant.doubleValue();
case TypeIds.T_float:
return floatValue() == otherConstant.floatValue();
case TypeIds.T_int:
return intValue() == otherConstant.intValue();
case TypeIds.T_short:
return shortValue() == otherConstant.shortValue();
case TypeIds.T_long:
return longValue() == otherConstant.longValue();
case TypeIds.T_JavaLangString:
String value = stringValue();
return value == null
? otherConstant.stringValue() == null
: value.equals(otherConstant.stringValue());
}
return false;
}
示例14: getWrappedConstantValue
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
/**
* Return a wrapper that contains the constant of the field.
* @return java.lang.Object
*/
public Object getWrappedConstantValue() {
if (this.wrappedConstantValue == null) {
if (hasConstant()) {
Constant fieldConstant = getConstant();
switch (fieldConstant.typeID()) {
case TypeIds.T_int :
this.wrappedConstantValue = new Integer(fieldConstant.intValue());
break;
case TypeIds.T_byte :
this.wrappedConstantValue = new Byte(fieldConstant.byteValue());
break;
case TypeIds.T_short :
this.wrappedConstantValue = new Short(fieldConstant.shortValue());
break;
case TypeIds.T_char :
this.wrappedConstantValue = new Character(fieldConstant.charValue());
break;
case TypeIds.T_float :
this.wrappedConstantValue = new Float(fieldConstant.floatValue());
break;
case TypeIds.T_double :
this.wrappedConstantValue = new Double(fieldConstant.doubleValue());
break;
case TypeIds.T_boolean :
this.wrappedConstantValue = Util.toBoolean(fieldConstant.booleanValue());
break;
case TypeIds.T_long :
this.wrappedConstantValue = new Long(fieldConstant.longValue());
break;
case TypeIds.T_JavaLangString :
this.wrappedConstantValue = fieldConstant.stringValue();
}
}
}
return this.wrappedConstantValue;
}
示例15: generateOptimizedStringConcatenation
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; //导入方法依赖的package包/类
public void generateOptimizedStringConcatenation(BlockScope blockScope,
CodeStream codeStream, int typeID) {
// keep implementation in sync with BinaryExpression and Expression
// #generateOptimizedStringConcatenation
if (this.referencesTable == null) {
super.generateOptimizedStringConcatenation(blockScope, codeStream,
typeID);
} else {
if ((((this.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT) ==
OperatorIds.PLUS)
&& ((this.bits & ASTNode.ReturnTypeIDMASK) == TypeIds.T_JavaLangString)) {
if (this.constant != Constant.NotAConstant) {
codeStream.generateConstant(this.constant, this.implicitConversion);
codeStream.invokeStringConcatenationAppendForType(
this.implicitConversion & TypeIds.COMPILE_TYPE_MASK);
} else {
BinaryExpression cursor = this.referencesTable[0];
int restart = 0;
// int cursorTypeID;
int pc = codeStream.position;
for (restart = this.arity - 1; restart >= 0; restart--) {
if ((cursor = this.referencesTable[restart]).constant !=
Constant.NotAConstant) {
codeStream.generateConstant(cursor.constant,
cursor.implicitConversion);
codeStream.invokeStringConcatenationAppendForType(
cursor.implicitConversion & TypeIds.COMPILE_TYPE_MASK);
break;
}
// never happens for now - may reconsider if we decide to
// cover more than string concatenation
// if (!((((cursor = this.referencesTable[restart]).bits &
// ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT) ==
// OperatorIds.PLUS) &
// ((cursorTypeID = cursor.bits & ASTNode.ReturnTypeIDMASK) ==
// TypeIds.T_JavaLangString)) {
// if (cursorTypeID == T_JavaLangString &&
// cursor.constant != Constant.NotAConstant &&
// cursor.constant.stringValue().length() == 0) {
// break; // optimize str + ""
// }
// cursor.generateCode(blockScope, codeStream, true);
// codeStream.invokeStringConcatenationAppendForType(
// cursorTypeID);
// break;
// }
}
restart++;
if (restart == 0) { // reached the leftmost expression
cursor.left.generateOptimizedStringConcatenation(
blockScope,
codeStream,
cursor.left.implicitConversion & TypeIds.COMPILE_TYPE_MASK);
}
int pcAux;
for (int i = restart; i < this.arity; i++) {
codeStream.recordPositionsFrom(pc,
(cursor = this.referencesTable[i]).left.sourceStart);
pcAux = codeStream.position;
cursor.right.generateOptimizedStringConcatenation(blockScope,
codeStream, cursor.right.implicitConversion &
TypeIds.COMPILE_TYPE_MASK);
codeStream.recordPositionsFrom(pcAux, cursor.right.sourceStart);
}
codeStream.recordPositionsFrom(pc, this.left.sourceStart);
pc = codeStream.position;
this.right.generateOptimizedStringConcatenation(
blockScope,
codeStream,
this.right.implicitConversion & TypeIds.COMPILE_TYPE_MASK);
codeStream.recordPositionsFrom(pc, this.right.sourceStart);
}
} else {
super.generateOptimizedStringConcatenation(blockScope, codeStream,
typeID);
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:80,代码来源:CombinedBinaryExpression.java