本文整理汇总了Java中org.eclipse.jdt.core.IMemberValuePair.K_QUALIFIED_NAME属性的典型用法代码示例。如果您正苦于以下问题:Java IMemberValuePair.K_QUALIFIED_NAME属性的具体用法?Java IMemberValuePair.K_QUALIFIED_NAME怎么用?Java IMemberValuePair.K_QUALIFIED_NAME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.IMemberValuePair
的用法示例。
在下文中一共展示了IMemberValuePair.K_QUALIFIED_NAME属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: appendAnnotationValue
private void appendAnnotationValue(IAnnotation annotation, Object value, int valueKind, long flags) throws JavaModelException {
// Note: To be bug-compatible with Javadoc from Java 5/6/7, we currently don't escape HTML tags in String-valued annotations.
if (value instanceof Object[]) {
fBuilder.append('{');
Object[] values= (Object[]) value;
for (int j= 0; j < values.length; j++) {
if (j > 0) {
fBuilder.append(JavaElementLabels.COMMA_STRING);
}
value= values[j];
appendAnnotationValue(annotation, value, valueKind, flags);
}
fBuilder.append('}');
} else {
switch (valueKind) {
case IMemberValuePair.K_CLASS:
appendTypeSignatureLabel(annotation, Signature.createTypeSignature((String) value, false), flags);
fBuilder.append(".class"); //$NON-NLS-1$
break;
case IMemberValuePair.K_QUALIFIED_NAME:
String name = (String) value;
int lastDot= name.lastIndexOf('.');
if (lastDot != -1) {
String type= name.substring(0, lastDot);
String field= name.substring(lastDot + 1);
appendTypeSignatureLabel(annotation, Signature.createTypeSignature(type, false), flags);
fBuilder.append('.');
fBuilder.append(getMemberName(annotation, type, field));
break;
}
// case IMemberValuePair.K_SIMPLE_NAME: // can't implement, since parent type is not known
//$FALL-THROUGH$
case IMemberValuePair.K_ANNOTATION:
appendAnnotationLabel((IAnnotation) value, flags);
break;
case IMemberValuePair.K_STRING:
fBuilder.append(ASTNodes.getEscapedStringLiteral((String) value));
break;
case IMemberValuePair.K_CHAR:
fBuilder.append(ASTNodes.getEscapedCharacterLiteral(((Character) value).charValue()));
break;
default:
fBuilder.append(String.valueOf(value));
break;
}
}
}
示例3: appendAnnotationValue
private void appendAnnotationValue(
IAnnotation annotation, Object value, int valueKind, long flags, StringBuilder builder)
throws JavaModelException {
// Note: To be bug-compatible with Javadoc from Java 5/6/7, we currently don't escape HTML tags
// in String-valued annotations.
if (value instanceof Object[]) {
builder.append('{');
Object[] values = (Object[]) value;
for (int j = 0; j < values.length; j++) {
if (j > 0) builder.append(JavaElementLabels.COMMA_STRING);
value = values[j];
appendAnnotationValue(annotation, value, valueKind, flags, builder);
}
builder.append('}');
} else {
switch (valueKind) {
case IMemberValuePair.K_CLASS:
appendTypeSignatureLabel(
annotation, Signature.createTypeSignature((String) value, false), flags, builder);
builder.append(".class"); // $NON-NLS-1$
break;
case IMemberValuePair.K_QUALIFIED_NAME:
String name = (String) value;
int lastDot = name.lastIndexOf('.');
if (lastDot != -1) {
String type = name.substring(0, lastDot);
String field = name.substring(lastDot + 1);
appendTypeSignatureLabel(
annotation, Signature.createTypeSignature(type, false), flags, builder);
builder.append('.');
builder.append(getMemberName(annotation, type, field));
break;
}
// case IMemberValuePair.K_SIMPLE_NAME: // can't implement, since parent type is not
// known
// $FALL-THROUGH$
case IMemberValuePair.K_ANNOTATION:
appendAnnotationLabel((IAnnotation) value, flags, builder);
break;
case IMemberValuePair.K_STRING:
builder.append(ASTNodes.getEscapedStringLiteral((String) value));
break;
case IMemberValuePair.K_CHAR:
builder.append(ASTNodes.getEscapedCharacterLiteral(((Character) value).charValue()));
break;
default:
builder.append(String.valueOf(value));
break;
}
}
}
示例4: appendAnnotationValue
private void appendAnnotationValue(
IAnnotation annotation, Object value, int valueKind, long flags) throws JavaModelException {
// Note: To be bug-compatible with Javadoc from Java 5/6/7, we currently don't escape HTML tags
// in String-valued annotations.
if (value instanceof Object[]) {
fBuffer.append('{');
Object[] values = (Object[]) value;
for (int j = 0; j < values.length; j++) {
if (j > 0) fBuffer.append(JavaElementLabels.COMMA_STRING);
value = values[j];
appendAnnotationValue(annotation, value, valueKind, flags);
}
fBuffer.append('}');
} else {
switch (valueKind) {
case IMemberValuePair.K_CLASS:
appendTypeSignatureLabel(
annotation, Signature.createTypeSignature((String) value, false), flags);
fBuffer.append(".class"); // $NON-NLS-1$
break;
case IMemberValuePair.K_QUALIFIED_NAME:
String name = (String) value;
int lastDot = name.lastIndexOf('.');
if (lastDot != -1) {
String type = name.substring(0, lastDot);
String field = name.substring(lastDot + 1);
appendTypeSignatureLabel(annotation, Signature.createTypeSignature(type, false), flags);
fBuffer.append('.');
fBuffer.append(getMemberName(annotation, type, field));
break;
}
// case IMemberValuePair.K_SIMPLE_NAME: // can't implement, since parent type is not
// known
// $FALL-THROUGH$
case IMemberValuePair.K_ANNOTATION:
appendAnnotationLabel((IAnnotation) value, flags);
break;
case IMemberValuePair.K_STRING:
fBuffer.append(ASTNodes.getEscapedStringLiteral((String) value));
break;
case IMemberValuePair.K_CHAR:
fBuffer.append(ASTNodes.getEscapedCharacterLiteral(((Character) value).charValue()));
break;
default:
fBuffer.append(String.valueOf(value));
break;
}
}
}
示例5: getAnnotationMemberValue
public static Object getAnnotationMemberValue(
JavaElement parent, MemberValuePair memberValuePair, Object binaryValue) {
if (binaryValue instanceof Constant) {
return getAnnotationMemberValue(memberValuePair, (Constant) binaryValue);
} else if (binaryValue instanceof IBinaryAnnotation) {
memberValuePair.valueKind = IMemberValuePair.K_ANNOTATION;
return getAnnotation(
parent, (IBinaryAnnotation) binaryValue, memberValuePair.getMemberName());
} else if (binaryValue instanceof ClassSignature) {
memberValuePair.valueKind = IMemberValuePair.K_CLASS;
char[] className =
Signature.toCharArray(
CharOperation.replaceOnCopy(((ClassSignature) binaryValue).getTypeName(), '/', '.'));
return new String(className);
} else if (binaryValue instanceof EnumConstantSignature) {
memberValuePair.valueKind = IMemberValuePair.K_QUALIFIED_NAME;
EnumConstantSignature enumConstant = (EnumConstantSignature) binaryValue;
char[] enumName =
Signature.toCharArray(CharOperation.replaceOnCopy(enumConstant.getTypeName(), '/', '.'));
char[] qualifiedName =
CharOperation.concat(enumName, enumConstant.getEnumConstantName(), '.');
return new String(qualifiedName);
} else if (binaryValue instanceof Object[]) {
memberValuePair.valueKind = -1; // modified below by the first call to getMemberValue(...)
Object[] binaryValues = (Object[]) binaryValue;
int length = binaryValues.length;
Object[] values = new Object[length];
for (int i = 0; i < length; i++) {
int previousValueKind = memberValuePair.valueKind;
Object value = getAnnotationMemberValue(parent, memberValuePair, binaryValues[i]);
if (previousValueKind != -1 && memberValuePair.valueKind != previousValueKind) {
// values are heterogeneous, value kind is thus unknown
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
}
if (value instanceof Annotation) {
Annotation annotation = (Annotation) value;
for (int j = 0; j < i; j++) {
if (annotation.equals(values[j])) {
annotation.occurrenceCount++;
}
}
}
values[i] = value;
}
if (memberValuePair.valueKind == -1) memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return values;
} else {
memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
return null;
}
}
示例6: appendAnnotationValue
private void appendAnnotationValue(IAnnotation annotation, Object value, int valueKind, long flags) throws JavaModelException {
// Note: To be bug-compatible with Javadoc from Java 5/6/7, we currently don't escape HTML tags in String-valued annotations.
if (value instanceof Object[]) {
fBuffer.append('{');
Object[] values= (Object[]) value;
for (int j= 0; j < values.length; j++) {
if (j > 0)
fBuffer.append(COMMA_STRING);
value= values[j];
appendAnnotationValue(annotation, value, valueKind, flags);
}
fBuffer.append('}');
} else {
switch (valueKind) {
case IMemberValuePair.K_CLASS:
appendTypeSignatureLabel(annotation, Signature.createTypeSignature((String) value, false), flags);
fBuffer.append(".class"); //$NON-NLS-1$
break;
case IMemberValuePair.K_QUALIFIED_NAME:
String name = (String) value;
int lastDot= name.lastIndexOf('.');
if (lastDot != -1) {
String type= name.substring(0, lastDot);
String field= name.substring(lastDot + 1);
appendTypeSignatureLabel(annotation, Signature.createTypeSignature(type, false), flags);
fBuffer.append('.');
fBuffer.append(getMemberName(annotation, type, field));
break;
}
// case IMemberValuePair.K_SIMPLE_NAME: // can't implement, since parent type is not known
//$FALL-THROUGH$
case IMemberValuePair.K_ANNOTATION:
appendAnnotationLabel((IAnnotation) value, flags);
break;
case IMemberValuePair.K_STRING:
fBuffer.append(getEscapedStringLiteral((String) value));
break;
case IMemberValuePair.K_CHAR:
fBuffer.append(getEscapedCharacterLiteral(((Character) value).charValue()));
break;
default:
fBuffer.append(String.valueOf(value));
break;
}
}
}
示例7: appendAnnotationValue
private void appendAnnotationValue(IAnnotation annotation, Object value, int valueKind, long flags) throws JavaModelException {
// Note: To be bug-compatible with Javadoc from Java 5/6/7, we currently don't escape HTML tags in String-valued annotations.
if (value instanceof Object[]) {
fBuffer.append('{');
Object[] values= (Object[]) value;
for (int j= 0; j < values.length; j++) {
if (j > 0)
fBuffer.append(JavaElementLabels.COMMA_STRING);
value= values[j];
appendAnnotationValue(annotation, value, valueKind, flags);
}
fBuffer.append('}');
} else {
switch (valueKind) {
case IMemberValuePair.K_CLASS:
appendTypeSignatureLabel(annotation, Signature.createTypeSignature((String) value, false), flags);
fBuffer.append(".class"); //$NON-NLS-1$
break;
case IMemberValuePair.K_QUALIFIED_NAME:
String name = (String) value;
int lastDot= name.lastIndexOf('.');
if (lastDot != -1) {
String type= name.substring(0, lastDot);
String field= name.substring(lastDot + 1);
appendTypeSignatureLabel(annotation, Signature.createTypeSignature(type, false), flags);
fBuffer.append('.');
fBuffer.append(getMemberName(annotation, type, field));
break;
}
// case IMemberValuePair.K_SIMPLE_NAME: // can't implement, since parent type is not known
//$FALL-THROUGH$
case IMemberValuePair.K_ANNOTATION:
appendAnnotationLabel((IAnnotation) value, flags);
break;
case IMemberValuePair.K_STRING:
fBuffer.append(ASTNodes.getEscapedStringLiteral((String) value));
break;
case IMemberValuePair.K_CHAR:
fBuffer.append(ASTNodes.getEscapedCharacterLiteral(((Character) value).charValue()));
break;
default:
fBuffer.append(String.valueOf(value));
break;
}
}
}
示例8: 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