diff options
| author | Christoph Schlosser <christophschlosser@users.noreply.github.com> | 2017-11-23 21:57:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-23 21:57:28 +0100 |
| commit | f397690f9fd9702d03ea1e1a6fbbfecd922e87be (patch) | |
| tree | da6822dacd128c75c81adf1f81ccee76382bbc9f | |
| parent | ac189c2150c598df6bc7bd8e3215540f257983d8 (diff) | |
| parent | 5616ad38e085b1270ad8ce230aeeff057b7d4b42 (diff) | |
| download | doxdocgen-f397690f9fd9702d03ea1e1a6fbbfecd922e87be.tar.gz | |
Merge pull request #32 from rowanG077/master
Fixed parser bug and comment generation bug.
| -rw-r--r-- | src/CodeParser/CParser/CParser.ts | 41 | ||||
| -rw-r--r-- | src/CodeParser/CodeParserController.ts | 8 |
2 files changed, 10 insertions, 39 deletions
diff --git a/src/CodeParser/CParser/CParser.ts b/src/CodeParser/CParser/CParser.ts index 6f598ad..b9219c7 100644 --- a/src/CodeParser/CParser/CParser.ts +++ b/src/CodeParser/CParser/CParser.ts @@ -233,18 +233,6 @@ export default class CParser implements ICodeParser { // return argument. const returnArg = this.GetArgument(tree); - // check if it is a constructor or descructor since these have no name.. - // and reverse the assignment of type and name. - if (returnArg.Name === undefined) { - if (returnArg.Type.nodes.length !== 1) { - throw new Error("Too many symbols found for constructor/descructor."); - } else if (returnArg.Type.nodes[0] instanceof ParseTree) { - throw new Error("One node found with just a parsetree. Malformed input."); - } - - returnArg.Name = (returnArg.Type.nodes[0] as Token).Value; - returnArg.Type.nodes = []; - } // Check if return type is a pointer const ptrReturnIndex = returnArg.Type.nodes @@ -424,30 +412,17 @@ export default class CParser implements ICodeParser { private GetDefaultArgument(tree: ParseTree): Argument { const argument: Argument = new Argument(); - for (const node of tree.nodes) { - if (node instanceof ParseTree) { + for (let i = tree.nodes.length - 1; i >= 0; i--) { + const node = tree.nodes[i]; + if (node instanceof Token && node.Type === TokenType.Symbol) { + argument.Name = node.Value; + tree.nodes.splice(i, 1); break; } + } - const symbolCount = argument.Type.nodes - .filter((n) => n instanceof Token) - .map((n) => n as Token) - .filter((n) => n.Type === TokenType.Symbol) - .filter((n) => this.keywords.find((k) => k === n.Value) === undefined) - .length; - - if (node.Type === TokenType.Symbol - && this.keywords.find((k) => k === node.Value) === undefined - ) { - if (symbolCount === 1 && argument.Name === undefined) { - argument.Name = node.Value; - continue; - } else if (symbolCount > 1) { - throw new Error("Too many non keyword symbols."); - } - } - - argument.Type.nodes.push(node); + if (tree.nodes.length > 0) { + argument.Type.nodes = tree.nodes.filter((x) => x instanceof Token); } this.StripNonTypeNodes(argument.Type); diff --git a/src/CodeParser/CodeParserController.ts b/src/CodeParser/CodeParserController.ts index bd5a60b..f4c07de 100644 --- a/src/CodeParser/CodeParserController.ts +++ b/src/CodeParser/CodeParserController.ts @@ -111,12 +111,8 @@ export default class CodeParserController { currentPos.character - this.triggerSequence.length, ); - let endReplace: Position = new Position(currentPos.line, currentPos.character); - const nextLineText: string = window.activeTextEditor.document.lineAt(endReplace.line + 1).text; - // VSCode may enter a * on itself, we don't want that in our comment. - if (nextLineText.trim() === "*") { - endReplace = new Position(currentPos.line + 1, nextLineText.length); - } + const nextLineText: string = window.activeTextEditor.document.lineAt(startReplace.line + 1).text; + const endReplace = new Position(currentPos.line + 1, nextLineText.length); parser.Parse(activeEditor, event).GenerateDoc(new Range(startReplace, endReplace)); } |