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

项目:lombok-ianchiu    文件:Eclipse.java   
/**
 * Searches the given field node for annotations and returns each one that matches the provided regular expression pattern.
 * 
 * Only the simple name is checked - the package and any containing class are ignored.
 */
public static Annotation[] findAnnotations(FieldDeclaration field, Pattern namePattern) {
    List<Annotation> result = new ArrayList<Annotation>();
    if (field.annotations == null) return EMPTY_ANNOTATIONS_ARRAY;
    for (Annotation annotation : field.annotations) {
        TypeReference typeRef = annotation.type;
        if (typeRef != null && typeRef.getTypeName() != null) {
            char[][] typeName = typeRef.getTypeName();
            String suspect = new String(typeName[typeName.length - 1]);
            if (namePattern.matcher(suspect).matches()) {
                result.add(annotation);
            }
        }
    }   
    return result.toArray(EMPTY_ANNOTATIONS_ARRAY);
}
项目:lombok-ianchiu    文件:PatchVal.java   
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;
}
项目:lombok-ianchiu    文件:HandlerLibrary.java   
/**
 * Handles the provided annotation node by first finding a qualifying instance of
 * {@link EclipseAnnotationHandler} and if one exists, calling it with a freshly cooked up
 * instance of {@link AnnotationValues}.
 * 
 * Note that depending on the printASTOnly flag, the {@link lombok.core.PrintAST} annotation
 * will either be silently skipped, or everything that isn't {@code PrintAST} will be skipped.
 * 
 * The HandlerLibrary will attempt to guess if the given annotation node represents a lombok annotation.
 * For example, if {@code lombok.*} is in the import list, then this method will guess that
 * {@code Getter} refers to {@code lombok.Getter}, presuming that {@link lombok.eclipse.handlers.HandleGetter}
 * has been loaded.
 * 
 * @param ast The Compilation Unit that contains the Annotation AST Node.
 * @param annotationNode The Lombok AST Node representing the Annotation AST Node.
 * @param annotation 'node.get()' - convenience parameter.
 */
