summaryrefslogtreecommitdiff
path: root/tools/ide_query
AgeCommit message (Collapse)Author
2025-02-04Merge "Pass jars to the list of targets." into main Ilshat Aliyev
2025-01-28Fix Cider prober scripts for Android. Stanislav Pyatykh
Change-Id: Ifb8c229c154dae8d42bcac2adfe84ee87f30a8ed
2025-01-24Pass jars to the list of targets. Ilshat Aliyev
Bug: 383594831 Change-Id: I87f00c21ae333fa199c7f1ac336d598b7daf8399
2025-01-22Merge "Link ide_query cc_analyzer README to clang-tools" into main Kadir Çetinkaya
2025-01-21Link ide_query cc_analyzer README to clang-tools Kadir Çetinkaya
Change-Id: I7653c8e6a463a6c13f8fde3ae7dda238065500b7
2025-01-21Disable warnings and errors during include-scanning. Kadir Çetinkaya
This makes include-scanning more robust against incomplete code and version discrepancies between clang-tooling and toolchain clang. Change-Id: I64d7da93f8858c3eec486caabbd651527f7c5262
2025-01-07Added prober tests for testing completion, parameters and diagnostics for ↵ Ilshat Aliyev
java files. The logic of generating ide_query.out will be submitted in a separate change. Change-Id: I88a0b1430136cca651bee2b1847b1613eda303db
2024-11-07Fix ide_query prober script. Ivan Kirichenko
Prober tests are broken, because the ide_query proto format has been changed, but we never tested the change. Regenerated ide_query.out fixes the tests. Also I removed a few lines from regen.sh that are not used anymore after some changes in the ide_query.sh script. Change-Id: Ib7108e6314bdf5935375905a1ec43825db609021
2024-10-23Make the result IDE query deterministic. Ilshat Aliyev
Bug: 375161836 Change-Id: I3e1168f5b7ce94b43ef1e7191b15775c6fcc6312
2024-10-10Assign DependencyIds and GeneratedFiles to the root module. Ilshat Aliyev
Bug: 372458442 Change-Id: I0e713567072aed9f571018317478661299d1c0f9
2024-10-02Merge "Add dependency information to the ide_query output." into main Ilshat Aliyev
2024-09-23Move cog setup logic into shell_utils so it can be used when any of these ↵ Sam Lewis
commands are run: - `m` - `lunch` - `source build/envsetup.sh` this will set up the symlink properly regardless of the order of commands so users don't get stuck with a broken build Bug: 362337892 Change-Id: Ibd3b262107dfc1024cd83ab8aeb33a299fb0ffb2
2024-08-23Add dependency information to the ide_query output. Ilshat Aliyev
Change-Id: I8497549a283a443aedde582593d5f275882f0268
2024-08-01Added a basic prober script to test code completion. Ilshat Aliyev
Run tests locally Change-Id: Id8b8b6b4d9b1fae9d7cd5f04a20c239628351b16
2024-07-10Merge "Update ide_query script to new format" into main Michael Merg
2024-07-02Add prober scripts for language services features Michael Merg
Change-Id: I8c4a39a575f7977c524cfd450cf952b20c8c2c11
2024-06-12Update ide_query script to new format Michael Merg
This includes using a separate (but backward compatible) proto for the cc_analyzer since some of the fields/messages were removed in the new ide_query format. Tested the ide_query.go with the old and the new cc_analyzer to ensure backward compatibility. Change-Id: If149f5f9dd88a8f50c184274e8b258dfce117498
2024-04-18Set enforce SOONG_GEN_COMPDB=1 when running soong for ide_query Michael Merg
Change-Id: I125a82fb07285bf53e9a6d591dee69d85ee82050
2024-03-20Write ide_qeury results to stdout Michael Merg
All other output will be written to stderr. Change-Id: Iefbd8292bb136e4723d5c168e4508ae183585c7c
2024-03-15Make sure ninja keeps going after errors Kadir Çetinkaya
Language services builds are usually executed in a non-building state of the codebase as the user is actively editing the code. This change ensures we can build as many dependencies as possible for language services by ninja. Note that this doesn't change the error-limit for soong itself, i.e. we can still fail-early if we encounter errors while generating ninja files. Change-Id: I594e2ae4591d2e75db082486f28f705833ceb4a8
2024-02-28Add CC analysis support to ide_query Kadir Çetinkaya
Introduces ide_query_cc_analyzer, which figures out relevant build targets that needs to be built for a given C++ source or header file. Once these targets are built, it analyzes the sources in question and reports any generated files that are used back. Full ide_query integration relies on this binary also being available in prebuilts clang-tools, it'll be done in a future patch. Change-Id: Ib0ef6da7a2bc8ecf66940b326e037fb1ee230bf9
2024-02-12Create IDE query script Michael Merg
This will be the integration point to provide build artifacts to Cider G. NOTE FOR REVIEWERS - original patch and result patch are not identical. PLEASE REVIEW CAREFULLY. Diffs between the patches: files := flag.Args() > - > - if prev, ok := modules[f]; ok && !strings.HasSuffix(prev.Name, ".impl") { > - log.Printf("File %q found in module %q but is already part of module %q", f, m.Name, prev.Name) > + if modules[f] != nil { > + log.Printf("File %q found in module %q but is already covered by module %q", f, m.Name, modules[f].Name) > - var genFiles []*pb.GeneratedFile > + var generated []*pb.GeneratedFile > - // Note: Contents will be filled below. > - genFiles = append(genFiles, &pb.GeneratedFile{Path: relPath}) > + contents, err := os.ReadFile(d) > + if err != nil { > + fmt.Printf("Generated file %q not found - will be skipped.\n", d) > + continue > + } > + > + generated = append(generated, &pb.GeneratedFile{ > + Path: relPath, > + Contents: contents, > + }) > - file.Generated = genFiles > + file.Generated = generated > - for _, s := range sources { > - for _, g := range s.GetGenerated() { > - contents, err := os.ReadFile(path.Join(env.OutDir, g.GetPath())) > - if err != nil { > - fmt.Printf("Failed to read generated file %q: %v. File contents will be missing.\n", g.GetPath(), err) > - continue > - } > - g.Contents = contents > - } > - } > - > - if strings.HasSuffix(name, "-jarjar") { > + if strings.HasSuffix(name, "-jarjar") || strings.HasSuffix(name, ".impl") { Original patch: diff --git a/tools/ide_query/ide_query.go b/tools/ide_query/ide_query.go old mode 100644 new mode 100644 --- a/tools/ide_query/ide_query.go +++ b/tools/ide_query/ide_query.go @@ -1,3 +1,5 @@ +// Binary ide_query generates and analyzes build artifacts. +// The produced result can be consumed by IDEs to provide language features. package main import ( @@ -34,10 +36,10 @@ var _ flag.Value = (*LunchTarget)(nil) -// Get implements flag.Value. -func (l *LunchTarget) Get() any { - return l -} +// // Get implements flag.Value. +// func (l *LunchTarget) Get() any { +// return l +// } // Set implements flag.Value. func (l *LunchTarget) Set(s string) error { @@ -64,13 +66,12 @@ env.RepoDir = os.Getenv("TOP") flag.Var(&env.LunchTarget, "lunch_target", "The lunch target to query") flag.Parse() - if flag.NArg() == 0 { + files := flag.Args() + if len(files) == 0 { fmt.Println("No files provided.") os.Exit(1) return } - - files := flag.Args() ctx := context.Background() javaDepsPath := pa [[[Original patch trimmed due to size. Decoded string size: 2916. Decoded string SHA1: 5d8fd4a92cc403da51c9ddb8442da2e391e6fcb1.]]] Result patch: diff --git a/tools/ide_query/ide_query.go b/tools/ide_query/ide_query.go index 2e76738..0fdb6de 100644 --- a/tools/ide_query/ide_query.go +++ b/tools/ide_query/ide_query.go @@ -1,3 +1,5 @@ +// Binary ide_query generates and analyzes build artifacts. +// The produced result can be consumed by IDEs to provide language features. package main import ( @@ -34,10 +36,10 @@ var _ flag.Value = (*LunchTarget)(nil) -// Get implements flag.Value. -func (l *LunchTarget) Get() any { - return l -} +// // Get implements flag.Value. +// func (l *LunchTarget) Get() any { +// return l +// } // Set implements flag.Value. func (l *LunchTarget) Set(s string) error { @@ -64,14 +66,13 @@ env.RepoDir = os.Getenv("TOP") flag.Var(&env.LunchTarget, "lunch_target", "The lunch target to query") flag.Parse() - if flag.NArg() == 0 { + files := flag.Args() + if len(files) == 0 { fmt.Println("No files provided.") os.Exit(1) return } - files := flag.Args() - ctx := context.Background() javaDepsPath := path [[[Result patch trimmed due to size. Decoded string size: 3022. Decoded string SHA1: a8824749eafbbb8d09c4e95fe491a16e3ea82569.]]] NOTE FOR REVIEWERS - original patch and result patch are not identical. PLEASE REVIEW CAREFULLY. Diffs between the patches: var javaFiles []string > + for _, f := range files { > + switch { > + case strings.HasSuffix(f, ".java") || strings.HasSuffix(f, ".kt"): > + javaFiles = append(javaFiles, f) > + default: > + log.Printf("File %q is supported - will be skipped.", f) > + } > + } > + > - modules := make(map[string]*javaModule) // file path -> module > - for _, f := range files { > + fileToModule := make(map[string]*javaModule) // file path -> module > + for _, f := range javaFiles { > - if modules[f] != nil { > - log.Printf("File %q found in module %q but is already covered by module %q", f, m.Name, modules[f].Name) > + if fileToModule[f] != nil { > + // TODO(michaelmerg): Handle the case where a file is covered by multiple modules. > + log.Printf("File %q found in module %q but is already covered by module %q", f, m.Name, fileToModule[f].Name) > - modules[f] = m > + fileToModule[f] = m > - for _, m := range modules { > + for _, m := range fileToModule { > + type depsAndGenerated struct { > + Deps []string > + Generated []*pb.GeneratedFile > + } > + moduleToDeps := make(map[string]*depsAndGenerated) > - m := modules[f] > + m := fileToModule[f] > + file.Status = &pb.Status{Code: pb.Status_OK} > + if moduleToDeps[m.Name] != nil { > + file.Generated = moduleToDeps[m.Name].Generated > + file.Deps = moduleToDeps[m.Name].Deps > + continue > + } > + > - > + moduleToDeps[m.Name] = &depsAndGenerated{deps, generated} > - file.Status = &pb.Status{Code: pb.Status_OK} Original patch: diff --git a/tools/ide_query/ide_query.go b/tools/ide_query/ide_query.go old mode 100644 new mode 100644 --- a/tools/ide_query/ide_query.go +++ b/tools/ide_query/ide_query.go @@ -72,6 +72,16 @@ os.Exit(1) return } + + var javaFiles []string + for _, f := range files { + switch { + case strings.HasSuffix(f, ".java") || strings.HasSuffix(f, ".kt"): + javaFiles = append(javaFiles, f) + default: + log.Printf("File %q is supported - will be skipped.", f) + } + } ctx := context.Background() javaDepsPath := path.Join(env.RepoDir, env.OutDir, "soong/module_bp_java_deps.json") @@ -85,22 +95,23 @@ log.Fatalf("Failed to load java modules: %v", err) } - modules := make(map[string]*javaModule) // file path -> module - for _, f := range files { + fileToModule := make(map[string]*javaModule) // file path -> module + for _, f := range javaFiles { for _, m := range javaModules { if !slices.Contains(m.Srcs, f) { continue } - if modules[f] != nil { - log.Printf("File %q found in [[[Original patch trimmed due to size. Decoded string size: 2629. Decoded string SHA1: 4517ba713fdb898ba9d77c4acbe934c08a2d9fe0.]]] Result patch: diff --git a/tools/ide_query/ide_query.go b/tools/ide_query/ide_query.go index 0fdb6de..7335875 100644 --- a/tools/ide_query/ide_query.go +++ b/tools/ide_query/ide_query.go @@ -73,6 +73,16 @@ return } + var javaFiles []string + for _, f := range files { + switch { + case strings.HasSuffix(f, ".java") || strings.HasSuffix(f, ".kt"): + javaFiles = append(javaFiles, f) + default: + log.Printf("File %q is supported - will be skipped.", f) + } + } + ctx := context.Background() javaDepsPath := path.Join(env.RepoDir, env.OutDir, "soong/module_bp_java_deps.json") // TODO(michaelmerg): Figure out if module_bp_java_deps.json is outdated. @@ -85,22 +95,23 @@ log.Fatalf("Failed to load java modules: %v", err) } - modules := make(map[string]*javaModule) // file path -> module - for _, f := range files { + fileToModule := make(map[string]*javaModule) // file path -> module + for _, f := range javaFiles { for _, m := range javaModules { if !slices.Contains(m.Srcs, f) { continue } [[[Result patch trimmed due to size. Decoded string size: 2717. Decoded string SHA1: 5e5223251ebdc548258bc27daf3528d662c39410.]]] Change-Id: Ibe5d386399affd2951206bb5a714972e0e2fee92