Skip to content

Commit 7db7dd9

Browse files
committed
Null check for structDoc
1 parent 5e16e22 commit 7db7dd9

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

src/features/documentation.ts

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,45 @@ export function GetDocumentationString(structDoc: protocol.DocumentationComment)
3636
let indentSpaces = "\t\t";
3737
let documentation = "";
3838

39-
if (structDoc.SummaryText) {
40-
documentation += structDoc.SummaryText + newLine;
39+
if (structDoc) {
40+
if (structDoc.SummaryText) {
41+
documentation += structDoc.SummaryText + newLine;
42+
}
43+
44+
if (structDoc.TypeParamElements && structDoc.TypeParamElements.length > 0) {
45+
documentation += "Type Parameters:" + newLine;
46+
documentation += indentSpaces + structDoc.TypeParamElements.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine;
47+
}
48+
49+
if (structDoc.ParamElements && structDoc.ParamElements.length > 0) {
50+
documentation += "Parameters:" + newLine;
51+
documentation += indentSpaces + structDoc.ParamElements.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine;
52+
}
53+
54+
if (structDoc.ReturnsText) {
55+
documentation += structDoc.ReturnsText + newLine;
56+
}
57+
58+
if (structDoc.RemarksText) {
59+
documentation += structDoc.RemarksText + newLine;
60+
}
61+
62+
if (structDoc.ExampleText) {
63+
documentation += structDoc.ExampleText + newLine;
64+
}
65+
66+
if (structDoc.ValueText) {
67+
documentation += structDoc.ValueText + newLine;
68+
}
69+
70+
if (structDoc.Exception && structDoc.Exception.length > 0) {
71+
documentation += "Exceptions:" + newLine;
72+
documentation += indentSpaces + structDoc.Exception.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine;
73+
}
74+
75+
documentation = documentation.trim();
4176
}
42-
43-
if (structDoc.TypeParamElements && structDoc.TypeParamElements.length > 0) {
44-
documentation += "Type Parameters:" + newLine;
45-
documentation += indentSpaces + structDoc.TypeParamElements.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine;
46-
}
47-
48-
if (structDoc.ParamElements && structDoc.ParamElements.length > 0) {
49-
documentation += "Parameters:" + newLine;
50-
documentation += indentSpaces + structDoc.ParamElements.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine;
51-
}
52-
53-
if (structDoc.ReturnsText) {
54-
documentation += structDoc.ReturnsText + newLine;
55-
}
56-
57-
if (structDoc.RemarksText) {
58-
documentation += structDoc.RemarksText + newLine;
59-
}
60-
61-
if (structDoc.ExampleText) {
62-
documentation += structDoc.ExampleText + newLine;
63-
}
64-
65-
if (structDoc.ValueText) {
66-
documentation += structDoc.ValueText + newLine;
67-
}
68-
69-
if (structDoc.Exception && structDoc.Exception.length > 0) {
70-
documentation += "Exceptions:" + newLine;
71-
documentation += indentSpaces + structDoc.Exception.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine;
72-
}
73-
74-
documentation = documentation.trim();
77+
7578
return documentation;
7679
}
7780

0 commit comments

Comments
 (0)