diff options
Diffstat (limited to 'src/Lang/Python')
| -rw-r--r-- | src/Lang/Python/PythonParser.ts | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/Lang/Python/PythonParser.ts b/src/Lang/Python/PythonParser.ts index 2d26ed8..74f1bef 100644 --- a/src/Lang/Python/PythonParser.ts +++ b/src/Lang/Python/PythonParser.ts @@ -1,17 +1,54 @@ -import { TextEditor } from "vscode"; +import { Position, TextEditor } from "vscode"; import ICodeParser from "../../Common/ICodeParser"; import { IDocGen } from "../../Common/IDocGen"; import { Config } from "../../Config"; +import { PythonDocGen } from "./PythonDocGen"; export default class CppParser implements ICodeParser { protected readonly cfg: Config; + protected activeSelection: Position; + protected activeEditor: TextEditor; constructor(cfg: Config) { this.cfg = cfg; } public Parse(activeEditor: TextEditor): IDocGen { - throw new Error("Method not implemented."); + this.activeEditor = activeEditor; + this.activeSelection = activeEditor.selection.active; + const params = this.getParams(this.getLogicalLine()); + return new PythonDocGen(); + } + + private getLogicalLine(): string { + let nextLine: Position = new Position(this.activeSelection.line + 1, this.activeSelection.character); + let nextLineTxt: string = this.activeEditor.document.lineAt(nextLine.line).text.trim(); + + let logicalLine = ""; + let linesToGet: number = this.cfg.Generic.linesToGet; + let foundStart = false; + while (linesToGet-- > 0) { // Check for end of expression. + nextLine = new Position(nextLine.line + 1, nextLine.character); + nextLineTxt = this.activeEditor.document.lineAt(nextLine.line).text.trim(); + + if (nextLineTxt.startsWith("def")) { + foundStart = true; + } + + if (foundStart) { + logicalLine += nextLineTxt; + } + + if (nextLineTxt.endsWith(":")) { + break; + } + } + + return logicalLine; + } + + private getParams(line: string): string[] { + return []; } } |