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

fix(go): invalid generated code for classes a keyword name #2641

Merged
merged 4 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
30 changes: 30 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2925,3 +2925,33 @@ export class TestStructWithEnum {
};
}
}

/**
* Docstrings with period
* @see https://github.com/aws/jsii/issues/2638
*/
export class Issue2638 {
/**
* First sentence. Second sentence. Third sentence.
*/
public constructor() {
return;
}
}

export class Issue2638B {
public constructor() {
return; // no docs
}
}

/**
* A class named "Default"
*
* @see https://github.com/aws/jsii/issues/2637
*/
export class Default {
public pleaseCompile() {
return;
}
}
1 change: 1 addition & 0 deletions packages/jsii-calc/lib/submodule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * as returnsparam from './returns-param';
export * from './my-class';
export * from './nested_submodule';
export * as back_references from './refers-to-parent';
export * from './issue2637';
8 changes: 8 additions & 0 deletions packages/jsii-calc/lib/submodule/issue2637.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* A struct named "Default"
*
* @see https://github.com/aws/jsii/issues/2637
*/
export interface Default {
readonly foo: number;
}
116 changes: 115 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -3373,6 +3373,38 @@
],
"name": "DataRenderer"
},
"jsii-calc.Default": {
"assembly": "jsii-calc",
"docs": {
"see": "https://github.com/aws/jsii/issues/2637",
"stability": "stable",
"summary": "A class named \"Default\"."
},
"fqn": "jsii-calc.Default",
"initializer": {
"docs": {
"stability": "stable"
}
},
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2953
},
"methods": [
{
"docs": {
"stability": "stable"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2954
},
"name": "pleaseCompile"
}
],
"name": "Default"
},
"jsii-calc.DefaultedConstructorArgument": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -7219,6 +7251,54 @@
],
"name": "Isomorphism"
},
"jsii-calc.Issue2638": {
"assembly": "jsii-calc",
"docs": {
"see": "https://github.com/aws/jsii/issues/2638",
"stability": "stable",
"summary": "Docstrings with period."
},
"fqn": "jsii-calc.Issue2638",
"initializer": {
"docs": {
"remarks": "Second sentence. Third sentence.",
"stability": "stable",
"summary": "First sentence."
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2937
}
},
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2933
},
"name": "Issue2638"
},
"jsii-calc.Issue2638B": {
"assembly": "jsii-calc",
"docs": {
"stability": "stable"
},
"fqn": "jsii-calc.Issue2638B",
"initializer": {
"docs": {
"stability": "stable"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2943
}
},
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2942
},
"name": "Issue2638B"
},
"jsii-calc.JSII417Derived": {
"assembly": "jsii-calc",
"base": "jsii-calc.JSII417PublicBaseOfBase",
Expand Down Expand Up @@ -14139,6 +14219,40 @@
"name": "OnlyStaticMethods",
"namespace": "onlystatic"
},
"jsii-calc.submodule.Default": {
"assembly": "jsii-calc",
"datatype": true,
"docs": {
"see": "https://github.com/aws/jsii/issues/2637",
"stability": "stable",
"summary": "A struct named \"Default\"."
},
"fqn": "jsii-calc.submodule.Default",
"kind": "interface",
"locationInModule": {
"filename": "lib/submodule/issue2637.ts",
"line": 6
},
"name": "Default",
"namespace": "submodule",
"properties": [
{
"abstract": true,
"docs": {
"stability": "stable"
},
"immutable": true,
"locationInModule": {
"filename": "lib/submodule/issue2637.ts",
"line": 7
},
"name": "foo",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.submodule.MyClass": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -14756,5 +14870,5 @@
}
},
"version": "3.20.120",
"fingerprint": "GfueSeyZdyEIZp4V4lbddw+TnoCel74KSDMPxp2phmw="
"fingerprint": "rH6rK3iHNatb4ojll7sd8rvJ4k/89Kybg89FRd96Hno="
}
4 changes: 3 additions & 1 deletion packages/jsii-pacmak/lib/targets/go/types/go-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export abstract class GoType {

public constructor(public pkg: Package, public type: Type) {
this.name = toPascalCase(type.name);
this.proxyName = toCamelCase(type.name);
// add "_jsiiProxy" postfix to private struct name to avoid keyword
// conflicts such as "default". see https://github.com/aws/jsii/issues/2637
this.proxyName = `${toCamelCase(type.name)}_jsiiProxy`;
this.fqn = type.fqn;
}

Expand Down
Loading