Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
20eaf59
feat(lang): parse .jsx files and the scripts of Vue, Svelte and Astro…
claude Nov 14, 2026
06d9c1f
merge reach-mvp/jsparse
claude Nov 14, 2026
2a4877b
fix(indexer): store the finished files of a batch when the context en…
claude Nov 14, 2026
60b80b4
merge reach-mvp/indexflush
claude Nov 14, 2026
c42c228
test(projectgraph): link the Go standard library in the method measur…
claude Nov 14, 2026
32ad6c4
test(projectgraph): check the Go answers of the method measure agains…
claude Nov 14, 2026
159784f
fix(projectgraph): record the Rust ? and skip builtins in the chained…
claude Nov 14, 2026
a31cf33
fix(indexer): link a Rust method call on a boxed trait object (FOU-578)
claude Nov 14, 2026
716f4c3
merge reach-mvp/rustdyn
claude Nov 14, 2026
4d2283e
docs(projectgraph): report the standard library unit and the govulnch…
claude Nov 14, 2026
3291fc3
fix(projectgraph): keep the method name of an ambiguous call (FOU-557)
claude Nov 14, 2026
734029a
merge reach-mvp/measure
claude Nov 14, 2026
b9adbc6
fix(projectgraph): index Go fields, constants and variables (FOU-558)
claude Nov 14, 2026
eebbedd
fix(projectgraph): bind a Go import whose path has one element (FOU-558)
claude Nov 14, 2026
a91ee1c
merge reach-mvp/goindex
claude Nov 14, 2026
b8b3581
fix(projectgraph): a Go call of a function value names no target (FOU…
claude Nov 14, 2026
f5d49c7
docs(projectgraph): keep the unknown code of a unit global, with guar…
claude Nov 14, 2026
8daf3d3
merge reach-mvp/scope
claude Nov 14, 2026
050c634
test(projectgraph): update two Go cases for the merge of FOU-558 and …
claude Nov 14, 2026
cbac552
fix(projectgraph): link Rust extern crate, pub use of a crate and typ…
claude Nov 14, 2026
4f4fdfd
merge reach-mvp/rustpaths
claude Nov 14, 2026
02dba3b
fix(projectgraph): give a Go definition of an internal package its ex…
claude Nov 14, 2026
7a857ff
fix(projectgraph): record Go code outside the graph that can call bac…
claude Nov 14, 2026
ef62742
merge reach-mvp/soundfix
claude Nov 14, 2026
b86cb26
chore: bump fileindex, projectgraph, reach and summary versions
claude Nov 14, 2026
305936f
fix(projectgraph): keep the record of a call on the result of a built…
claude Nov 14, 2026
7027f96
refactor(parser): pick the source of a file once (FOU-576)
claude Nov 14, 2026
9e47c25
fix(indexer): record the markup of a component file (FOU-576)
claude Nov 14, 2026
b713d22
fix(indexer): give a JSX element name a reference (FOU-576)
claude Nov 14, 2026
1f112f6
fix(projectgraph): resolve a Rust use path through a use of its modul…
claude Nov 14, 2026
644b14c
fix(indexer): record each form of a Go function value (FOU-560)
claude Nov 14, 2026
24f854b
fix(indexer): keep a Go var value that names a function in a skeleton…
claude Nov 14, 2026
32eabd9
refactor(projectgraph): read the definitions of code through one acce…
claude Nov 14, 2026
289092c
refactor(projectgraph): move the Go rules of the link step behind the…
claude Nov 14, 2026
7f5e284
refactor(indexer): add definitions through one helper (FOU-558)
claude Nov 14, 2026
39eae86
fix(reach): count the uncertainties of the code that a scope reaches …
claude Nov 14, 2026
078534f
refactor(indexer): look up a local of a Go function by its name (FOU-…
claude Nov 14, 2026
757384c
fix(projectgraph): give a Go method record the records of code outsid…
claude Nov 14, 2026
61fc34e
fix(indexer): check every Rust binder of a name before a typed call (…
claude Nov 14, 2026
0a5eebd
refactor(projectgraph): give the Rust path ladder one owner
claude Nov 14, 2026
3976311
refactor(langcode): ask for a smart pointer by language with IsPointer
claude Nov 14, 2026
ecfc33c
docs(fileindex): say why a Go type alias stays a class
claude Nov 14, 2026
782faad
merge reach-mvp/fix-component
claude Nov 14, 2026
40b327f
fix(indexer): count a Rust static or const in its whole block (FOU-562)
claude Nov 14, 2026
11cdc0a
merge reach-mvp/fix-reach
claude Nov 14, 2026
3fad7a9
merge reach-mvp/fix-rust
claude Nov 14, 2026
65b7c53
merge reach-mvp/fix-goindex
claude Nov 14, 2026
dc74154
fix(projectgraph): link the item that a Rust use path names
claude Nov 14, 2026
2e0f3d6
merge reach-mvp/fix-rustuse
claude Nov 14, 2026
4eb15e5
fix(reach): enter the load code of a package from a source (FOU-560)
claude Nov 14, 2026
780969e
merge reach-mvp/fix-sources
claude Nov 14, 2026
4e81cee
test(projectgraph): update the hash rows for the review fixes
claude Nov 14, 2026
ce5470d
docs(projectgraph): report the method measure of the reach MVP branch
claude Nov 14, 2026
45ac9a0
fix(indexer): keep a Rust declared type only where the root means it …
claude Nov 14, 2026
2984fc1
merge reach-mvp/fix-c2
claude Nov 14, 2026
ab6e59d
fix(reach): count a call of a function value in a search with a sourc…
claude Nov 14, 2026
e16286a
fix(projectgraph): keep the method name of an ambiguous site only whe…
claude Nov 14, 2026
f7ce031
merge reach-mvp/fix-c13
claude Nov 14, 2026
ac0bd9a
test(projectgraph): update the hash rows for the second review fixes
claude Nov 14, 2026
7f6516e
docs(projectgraph): update the method measure of the reach MVP branch
claude Nov 14, 2026
c799adb
fix(reach): let a method record concern the aliases of its name (FOU-…
claude Nov 14, 2026
4e7940d
fix(indexer): keep a predeclared Go name as a reference (FOU-560)
claude Nov 14, 2026
93b9a3c
fix(projectgraph): treat a Go plugin as reflection (FOU-560)
claude Nov 14, 2026
06577da
test(projectgraph): update the hash rows for the fixes of the PR review
claude Nov 14, 2026
c642d32
fix(indexer): check the scope of a typed Go local before it hides a name
claude Nov 14, 2026
a2e1594
fix(projectgraph): record a Go call of a field or a variable as a fun…
claude Nov 14, 2026
f5a7c1d
test(projectgraph): case for a Rust alias that replaces a struct of t…
claude Nov 15, 2026
3ca4e6b
test(projectgraph): case for a JSX spread attribute in a .jsx file
claude Nov 15, 2026
b0315ff
test(projectgraph): case for a Rust module that a glob use brings int…
claude Nov 15, 2026
88d6dee
fix(projectgraph): bind no type for a Rust alias with a second declar…
claude Nov 15, 2026
6ae2983
fix(indexer): read the object of a JSX spread attribute
claude Nov 15, 2026
a693376
fix(projectgraph): resolve a Rust path through a glob use of the file
claude Nov 15, 2026
a823841
fix(indexer): sort the functions that a JSX spread passes
claude Nov 15, 2026
3e3539d
test(projectgraph): update the hash rows for the fixes of review 4
claude Nov 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
env:
PROJECTGRAPH_PUBLIC_REPORT: ${{ runner.temp }}/public.txt
PROJECTGRAPH_GOVULNCHECK_REPORT: ${{ runner.temp }}/govulncheck.txt
run: go test -tags projectgraph -run 'TestPublicSets|TestGovulncheckTraces' -count=1 ./test/projectgraph/
run: go test -tags projectgraph -run 'TestPublicSets|TestGovulncheckTraces|TestVulnAgreement' -count=1 ./test/projectgraph/

- name: Check the gates
run: bash scripts/check_projectgraph_gates.sh "$RUNNER_TEMP/public.txt" "$RUNNER_TEMP/govulncheck.txt" pycg-micro=0.95
43 changes: 43 additions & 0 deletions core/language.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,46 @@ type Language interface {
type GrammarSelector interface {
LanguageForExtension(ext string) Language
}

// SourceSelector is an optional interface of a Language whose files of some
// extensions hold their code in blocks among markup, as the script blocks
// of a Vue component. Source returns the source of the data of a file of
// the extension. A file of another extension gives the Language and data.
type SourceSelector interface {
Source(ext string, data []byte) Source
}

// Source is what the grammar of a file parses.
type Source struct {
Language Language
// Code is data with each byte outside the code replaced by a space. It
// keeps the offsets and the line ends of data, so a node reports its
// line and column in the file, and its content in data.
Code []byte
// Markup is what the file holds outside the code, or nil.
Markup *Markup
}

// Markup is the part of a file that the grammar does not parse, as the
// template of a Vue component. The framework of the file runs it.
type Markup struct {
// Offset is the offset of the first byte of the markup that is no
// space.
Offset int
// Scripts are the script elements that load a file, in file order.
Scripts []Script
}

// Script is a script element that loads a file, as <script src="./a.js">.
type Script struct {
// Src is the src attribute as written, as ./a.js.
Src string
// Offset is the offset of the element.
Offset int
}

// MarkupTree is an optional interface of a ParseTree. Markup returns the
// markup of the file of the tree, or nil.
type MarkupTree interface {
Markup() *Markup
}
570 changes: 557 additions & 13 deletions docs/projectgraph.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/projectgraph/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestExampleSearchesFromASource(t *testing.T) {

out, err = exec.Command(bin, "-dir", deadCallCase, "-source", "handlers.py:load_old", "-sources-only", "-target", "json//load").CombinedOutput()
require.NoError(t, err, string(out))
assert.Equal(t, "json//load: not-found\n call at handlers.py:8 in handlers.py//parse, which no root reaches\n searched 1 roots, 3 nodes, 2 edges\n", string(out))
assert.Equal(t, "json//load: not-found\n call at handlers.py:8 in handlers.py//parse, which no root reaches\n searched 1 roots, 4 nodes, 4 edges\n", string(out))

cmd := exec.Command(bin, "-dir", deadCallCase, "-source", "handlers.py:load_odl", "-target", "yaml//load")
var stderr strings.Builder
Expand Down
66 changes: 60 additions & 6 deletions fileindex/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"cmp"
"crypto/sha256"
"encoding/hex"
"iter"
"slices"
"strings"

Expand All @@ -19,7 +20,7 @@ import (
// Version is the version of the index records and of the rules that fill
// them. Bump it when a field, a kind, an order or a fill rule changes. A
// store keys an index by Version, so the bump makes every older index miss.
const Version = "15"
const Version = "16"

// DefaultTestPaths are the globs that mark the test files of the common
// layouts, as projectgraph.Options.TestPaths takes them. A glob with no "/"
Expand Down Expand Up @@ -57,8 +58,23 @@ const (
// DefInterface is a TypeScript or Go interface. It has no code, but a
// declared type can name it and a class can implement it.
DefInterface DefKind = "interface"
// DefField is a named field of a Go struct, under the key of its type,
// as Node//Data. It holds data and no code.
DefField DefKind = "field"
// DefConstant is a constant of a Go package. It holds data and no code.
DefConstant DefKind = "constant"
// DefAlias is a type alias, as type A = B of Rust. It has no code. A
// path through it goes on to the type that it names. A Go alias stays
// a class with the type that it names as its base, because a Go method
// can name the alias as its receiver, so the alias holds methods.
DefAlias DefKind = "alias"
)

// TryName is the name that a ? of Rust takes in a call target, as
// dep//load//?//run for dep::load()?.run(). The ? gives the value inside
// an Option or a Result, so the name after it is a name of that value.
const TryName = "?"

type CallKind string

const (
Expand Down Expand Up @@ -96,8 +112,19 @@ const (
UnresolvedTraitReceiver UnresolvedReason = "trait-receiver"
// UnresolvedNoDependencySource is a call on a value whose type comes
// from a package with no code in the graph, as the result of a
// function of a module that no unit gives.
// function of a module that no unit gives, or an external key of such a
// package, whose code can call back into the graph.
UnresolvedNoDependencySource UnresolvedReason = "no-dependency-source"
// UnresolvedFunctionValue is a call of a function value, as f(x)(y) or
// handlers[i](c), in a language whose function values the link step
// joins to the code that holds them. The link step gives the reason
// in place of computed-name, and the record names no target.
UnresolvedFunctionValue UnresolvedReason = "function-value"
// UnresolvedMarkup is the markup of a component file, as the template
// of a Vue component, which the index does not parse. The framework
// runs the markup and calls the functions of the component, so the
// record can name any target.
UnresolvedMarkup UnresolvedReason = "markup"
)

type FlagKind string
Expand Down Expand Up @@ -206,9 +233,10 @@ type Export struct {
}

// Definition is one module, function, method, class, constructor, module
// variable or interface. Key is its symbol key, as src/a.py//Parser//parse.
// Parent is the class key of a method. A JavaScript function that an object
// property or a property assignment holds is a method with no parent.
// variable, interface, field or constant. Key is its symbol key, as
// src/a.py//Parser//parse. Parent is the class key of a method or a
// field. A JavaScript function that an object property or a property
// assignment holds is a method with no parent.
// Decorators are as written, in source order, and hold the annotations of
// a Java definition. Values are the per-file targets that a variable
// holds, as the targets of a Call. Params are the parameters that declare
Expand All @@ -223,7 +251,8 @@ type Export struct {
// "" for a result with no named type. Wraps names the Option or the Result
// that holds the result of a Rust function, and Returns then names the
// type inside, as Thing for -> Option<Thing>. Static marks a static method
// of Java.
// of Java. Data marks a Go variable whose value the source shows is no
// function, as var n int or var ErrX = errors.New("x").
type Definition struct {
Key string `json:"key"`
Kind DefKind `json:"kind"`
Expand All @@ -242,7 +271,18 @@ type Definition struct {
Results []string `json:"results,omitempty"`
Wraps string `json:"wraps,omitempty"`
Static bool `json:"static,omitempty"`
Data bool `json:"data,omitempty"`
Flags []Flag `json:"flags,omitempty"`
// Alias is the type that a DefAlias names, as written, with no type
// arguments, as B for type A = B<u8>.
Alias string `json:"alias,omitempty"`
}

// HoldsData reports whether the definition holds data and no code: a
// field, a constant or a variable with Data. A read of it runs no code, and
// a call of it does not compile.
func (d Definition) HoldsData() bool {
return d.Kind == DefField || d.Kind == DefConstant || d.Data
}

// Class is one class or interface of the file. Bases are as written, in
Expand Down Expand Up @@ -452,6 +492,19 @@ func (ix *Index) ExternalCalls() []Call {
return calls
}

// CodeDefinitions returns the definitions of the file that hold code, in
// the order of Definitions. A definition of data runs no code, so the graph
// has no node for it and no root or caller is one.
func (ix *Index) CodeDefinitions() iter.Seq[*Definition] {
return func(yield func(*Definition) bool) {
for i := range ix.Definitions {
if !ix.Definitions[i].HoldsData() && !yield(&ix.Definitions[i]) {
return
}
}
}
}

// DynamicSites returns the flags of the file and of its definitions, by line.
func (ix *Index) DynamicSites() []Flag {
flags := slices.Clone(ix.Flags)
Expand Down Expand Up @@ -624,6 +677,7 @@ func (ix *Index) EachString(fn func(string) string) {
kind(&def.Returns)
strs(def.Results)
kind(&def.Wraps)
kind(&def.Alias)
flags(def.Flags)
}
for i := range ix.Classes {
Expand Down
2 changes: 1 addition & 1 deletion fileindex/testdata/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "15",
"version": "16",
"path": "src/app.py",
"language": "python",
"content_hash": "a172cedcae47474b615c54d510a5d84a8dea3032e958587430b413538be3f333",
Expand Down
Loading
Loading