From f928a1049c6582e2fbb044676c5bbca89d9b7e33 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 24 Feb 2018 10:57:22 +0100 Subject: Generate description of file Fix #51 --- src/Lang/Cpp/CppParser.ts | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/Lang/Cpp/CppParser.ts') diff --git a/src/Lang/Cpp/CppParser.ts b/src/Lang/Cpp/CppParser.ts index 4792e14..46f22e3 100644 --- a/src/Lang/Cpp/CppParser.ts +++ b/src/Lang/Cpp/CppParser.ts @@ -227,22 +227,27 @@ export default class CppParser implements ICodeParser { } catch (err) { // console.dir(err); } - - // template parsing is simpler by using heuristics rather then CppTokenizing first. const templateArgs: string[] = []; - while (line.startsWith("template")) { - const template: string = this.GetTemplate(line); + let args: [CppArgument, CppArgument[]] = [new CppArgument(), []]; - templateArgs.push.apply(templateArgs, this.GetArgsFromTemplate(template)); + if (line === "#include" || + (activeEdit.selection.active.line === 0 && line.length === 0)) { // head of file + args[0].name = "#include"; + } else { // method + // template parsing is simpler by using heuristics rather then CppTokenizing first. + while (line.startsWith("template")) { + const template: string = this.GetTemplate(line); - line = line.slice(template.length, line.length + 1).trim(); - } + templateArgs.push.apply(templateArgs, this.GetArgsFromTemplate(template)); - let args: [CppArgument, CppArgument[]] = [new CppArgument(), []]; - try { - args = this.GetReturnAndArgs(line); - } catch (err) { - // console.dir(err); + line = line.slice(template.length, line.length + 1).trim(); + } + + try { + args = this.GetReturnAndArgs(line); + } catch (err) { + // console.dir(err); + } } return new CppDocGen( @@ -298,6 +303,11 @@ export default class CppParser implements ICodeParser { } } + // Head of file probably + if (nextLineTxt.startsWith("#include")) { + return "#include"; + } + logicalLine += "\n" + nextLineTxt; } -- cgit v1.2.3