Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kythe/go/services/xrefs/xrefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ func IsCallerKind(requestedKind xpb.CrossReferencesRequest_CallerKind, edgeKind
}
}

// IsSpeculative returns whether the edge kind is considered speculative.
func IsSpeculative(edgeKind string) bool {
return edgeKind == internalCallerKindOverride || strings.HasSuffix(edgeKind, "/thunk")
}

// ConvertFilters converts each filter glob into an equivalent regexp.
func ConvertFilters(filters []string) []*regexp.Regexp {
var patterns []*regexp.Regexp
Expand Down
9 changes: 8 additions & 1 deletion kythe/go/serving/xrefs/xrefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,8 @@ func (s *refStats) addCallers(crs *xpb.CrossReferencesReply_CrossReferenceSet, g
Anchor: converter.Convert(c.Caller).Anchor,
Ticket: c.SemanticCaller,
Site: make([]*xpb.Anchor, 0, len(c.Callsite)),

Speculative: xrefs.IsSpeculative(grp.GetKind()),
}
ra.MarkedSource = c.MarkedSource
for _, site := range c.Callsite {
Expand Down Expand Up @@ -1474,6 +1476,8 @@ func (s *refStats) addAnchors(to *[]*xpb.CrossReferencesReply_RelatedAnchor, grp
Anchor: scope,
Ticket: sr.SemanticScope,
Site: make([]*xpb.Anchor, 0, len(sr.Reference)),

Speculative: xrefs.IsSpeculative(grp.GetKind()),
}
ra.MarkedSource = sr.MarkedSource
refs := sr.GetReference()
Expand Down Expand Up @@ -1528,7 +1532,10 @@ func (c *anchorConverter) Convert(a *srvpb.ExpandedAnchor) *xpb.CrossReferencesR
SnippetSpan: a.SnippetSpan,
BuildConfig: a.BuildConfiguration,
Revision: fileInfo.GetRevision(),
}}
},

Speculative: xrefs.IsSpeculative(a.GetKind()),
}
}

type documentConverter struct {
Expand Down
2 changes: 2 additions & 0 deletions kythe/go/serving/xrefs/xrefs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2865,6 +2865,7 @@ func TestCrossReferencesOverrideCallers(t *testing.T) {
Parent: "kythe:?path=someFile",
}},
}, {
Speculative: true,
Anchor: &xpb.Anchor{
Ticket: "kythe:?path=someFile#someOverrideCallerAnchor1",
Parent: "kythe:?path=someFile",
Expand All @@ -2876,6 +2877,7 @@ func TestCrossReferencesOverrideCallers(t *testing.T) {
Span: arbitrarySpan,
}},
}, {
Speculative: true,
Anchor: &xpb.Anchor{
Ticket: "kythe:?path=someFile#someOverrideCallerAnchor2",
Parent: "kythe:?path=someFile",
Expand Down
8 changes: 7 additions & 1 deletion kythe/proto/xref.proto
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ message CrossReferencesRequest {
// Callgraph information will be populated in the CrossReferencesReply.
DIRECT_CALLERS = 1;
// Callgraph information will be populated in the CrossReferencesReply.
// Calls to override-related functions will also be considered.
// Calls to override-related functions will also be considered and each
// RelatedAnchor will be marked as speculative.
OVERRIDE_CALLERS = 2;
}

Expand Down Expand Up @@ -539,6 +540,11 @@ message CrossReferencesReply {
// references.
string ticket = 4;

// Whether the anchor, and its sites, are speculative and may not be precise
// with respect to a program's execution. Examples include callsites that
// may occur through dynamic dispatch or ref/writes/thunk locations.
bool speculative = 6;

reserved 2;
}

Expand Down
Loading