Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typescript): emit marked sources for functions, classes and enums (
#5578) Co-authored-by: Shahms King <shahms@google.com>
- Loading branch information
1 parent
2da2dcf
commit 02c7c21
Showing
4 changed files
with
229 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
//- @MyClass defines/binding MyClass | ||
//- | ||
//- MyClass code MyClassCode | ||
//- MyClassCode.kind "IDENTIFIER" | ||
//- MyClassCode.pre_text "MyClass" | ||
class MyClass { | ||
constructor(arg: string) {} | ||
|
||
//- @myMethod defines/binding MyMethod | ||
//- | ||
//- MyMethod code MyMethodCode | ||
//- MyMethodCode.kind "BOX" | ||
//- | ||
//- MyMethodCode child.0 MyMethodContext | ||
//- MyMethodContext.kind "CONTEXT" | ||
//- MyMethodContext.pre_text "(method)" | ||
//- | ||
//- MyMethodCode child.1 MyMethodSpace | ||
//- MyMethodSpace.pre_text " " | ||
//- | ||
//- MyMethodCode child.2 MyMethodCodeId | ||
//- MyMethodCodeId.kind "IDENTIFIER" | ||
//- MyMethodCodeId.pre_text "myMethod" | ||
//- | ||
//- MyMethodCode child.3 MyMethodParams | ||
//- MyMethodParams.kind "PARAMETER_LOOKUP_BY_PARAM" | ||
//- MyMethodParams.pre_text "(" | ||
//- MyMethodParams.post_text ")" | ||
//- MyMethodParams.post_child_text ", " | ||
//- | ||
//- MyMethodCode child.4 MyMethodReturnType | ||
//- MyMethodReturnType.kind "TYPE" | ||
//- MyMethodReturnType.pre_text ": " | ||
//- MyMethodReturnType.post_text "MyClass" | ||
//- | ||
//- @arg defines/binding Arg | ||
//- Arg code ArgCode | ||
//- ArgCode.kind "BOX" | ||
//- | ||
//- ArgCode child.0 ArgCodeContext | ||
//- ArgCodeContext.kind "CONTEXT" | ||
//- ArgCodeContext.pre_text "(parameter)" | ||
//- | ||
//- ArgCode child.1 ArgCodeSpace | ||
//- ArgCodeSpace.pre_text " " | ||
//- | ||
//- ArgCode child.2 ArgCodeId | ||
//- ArgCodeId.kind "IDENTIFIER" | ||
//- ArgCodeId.pre_text "arg" | ||
//- | ||
//- ArgCode child.3 ArgCodeType | ||
//- ArgCodeType.kind "TYPE" | ||
//- ArgCodeType.pre_text ": " | ||
//- ArgCodeType.post_text "number" | ||
myMethod(arg: number): MyClass { | ||
return this; | ||
} | ||
|
||
// Test that return type is inferred. | ||
//- @returnNumber defines/binding ReturnNumber | ||
//- ReturnNumber code ReturnNumberCode | ||
//- ReturnNumberCode child.4 ReturnNumberType | ||
//- ReturnNumberType.kind "TYPE" | ||
//- ReturnNumberType.pre_text ": " | ||
//- ReturnNumberType.post_text "number" | ||
returnNumber() { | ||
return 42; | ||
} | ||
} | ||
|
||
//- @MyInterface defines/binding MyInterface | ||
//- | ||
//- MyInterface code MyInterfaceCode | ||
//- MyInterfaceCode.kind "IDENTIFIER" | ||
//- MyInterfaceCode.pre_text "MyInterface" | ||
interface MyInterface {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
//- @MyEnum defines/binding MyEnum | ||
//- | ||
//- MyEnum code MyEnumCode | ||
//- MyEnumCode.kind "IDENTIFIER" | ||
//- MyEnumCode.pre_text "MyEnum" | ||
enum MyEnum { | ||
|
||
//- @MY_VALUE defines/binding MyValue | ||
//- | ||
//- MyValue code MyValueCode | ||
//- MyValueCode.kind "BOX" | ||
//- | ||
//- MyValueCode child.0 MyValueContext | ||
//- MyValueContext.kind "CONTEXT" | ||
//- MyValueContext.pre_text "(enum member)" | ||
//- | ||
//- MyValueCode child.1 MyValueSpace | ||
//- MyValueSpace.pre_text " " | ||
//- | ||
//- MyValueCode child.2 MyValueId | ||
//- MyValueId.kind "IDENTIFIER" | ||
//- MyValueId.pre_text "MY_VALUE" | ||
//- | ||
//- MyValueCode child.3 MyValueEqual | ||
//- MyValueEqual.kind "BOX" | ||
//- MyValueEqual.pre_text " = " | ||
//- | ||
//- MyValueCode child.4 MyValueInitializer | ||
//- MyValueInitializer.kind "INITIALIZER" | ||
//- MyValueInitializer.pre_text "123" | ||
MY_VALUE = 123, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
//- @myFunction defines/binding MyFunction | ||
//- MyFunction code MyFunctionCode | ||
//- | ||
//- MyFunctionCode child.0 MyFunctionContext | ||
//- MyFunctionContext.kind "CONTEXT" | ||
//- MyFunctionContext.pre_text "function" | ||
//- | ||
//- MyFunctionCode child.1 MyFunctionSpace | ||
//- MyFunctionSpace.pre_text " " | ||
//- | ||
//- MyFunctionCode child.2 MyFunctionName | ||
//- MyFunctionName.kind "IDENTIFIER" | ||
//- MyFunctionName.pre_text "myFunction" | ||
//- | ||
//- MyFunctionCode child.3 MyFunctionParams | ||
//- MyFunctionParams.kind "PARAMETER_LOOKUP_BY_PARAM" | ||
//- MyFunctionParams.pre_text "(" | ||
//- MyFunctionParams.post_text ")" | ||
//- MyFunctionParams.post_child_text ", " | ||
//- | ||
//- MyFunctionCode child.4 MyFunctionReturnType | ||
//- MyFunctionReturnType.kind "TYPE" | ||
//- MyFunctionReturnType.pre_text ": " | ||
//- MyFunctionReturnType.post_text "number" | ||
//- | ||
//- @arg defines/binding Arg | ||
//- Arg code ArgCode | ||
//- ArgCode.kind "BOX" | ||
//- | ||
//- ArgCode child.0 ArgCodeContext | ||
//- ArgCodeContext.kind "CONTEXT" | ||
//- ArgCodeContext.pre_text "(parameter)" | ||
//- | ||
//- ArgCode child.1 ArgCodeSpace | ||
//- ArgCodeSpace.pre_text " " | ||
//- | ||
//- ArgCode child.2 ArgCodeId | ||
//- ArgCodeId.kind "IDENTIFIER" | ||
//- ArgCodeId.pre_text "arg" | ||
//- | ||
//- ArgCode child.3 ArgCodeType | ||
//- ArgCodeType.kind "TYPE" | ||
//- ArgCodeType.pre_text ": " | ||
//- ArgCodeType.post_text "string" | ||
//- | ||
//- ArgCode child.4 ArgCodeEqual | ||
//- ArgCodeEqual.kind "BOX" | ||
//- ArgCodeEqual.pre_text " = " | ||
//- | ||
//- ArgCode child.5 ArgCodeDefaultValue | ||
//- ArgCodeDefaultValue.kind "INITIALIZER" | ||
//- ArgCodeDefaultValue.pre_text "'0'" | ||
function myFunction(arg: string = '0'): number { | ||
return 0; | ||
} |