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(compiler): inherit parent docstring in case no docstring was provided in child member #7172

Merged
merged 5 commits into from
Sep 27, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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