Skip to content

Commit

Permalink
fix(compiler): inherit parent docstring in case no docstring was prov…
Browse files Browse the repository at this point in the history
…ided in child member (#7172)

fixes: #6488

## Checklist

- [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [ ] Description explains motivation and solution
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
tsuf239 authored Sep 27, 2024
1 parent 9176564 commit bca2b7c
Show file tree
Hide file tree
Showing 16 changed files with 219 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/@winglang/wingc/src/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ fn render_docs(markdown: &mut CodeMaker, docs: &Docs) {
// Psuedo-abstract marker, mostly useful internally
| "abstract"
// Marker type use, not for users
| "skipDocs" | "wingType"
| "skipDocs" | "wingType" | "noinflight"
) {
return;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/@winglang/wingc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ const WINGSDK_SIM_IRESOURCE_FQN: &'static str = formatcp!(
assembly = WINGSDK_ASSEMBLY_NAME,
iface = WINGSDK_SIM_IRESOURCE
);
const WINGSDK_RESOURCE_FQN: &'static str = formatcp!(
"{assembly}.{class}",
assembly = WINGSDK_ASSEMBLY_NAME,
class = WINGSDK_RESOURCE
);

const CONSTRUCT_BASE_CLASS: &'static str = "constructs.Construct";
const CONSTRUCT_BASE_INTERFACE: &'static str = "constructs.IConstruct";
Expand Down
91 changes: 91 additions & 0 deletions packages/@winglang/wingc/src/lsp/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,97 @@ Json.stringify({});
"#,
);

test_hover_list!(
parent_class_docs_are_inherited_on_declaration,
r#"
/// Some parent docs
class Parent {
/// Some method docs
pub method() {}
}
class Child extends Parent {
//^
pub method() {}
}
new Child().method();
"#,
);

test_hover_list!(
parent_class_docs_are_inherited_on_method_declaration,
r#"
/// Some parent docs
class Parent {
/// Some method docs
pub method() {}
}
class Child extends Parent {
pub method() {}
//^
}
new Child().method();
"#,
);

test_hover_list!(
parent_class_docs_are_inherited_on_call,
r#"
/// Some parent docs
class Parent {
/// Some method docs
pub method() {}
}
class Child extends Parent {
pub method() {}
}
new Child().method();
//^
"#,
);

test_hover_list!(
parent_class_docs_are_inherited_on_method_call,
r#"
/// Some parent docs
class Parent {
/// Some method docs
pub method() {}
}
class Child extends Parent {
pub method() {}
//^
}
new Child().method();
//^
"#,
);

test_hover_list!(
parent_class_docs_are_overridden,
r#"
/// Some parent docs
class Parent {
/// Some method docs
pub method() {}
}
/// Some child docs
class Child extends Parent {
}
new Child().method();
//^
"#,
);

test_hover_list!(
ignoe_empty_lines_in_doc,
r#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: 7
documentation:
kind: markdown
value: "```wing\nclass Button extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nA button can be used to perform an action.\n\n*@noinflight*"
value: "```wing\nclass Button extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nA button can be used to perform an action."
sortText: gg|Button
insertText: Button($1)
insertTextFormat: 2
Expand All @@ -16,7 +16,7 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: 7
documentation:
kind: markdown
value: "```wing\nclass Field extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nA field can be used to display a value.\n\n*@noinflight*"
value: "```wing\nclass Field extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nA field can be used to display a value."
sortText: gg|Field
insertText: Field($1)
insertTextFormat: 2
Expand All @@ -27,7 +27,7 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: 7
documentation:
kind: markdown
value: "```wing\nclass FileBrowser extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nA file browser can be used to browse files.\n\n*@noinflight*"
value: "```wing\nclass FileBrowser extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nA file browser can be used to browse files."
sortText: gg|FileBrowser
insertText: FileBrowser($1)
insertTextFormat: 2
Expand All @@ -38,7 +38,7 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: 7
documentation:
kind: markdown
value: "```wing\nclass HttpClient extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nAn HttpClient can be used to make HTTP requests.\n\n*@noinflight*"
value: "```wing\nclass HttpClient extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nAn HttpClient can be used to make HTTP requests."
sortText: gg|HttpClient
insertText: HttpClient($1)
insertTextFormat: 2
Expand All @@ -49,7 +49,7 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: 7
documentation:
kind: markdown
value: "```wing\nclass Section extends VisualComponent {\n add(...): void;\n addButton(...): void;\n addField(...): void;\n static isVisualComponent(...): bool;\n}\n```\n---\nA section can be used to group other visual components.\n\n*@noinflight*"
value: "```wing\nclass Section extends VisualComponent {\n add(...): void;\n addButton(...): void;\n addField(...): void;\n static isVisualComponent(...): bool;\n}\n```\n---\nA section can be used to group other visual components."
sortText: gg|Section
insertText: Section($1)
insertTextFormat: 2
Expand All @@ -60,7 +60,7 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: 7
documentation:
kind: markdown
value: "```wing\nclass Table extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nA table can be used to browse files.\n\n*@noinflight*"
value: "```wing\nclass Table extends VisualComponent {\n static isVisualComponent(...): bool;\n}\n```\n---\nA table can be used to browse files."
sortText: gg|Table
insertText: Table($1)
insertTextFormat: 2
Expand All @@ -71,7 +71,7 @@ source: packages/@winglang/wingc/src/lsp/completions.rs
kind: 7
documentation:
kind: markdown
value: "```wing\nclass ValueField extends Field {\n static isVisualComponent(...): bool;\n}\n```\n---\nA value field can be used to display a string value.\n\n*@noinflight*"
value: "```wing\nclass ValueField extends Field {\n static isVisualComponent(...): bool;\n}\n```\n---\nA value field can be used to display a string value."
sortText: gg|ValueField
insertText: ValueField($1)
insertTextFormat: 2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
value: "```wing\nnew(): Child\n```\n---\nSome parent docs"
range:
start:
line: 11
character: 4
end:
line: 11
character: 9

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
value: "```wing\nclass Child extends Parent {\n method(): void;\n}\n```\n---\nSome parent docs"
range:
start:
line: 7
character: 6
end:
line: 7
character: 11

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
value: "```wing\npreflight method(): void\n```\n---\nSome method docs"
range:
start:
line: 8
character: 6
end:
line: 8
character: 12

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
value: "```wing\npreflight method(): void\n```\n---\nSome method docs"
range:
start:
line: 8
character: 6
end:
line: 8
character: 12

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
value: "```wing\nnew(): Child\n```\n---\nSome child docs"
range:
start:
line: 11
character: 4
end:
line: 11
character: 9

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: libs/wingc/src/lsp/hover.rs
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: libs/wingc/src/lsp/hover.rs
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: libs/wingc/src/lsp/hover.rs
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: libs/wingc/src/lsp/hover.rs
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: libs/wingc/src/lsp/hover.rs
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: libs/wingc/src/lsp/hover.rs
source: packages/@winglang/wingc/src/lsp/hover.rs
---
contents:
kind: markdown
Expand Down
Loading

0 comments on commit bca2b7c

Please sign in to comment.