Search in sources :

Example 1 with FlowExpressionContext

use of org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext in project checker-framework by typetools.

the class DependentTypesHelper method standardizeReturnType.

public void standardizeReturnType(MethodTree m, AnnotatedTypeMirror atm) {
    if (atm.getKind() == TypeKind.NONE) {
        return;
    }
    if (!hasDependentType(atm)) {
        return;
    }
    Element ele = TreeUtils.elementFromDeclaration(m);
    TypeMirror enclosingType = ElementUtils.enclosingClass(ele).asType();
    FlowExpressionContext context = FlowExpressionContext.buildContextForMethodDeclaration(m, enclosingType, factory.getContext());
    standardizeDoNotUseLocals(context, factory.getPath(m), atm);
}
Also used : AnnotatedTypeMirror(org.checkerframework.framework.type.AnnotatedTypeMirror) TypeMirror(javax.lang.model.type.TypeMirror) FlowExpressionContext(org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext) TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element)

Example 2 with FlowExpressionContext

use of org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext in project checker-framework by typetools.

the class DependentTypesHelper method viewpointAdaptTypeVariableBounds.

/**
 * Viewpoint-adapts the dependent type annotations on the bounds to the use of the type.
 *
 * @param classDecl class or interface declaration whose type variables should be viewpoint
 *     adapted
 * @param bounds annotated types of the bounds of the type variables
 * @param pathToUse tree path to the use of the class or interface
 */
public void viewpointAdaptTypeVariableBounds(TypeElement classDecl, List<AnnotatedTypeParameterBounds> bounds, TreePath pathToUse) {
    FlowExpressions.Receiver r = FlowExpressions.internalReprOfImplicitReceiver(classDecl);
    FlowExpressionContext context = new FlowExpressionContext(r, null, factory.getContext());
    for (AnnotatedTypeParameterBounds bound : bounds) {
        standardizeDoNotUseLocals(context, pathToUse, bound.getUpperBound());
        standardizeDoNotUseLocals(context, pathToUse, bound.getLowerBound());
    }
}
Also used : AnnotatedTypeParameterBounds(org.checkerframework.framework.type.AnnotatedTypeParameterBounds) FlowExpressionContext(org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext) FlowExpressions(org.checkerframework.dataflow.analysis.FlowExpressions) Receiver(org.checkerframework.dataflow.analysis.FlowExpressions.Receiver)

Example 3 with FlowExpressionContext

use of org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext in project checker-framework by typetools.

the class DependentTypesHelper method checkTypeVariables.

private void checkTypeVariables(MethodTree node, AnnotatedExecutableType methodType) {
    Element ele = TreeUtils.elementFromDeclaration(node);
    TypeMirror enclosingType = ElementUtils.enclosingClass(ele).asType();
    FlowExpressionContext context = FlowExpressionContext.buildContextForMethodDeclaration(node, enclosingType, factory.getContext());
    for (int i = 0; i < methodType.getTypeVariables().size(); i++) {
        AnnotatedTypeMirror atm = methodType.getTypeVariables().get(i);
        standardizeDoNotUseLocals(context, factory.getPath(node), atm);
        checkType(atm, node.getTypeParameters().get(i));
    }
}
Also used : AnnotatedTypeMirror(org.checkerframework.framework.type.AnnotatedTypeMirror) TypeMirror(javax.lang.model.type.TypeMirror) FlowExpressionContext(org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext) TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) AnnotatedTypeMirror(org.checkerframework.framework.type.AnnotatedTypeMirror)

Example 4 with FlowExpressionContext

use of org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext in project checker-framework by typetools.

the class DependentTypesHelper method standardizeNewClassTree.