public void handleAnnotation(CompilationUnitDeclaration ast, EclipseNode annotationNode, org.eclipse.jdt.internal.compiler.ast.Annotation annotation, long priority) {
    TypeResolver resolver = new TypeResolver(annotationNode.getImportList());
    TypeReference rawType = annotation.type;
    if (rawType == null) return;

    String fqn = resolver.typeRefToFullyQualifiedName(annotationNode, typeLibrary, toQualifiedName(annotation.type.getTypeName()));
    if (fqn == null) return;
    AnnotationHandlerContainer<?> container = annotationHandlers.get(fqn);
    if (container == null) return;
    if (priority != container.getPriority()) return;

    if (!annotationNode.isCompleteParse() && container.deferUntilPostDiet()) {
        if (needsHandling(annotation)) container.preHandle(annotation, annotationNode);
        return;
    }

    try {
        if (checkAndSetHandled(annotation)) container.handle(annotation, annotationNode);
    } catch (AnnotationValueDecodeFail fail) {
        fail.owner.setError(fail.getMessage(), fail.idx);
    } catch (Throwable t) {
        error(ast, String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);
    }
}
项目:lombok-ianchiu    文件:HandleBuilder.java   
private MethodDeclaration generateCleanMethod(List<BuilderFieldData> builderFields, EclipseNode builderType, ASTNode source) {
    List<Statement> statements = new ArrayList<Statement>();

    for (BuilderFieldData bfd : builderFields) {
        if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
            bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements);
        }
    }

    FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0);
    thisUnclean.receiver = new ThisReference(0, 0);
    statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0));
    MethodDeclaration decl = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
    decl.selector = CLEAN_METHOD_NAME;
    decl.modifiers = ClassFileConstants.AccPrivate;
    decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
    decl.statements = statements.toArray(new Statement[0]);
    decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
    return decl;
}
项目: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);
}
项目:lombok-ianchiu    文件:HandleEqualsAndHashCode.java   
/** Give 2 clones! */
public Expression longToIntForHashCode(Expression ref1, Expression ref2, ASTNode source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    /* (int)(ref >>> 32 ^ ref) */
    IntLiteral int32 = makeIntLiteral("32".toCharArray(), source);
    BinaryExpression higherBits = new BinaryExpression(ref1, int32, OperatorIds.UNSIGNED_RIGHT_SHIFT);
    setGeneratedBy(higherBits, source);
    BinaryExpression xorParts = new BinaryExpression(ref2, higherBits, OperatorIds.XOR);
    setGeneratedBy(xorParts, source);
    TypeReference intRef = TypeReference.baseTypeReference(TypeIds.T_int, 0);
    intRef.sourceStart = pS; intRef.sourceEnd = pE;
    setGeneratedBy(intRef, source);
    CastExpression expr = makeCastExpression(xorParts, intRef, source);
    expr.sourceStart = pS; expr.sourceEnd = pE;
    return expr;
}
项目:lombok-ianchiu    文件:EclipseSingularsRecipes.java   
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);
}
项目:lombok-ianchiu    文件:EclipseJavaUtilListSetSingularizer.java   
@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));
}
项目:lombok-ianchiu    文件:EclipseJavaUtilListSetSingularizer.java   
@Override public void generateMethods(SingularData data, EclipseNode builderType, boolean fluent, boolean chain) {
    if (useGuavaInstead(builderType)) {
        guavaListSetSingularizer.generateMethods(data, builderType, fluent, chain);
        return;
    }

    TypeReference returnType = chain ? cloneSelfType(builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
    Statement returnStatement = chain ? new ReturnStatement(new ThisReference(0, 0), 0, 0) : null;
    generateSingularMethod(returnType, returnStatement, data, builderType, fluent);

    returnType = chain ? cloneSelfType(builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
    returnStatement = chain ? new ReturnStatement(new ThisReference(0, 0), 0, 0) : null;
    generatePluralMethod(returnType, returnStatement, data, builderType, fluent);

    returnType = chain ? cloneSelfType(builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
    returnStatement = chain ? new ReturnStatement(new ThisReference(0, 0), 0, 0) : null;
    generateClearMethod(returnType, returnStatement, data, builderType);
}
项目:lombok-ianchiu    文件:EclipseJavaUtilListSetSingularizer.java   
private void generateClearMethod(TypeReference returnType, Statement returnStatement, SingularData data, EclipseNode builderType) {
    MethodDeclaration md = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
    md.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    md.modifiers = ClassFileConstants.AccPublic;

    FieldReference thisDotField = new FieldReference(data.getPluralName(), 0L);
    thisDotField.receiver = new ThisReference(0, 0);
    FieldReference thisDotField2 = new FieldReference(data.getPluralName(), 0L);
    thisDotField2.receiver = new ThisReference(0, 0);
    md.selector = HandlerUtil.buildAccessorName("clear", new String(data.getPluralName())).toCharArray();
    MessageSend clearMsg = new MessageSend();
    clearMsg.receiver = thisDotField2;
    clearMsg.selector = "clear".toCharArray();
    Statement clearStatement = new IfStatement(new EqualExpression(thisDotField, new NullLiteral(0, 0), OperatorIds.NOT_EQUAL), clearMsg, 0, 0);
    md.statements = returnStatement != null ? new Statement[] {clearStatement, returnStatement} : new Statement[] {clearStatement};
    md.returnType = returnType;
    injectMethod(builderType, md);
}
项目:lombok-ianchiu    文件:EclipseJavaUtilMapSingularizer.java   
@Override public void generateMethods(SingularData data, EclipseNode builderType, boolean fluent, boolean chain) {
    if (useGuavaInstead(builderType)) {
        guavaMapSingularizer.generateMethods(data, builderType, fluent, chain);
        return;
    }

    TypeReference returnType = chain ? cloneSelfType(builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
    Statement returnStatement = chain ? new ReturnStatement(new ThisReference(0, 0), 0, 0) : null;
    generateSingularMethod(returnType, returnStatement, data, builderType, fluent);

    returnType = chain ? cloneSelfType(builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
    returnStatement = chain ? new ReturnStatement(new ThisReference(0, 0), 0, 0) : null;
    generatePluralMethod(returnType, returnStatement, data, builderType, fluent);

    returnType = chain ? cloneSelfType(builderType) : TypeReference.baseTypeReference(TypeIds.T_void, 0);
    returnStatement = chain ? new ReturnStatement(new ThisReference(0, 0), 0, 0) : null;
    generateClearMethod(returnType, returnStatement, data, builderType);
}
项目:EasyMPermission    文件:Eclipse.java   
/**
 * Searches the given field node for annotations and returns each one that matches the provided regular expression pattern.
 * 
 * Only the simple name is checked - the package and any containing class are ignored.
 */
public static Annotation[] findAnnotations(FieldDeclaration field, Pattern namePattern) {
    List<Annotation> result = new ArrayList<Annotation>();
    if (field.annotations == null) return EMPTY_ANNOTATIONS_ARRAY;
    for (Annotation annotation : field.annotations) {
        TypeReference typeRef = annotation.type;
        if (typeRef != null && typeRef.getTypeName() != null) {
            char[][] typeName = typeRef.getTypeName();
            String suspect = new String(typeName[typeName.length - 1]);
            if (namePattern.matcher(suspect).matches()) {
                result.add(annotation);
            }
        }
    }   
    return result.toArray(EMPTY_ANNOTATIONS_ARRAY);
}
项目:EasyMPermission    文件:PatchVal.java   
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;
}
项目:EasyMPermission    文件:HandlerLibrary.java   
/**
 * Handles the provided annotation node by first finding a qualifying instance of
 * {@link EclipseAnnotationHandler} and if one exists, calling it with a freshly cooked up
 * instance of {@link AnnotationValues}.
 * 
 * Note that depending on the printASTOnly flag, the {@link lombok.core.PrintAST} annotation
 * will either be silently skipped, or everything that isn't {@code PrintAST} will be skipped.
 * 
 * The HandlerLibrary will attempt to guess if the given annotation node represents a lombok annotation.
 * For example, if {@code lombok.*} is in the import list, then this method will guess that
 * {@code Getter} refers to {@code lombok.Getter}, presuming that {@link lombok.eclipse.handlers.HandleGetter}
 * has been loaded.
 * 
 * @param ast The Compilation Unit that contains the Annotation AST Node.
 * @param annotationNode The Lombok AST Node representing the Annotation AST Node.
 * @param annotation 'node.get()' - convenience parameter.
 */
public void handleAnnotation(CompilationUnitDeclaration ast, EclipseNode annotationNode, org.eclipse.jdt.internal.compiler.ast.Annotation annotation, long priority) {
    TypeResolver resolver = new TypeResolver(annotationNode.getImportList());
    TypeReference rawType = annotation.type;
    if (rawType == null) return;

    String fqn = resolver.typeRefToFullyQualifiedName(annotationNode, typeLibrary, toQualifiedName(annotation.type.getTypeName()));
    if (fqn == null) return;
    AnnotationHandlerContainer<?> container = annotationHandlers.get(fqn);
    if (container == null) return;
    if (priority != container.getPriority()) return;

    if (!annotationNode.isCompleteParse() && container.deferUntilPostDiet()) {
        if (needsHandling(annotation)) container.preHandle(annotation, annotationNode);
        return;
    }

    try {
        if (checkAndSetHandled(annotation)) container.handle(annotation, annotationNode);
    } catch (AnnotationValueDecodeFail fail) {
        fail.owner.setError(fail.getMessage(), fail.idx);
    } catch (Throwable t) {
        error(ast, String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);
    }
}
项目:EasyMPermission    文件:HandleBuilder.java   
private MethodDeclaration generateCleanMethod(List<BuilderFieldData> builderFields, EclipseNode builderType, ASTNode source) {
    List<Statement> statements = new ArrayList<Statement>();

    for (BuilderFieldData bfd : builderFields) {
        if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) {
            bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements);
        }
    }

    FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0);
    thisUnclean.receiver = new ThisReference(0, 0);
    statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0));
    MethodDeclaration decl = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult);
    decl.selector = CLEAN_METHOD_NAME;
    decl.modifiers = ClassFileConstants.AccPrivate;
    decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG;
    decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
    decl.statements = statements.toArray(new Statement[0]);
    decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null);
    return decl;
}
项目: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);
}
项目:EasyMPermission    文件:HandleEqualsAndHashCode.java   
/** Give 2 clones! */
public Expression longToIntForHashCode(Expression ref1, Expression ref2, ASTNode source) {
    int pS = source.sourceStart, pE = source.sourceEnd;
    /* (int)(ref >>> 32 ^ ref) */
    IntLiteral int32 = makeIntLiteral("32".toCharArray(), source);
    BinaryExpression higherBits = new BinaryExpression(ref1, int32, OperatorIds.UNSIGNED_RIGHT_SHIFT);
    setGeneratedBy(higherBits, source);
    BinaryExpression xorParts = new BinaryExpression(ref2, higherBits, OperatorIds.XOR);
    setGeneratedBy(xorParts, source);
    TypeReference intRef = TypeReference.baseTypeReference(TypeIds.T_int, 0);
    intRef.sourceStart = pS; intRef.sourceEnd = pE;
    setGeneratedBy(intRef, source);
    CastExpression expr = makeCastExpression(xorParts, intRef, source);
    expr.sourceStart = pS; expr.sourceEnd = pE;
    return expr;
}
项目:EasyMPermission    文件:EclipseSingularsRecipes.java   
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);
}
项目:EasyMPermission    文件:EclipseJavaUtilListSetSingularizer.java   
@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));
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void illegalAnnotationForBaseType(TypeReference type, Annotation[] annotations, long nullAnnotationTagBit)
{
    int typeId = (nullAnnotationTagBit == TagBits.AnnotationNullable) 
            ? TypeIds.T_ConfiguredAnnotationNullable : TypeIds.T_ConfiguredAnnotationNonNull;
    char[][] annotationNames = (nullAnnotationTagBit == TagBits.AnnotationNonNull)
            ? this.options.nonNullAnnotationName
            : this.options.nullableAnnotationName;
    String[] args = new String[] { new String(annotationNames[annotationNames.length-1]), new String(type.getLastToken()) };
    Annotation annotation = findAnnotation(annotations, typeId);
    int start = annotation != null ? annotation.sourceStart : type.sourceStart;
    int end = annotation != null ? annotation.sourceEnd : type.sourceEnd;
    this.handle(IProblem.IllegalAnnotationForBaseType,
            args,
            args,
            start,
            end);
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeMethodInvocationPrimaryWithTypeArguments() {
    //optimize the push/pop
    //MethodInvocation ::= Primary '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'

    MessageSend m = newMessageSendWithTypeArguments();
    m.sourceStart =
        (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
    m.selector = this.identifierStack[this.identifierPtr--];
    this.identifierLengthPtr--;

    // handle type arguments
    int length = this.genericsLengthStack[this.genericsLengthPtr--];
    this.genericsPtr -= length;
    System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
    this.intPtr--; // consume position of '<'

    m.receiver = this.expressionStack[this.expressionPtr];
    m.sourceStart = m.receiver.sourceStart;
    m.sourceEnd = this.rParenPos;
    this.expressionStack[this.expressionPtr] = m;
    consumeInvocationExpression();
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void wrongSequenceOfExceptionTypesError(TypeReference typeRef, TypeBinding exceptionType, TypeBinding hidingExceptionType) {
    //the two catch block under and upper are in an incorrect order.
    //under should be define BEFORE upper in the source

    this.handle(
        IProblem.InvalidCatchBlockSequence,
        new String[] {
            new String(exceptionType.readableName()),
            new String(hidingExceptionType.readableName()),
         },
        new String[] {
            new String(exceptionType.shortReadableName()),
            new String(hidingExceptionType.shortReadableName()),
         },
        typeRef.sourceStart,
        typeRef.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemReporter.java   
public void annotationCircularity(TypeBinding sourceType, TypeBinding otherType, TypeReference reference) {
    if (sourceType == otherType)
        this.handle(
            IProblem.AnnotationCircularitySelfReference,
            new String[] {new String(sourceType.readableName())},
            new String[] {new String(sourceType.shortReadableName())},
            reference.sourceStart,
            reference.sourceEnd);
    else
        this.handle(
            IProblem.AnnotationCircularity,
            new String[] {new String(sourceType.readableName()), new String(otherType.readableName())},
            new String[] {new String(sourceType.shortReadableName()), new String(otherType.shortReadableName())},
            reference.sourceStart,
            reference.sourceEnd);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTConverter.java   
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;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CompletionElementNotifier.java   
protected char[][] getThrownExceptions(AbstractMethodDeclaration methodDeclaration) {
    char[][] thrownExceptionTypes = null;
    TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
    if (thrownExceptions != null) {
        int thrownExceptionLength = thrownExceptions.length;
        int thrownExceptionCount = 0;
        thrownExceptionTypes = new char[thrownExceptionLength][];
        next : for (int i = 0; i < thrownExceptionLength; i++) {
            TypeReference thrownException = thrownExceptions[i];

            if (thrownException instanceof CompletionOnKeyword) continue next;
            if (CompletionUnitStructureRequestor.hasEmptyName(thrownException, this.assistNode)) continue next;

            thrownExceptionTypes[thrownExceptionCount++] =
                CharOperation.concatWith(thrownException.getParameterizedTypeName(), '.');
        }

        if (thrownExceptionCount == 0) return null;
        if (thrownExceptionCount < thrownExceptionLength) {
            System.arraycopy(thrownExceptionTypes, 0, thrownExceptionTypes = new char[thrownExceptionCount][], 0, thrownExceptionCount);
        }
    }
    return thrownExceptionTypes;
}
项目:Eclipse-Postfix-Code-Completion    文件:ParameterizedTypeBinding.java   
/**
 * Iterate type arguments, and validate them according to corresponding variable bounds.
 */
public void boundCheck(Scope scope, TypeReference[] argumentReferences) {
    if ((this.tagBits & TagBits.PassedBoundCheck) == 0) {
        boolean hasErrors = false;
        TypeVariableBinding[] typeVariables = this.type.typeVariables();
        if (this.arguments != null && typeVariables != null) { // arguments may be null in error cases
            for (int i = 0, length = typeVariables.length; i < length; i++) {
                if (typeVariables[i].boundCheck(this, this.arguments[i], scope)  != TypeConstants.OK) {
                    hasErrors = true;
                    if ((this.arguments[i].tagBits & TagBits.HasMissingType) == 0) {
                        // do not report secondary error, if type reference already got complained against
                        scope.problemReporter().typeMismatchError(this.arguments[i], typeVariables[i], this.type, argumentReferences[i]);
                    }
                }
            }
        }
        if (!hasErrors) this.tagBits |= TagBits.PassedBoundCheck; // no need to recheck it in the future
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeReferenceExpressionSuperForm() {
    // ReferenceExpression ::= 'super' '::' NonWildTypeArgumentsopt Identifier

    ReferenceExpression referenceExpression = newReferenceExpression();
    TypeReference [] typeArguments = null;
    char [] selector;
    int sourceEnd;

    sourceEnd = (int) this.identifierPositionStack[this.identifierPtr];
    referenceExpression.nameSourceStart = (int) (this.identifierPositionStack[this.identifierPtr] >>> 32);
    selector = this.identifierStack[this.identifierPtr--];
    this.identifierLengthPtr--;

    int length = this.genericsLengthStack[this.genericsLengthPtr--];
    if (length > 0) {
        this.genericsPtr -= length;
        System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments = new TypeReference[length], 0, length);
        this.intPtr--;  // pop type arguments source start.
    }

    SuperReference superReference = new SuperReference(this.intStack[this.intPtr--], this.endPosition);
    referenceExpression.initialize(this.compilationUnit.compilationResult, superReference, typeArguments, selector, sourceEnd);
    consumeReferenceExpression(referenceExpression);
}
项目:Eclipse-Postfix-Code-Completion    文件:LocalTypeBinding.java   
public ReferenceBinding anonymousOriginalSuperType() {
    if (!isPrototype())
        return ((LocalTypeBinding) this.prototype).anonymousOriginalSuperType();

    if (this.superInterfaces != Binding.NO_SUPERINTERFACES) {
        return this.superInterfaces[0];
    }
    if ((this.tagBits & TagBits.HierarchyHasProblems) == 0) {
        return this.superclass;
    }
    if (this.scope != null) {
        TypeReference typeReference = this.scope.referenceContext.allocation.type;
        if (typeReference != null) {
            return (ReferenceBinding) typeReference.resolvedType;
        }
    }
    return this.superclass; // default answer
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeConverter.java   
protected TypeParameter createTypeParameter(char[] typeParameterName, char[][] typeParameterBounds, int start, int end) {

        TypeParameter parameter = new TypeParameter();
        parameter.name = typeParameterName;
        parameter.sourceStart = start;
        parameter.sourceEnd = end;
        if (typeParameterBounds != null) {
            int length = typeParameterBounds.length;
            if (length > 0) {
                parameter.type = createTypeReference(typeParameterBounds[0], start, end);
                if (length > 1) {
                    parameter.bounds = new TypeReference[length-1];
                    for (int i = 1; i < length; i++) {
                        TypeReference bound = createTypeReference(typeParameterBounds[i], start, end);
                        bound.bits |= ASTNode.IsSuperType;
                        parameter.bounds[i-1] = bound;
                    }
                }
            }
        }
        return parameter;
    }
项目:Eclipse-Postfix-Code-Completion    文件:TypeConverter.java   
private TypeReference[] decodeTypeArguments(String typeSignature, int length, int start, int end) {
    ArrayList argumentList = new ArrayList(1);
    int count = 0;
    argumentsLoop: while (this.namePos < length) {
        TypeReference argument = decodeType(typeSignature, length, start, end);
        count++;
        argumentList.add(argument);
        if (this.namePos >= length) break argumentsLoop;
        if (typeSignature.charAt(this.namePos) == Signature.C_GENERIC_END) {
            break argumentsLoop;
        }
    }
    TypeReference[] typeArguments = new TypeReference[count];
    argumentList.toArray(typeArguments);
    return typeArguments;
}
项目:Eclipse-Postfix-Code-Completion    文件:ASTConverter.java   
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;
    }
}
项目: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);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ProblemReporter.java   
public void javadocMissingThrowsTag(TypeReference typeRef, int modifiers){
    int severity = computeSeverity(IProblem.JavadocMissingThrowsTag);
    if (severity == ProblemSeverities.Ignore) return;
    boolean overriding = (modifiers & (ExtraCompilerModifiers.AccImplementing|ExtraCompilerModifiers.AccOverriding)) != 0;
    boolean report = (this.options.getSeverity(CompilerOptions.MissingJavadocTags) != ProblemSeverities.Ignore)
                    && (!overriding || this.options.reportMissingJavadocTagsOverriding);
    if (report && javadocVisibility(this.options.reportMissingJavadocTagsVisibility, modifiers)) {
        String[] arguments = new String[] { String.valueOf(typeRef.resolvedType.sourceName()) };
        this.handle(
            IProblem.JavadocMissingThrowsTag,
            arguments,
            arguments,
            severity,
            typeRef.sourceStart,
            typeRef.sourceEnd);
    }
}
项目: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    文件:Parser.java   
protected void consumeCastExpressionLL1() {
    //CastExpression ::= '(' Name ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus


    //optimize push/pop

    Expression cast;
    Expression exp;
    this.expressionPtr--;
    this.expressionStack[this.expressionPtr] =
        cast = new CastExpression(
            exp=this.expressionStack[this.expressionPtr+1] ,
            (TypeReference) this.expressionStack[this.expressionPtr]);
    this.expressionLengthPtr -- ;
    updateSourcePosition(cast);
    cast.sourceEnd=exp.sourceEnd;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeCastExpressionLL1WithBounds() {
    //CastExpression ::= '(' Name AdditionalBoundsList ')' UnaryExpressionNotPlusMinus
    Expression cast;
    Expression exp;
    int length;
    exp = this.expressionStack[this.expressionPtr--];
    this.expressionLengthPtr --;
    TypeReference[] bounds = new TypeReference[length = this.expressionLengthStack[this.expressionLengthPtr]];
    System.arraycopy(this.expressionStack, this.expressionPtr -= (length - 1), bounds, 0, length);
    this.expressionStack[this.expressionPtr] =
        cast = new CastExpression(
            exp,
            createIntersectionCastTypeReference(bounds));
    this.expressionLengthStack[this.expressionLengthPtr] = 1;
    updateSourcePosition(cast);
    cast.sourceEnd=exp.sourceEnd;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeClassHeaderImplements() {
    // ClassHeaderImplements ::= 'implements' InterfaceTypeList
    int length = this.astLengthStack[this.astLengthPtr--];
    //super interfaces
    this.astPtr -= length;
    // There is a class declaration on the top of stack
    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
    System.arraycopy(
        this.astStack,
        this.astPtr + 1,
        typeDecl.superInterfaces = new TypeReference[length],
        0,
        length);
    TypeReference[] superinterfaces = typeDecl.superInterfaces;
    for (int i = 0, max = superinterfaces.length; i < max; i++) {
        TypeReference typeReference = superinterfaces[i];
        typeDecl.bits |= (typeReference.bits & ASTNode.HasTypeAnnotations);
        typeReference.bits |= ASTNode.IsSuperType;
    }
    typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1;
    this.listLength = 0; // reset after having read super-interfaces
    // recovery
    if (this.currentElement != null) { // is recovering
        this.lastCheckPoint = typeDecl.bodyStart;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ClassScope.java   
public boolean detectHierarchyCycle(TypeBinding superType, TypeReference reference) {
    if (!(superType instanceof ReferenceBinding)) return false;

    if (reference == this.superTypeReference) { // see findSuperType()
        if (superType.isTypeVariable())
            return false; // error case caught in resolveSuperType()
        // abstract class X<K,V> implements java.util.Map<K,V>
        //    static abstract class M<K,V> implements Entry<K,V>
        if (superType.isParameterizedType())
            superType = ((ParameterizedTypeBinding) superType).genericType();
        compilationUnitScope().recordSuperTypeReference(superType); // to record supertypes
        return detectHierarchyCycle(this.referenceContext.binding, (ReferenceBinding) superType, reference);
    }
    // Reinstate the code deleted by the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=205235
    // For details, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=294057. 
    if ((superType.tagBits & TagBits.BeginHierarchyCheck) == 0 && superType instanceof SourceTypeBinding)
        // ensure if this is a source superclass that it has already been checked
        ((SourceTypeBinding) superType).scope.connectTypeHierarchyWithoutMembers();

    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeInsideCastExpressionLL1WithBounds() {
    // InsideCastExpressionLL1WithBounds ::= $empty
    int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
    TypeReference[] bounds = new TypeReference[additionalBoundsLength + 1];
    this.genericsPtr -= additionalBoundsLength;
    System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 1, additionalBoundsLength);

    pushOnGenericsLengthStack(0); // handle type arguments
    pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
    bounds[0] = getTypeReference(0);

    for (int i = 0; i <= additionalBoundsLength; i++) {
        pushOnExpressionStack(bounds[i]);
        if (i > 0)
            this.expressionLengthStack[--this.expressionLengthPtr]++;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeInstanceOfExpressionWithName() {
    // RelationalExpression_NotName ::= Name instanceof ReferenceType
    //optimize the push/pop

    //by construction, no base type may be used in getTypeReference
    TypeReference reference = getTypeReference(this.intStack[this.intPtr--]);
    pushOnExpressionStack(getUnspecifiedReferenceOptimized());
    Expression exp;
    this.expressionStack[this.expressionPtr] = exp =
        new InstanceOfExpression(
            this.expressionStack[this.expressionPtr],
            reference);
    if (exp.sourceEnd == 0) {
        //array on base type....
        exp.sourceEnd = this.scanner.startPosition - 1;
    }
    //the scanner is on the next token already....
}