Skip to content
Browse files

* lang_java/analyze/tags_java.ml: removed, factorized in graph_code_t…

…ags.ml
  • Loading branch information...
1 parent 4bec124 commit f498de0aebe6401e98c4858cde66f612db7e7fab @aryx aryx committed
View
6 h_program-lang/graph_code_tags.ml
@@ -88,7 +88,11 @@ let defs_of_graph_code ?(verbose=false) g =
Hashtbl.add hfile_to_tags file
{ tag with Tags_file.tagname = reversed_tagname }
- with Not_found -> ()
+ with Not_found ->
+ (match kind with
+ | E.Package | E.File | E.Dir | E.TopStmts -> ()
+ | _ -> pr2 (spf "PB, nodeinfo not found for %s" str);
+ )
)
);
Common.hkeys hfile_to_tags +> List.map (fun file ->
View
1 lang_java/analyze/Makefile
@@ -9,7 +9,6 @@ SRC= \
ast_java_simple.ml \
package_java.ml graph_code_java.ml \
builtins_java.ml \
- tags_java.ml \
unit_analyze_java.ml test_analyze_java.ml
-include $(TOP)/Makefile.config
View
78 lang_java/analyze/tags_java.ml
@@ -1,78 +0,0 @@
-(* Yoann Padioleau
- *
- * Copyright (C) 2012 Facebook
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation, with the
- * special exception on linking described in file license.txt.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
- * license.txt for more details.
- *)
-open Common
-
-module G = Graph_code
-module E = Database_code
-module PI = Parse_info
-
-(*****************************************************************************)
-(* Prelude *)
-(*****************************************************************************)
-(*
- * Small wrapper around Graph_code_java to extract tags information.
- *
- * Normally you should really use Intellij or Eclipse to navigate
- * a Java codebase, but a few things can be faster to do with Emacs.
- *)
-
-(*****************************************************************************)
-(* Helpers *)
-(*****************************************************************************)
-
-(*****************************************************************************)
-(* Main entry point *)
-(*****************************************************************************)
-
-let defs_of_dir_or_file ?(verbose=false) dir_or_file skip_list =
- let g = Graph_code_java.build ~verbose ~only_defs:true dir_or_file skip_list
- in
-
- (* use the multi-val-for-same-key propery of Hashtbl.add *)
- let h = Hashtbl.create 101 in
- let hmemo = Hashtbl.create 101 in
-
- g +> G.iter_nodes (fun (str, kind) ->
- try
- let nodeinfo = g +> G.nodeinfo (str, kind) in
- let parse_info = nodeinfo.G.pos in
- let info = { PI.
- token = PI.OriginTok parse_info;
- comments = ();
- transfo = PI.NoTransfo;
- }
- in
- (* wants the fully qualified tag, foo.Bar, not just Bar *)
- let info = PI.rewrap_str str info in
-
- let file = PI.file_of_info info in
- let filelines =
- Common.memoized hmemo file (fun () ->
- Common.cat_array file
- )
- in
-
- let tag = Tags_file.tag_of_info filelines info kind in
- Hashtbl.add h file tag
- with Not_found ->
- (match kind with
- | E.Package | E.File | E.Dir | E.TopStmts -> ()
- | _ -> pr2 (spf "PB, nodeinfo not found for %s" str);
- )
- );
- let keys = Common.hkeys h in
- keys +> List.map (fun k -> k, Hashtbl.find_all h k)
-
-
View
4 lang_java/analyze/tags_java.mli
@@ -1,4 +0,0 @@
-val defs_of_dir_or_file:
- ?verbose:bool ->
- Common.path -> Skip_code.skip list ->
- (Common.filename * Tags_file.tag list) list
View
2 lang_java/analyze/unit_analyze_java.ml
@@ -13,6 +13,7 @@ let unittest =
(*****************************************************************************)
(* Tags *)
(*****************************************************************************)
+(*
"tags_java" >::: [
"basic tags" >:: (fun () ->
@@ -37,6 +38,7 @@ let unittest =
)
);
]
+*)
(*---------------------------------------------------------------------------*)
(* Final suite *)
View
16 main_stags.ml
@@ -86,18 +86,18 @@ let rec defs_of_files_or_dirs lang xs =
let tag1 = defs_of_files_or_dirs "php" xs in
let tag2 = defs_of_files_or_dirs "js" xs in
tag1 ++ tag2
- | "java" ->
- (match xs with
- | [x] -> Tags_java.defs_of_dir_or_file ~verbose x skip_list
- | _ -> failwith "the java option accept only a single dir or file"
- )
- | "cmt" ->
+ | ("cmt" | "java") ->
(match xs with
| [root] ->
- let g = Graph_code_cmt.build root skip_list in
+ let g =
+ match lang with
+ | "cmt" -> Graph_code_cmt.build root skip_list
+ | "java" -> Graph_code_java.build ~only_defs:true root skip_list
+ | _ -> raise Impossible
+ in
Graph_code_tags.defs_of_graph_code ~verbose g
- | _ -> failwith "the cmt option accept only a single dir or file"
+ | _ -> failwith "the cmt|java options accept only a single dir or file"
)
| _ -> failwith ("language not supported: " ^ lang)

0 comments on commit f498de0

Please sign in to comment.
Something went wrong with that request. Please try again.