本文整理汇总了Java中org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference类的典型用法代码示例。如果您正苦于以下问题:Java QualifiedTypeReference类的具体用法?Java QualifiedTypeReference怎么用?Java QualifiedTypeReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QualifiedTypeReference类属于org.eclipse.jdt.internal.compiler.ast包,在下文中一共展示了QualifiedTypeReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleValForForEach
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
public static boolean handleValForForEach(ForeachStatement forEach, BlockScope scope) {
if (forEach.elementVariable == null) return false;
if (!isVal(forEach.elementVariable.type, scope)) return false;
TypeBinding component = getForEachComponentType(forEach.collection, scope);
if (component == null) return false;
TypeReference replacement = makeType(component, forEach.elementVariable.type, false);
forEach.elementVariable.modifiers |= ClassFileConstants.AccFinal;
forEach.elementVariable.annotations = addValAnnotation(forEach.elementVariable.annotations, forEach.elementVariable.type, scope);
forEach.elementVariable.type = replacement != null ? replacement :
new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, poss(forEach.elementVariable.type, 3));
return false;
}
示例2: generateDeprecatedAnnotation
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
public static MarkerAnnotation generateDeprecatedAnnotation(ASTNode source) {
QualifiedTypeReference qtr = new QualifiedTypeReference(new char[][] {
{'j', 'a', 'v', 'a'}, {'l', 'a', 'n', 'g'}, {'D', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd'}}, poss(source, 3));
setGeneratedBy(qtr, source);
MarkerAnnotation ma = new MarkerAnnotation(qtr, source.sourceStart);
// No matter what value you input for sourceEnd, the AST->DOM converter of eclipse will reparse to find the end, and will fail as
// it can't find code that isn't really there. This results in the end position being set to 2 or 0 or some weird magic value, and thus,
// length, as calculated by end-start, is all screwed up, resulting in IllegalArgumentException during a setSourceRange call MUCH later in the process.
// We solve it by going with a voodoo magic source start value such that the calculated length so happens to exactly be 0. 0 lengths are accepted
// by eclipse. For some reason.
// TL;DR: Don't change 1. 1 is sacred. Trust the 1.
// issue: #408.
ma.sourceStart = 1;
setGeneratedBy(ma, source);
return ma;
}
示例3: createTypeReference
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
public TypeReference createTypeReference(EclipseNode type, long p) {
List<String> list = new ArrayList<String>();
list.add(type.getName());
EclipseNode tNode = type.up();
while (tNode != null && tNode.getKind() == Kind.TYPE) {
list.add(tNode.getName());
tNode = tNode.up();
}
Collections.reverse(list);
if (list.size() == 1) return new SingleTypeReference(list.get(0).toCharArray(), p);
long[] ps = new long[list.size()];
char[][] tokens = new char[list.size()][];
for (int i = 0; i < list.size(); i++) {
ps[i] = p;
tokens[i] = list.get(i).toCharArray();
}
return new QualifiedTypeReference(tokens, ps);
}
示例4: cloneParamType
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
protected TypeReference cloneParamType(int index, List<TypeReference> typeArgs, EclipseNode builderType) {
if (typeArgs != null && typeArgs.size() > index) {
TypeReference originalType = typeArgs.get(index);
if (originalType instanceof Wildcard) {
Wildcard wOriginalType = (Wildcard) originalType;
if (wOriginalType.kind == Wildcard.EXTENDS) {
try {
return copyType(wOriginalType.bound);
} catch (Exception e) {
// fallthrough
}
}
} else {
return copyType(originalType);
}
}
return new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, NULL_POSS);
}
示例5: generateFields
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
@Override public List<EclipseNode> generateFields(SingularData data, EclipseNode builderType) {
if (useGuavaInstead(builderType)) {
return guavaListSetSingularizer.generateFields(data, builderType);
}
TypeReference type = new QualifiedTypeReference(JAVA_UTIL_ARRAYLIST, NULL_POSS);
type = addTypeArgs(1, false, builderType, type, data.getTypeArgs());
FieldDeclaration buildField = new FieldDeclaration(data.getPluralName(), 0, -1);
buildField.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
buildField.modifiers = ClassFileConstants.AccPrivate;
buildField.declarationSourceEnd = -1;
buildField.type = type;
data.setGeneratedByRecursive(buildField);
return Collections.singletonList(injectFieldAndMarkGenerated(builderType, buildField));
}
示例6: visit
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
/**
* @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference, org.eclipse.jdt.internal.compiler.lookup.ClassScope)
*/
public boolean visit(
QualifiedTypeReference qualifiedTypeReference,
ClassScope scope) {
final int numberOfParens = (qualifiedTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
if (numberOfParens > 0) {
manageOpeningParenthesizedExpression(qualifiedTypeReference, numberOfParens);
}
formatQualifiedTypeReference(qualifiedTypeReference);
if (numberOfParens > 0) {
manageClosingParenthesizedExpression(qualifiedTypeReference, numberOfParens);
}
return false;
}
示例7: convert
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
public Name convert(org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference) {
char[][] typeName = typeReference.getTypeName();
int length = typeName.length;
if (length > 1) {
// QualifiedName
org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference qualifiedTypeReference = (org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference) typeReference;
final long[] positions = qualifiedTypeReference.sourcePositions;
return setQualifiedNameNameAndSourceRanges(typeName, positions, typeReference);
} else {
final SimpleName name = new SimpleName(this.ast);
name.internalSetIdentifier(new String(typeName[0]));
name.setSourceRange(typeReference.sourceStart, typeReference.sourceEnd - typeReference.sourceStart + 1);
name.index = 1;
if (this.resolveBindings) {
recordNodes(name, typeReference);
}
return name;
}
}
示例8: setTypeNameForAnnotation
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
protected void setTypeNameForAnnotation(org.eclipse.jdt.internal.compiler.ast.Annotation compilerAnnotation, Annotation annotation) {
TypeReference typeReference = compilerAnnotation.type;
if (typeReference instanceof QualifiedTypeReference) {
QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) typeReference;
char[][] tokens = qualifiedTypeReference.tokens;
long[] positions = qualifiedTypeReference.sourcePositions;
// QualifiedName
annotation.setTypeName(setQualifiedNameNameAndSourceRanges(tokens, positions, typeReference));
} else {
SingleTypeReference singleTypeReference = (SingleTypeReference) typeReference;
final SimpleName name = new SimpleName(this.ast);
name.internalSetIdentifier(new String(singleTypeReference.token));
int start = singleTypeReference.sourceStart;
int end = singleTypeReference.sourceEnd;
name.setSourceRange(start, end - start + 1);
name.index = 1;
annotation.setTypeName(name);
if (this.resolveBindings) {
recordNodes(name, typeReference);
}
}
}
示例9: getAnnotationType
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
protected TypeReference getAnnotationType() {
int length = this.identifierLengthStack[this.identifierLengthPtr--];
if (length == 1) {
return new SingleTypeReference(
this.identifierStack[this.identifierPtr],
this.identifierPositionStack[this.identifierPtr--]);
} else {
char[][] tokens = new char[length][];
this.identifierPtr -= length;
long[] positions = new long[length];
System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
System.arraycopy(
this.identifierPositionStack,
this.identifierPtr + 1,
positions,
0,
length);
return new QualifiedTypeReference(tokens, positions);
}
}
示例10: deprecatedType
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
public void deprecatedType(TypeBinding type, ASTNode location, int index) {
if (location == null) return; // 1G828DN - no type ref for synthetic arguments
int severity = computeSeverity(IProblem.UsingDeprecatedType);
if (severity == ProblemSeverities.Ignore) return;
type = type.leafComponentType();
int sourceStart = -1;
if (location instanceof QualifiedTypeReference) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=300031
QualifiedTypeReference ref = (QualifiedTypeReference) location;
if (index < Integer.MAX_VALUE) {
sourceStart = (int) (ref.sourcePositions[index] >> 32);
}
}
this.handle(
IProblem.UsingDeprecatedType,
new String[] {new String(type.readableName())},
new String[] {new String(type.shortReadableName())},
severity,
(sourceStart == -1) ? location.sourceStart : sourceStart,
nodeSourceEnd(null, location, index));
}
示例11: redundantSpecificationOfTypeArguments
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
public void redundantSpecificationOfTypeArguments(ASTNode location, TypeBinding[] argumentTypes) {
int severity = computeSeverity(IProblem.RedundantSpecificationOfTypeArguments);
if (severity != ProblemSeverities.Ignore) {
int sourceStart = -1;
if (location instanceof QualifiedTypeReference) {
QualifiedTypeReference ref = (QualifiedTypeReference)location;
sourceStart = (int) (ref.sourcePositions[ref.sourcePositions.length - 1] >> 32);
} else {
sourceStart = location.sourceStart;
}
this.handle(
IProblem.RedundantSpecificationOfTypeArguments,
new String[] {typesAsString(argumentTypes, false)},
new String[] {typesAsString(argumentTypes, true)},
severity,
sourceStart,
location.sourceEnd);
}
}
示例12: visit
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
/**
* @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
*/
public boolean visit(
QualifiedTypeReference qualifiedTypeReference,
BlockScope scope) {
final int numberOfParens = (qualifiedTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
if (numberOfParens > 0) {
manageOpeningParenthesizedExpression(qualifiedTypeReference, numberOfParens);
}
this.scribe.printQualifiedReference(qualifiedTypeReference.sourceEnd, numberOfParens>=0/*expect parenthesis*/);
if (numberOfParens > 0) {
manageClosingParenthesizedExpression(qualifiedTypeReference, numberOfParens);
}
return false;
}
示例13: createSuppressWarningsAll
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
public static Annotation[] createSuppressWarningsAll(ASTNode source, Annotation[] originalAnnotationArray) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long)pS << 32 | pE;
long[] poss = new long[3];
Arrays.fill(poss, p);
QualifiedTypeReference suppressWarningsType = new QualifiedTypeReference(TypeConstants.JAVA_LANG_SUPPRESSWARNINGS, poss);
setGeneratedBy(suppressWarningsType, source);
SingleMemberAnnotation ann = new SingleMemberAnnotation(suppressWarningsType, pS);
ann.declarationSourceEnd = pE;
ann.memberValue = new StringLiteral(ALL, pS, pE, 0);
setGeneratedBy(ann, source);
setGeneratedBy(ann.memberValue, source);
if (originalAnnotationArray == null) return new Annotation[] { ann };
Annotation[] newAnnotationArray = new Annotation[originalAnnotationArray.length + 1];
System.arraycopy(originalAnnotationArray, 0, newAnnotationArray, 0, originalAnnotationArray.length);
newAnnotationArray[originalAnnotationArray.length] = ann;
return newAnnotationArray;
}
示例14: generateNullCheck
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
/**
* Generates a new statement that checks if the given variable is null, and if so, throws a {@code NullPointerException} with the
* variable name as message.
*/
public static Statement generateNullCheck(AbstractVariableDeclaration variable, ASTNode source) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long)pS << 32 | pE;
if (isPrimitive(variable.type)) return null;
AllocationExpression exception = new AllocationExpression();
setGeneratedBy(exception, source);
exception.type = new QualifiedTypeReference(fromQualifiedName("java.lang.NullPointerException"), new long[]{p, p, p});
setGeneratedBy(exception.type, source);
exception.arguments = new Expression[] { new StringLiteral(variable.name, pS, pE, 0)};
setGeneratedBy(exception.arguments[0], source);
ThrowStatement throwStatement = new ThrowStatement(exception, pS, pE);
setGeneratedBy(throwStatement, source);
SingleNameReference varName = new SingleNameReference(variable.name, p);
setGeneratedBy(varName, source);
NullLiteral nullLiteral = new NullLiteral(pS, pE);
setGeneratedBy(nullLiteral, source);
EqualExpression equalExpression = new EqualExpression(varName, nullLiteral, OperatorIds.EQUAL_EQUAL);
equalExpression.sourceStart = pS; equalExpression.statementEnd = equalExpression.sourceEnd = pE;
setGeneratedBy(equalExpression, source);
IfStatement ifStatement = new IfStatement(equalExpression, throwStatement, 0, 0);
setGeneratedBy(ifStatement, source);
return ifStatement;
}
示例15: createTypeReference
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; //导入依赖的package包/类
private TypeReference createTypeReference(EclipseNode type, long p) {
List<String> list = new ArrayList<String>();
list.add(type.getName());
EclipseNode tNode = type.up();
while (tNode != null && tNode.getKind() == Kind.TYPE) {
list.add(tNode.getName());
tNode = tNode.up();
}
Collections.reverse(list);
if (list.size() == 1) return new SingleTypeReference(list.get(0).toCharArray(), p);
long[] ps = new long[list.size()];
char[][] tokens = new char[list.size()][];
for (int i = 0; i < list.size(); i++) {
ps[i] = p;
tokens[i] = list.get(i).toCharArray();
}
return new QualifiedTypeReference(tokens, ps);
}