use of scenelib.annotations.el.AMethod in project checker-framework by typetools.
the class WholeProgramInferenceScenesStorage method getPostconditionsForExpression.
/**
* Returns the postcondition annotations for a Java expression.
*
* @param methodElement the method
* @param expression the expression
* @param declaredType the declared type of the expression
* @return the postcondition annotations for a Java expression
*/
private ATypeElement getPostconditionsForExpression(ExecutableElement methodElement, String expression, AnnotatedTypeMirror declaredType) {
AMethod methodAnnos = getMethodAnnos(methodElement);
postconditionsToDeclaredTypes.put(methodAnnos.methodSignature + expression, declaredType);
return methodAnnos.vivifyAndAddTypeMirrorToPostcondition(expression, declaredType.getUnderlyingType()).type;
}
use of scenelib.annotations.el.AMethod in project checker-framework by typetools.
the class WholeProgramInferenceScenesStorage method getParameterAnnotations.
@Override
public ATypeElement getParameterAnnotations(ExecutableElement methodElt, int i, AnnotatedTypeMirror paramATM, VariableElement ve, AnnotatedTypeFactory atypeFactory) {
AMethod methodAnnos = getMethodAnnos(methodElt);
AField param = methodAnnos.vivifyAndAddTypeMirrorToParameter(i, paramATM.getUnderlyingType(), ve.getSimpleName());
return param.type;
}
use of scenelib.annotations.el.AMethod in project checker-framework by typetools.
the class SceneToStubWriter method printClass.
/**
* Print the class body, or nothing if this is an anonymous inner class. Call {@link
* #isPrintable(String, AClass)} and check that it returns true before calling this method.
*
* @param classname the class name
* @param aClass the representation of the class
* @param checker the checker, for computing preconditions
* @param printWriter the writer on which to print
*/
private static void printClass(@BinaryName String classname, AClass aClass, BaseTypeChecker checker, PrintWriter printWriter) {
String basename = basenamePart(classname);
String innermostClassname = basename.contains("$") ? basename.substring(basename.lastIndexOf('$') + 1) : basename;
String pkg = packagePart(classname);
if (pkg != null) {
printWriter.println("package " + pkg + ";");
}
int curlyCount = printClassDefinitions(basename, aClass, printWriter, checker);
String indentLevel = indents(curlyCount);
List<VariableElement> enumConstants = aClass.getEnumConstants();
if (enumConstants != null) {
StringJoiner sj = new StringJoiner(", ");
for (VariableElement enumConstant : enumConstants) {
sj.add(enumConstant.getSimpleName());
}
printWriter.println(indentLevel + "// enum constants:");
printWriter.println();
printWriter.println(indentLevel + sj.toString() + ";");
printWriter.println();
}
printFields(aClass, printWriter, indentLevel);
if (!aClass.getMethods().isEmpty()) {
// print method signatures
printWriter.println(indentLevel + "// methods:");
printWriter.println();
for (Map.Entry<String, AMethod> methodEntry : aClass.getMethods().entrySet()) {
printMethodDeclaration(methodEntry.getValue(), innermostClassname, printWriter, indentLevel, checker.getTypeFactory());
}
}
for (int i = 0; i < curlyCount; i++) {
printWriter.println(indents(curlyCount - i - 1) + "}");
}
}
use of scenelib.annotations.el.AMethod in project checker-framework by typetools.
the class ToIndexFileConverter method visit.
@Override
public Void visit(ConstructorDeclaration decl, AElement elem) {
List<Parameter> params = decl.getParameters();
List<AnnotationExpr> rcvrAnnos = decl.getAnnotations();
BlockStmt body = decl.getBody();
StringBuilder sb = new StringBuilder("<init>(");
AClass clazz = (AClass) elem;
AMethod method;
// Some of the methods in the generated parser use null to represent an empty list.
if (params != null) {
for (Parameter param : params) {
Type ptype = param.getType();
sb.append(getJVML(ptype));
}
}
sb.append(")V");
method = clazz.methods.getVivify(sb.toString());
visitDecl(decl, method);
if (params != null) {
for (int i = 0; i < params.size(); i++) {
Parameter param = params.get(i);
AField field = method.parameters.getVivify(i);
visitType(param.getType(), field.type);
}
}
if (rcvrAnnos != null) {
for (AnnotationExpr expr : rcvrAnnos) {
Annotation anno = extractAnnotation(expr);
method.receiver.tlAnnotationsHere.add(anno);
}
}
return body == null ? null : body.accept(this, method);
// return super.visit(decl, elem);
}
Aggregations