From 1499e8e59cf044807de26f040ec597e8ebe7c211 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Thu, 23 Nov 2017 19:43:43 +0100 Subject: -- Fixed bug where using a different trigger sequence then "*" causes a newline to be addd between the comment and the documented entity. --- src/CodeParser/CodeParserController.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/CodeParser/CodeParserController.ts b/src/CodeParser/CodeParserController.ts index bd5a60b..72aafa4 100644 --- a/src/CodeParser/CodeParserController.ts +++ b/src/CodeParser/CodeParserController.ts @@ -111,12 +111,9 @@ export default class CodeParserController { currentPos.character - this.triggerSequence.length, ); - let endReplace: Position = new Position(currentPos.line, currentPos.character); + let endReplace: Position = new Position(currentPos.line, currentPos.character + 1); 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); - } + endReplace = new Position(currentPos.line + 1, nextLineText.length); parser.Parse(activeEditor, event).GenerateDoc(new Range(startReplace, endReplace)); } -- cgit v1.2.3 From 126868ba799668d94f3c34ce05d8c62b62173c2b Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Thu, 23 Nov 2017 19:45:30 +0100 Subject: -- Fixed unused assignment. --- src/CodeParser/CodeParserController.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/CodeParser/CodeParserController.ts b/src/CodeParser/CodeParserController.ts index 72aafa4..496005b 100644 --- a/src/CodeParser/CodeParserController.ts +++ b/src/CodeParser/CodeParserController.ts @@ -111,9 +111,8 @@ export default class CodeParserController { currentPos.character - this.triggerSequence.length, ); - let endReplace: Position = new Position(currentPos.line, currentPos.character + 1); const nextLineText: string = window.activeTextEditor.document.lineAt(endReplace.line + 1).text; - endReplace = new Position(currentPos.line + 1, nextLineText.length); + const endReplace = new Position(currentPos.line + 1, nextLineText.length); parser.Parse(activeEditor, event).GenerateDoc(new Range(startReplace, endReplace)); } -- cgit v1.2.3 From 08445144517d2cd1ac97e737b1bda0e65db6c999 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Thu, 23 Nov 2017 19:53:22 +0100 Subject: -- Fixed error where endReplace was used before declaration. --- src/CodeParser/CodeParserController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CodeParser/CodeParserController.ts b/src/CodeParser/CodeParserController.ts index 496005b..f4c07de 100644 --- a/src/CodeParser/CodeParserController.ts +++ b/src/CodeParser/CodeParserController.ts @@ -111,7 +111,7 @@ export default class CodeParserController { currentPos.character - this.triggerSequence.length, ); - const nextLineText: string = window.activeTextEditor.document.lineAt(endReplace.line + 1).text; + 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)); -- cgit v1.2.3 From 66fb321a2399d37960abefaec80548f86fc5e1d4 Mon Sep 17 00:00:00 2001 From: Rowan Goemans Date: Thu, 23 Nov 2017 20:35:00 +0100 Subject: -- Fixed bug where type modifiers like unsigned signed weren't properly recognized. --- src/CodeParser/CParser/CParser.ts | 41 ++++++++------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) (limited to 'src') 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); -- cgit v1.2.3