Java 类org.eclipse.jdt.internal.compiler.ast.SingleTypeReference 实例源码

项目:lombok-ianchiu    文件:HandleEqualsAndHashCode.java   
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);
}
项目:EasyMPermission    文件:HandleEqualsAndHashCode.java   
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);
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.SingleTypeReference, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(
    SingleTypeReference singleTypeReference,
    BlockScope scope) {

    final int numberOfParens = (singleTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
        manageOpeningParenthesizedExpression(singleTypeReference, numberOfParens);
    }
    if (singleTypeReference.annotations != null) {
        formatInlineAnnotations(singleTypeReference.annotations[0], false);
    }
    this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);

    if (numberOfParens > 0) {
        manageClosingParenthesizedExpression(singleTypeReference, numberOfParens);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.SingleTypeReference, org.eclipse.jdt.internal.compiler.lookup.ClassScope)
 */
public boolean visit(
    SingleTypeReference singleTypeReference,
    ClassScope scope) {

    final int numberOfParens = (singleTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
        manageOpeningParenthesizedExpression(singleTypeReference, numberOfParens);
    }
    if (singleTypeReference.annotations != null) {
        formatInlineAnnotations(singleTypeReference.annotations[0], false);
    }
    this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);

    if (numberOfParens > 0) {
        manageClosingParenthesizedExpression(singleTypeReference, numberOfParens);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:ASTConverter.java   
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);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
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);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.SingleTypeReference, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(
    SingleTypeReference singleTypeReference,
    BlockScope scope) {

    final int numberOfParens = (singleTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
        manageOpeningParenthesizedExpression(singleTypeReference, numberOfParens);
    }
    this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);

    if (numberOfParens > 0) {
        manageClosingParenthesizedExpression(singleTypeReference, numberOfParens);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.SingleTypeReference, org.eclipse.jdt.internal.compiler.lookup.ClassScope)
 */
