Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): support MarkedSource MODIFIER type #5778

Merged
merged 2 commits into from
Aug 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions kythe/cxx/verifier/verifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ Verifier::Verifier(bool trace_lex, bool trace_parse)
marked_source_context_id_ = IdentifierFor(builtin_location_, "CONTEXT");
marked_source_initializer_id_ =
IdentifierFor(builtin_location_, "INITIALIZER");
marked_source_modifier_id_ = IdentifierFor(builtin_location_, "MODIFIER");
marked_source_parameter_lookup_by_param_id_ =
IdentifierFor(builtin_location_, "PARAMETER_LOOKUP_BY_PARAM");
marked_source_lookup_by_param_id_ =
Expand Down Expand Up @@ -1420,6 +1421,9 @@ AstNode* Verifier::ConvertMarkedSource(
case proto::common::MarkedSource::INITIALIZER:
emit_fact(marked_source_kind_id_, marked_source_initializer_id_);
break;
case proto::common::MarkedSource::MODIFIER:
emit_fact(marked_source_kind_id_, marked_source_modifier_id_);
break;
case proto::common::MarkedSource::PARAMETER_LOOKUP_BY_PARAM:
emit_fact(marked_source_kind_id_,
marked_source_parameter_lookup_by_param_id_);
Expand Down
3 changes: 3 additions & 0 deletions kythe/cxx/verifier/verifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ class Verifier {
/// Identifier for MarkedSource INITIALIZER kinds.
AstNode* marked_source_initializer_id_;

/// Identifier for MarkedSource MODIFIER kinds.
AstNode* marked_source_modifier_id_;

/// Identifier for MarkedSource PARAMETER_LOOKUP_BY_PARAM kinds.
AstNode* marked_source_parameter_lookup_by_param_id_;

Expand Down
8 changes: 6 additions & 2 deletions kythe/go/indexer/markedsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ func (pi *PackageInfo) MarkedSource(obj types.Object) *cpb.MarkedSource {
// Methods: func (R) Name(p1, ...) (r0, ...)
// Functions: func Name(p0, ...) (r0, ...)
fn := &cpb.MarkedSource{
Kind: cpb.MarkedSource_BOX,
Child: []*cpb.MarkedSource{{PreText: "func "}},
Kind: cpb.MarkedSource_BOX,
Child: []*cpb.MarkedSource{{
Kind: cpb.MarkedSource_MODIFIER,
PreText: "func",
PostText: " ",
}},
}
sig := t.Type().(*types.Signature)
firstParam := 0
Expand Down
8 changes: 6 additions & 2 deletions kythe/go/indexer/testdata/code/funcdecl.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ package funcdecl
// - PosCode child.3 PCResult // result
// -
// - //--------------------------------------------------
// - PCFunc.pre_text "func "
// - PCFunc.kind "MODIFIER"
// - PCFunc.pre_text "func"
// - PCFunc.post_text " "
// -
// - PCName child.0 PCContext
// - PCName child.1 PCIdent
Expand Down Expand Up @@ -75,7 +77,9 @@ func Positive(x int) bool {
// - TrueCode child.2 TCParams
// - TrueCode child.3 TCResult
// -
// - TCFunc.pre_text "func "
// - TCFunc.kind "MODIFIER"
// - TCFunc.pre_text "func"
// - TCFunc.post_text " "
// -
// - TCName child.0 _TCContext
// - TCName child.1 _TCIdent
Expand Down
4 changes: 3 additions & 1 deletion kythe/go/indexer/testdata/code/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ type Thinger interface {
//- MCode child.2 MName
//- MCode child.3 MParams
//-
//- MFunc.pre_text "func "
//- MFunc.kind "MODIFIER"
//- MFunc.pre_text "func"
//- MFunc.post_text " "
//-
//- MRecv.kind "PARAMETER"
//- MRecv.pre_text "("
Expand Down
8 changes: 6 additions & 2 deletions kythe/go/indexer/testdata/code/methdecl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ type w struct{}
// - LTCode child.3 LTParams
// - LTCode child.4 LTResult
// -
// - LTFunc.pre_text "func "
// - LTFunc.kind "MODIFIER"
// - LTFunc.pre_text "func"
// - LTFunc.post_text " "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that eventually we want to make this space part of the post_child_text of the enclosing BOX (but that's a larger refactoring that doesn't belong in this change).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it matters in this particular case.

// -
// - LTRecv.kind "PARAMETER"
// - LTRecv.pre_text "("
Expand Down Expand Up @@ -80,7 +82,9 @@ type API struct{}
// - RFCode child.3 RFParams
// - RFCode child.4 RFResult
// -
// - RFFunc.pre_text "func "
// - RFFunc.kind "MODIFIER"
// - RFFunc.pre_text "func"
// - RFFunc.post_text " "
// -
// - RFRecv.kind "PARAMETER"
// - RFRecv.pre_text "("
Expand Down
2 changes: 2 additions & 0 deletions kythe/proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ message MarkedSource {
CONTEXT = 4;
// This node dominates nodes that should be classified as initializers.
INITIALIZER = 5;
// This node dominates nodes that should be classified as modifiers.
MODIFIER = 12;
// Substitute this node with a PARAMETER formed from the param edges from
// the context node starting with `lookup_index`.
PARAMETER_LOOKUP_BY_PARAM = 6;
Expand Down
114 changes: 59 additions & 55 deletions kythe/proto/common_go_proto/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.