public void standardizeNewClassTree(NewClassTree tree, AnnotatedDeclaredType type) {
    if (!hasDependentType(type)) {
        return;
    }
    TreePath path = factory.getPath(tree);
    FlowExpressions.Receiver r = FlowExpressions.internalReprOfImplicitReceiver(TreeUtils.elementFromUse(tree));
    FlowExpressionContext context = new FlowExpressionContext(r, FlowExpressions.getParametersOfEnclosingMethod(factory, path), factory.getContext());
    standardizeUseLocals(context, path, type);
}
Also used : TreePath(com.sun.source.util.TreePath) FlowExpressionContext(org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext) FlowExpressions(org.checkerframework.dataflow.analysis.FlowExpressions) Receiver(org.checkerframework.dataflow.analysis.FlowExpressions.Receiver)

Example 5 with FlowExpressionContext

use of org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext in project checker-framework by typetools.

the class DependentTypesHelper method standardizeExpression.

public void standardizeExpression(ExpressionTree tree, AnnotatedTypeMirror annotatedType) {
    if (!hasDependentType(annotatedType)) {
        return;
    }
    TreePath path = factory.getPath(tree);
    if (path == null) {
        return;
    }
    Tree enclosingClass = TreeUtils.enclosingClass(path);
    if (enclosingClass == null) {
        return;
    }
    TypeMirror enclosingType = TreeUtils.typeOf(enclosingClass);
    FlowExpressions.Receiver receiver = FlowExpressions.internalReprOfPseudoReceiver(path, enclosingType);
    FlowExpressionContext localContext = new FlowExpressionContext(receiver, FlowExpressions.getParametersOfEnclosingMethod(factory, path), factory.getContext());
    standardizeUseLocals(localContext, path, annotatedType);
}
Also used : TreePath(com.sun.source.util.TreePath) AnnotatedTypeMirror(org.checkerframework.framework.type.AnnotatedTypeMirror) TypeMirror(javax.lang.model.type.TypeMirror) FlowExpressionContext(org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext) MethodInvocationTree(com.sun.source.tree.MethodInvocationTree) LambdaExpressionTree(com.sun.source.tree.LambdaExpressionTree) IdentifierTree(com.sun.source.tree.IdentifierTree) MemberSelectTree(com.sun.source.tree.MemberSelectTree) ModifiersTree(com.sun.source.tree.ModifiersTree) AnnotationTree(com.sun.source.tree.AnnotationTree) MethodTree(com.sun.source.tree.MethodTree) VariableTree(com.sun.source.tree.VariableTree) NewClassTree(com.sun.source.tree.NewClassTree) Tree(com.sun.source.tree.Tree) ExpressionTree(com.sun.source.tree.ExpressionTree) FlowExpressions(org.checkerframework.dataflow.analysis.FlowExpressions) Receiver(org.checkerframework.dataflow.analysis.FlowExpressions.Receiver)

Aggregations

FlowExpressionContext (org.checkerframework.framework.util.FlowExpressionParseUtil.FlowExpressionContext)9 FlowExpressions (org.checkerframework.dataflow.analysis.FlowExpressions)7 Receiver (org.checkerframework.dataflow.analysis.FlowExpressions.Receiver)7 TreePath (com.sun.source.util.TreePath)5 Element (javax.lang.model.element.Element)4 TypeElement (javax.lang.model.element.TypeElement)4 TypeMirror (javax.lang.model.type.TypeMirror)4 AnnotatedTypeMirror (org.checkerframework.framework.type.AnnotatedTypeMirror)4 ExpressionTree (com.sun.source.tree.ExpressionTree)3 LambdaExpressionTree (com.sun.source.tree.LambdaExpressionTree)3 MethodTree (com.sun.source.tree.MethodTree)3 AnnotationTree (com.sun.source.tree.AnnotationTree)2 IdentifierTree (com.sun.source.tree.IdentifierTree)2 MemberSelectTree (com.sun.source.tree.MemberSelectTree)2 MethodInvocationTree (com.sun.source.tree.MethodInvocationTree)2 ModifiersTree (com.sun.source.tree.ModifiersTree)2 NewClassTree (com.sun.source.tree.NewClassTree)2 Tree (com.sun.source.tree.Tree)2 VariableTree (com.sun.source.tree.VariableTree)2 ArrayList (java.util.ArrayList)1