public boolean visit(
    SingleTypeReference singleTypeReference,
    ClassScope scope) {

    final int numberOfParens = (singleTypeReference.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
        manageOpeningParenthesizedExpression(singleTypeReference, numberOfParens);
    }
    this.scribe.printNextToken(SINGLETYPEREFERENCE_EXPECTEDTOKENS);

    if (numberOfParens > 0) {
        manageClosingParenthesizedExpression(singleTypeReference, numberOfParens);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTConverter.java   
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);
        }
    }
}
项目:lombok    文件:HandleEqualsAndHashCode.java   
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);
}
项目:lombok-ianchiu    文件:PatchVal.java   
public static boolean couldBeVal(TypeReference ref) {
    if (ref instanceof SingleTypeReference) {
        char[] token = ((SingleTypeReference)ref).token;
        return matches("val", token);
    }

    if (ref instanceof QualifiedTypeReference) {
        char[][] tokens = ((QualifiedTypeReference)ref).tokens;
        if (tokens == null || tokens.length != 2) return false;
        return matches("lombok", tokens[0]) && matches("val", tokens[1]);
    }

    return false;
}
项目:lombok-ianchiu    文件:HandleLog.java   
public static ClassLiteralAccess selfType(EclipseNode type, Annotation source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    TypeDeclaration typeDeclaration = (TypeDeclaration)type.get();
    TypeReference typeReference = new SingleTypeReference(typeDeclaration.name, p);
    setGeneratedBy(typeReference, source);

    ClassLiteralAccess result = new ClassLiteralAccess(source.sourceEnd, typeReference);
    setGeneratedBy(result, source);

    return result;
}
项目:lombok-ianchiu    文件:EclipseHandlerUtil.java   
public static TypeReference namePlusTypeParamsToTypeReference(char[] typeName, TypeParameter[] params, long p) {
    if (params != null && params.length > 0) {
        TypeReference[] refs = new TypeReference[params.length];
        int idx = 0;
        for (TypeParameter param : params) {
            TypeReference typeRef = new SingleTypeReference(param.name, p);
            refs[idx++] = typeRef;
        }
        return new ParameterizedSingleTypeReference(typeName, refs, 0, p);
    }

    return new SingleTypeReference(typeName, p);
}
项目:EasyMPermission    文件:PatchVal.java   
public static boolean couldBeVal(TypeReference ref) {
    if (ref instanceof SingleTypeReference) {
        char[] token = ((SingleTypeReference)ref).token;
        return matches("val", token);
    }

    if (ref instanceof QualifiedTypeReference) {
        char[][] tokens = ((QualifiedTypeReference)ref).tokens;
        if (tokens == null || tokens.length != 2) return false;
        return matches("lombok", tokens[0]) && matches("val", tokens[1]);
    }

    return false;
}
项目:EasyMPermission    文件:HandleLog.java   
public static ClassLiteralAccess selfType(EclipseNode type, Annotation source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    TypeDeclaration typeDeclaration = (TypeDeclaration)type.get();
    TypeReference typeReference = new SingleTypeReference(typeDeclaration.name, p);
    setGeneratedBy(typeReference, source);

    ClassLiteralAccess result = new ClassLiteralAccess(source.sourceEnd, typeReference);
    setGeneratedBy(result, source);

    return result;
}
项目:EasyMPermission    文件:EclipseHandlerUtil.java   
public static TypeReference namePlusTypeParamsToTypeReference(char[] typeName, TypeParameter[] params, long p) {
    if (params != null && params.length > 0) {
        TypeReference[] refs = new TypeReference[params.length];
        int idx = 0;
        for (TypeParameter param : params) {
            TypeReference typeRef = new SingleTypeReference(param.name, p);
            refs[idx++] = typeRef;
        }
        return new ParameterizedSingleTypeReference(typeName, refs, 0, p);
    }

    return new SingleTypeReference(typeName, p);
}
项目:lombok    文件:PatchVal.java   
public static boolean couldBeVal(TypeReference ref) {
    if (ref instanceof SingleTypeReference) {
        char[] token = ((SingleTypeReference)ref).token;
        return matches("val", token);
    }

    if (ref instanceof QualifiedTypeReference) {
        char[][] tokens = ((QualifiedTypeReference)ref).tokens;
        if (tokens == null || tokens.length != 2) return false;
        return matches("lombok", tokens[0]) && matches("val", tokens[1]);
    }

    return false;
}
项目:lombok    文件:HandleLog.java   
private static ClassLiteralAccess selfType(EclipseNode type, Annotation source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    TypeDeclaration typeDeclaration = (TypeDeclaration)type.get();
    TypeReference typeReference = new SingleTypeReference(typeDeclaration.name, p);
    setGeneratedBy(typeReference, source);

    ClassLiteralAccess result = new ClassLiteralAccess(source.sourceEnd, typeReference);
    setGeneratedBy(result, source);

    return result;
}
项目:lombok    文件:EclipseHandlerUtil.java   
private static TypeReference createTypeReference(String type, long p) {
    String[] list = type.split("\\.");
    if (list.length == 1) return new SingleTypeReference(list[0].toCharArray(), p);
    long[] ps = new long[list.length];
    char[][] tokens = new char[list.length][];
    for (int i = 0; i < list.length; i++) {
        ps[i] = p;
        tokens[i] = list[i].toCharArray();
    }

    return new QualifiedTypeReference(tokens, ps);
}
项目:lombok    文件:HandleRelations.java   
private static TypeReference createTypeReference(String[] parts, long p) {
    if (parts.length == 1) return new SingleTypeReference(parts[0].toCharArray(), p);

    long[] ps = new long[parts.length];
    char[][] tokens = new char[parts.length][];
    for (int i = 0; i < parts.length; i++) {
        ps[i] = p;
        tokens[i] = parts[i].toCharArray();
    }

    return new QualifiedTypeReference(tokens, ps);
}
项目:lombok-ianchiu    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(SingleTypeReference node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:lombok-ianchiu    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(SingleTypeReference node, ClassScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:EasyMPermission    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(SingleTypeReference node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:EasyMPermission    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(SingleTypeReference node, ClassScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:lombok    文件:HandleConstructor.java   
private MethodDeclaration createStaticConstructor(AccessLevel level, String name, EclipseNode type, Collection<EclipseNode> fields, ASTNode source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    long p = (long)pS << 32 | pE;

    MethodDeclaration constructor = new MethodDeclaration(
            ((CompilationUnitDeclaration) type.top().get()).compilationResult);

    constructor.modifiers = toEclipseModifier(level) | Modifier.STATIC;
    TypeDeclaration typeDecl = (TypeDeclaration) type.get();
    if (typeDecl.typeParameters != null && typeDecl.typeParameters.length > 0) {
        TypeReference[] refs = new TypeReference[typeDecl.typeParameters.length];
        int idx = 0;
        for (TypeParameter param : typeDecl.typeParameters) {
            TypeReference typeRef = new SingleTypeReference(param.name, (long)param.sourceStart << 32 | param.sourceEnd);
            setGeneratedBy(typeRef, source);
            refs[idx++] = typeRef;
        }
        constructor.returnType = new ParameterizedSingleTypeReference(typeDecl.name, refs, 0, p);
    } else constructor.returnType = new SingleTypeReference(((TypeDeclaration)type.get()).name, p);
    constructor.annotations = null;
    constructor.selector = name.toCharArray();
    constructor.thrownExceptions = null;
    constructor.typeParameters = copyTypeParams(((TypeDeclaration)type.get()).typeParameters, source);
    constructor.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    constructor.bodyStart = constructor.declarationSourceStart = constructor.sourceStart = source.sourceStart;
    constructor.bodyEnd = constructor.declarationSourceEnd = constructor.sourceEnd = source.sourceEnd;

    List<Argument> params = new ArrayList<Argument>();
    List<Expression> assigns = new ArrayList<Expression>();
    AllocationExpression statement = new AllocationExpression();
    statement.sourceStart = pS; statement.sourceEnd = pE;
    statement.type = copyType(constructor.returnType, source);

    for (EclipseNode fieldNode : fields) {
        FieldDeclaration field = (FieldDeclaration) fieldNode.get();
        long fieldPos = (((long)field.sourceStart) << 32) | field.sourceEnd;
        SingleNameReference nameRef = new SingleNameReference(field.name, fieldPos);
        assigns.add(nameRef);

        Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL);

        Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN), findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN));
        if (copiedAnnotations.length != 0) parameter.annotations = copiedAnnotations;
        params.add(parameter);
    }

    statement.arguments = assigns.isEmpty() ? null : assigns.toArray(new Expression[assigns.size()]);
    constructor.arguments = params.isEmpty() ? null : params.toArray(new Argument[params.size()]);
    constructor.statements = new Statement[] { new ReturnStatement(statement, (int)(p >> 32), (int)p) };

    constructor.traverse(new SetGeneratedByVisitor(source), typeDecl.scope);
    return constructor;
}
项目:lombok    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(SingleTypeReference node, BlockScope scope) {
    setGeneratedBy(node, source);
    applyOffsetExpression(node);
    return super.visit(node, scope);
}
项目:lombok    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(SingleTypeReference node, ClassScope scope) {
    setGeneratedBy(node, source);
    applyOffsetExpression(node);
    return super.visit(node, scope);
}