Search in sources :

Example 16 with UserError

use of org.checkerframework.javacutil.UserError in project checker-framework by typetools.

the class WholeProgramInferenceScenesStorage method getScene.

/**
 * Reads a Scene from the given .jaif file, or returns an empty Scene if the file does not exist.
 *
 * @param jaifPath the .jaif file
 * @return the Scene read from the file, or an empty Scene if the file does not exist
 */
private ASceneWrapper getScene(String jaifPath) {
    AScene scene;
    if (!scenes.containsKey(jaifPath)) {
        File jaifFile = new File(jaifPath);
        scene = new AScene();
        if (jaifFile.exists()) {
            try {
                IndexFileParser.parseFile(jaifPath, scene);
            } catch (IOException e) {
                throw new UserError("Problem while reading %s: %s", jaifPath, e.getMessage());
            }
        }
        ASceneWrapper wrapper = new ASceneWrapper(scene);
        scenes.put(jaifPath, wrapper);
        return wrapper;
    } else {
        return scenes.get(jaifPath);
    }
}
Also used : AScene(scenelib.annotations.el.AScene) ASceneWrapper(org.checkerframework.common.wholeprograminference.scenelib.ASceneWrapper) UserError(org.checkerframework.javacutil.UserError) IOException(java.io.IOException) File(java.io.File)

Aggregations

UserError (org.checkerframework.javacutil.UserError)16 IOException (java.io.IOException)4 JavacProcessingEnvironment (com.sun.tools.javac.processing.JavacProcessingEnvironment)3 FileWriter (java.io.FileWriter)3 Map (java.util.Map)3 Nullable (org.checkerframework.checker.nullness.qual.Nullable)3 Context (com.sun.tools.javac.util.Context)2 BufferedWriter (java.io.BufferedWriter)2 File (java.io.File)2 HashMap (java.util.HashMap)2 IdentityHashMap (java.util.IdentityHashMap)2 AnnotationMirror (javax.lang.model.element.AnnotationMirror)2 BugInCF (org.checkerframework.javacutil.BugInCF)2 TypeSystemError (org.checkerframework.javacutil.TypeSystemError)2 AScene (scenelib.annotations.el.AScene)2 ExpressionTree (com.sun.source.tree.ExpressionTree)1 VariableTree (com.sun.source.tree.VariableTree)1 Source (com.sun.tools.javac.code.Source)1 DiagnosticSource (com.sun.tools.javac.util.DiagnosticSource)1 Log (com.sun.tools.javac.util.Log)1