本文整理汇总了Java中org.eclipse.jdt.core.IMemberValuePair.K_SIMPLE_NAME属性的典型用法代码示例。如果您正苦于以下问题:Java IMemberValuePair.K_SIMPLE_NAME属性的具体用法?Java IMemberValuePair.K_SIMPLE_NAME怎么用?Java IMemberValuePair.K_SIMPLE_NAME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.IMemberValuePair
的用法示例。
在下文中一共展示了IMemberValuePair.K_SIMPLE_NAME属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: eval
public static String eval(Object value, int valueKind, AST ast, IProject project)
{
if (ast != null
&& (valueKind == IMemberValuePair.K_SIMPLE_NAME
|| valueKind == IMemberValuePair.K_QUALIFIED_NAME))
{
Name name = ast.newName((String) value);
return evalExpression(project, name);
}
return String.valueOf(value);
}
示例2: getMemberValue
protected Object getMemberValue(org.eclipse.jdt.internal.core.MemberValuePair memberValuePair, Expression expression) {
if (expression instanceof NullLiteral) {
return null;
} else if (expression instanceof Literal) {
((Literal) expression).computeConstant();
return Util.getAnnotationMemberValue(memberValuePair, expression.constant);
} else if (expression instanceof org.eclipse.jdt.internal.compiler.ast.Annotation) {
org.eclipse.jdt.internal.compiler.ast.Annotation annotation = (org.eclipse.jdt.internal.compiler.ast.Annotation) expression;
Object handle = acceptAnnotation(annotation, null, (JavaElement) this.handleStack.peek());
memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
return handle;
} else if (expression instanceof ClassLiteralAccess) {
ClassLiteralAccess classLiteral = (ClassLiteralAccess) expression;
char[] name = CharOperation.concatWith(classLiteral.type.getTypeName(), '.');
memberValuePair.valueKind = IMemberValuePair.K_CLASS;
return new String(name);
} else if (expression instanceof QualifiedNameReference) {
char[] qualifiedName = CharOperation.concatWith(((QualifiedNameReference) expression).tokens, '.');
memberValuePair.valueKind = IMemberValuePair.K_QUALIFIED_NAME;
return new String(qualifiedName);
} else if (expression instanceof SingleNameReference) {
char[] simpleName = ((SingleNameReference) expression).token;
if (simpleName == RecoveryScanner.FAKE_IDENTIFIER) {
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
}
memberValuePair.valueKind = IMemberValuePair.K_SIMPLE_NAME;
return new String(simpleName);
} else if (expression instanceof ArrayInitializer) {
memberValuePair.valueKind = -1; // modified below by the first call to getMemberValue(...)
Expression[] expressions = ((ArrayInitializer) expression).expressions;
int length = expressions == null ? 0 : expressions.length;
Object[] values = new Object[length];
for (int i = 0; i < length; i++) {
int previousValueKind = memberValuePair.valueKind;
Object value = getMemberValue(memberValuePair, expressions[i]);
if (previousValueKind != -1 && memberValuePair.valueKind != previousValueKind) {
// values are heterogeneous, value kind is thus unknown
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
}
values[i] = value;
}
if (memberValuePair.valueKind == -1)
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return values;
} else if (expression instanceof UnaryExpression) { // to deal with negative numerals (see bug - 248312)
UnaryExpression unaryExpression = (UnaryExpression) expression;
if ((unaryExpression.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT == OperatorIds.MINUS) {
if (unaryExpression.expression instanceof Literal) {
Literal subExpression = (Literal) unaryExpression.expression;
subExpression.computeConstant();
return Util.getNegativeAnnotationMemberValue(memberValuePair, subExpression.constant);
}
}
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
} else {
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:61,代码来源:CompilationUnitStructureRequestor.java