diff --git a/infer/annotations/com/facebook/infer/annotprocess/ClassToSourceMapper.java b/infer/annotations/com/facebook/infer/annotprocess/ClassToSourceMapper.java deleted file mode 100644 index e0256c8e1..000000000 --- a/infer/annotations/com/facebook/infer/annotprocess/ClassToSourceMapper.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2015 - present Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package com.facebook.infer.annotprocess; - -import com.sun.source.tree.CompilationUnitTree; -import com.sun.source.util.Trees; -import com.sun.source.util.TreePath; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.annotation.processing.SupportedOptions; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; - -@SupportedOptions({ "classSourceMapOutputFilename" }) -// this says: "process all classes, even ones without any annotations" -@SupportedAnnotationTypes({ "*" }) -public class ClassToSourceMapper extends AbstractProcessor { - - // map from class name -> absolute path to source file - // e.g., com.example.MyClass -> = /Users/me/MyClass.Java - // note that this map does not contain inner or anonymous classes - private Map mClassSourceMap = new LinkedHashMap(); - - private static final String DEFAULT_OUTPUT_FILENAME = "classSourceMap.json"; - - private static final String OUTPUT_FILENAME_OPTION = "classSourceMapOutputFilename"; - - private void exportClassSourceMap(String filename) throws FileNotFoundException, IOException { - try (PrintWriter out = new PrintWriter(filename)) { - out.println("{"); - int elemCount = 0; - int elemMax = mClassSourceMap.size(); - for (Map.Entry entry : mClassSourceMap.entrySet()) { - String className = entry.getKey(); - String sourcePath = entry.getValue(); - JSONOutputUtils.outputClassSourcePair(out, className, sourcePath, ++elemCount, elemMax); - } - out.println("}"); - } - } - - private void makeClassSourceMap(RoundEnvironment env) { - Set rootEnv = env.getRootElements(); - Trees trees = Trees.instance(processingEnv); - for (Element e : rootEnv) { - if (e instanceof TypeElement) { // class or interface - TreePath path = trees.getPath(e); - TypeElement typeElem = (TypeElement) e; - CompilationUnitTree compilationUnit = path.getCompilationUnit(); - String absoluteSourcePath = compilationUnit.getSourceFile().toUri().getPath(); - // map a class name to its source file. this will only capture top-level class names; inner - // classes (anonymous and otherwise) are dealt with later reading each top-level class's - // list of inner classes and mapping each one to the source file of the parent class - mClassSourceMap.put(typeElem.getQualifiedName().toString(), absoluteSourcePath); - } - } - } - - @Override - public boolean process(Set annotations, RoundEnvironment env) { - makeClassSourceMap(env); - if (env.processingOver()) { - try { - Map options = processingEnv.getOptions(); - String outputFilename = options.get(OUTPUT_FILENAME_OPTION); - if (outputFilename == null) { - outputFilename = DEFAULT_OUTPUT_FILENAME; - } - exportClassSourceMap(outputFilename); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return false; - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latestSupported(); - } - -} diff --git a/infer/lib/python/inferlib/config.py b/infer/lib/python/inferlib/config.py index 15665a38f..69be17547 100644 --- a/infer/lib/python/inferlib/config.py +++ b/infer/lib/python/inferlib/config.py @@ -55,7 +55,6 @@ LOG_FILE = 'toplevel.log' BUCK_INFER_OUT = 'infer' -CLASS_SOURCE_MAP_OUTPUT_FILENAME_OPTION = 'classSourceMapOutputFilename' SUPRESS_WARNINGS_OUTPUT_FILENAME_OPTION = 'SuppressWarningsOutputFilename' diff --git a/infer/lib/python/inferlib/jwlib.py b/infer/lib/python/inferlib/jwlib.py index 7b78cfb54..b4e262629 100644 --- a/infer/lib/python/inferlib/jwlib.py +++ b/infer/lib/python/inferlib/jwlib.py @@ -158,16 +158,6 @@ class CompilerCall(object): self.args.processor) javac_args += ['-processor', processor] - with tempfile.NamedTemporaryFile( - mode='w', - suffix='.json', - prefix='classSourceMap_', - delete=False) as class_source_map_out: - self.class_source_map = class_source_map_out.name - javac_args += ['-A%s=%s' % - (config.CLASS_SOURCE_MAP_OUTPUT_FILENAME_OPTION, - self.class_source_map)] - with tempfile.NamedTemporaryFile( mode='w', suffix='.out', @@ -297,7 +287,6 @@ class AnalyzerWithFrontendWrapper(analyze.AnalyzerWrapper): def _run_infer_frontend(self): infer_cmd = [utils.get_cmd_in_bin_dir('InferJava')] infer_cmd += ['-classpath', self._create_frontend_classpath()] - infer_cmd += ['-class_source_map', self.javac.class_source_map] if not self.args.absolute_paths: infer_cmd += ['-project_root', self.args.project_root] diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index a289de16b..b02ce49b4 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -603,10 +603,6 @@ and _ = CLOpt.mk_string_opt ~deprecated:["classpath"] ~long:"classpath" ~meta:"path" "Specify where to find user class files and annotation processors" -and _ = - CLOpt.mk_string_opt ~deprecated:["class_source_map"] ~long:"class-source-map" - ~meta:"file" "path to class -> source map in JSON format" - (** optional command-line name of the .cluster file *) and cluster = CLOpt.mk_string_opt ~deprecated:["cluster"] ~long:"cluster"