Skip to content

Commit

Permalink
fix(typescript_indexer): remove superfluous BOX (#5780)
Browse files Browse the repository at this point in the history
  • Loading branch information
schroederc committed Aug 9, 2023
1 parent 12a7fe6 commit a47fcd4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 47 deletions.
1 change: 0 additions & 1 deletion kythe/typescript/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,6 @@ class Visitor {
init = narrowedInit || init;
}

codeParts.push({kind: MarkedSourceKind.BOX, pre_text: ' = '});
codeParts.push(
{kind: MarkedSourceKind.INITIALIZER, pre_text: fmtMarkedSource(init.getText())});
}
Expand Down
8 changes: 2 additions & 6 deletions kythe/typescript/testdata/marked_source/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ enum MyEnum {
//- MyValueCode child.1 MyValueId
//- MyValueId.kind "IDENTIFIER"
//- MyValueId.pre_text "MY_VALUE"
//-
//- MyValueCode child.2 MyValueEqual
//- MyValueEqual.kind "BOX"
//- MyValueEqual.pre_text " = "
//-
//- MyValueCode child.3 MyValueInitializer
//- MyValueCode child.2 MyValueInitializer
//- MyValueInitializer.kind "INITIALIZER"
//- MyValueInitializer.pre_text "123"
MY_VALUE = 123,
}
}
6 changes: 1 addition & 5 deletions kythe/typescript/testdata/marked_source/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@
//- ArgCodeType.pre_text ": "
//- ArgCodeType.post_text "string"
//-
//- ArgCode child.3 ArgCodeEqual
//- ArgCodeEqual.kind "BOX"
//- ArgCodeEqual.pre_text " = "
//-
//- ArgCode child.4 ArgCodeDefaultValue
//- ArgCode child.3 ArgCodeDefaultValue
//- ArgCodeDefaultValue.kind "INITIALIZER"
//- ArgCodeDefaultValue.pre_text "'0'"
function myFunction(arg: string = '0'): number {
Expand Down
12 changes: 3 additions & 9 deletions kythe/typescript/testdata/marked_source/property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ class A {
//- MemberName.pre_text "member"
//- MemberCode child.2 MemberTy
//- MemberTy.post_text "string"
//- MemberCode child.3 MemberEq
//- MemberEq.pre_text " = "
//- MemberCode child.4 MemberInit
//- MemberCode child.3 MemberInit
//- MemberInit.pre_text "'member'"
member = 'member';

Expand All @@ -33,9 +31,7 @@ class A {
//- StaticMemberName.pre_text "staticmember"
//- StaticMemberCode child.2 StaticMemberTy
//- StaticMemberTy.post_text "string"
//- StaticMemberCode child.3 StaticMemberEq
//- StaticMemberEq.pre_text " = "
//- StaticMemberCode child.4 StaticMemberInit
//- StaticMemberCode child.3 StaticMemberInit
//- StaticMemberInit.pre_text "'staticmember'"
static staticmember = 'staticmember';
}
Expand All @@ -47,9 +43,7 @@ let b = {
//- BPropName.pre_text "bprop"
//- BPropCode child.1 BPropTy
//- BPropTy.post_text "number"
//- BPropCode child.2 BPropEq
//- BPropEq.pre_text " = "
//- BPropCode child.3 BPropInit
//- BPropCode child.2 BPropInit
//- BPropInit.pre_text "1"
bprop: 1,
};
Expand Down
31 changes: 8 additions & 23 deletions kythe/typescript/testdata/marked_source/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export {}
//- ATy.kind "TYPE"
//- ATy.pre_text ": "
//- ATy.post_text "string"
//- ACode child.2 AEq
//- AEq.kind "BOX"
//- AEq.pre_text " = "
//- ACode child.3 AInit
//- ACode child.2 AInit
//- AInit.kind "INITIALIZER"
//- AInit.pre_text "'text'"
const a: string = 'text';
Expand All @@ -23,9 +20,7 @@ const a: string = 'text';
//- BName.pre_text "b"
//- BCode child.1 BTy
//- BTy.post_text "\"text\""
//- BCode child.2 BEq
//- BEq.pre_text " = "
//- BCode child.3 BInit
//- BCode child.2 BInit
//- BInit.pre_text "'text'"
const b = 'text';

Expand All @@ -35,9 +30,7 @@ const b = 'text';
//- CName.pre_text "c"
//- CCode child.1 CTy
//- CTy.post_text "string"
//- CCode child.2 CEq
//- CEq.pre_text " = "
//- CCode child.3 CInit
//- CCode child.2 CInit
//- CInit.pre_text "'text'"
let c = 'text';

Expand Down Expand Up @@ -67,29 +60,23 @@ try {
//- FName.pre_text "f"
//- FCode child.1 FTy
//- FTy.post_text "number"
//- FCode child.2 FEq
//- FEq.pre_text " = "
//- FCode child.3 FInit
//- FCode child.2 FInit
//- FInit.pre_text "0"
//- @halias defines/binding H
//- H code HCode
//- HCode child.0 HName
//- HName.pre_text "halias"
//- HCode child.1 HTy
//- HTy.post_text "number"
//- HCode child.2 HEq
//- HEq.pre_text " = "
//- HCode child.3 HInit
//- HCode child.2 HInit
//- HInit.pre_text "1"
//- @#0redcat defines/binding Redcat
//- Redcat code RedcatCode
//- RedcatCode child.0 RedcatName
//- RedcatName.pre_text "redcat"
//- RedcatCode child.1 RedcatTy
//- RedcatTy.post_text "number"
//- RedcatCode child.2 RedcatEq
//- RedcatEq.pre_text " = "
//- RedcatCode child.3 RedcatInit
//- RedcatCode child.2 RedcatInit
//- RedcatInit.pre_text "2"
let {f, g: {h: halias}, redcat} = {f: 0, g: {h: 1}, ['redcat']: 2};

Expand All @@ -99,17 +86,15 @@ let {f, g: {h: halias}, redcat} = {f: 0, g: {h: 1}, ['redcat']: 2};
//- IName.pre_text "i"
//- ICode child.1 ITy
//- ITy.post_text "number"
//- ICode child.2 IEq
//- IEq.pre_text " = "
//- ICode child.3 IInit
//- ICode child.2 IInit
//- IInit.pre_text "3"
let [_, [i]] = [2, [3]];

// We can't narrow the initializer of j here, so the initializer should be the
// whole RHS of the variable declaration.
//- @#0j defines/binding J
//- J code JCode
//- JCode child.3 JInit
//- JCode child.2 JInit
//- JInit.pre_text "(() => {\n return {j: 1};\n})()"
let {j} = (() => {
return {j: 1};
Expand Down
4 changes: 1 addition & 3 deletions kythe/typescript/testdata/tsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ function render() {
//- AttrName.pre_text "attr"
//- AttrCode child.1 AttrTy
//- AttrTy.post_text "string"
//- AttrCode child.2 AttrEq
//- AttrEq.pre_text " = "
//- AttrCode child.3 AttrInit
//- AttrCode child.2 AttrInit
//- AttrInit.pre_text "{value}"
//- @+4"src" defines/binding _Src1
//- @+3"value" ref Value
Expand Down

0 comments on commit a47fcd4

Please sign in to comment.