-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
271 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Language } from "../language"; | ||
|
||
export interface IFile { | ||
filePath: string | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,39 @@ | ||
import JavaParserVisitor from "../../../grammars-v4/java/java20/Java20ParserVisitor"; | ||
import { JavaClass } from "./JavaClass"; | ||
import { JavaMethod } from "./JavaMethod"; | ||
import { CompilationUnitContext, NormalClassDeclarationContext, MethodDeclarationContext } from "../../../grammars-v4/java/java20/Java20Parser"; | ||
import { JavaCodeBlockBase } from "./JavaCodeBlockBase"; | ||
import { ParserRuleContext } from 'antlr4'; | ||
import { StatementContext } from '../../../grammars-v4/java/java20/Java20Parser'; | ||
import JavaParserVisitor from '../../../grammars-v4/java/java20/Java20ParserVisitor'; | ||
import { Language } from '../../language'; | ||
|
||
export class JavaCodeBlock extends JavaCodeBlockBase<CompilationUnitContext> { | ||
constructor(ctx: CompilationUnitContext) { | ||
super(ctx); | ||
} | ||
export abstract class JavaCodeBlock<T extends ParserRuleContext> { | ||
ctx: T | ||
language: Language | ||
|
||
getClasses(): JavaClass[] { | ||
class ClassVisitor extends JavaParserVisitor<void> { | ||
classes: JavaClass[]; | ||
constructor() { | ||
super(); | ||
this.classes = []; | ||
} | ||
constructor(ctx: T) { | ||
this.ctx = ctx; | ||
this.language = Language.JAVA; | ||
} | ||
|
||
visitNormalClassDeclaration = (ctx: NormalClassDeclarationContext) => { | ||
this.classes.push(new JavaClass(ctx)); | ||
} | ||
} | ||
getClasses() { | ||
throw new Error("Method getClasses() must be implemented"); | ||
} | ||
|
||
const visitor = new ClassVisitor(); | ||
visitor.visit(this.ctx); | ||
return visitor.classes; | ||
} | ||
} | ||
getFunctions() { | ||
throw new Error("Method getFunctions() must be implemented"); | ||
} | ||
|
||
getMethods() { | ||
throw new Error("Method getMethods() must be implemented"); | ||
} | ||
|
||
getSimpleStatements(): StatementContext[] { | ||
const visitor = new (class extends JavaParserVisitor<void> { | ||
statements: StatementContext[] = []; | ||
|
||
visitStatement = (ctx: StatementContext): void => { | ||
this.statements.push(ctx); | ||
} | ||
})(); | ||
|
||
visitor.visit(this.ctx); | ||
return visitor.statements; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import JavaParserVisitor from "../../../grammars-v4/java/java20/Java20ParserVisitor"; | ||
import { JavaClass } from "./JavaClass"; | ||
import { CompilationUnitContext, NormalClassDeclarationContext } from "../../../grammars-v4/java/java20/Java20Parser"; | ||
import { JavaCodeBlock } from "./JavaCodeBlock"; | ||
import { IFile } from "../../interface/IFile"; | ||
|
||
export class JavaFile extends JavaCodeBlock<CompilationUnitContext> implements IFile{ | ||
filePath: string | undefined; | ||
|
||
constructor(ctx: CompilationUnitContext) { | ||
super(ctx); | ||
} | ||
|
||
getClasses(): JavaClass[] { | ||
const visitor = new (class extends JavaParserVisitor<void> { | ||
classes: JavaClass[] = []; | ||
visitNormalClassDeclaration = (ctx: NormalClassDeclarationContext): void => { | ||
this.classes.push(new JavaClass(ctx)); | ||
} | ||
})(); | ||
|
||
visitor.visit(this.ctx); | ||
return visitor.classes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.