diff --git a/Dockerfile b/Dockerfile index cb03297..b38930a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:11-jdk-jammy +FROM eclipse-temurin:17-jdk-jammy WORKDIR /workspace # Optional: install tools you like RUN apt-get update && apt-get install -y bash git && rm -rf /var/lib/apt/lists/* diff --git a/README.md b/README.md index b9f7cae..dbb7bd7 100644 --- a/README.md +++ b/README.md @@ -149,15 +149,15 @@ Each line has a `kind` field: SQL file analysis uses a hybrid JSqlParser + ANTLR approach to support multiple dialects (PostgreSQL, MySQL, T-SQL, PL/SQL) without configuration. -For complete documentation on SQL support, see **[SQL_ANALYSIS.md](SQL_ANALYSIS.md)**. +For complete documentation on SQL support, see **[SQL_ANALYSIS.md](docs/SQL_ANALYSIS.md)**. ## Architecture -See **[ARCHITECTURE.md](ARCHITECTURE.md)** for details on core components and design decisions. +See **[ARCHITECTURE.md](docs/ARCHITECTURE.md)** for details on core components and design decisions. ## Contributing -See **[CONTRIBUTING.md](CONTRIBUTING.md)** for guidelines on adding new languages and analyzer conventions. +See **[CONTRIBUTING.md](docs/CONTRIBUTING.md)** for guidelines on adding new languages and analyzer conventions. ## Requirements @@ -184,7 +184,7 @@ This project uses Tree-sitter and its language grammars, which are licensed unde - **C#**: Events not handled; see test samples for details - **Java**: Local/anonymous classes not extracted as separate types - **Python**: Type aliases using `TypeAlias` annotation are captured with `kind: "type_alias"`. PEP 695 style (`type X = ...`) is not yet supported by the tree-sitter-python grammar -- **SQL**: See [SQL_ANALYSIS.md](SQL_ANALYSIS.md) +- **SQL**: See [SQL_ANALYSIS.md](docs/SQL_ANALYSIS.md) ## Testing @@ -192,4 +192,4 @@ This project uses Tree-sitter and its language grammars, which are licensed unde ./gradlew test ``` -See [CONTRIBUTING.md](CONTRIBUTING.md) for testing workflow and conventions. +See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for testing workflow and conventions. diff --git a/build.gradle b/build.gradle index 5127874..3e2104f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,28 +1,28 @@ plugins { id 'java' id 'application' - id 'com.github.johnrengelman.shadow' version '8.1.1' + id 'com.gradleup.shadow' version '9.3.1' id 'antlr' } java { - toolchain { languageVersion = JavaLanguageVersion.of(11) } + toolchain { languageVersion = JavaLanguageVersion.of(17) } + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 group = 'org.dxworks' version = '1.0-SNAPSHOT' repositories { mavenCentral() - maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } + mavenLocal() } dependencies { // Core binding (bundles natives for Win/Linux/macOS) - implementation 'io.github.bonede:tree-sitter:0.25.3' + implementation 'io.github.bonede:tree-sitter:0.26.3' // Language grammars implementation 'io.github.bonede:tree-sitter-java:0.23.4' @@ -34,17 +34,18 @@ dependencies { implementation 'io.github.bonede:tree-sitter-ruby:0.23.1' implementation 'io.github.bonede:tree-sitter-rust:0.23.1' - implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1' - implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.1' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.21.0' + implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.21.0' implementation 'com.github.jsqlparser:jsqlparser:5.3' - implementation 'org.antlr:antlr4-runtime:4.13.1' - antlr 'org.antlr:antlr4:4.13.1' + implementation 'org.antlr:antlr4-runtime:4.13.2' + antlr 'org.antlr:antlr4:4.13.2' // DXWorks ignore library (loads .ignore patterns) - implementation 'org.dxworks:dx-ignore:1.1.0-SNAPSHOT' + implementation 'org.dxworks.utils:dx-ignore:1.1.0' // Testing - testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1' - testImplementation 'com.approvaltests:approvaltests:22.3.3' + testImplementation 'org.junit.jupiter:junit-jupiter:6.0.2' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:6.0.2' + testImplementation 'com.approvaltests:approvaltests:26.6.0' } application { @@ -53,18 +54,43 @@ application { import org.gradle.api.plugins.antlr.AntlrTask -// Configure ANTLR generation for all grammars in src/main/antlr -tasks.withType(AntlrTask).configureEach { - // Generate visitor interfaces and set a shared Java package for generated sources +task generateSqlGrammarSource(type: AntlrTask) { + source = fileTree(dir: 'src/main/antlr', include: 'sql/**/*.g4') + outputDirectory = file('build/generated-src/antlr/sql') arguments.clear() arguments += ['-visitor', '-package', 'org.dxworks.codeframe.analyzer.sql.generated', - // Make sure grammar imports like `import PlSqlLexer;` can be resolved - // when the grammars live under src/main/antlr/plsql '-lib', 'src/main/antlr'] } +task generateCobolGrammarSource(type: AntlrTask) { + source = fileTree(dir: 'src/main/antlr', include: 'cobol/**/*.g4') + outputDirectory = file('build/generated-src/antlr/cobol') + arguments.clear() + arguments += ['-visitor', + '-package', 'org.dxworks.codeframe.analyzer.cobol.generated', + '-lib', 'src/main/antlr'] +} + +tasks.named('generateGrammarSource') { + enabled = false +} + +task generateAllGrammarSource { + dependsOn generateSqlGrammarSource, generateCobolGrammarSource +} + +sourceSets { + main { + java { + srcDir 'build/generated-src/antlr/sql' + srcDir 'build/generated-src/antlr/cobol' + } + } +} + tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' } +tasks.named('compileJava') { dependsOn generateAllGrammarSource } // Produce a single, self-contained JAR named exactly 'codeframe.jar' tasks.named('shadowJar') { @@ -80,4 +106,14 @@ tasks.named('build') { // Configure all Test tasks to use JUnit Platform and run in parallel tasks.withType(Test).configureEach { useJUnitPlatform() + dependsOn 'generateAllGrammarSource' + + testLogging { + events 'skipped', 'failed' + exceptionFormat 'full' + showExceptions true + showCauses true + showStackTraces true + showStandardStreams = false + } } \ No newline at end of file diff --git a/docs/AGENTS.md b/docs/AGENTS.md new file mode 100644 index 0000000..8336f95 --- /dev/null +++ b/docs/AGENTS.md @@ -0,0 +1,9 @@ +# Project Scope +See the [README](README.md) for overall project scope + +# Design guidline +- Use at little Regex as possible +- Do not add complexity only for backward compatibility unless the user explicitly asks for it. +- Do not hack your way to a solution. Understand the problem and find a proper solution. Many times, a better understanding of the grammar or the tree will help you find a better solution. +- For parser/analyzer behavior, follow the global **Extraction Contract (All Parsers)** in [CONTRIBUTING.md](CONTRIBUTING.md). +- I'm running on Windows, but I can't run the app locally, so I work with docker. If you suggest comamnds, specify them using Unix syntax, but don't offer to run them. Just tell me the command. I will run it and give you the output. \ No newline at end of file diff --git a/ARCHITECTURE.md b/docs/ARCHITECTURE.md similarity index 100% rename from ARCHITECTURE.md rename to docs/ARCHITECTURE.md diff --git a/CONTRIBUTING.md b/docs/CONTRIBUTING.md similarity index 94% rename from CONTRIBUTING.md rename to docs/CONTRIBUTING.md index 2109133..5a99022 100644 --- a/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -13,6 +13,14 @@ Follow these conventions to ensure consistency across all analyzers. +### Extraction Contract (All Parsers) + +- Extract facts only. Do not infer capabilities or intent. +- Keep output deterministic. +- Do not write files as side effects. +- On parse errors, return partial results when possible. +- Keep analyzers simple and fast; enrichment belongs to post-processing tools. + ### Using TreeSitterHelper `TreeSitterHelper` provides shared utilities that all analyzers should use: diff --git a/SQL_ANALYSIS.md b/docs/SQL_ANALYSIS.md similarity index 100% rename from SQL_ANALYSIS.md rename to docs/SQL_ANALYSIS.md diff --git a/docs/specs/COBOL_SPEC.md b/docs/specs/COBOL_SPEC.md new file mode 100644 index 0000000..6571a3a --- /dev/null +++ b/docs/specs/COBOL_SPEC.md @@ -0,0 +1,243 @@ +# COBOL Specification (CodeFrame) + +## Purpose + +This document defines the **COBOL analysis specification** for CodeFrame. + +It describes: +- what COBOL facts are extracted, +- why these facts are part of the model, +- what is in scope vs out of scope, +- the explicit COBOL limitations for the current version. + +This is a **normative spec** for COBOL behavior and output shape. It is not an implementation plan. + +--- + +## 1. COBOL Language Scope + +### 1.1 Supported COBOL dialect/version + +- Target language: **COBOL85**. + +### 1.2 Source format + +- Source format is **fixed format only** (80-column COBOL). +- Format auto-detection is out of scope. + +### 1.3 File extensions in scope + +- `.cbl` +- `.cob` +- `.cobol` + +### 1.4 Copybook files (`.cpy`) + +- `.cpy` files are not analyzed as standalone COBOL structural artifacts in this spec version. +- Copybook content is expected to be embedded where `COPY` statements are used (see Section 4). + +--- + +## 2. COBOL Output Contract + +COBOL analysis output is represented by `COBOLFileAnalysis`. + +### 2.1 Top-level fields + +- `filePath`: analyzed file path. +- `language`: always `"cobol"`. +- `programId`: COBOL `PROGRAM-ID`. +- `fileControls`: logical file definitions from `FILE-CONTROL SELECT` clauses. +- `dataItems`: data hierarchy extracted from DATA DIVISION sections. +- `fileDefinitions`: FD-based file record definitions. +- `copyStatements`: copybook names referenced via `COPY`. +- `procedureParameters`: names from `PROCEDURE DIVISION USING`. +- `sections`: named procedure sections with nested paragraphs. +- `paragraphs`: top-level procedure paragraphs (including synthetic prologue when applicable). +- `hasExecSql`: whether EXEC SQL appears. +- `hasExecCics`: whether EXEC CICS appears. +- `hasExecSqlIms`: whether EXEC SQLIMS appears. + +### 2.2 COBOL-specific model intent + +The model is designed around COBOL compilation-unit semantics (program/divisions/paragraphs/data hierarchy), not class/method semantics. + +--- + +## 3. Semantic Extraction Rules + +### 3.1 IDENTIFICATION DIVISION + +- Extract `PROGRAM-ID` into `programId`. +- Other identification entries are not primary contract fields. + +### 3.2 ENVIRONMENT DIVISION: FILE-CONTROL + +Each `SELECT` contributes a `COBOLFileControl` with: +- `name` +- `organization` (when present) +- `accessMode` (when present) +- `hasKey` (true when `RECORD KEY` is present) + +Physical assignment targets are not part of the current contract. + +### 3.3 DATA DIVISION: data hierarchy + +`dataItems` capture hierarchical COBOL data declarations from: +- WORKING-STORAGE SECTION +- LOCAL-STORAGE SECTION +- LINKAGE SECTION +- FILE SECTION (as applicable) + +Per item semantics: +- `name`, `level`, `picture`, `section` +- optional `usage`, `redefines`, `occurs` +- `children` preserves nesting by level numbers (01/05/10/77/88, etc.) + +#### 88-level condition names + +Level-88 condition names are included as children of their parent data item. They carry `name`, `level: 88`, and `section` (inherited from parent). The `VALUE` clause is **not** captured (consistent with Decision #12 in the research doc — no VALUE extraction for any level). + +### 3.4 FILE SECTION: fileDefinitions + +`fileDefinitions` represent FD ownership: +- `name`: FD file name +- `records`: record layouts belonging to that FD + +Record ownership is FD-scoped (records belong to the corresponding FD, not shifted across FDs). + +### 3.5 PROCEDURE DIVISION USING + +- Names in `PROCEDURE DIVISION USING ...` are extracted into `procedureParameters`. +- Stored as names only. + +### 3.6 Sections and paragraphs + +- Named sections are emitted in `sections`. +- Paragraphs inside sections are emitted in `sections[].paragraphs`. +- Paragraphs outside sections are emitted in top-level `paragraphs`. + +### 3.7 Procedure prologue behavior + +When executable statements exist in PROCEDURE DIVISION before the first named paragraph, they are captured in a synthetic paragraph: +- `__PROCEDURE_DIVISION_PROLOGUE__` + +This paragraph is part of top-level `paragraphs`. + +### 3.8 CALL statements + +Paragraph-level `externalCalls` capture: +- `programName` +- `isDynamic` +- `parameterCount` (when determinable) + +Calls are represented at paragraph level (including prologue paragraph where applicable). + +### 3.9 PERFORM statements + +Paragraph-level `performCalls` capture: +- `targetParagraph` +- optional `thruParagraph` + +### 3.10 File operations + +Paragraph-level `fileOperations` capture operation + target for: +- `READ` +- `WRITE` +- `OPEN` +- `CLOSE` +- `REWRITE` +- `DELETE` +- `START` + +Each file operation has: +- `verb`: the operation keyword. +- `target`: the operand of the verb. For `OPEN`/`CLOSE`, this is the COBOL file name (e.g., `STMT-FILE`). For `WRITE`, this is the record name (e.g., `FD-STMTFILE-REC`). For `READ`, this is the file name. The field is named `target` (not `fileName`) because different verbs operate on different entity types. + +### 3.11 Control-flow statements + +Paragraph-level `controlFlowStatements` capture explicit control flow: +- `GOBACK` +- `STOP RUN` +- `EXIT PROGRAM` +- `RETURN` + +`RETURN` may include a `target` when syntactically present. + +**Note**: A bare `EXIT` statement (without `PROGRAM`) is a COBOL no-op placeholder and is **not** captured as a control-flow statement. + +### 3.12 Data references + +Paragraph-level `dataReferences` capture identifier references in executable statements, including: +- assignment/movement statements (`MOVE`), +- arithmetic statements (`ADD`, `SUBTRACT`, `MULTIPLY`, `DIVIDE`, `COMPUTE`), +- `SET` statements (including condition names), +- call-argument identifiers (`CALL USING`), +- `STRING`/`UNSTRING` operands and targets, +- `EVALUATE` subject identifiers, +- `INITIALIZE` target identifiers, +- `DISPLAY` identifier operands. + +Identifiers are captured as names. Literal constants are excluded. + +Subscripted references preserve their subscript expressions (e.g., `WS-TRAN-NUM(CR-JMP, TR-JMP)`). + +### 3.13 EXEC block presence flags + +The analysis records presence flags for: +- EXEC SQL +- EXEC CICS +- EXEC SQLIMS + +The inner content of EXEC blocks is not modeled in this spec. + +--- + +## 4. Copybook Semantics + +### 4.1 Required copybook output + +- `copyStatements` must contain referenced copybook names from `COPY` statements. + +### 4.2 Expansion expectation + +- COPY content is expected to be expanded into parser-visible source when copybooks are resolvable. +- `copyStatements` still records referenced copybook names from source files. +- Parsing note: copybooks are often grammar fragments rather than full compilation units; expansion therefore depends on a parsing-compatibility strategy for copybook fragments. + +### 4.3 Duplicate copybook names + +Decision: when multiple copybooks share the same name in different directories, resolution uses the current first-match rule. + +- Matching is by copybook base name (case-insensitive). +- If multiple candidates match, the first candidate in the provided copybook list is selected. +- This behavior is deterministic for a stable input ordering and must be validated by approval output. + +--- + +## 5. Current Limitations (V1) + +- COBOL scope is limited to COBOL85. +- Fixed-format source only (no variable/free-format mode). +- No semantic interpretation of EXEC block content. +- No standalone structural extraction output for `.cpy` files. +- COPY expansion applies only to resolvable copybooks; unresolved copybooks are skipped (non-fatal). +- `dataReferences` are paragraph-level merged references; statement-level attribution is not modeled. +--- + +## 6. Out of Scope (for this spec version) + +The following are outside the current COBOL specification baseline: +- COBOL 2002+ language features. +- Semantic/data-flow analysis beyond structured extraction fields. +- Cross-program behavioral inference. +- Non-COBOL artifacts (e.g., JCL, BMS, assembler) in this COBOL model. + +--- + +## 7. Future COBOL Enhancements (Non-normative) + +Potential future expansions include: +- richer copybook resolution contracts, +- broader COBOL version coverage, +- deeper semantic extraction where explicitly required by a revised specification. diff --git a/releaseNotes/0.6.5.md b/releaseNotes/0.6.5.md new file mode 100644 index 0000000..bb9f196 --- /dev/null +++ b/releaseNotes/0.6.5.md @@ -0,0 +1,2 @@ +* Refactor SQL Analyzer +* Update versions \ No newline at end of file diff --git a/src/main/antlr/cobol/Cobol85.g4 b/src/main/antlr/cobol/Cobol85.g4 new file mode 100644 index 0000000..2924a71 --- /dev/null +++ b/src/main/antlr/cobol/Cobol85.g4 @@ -0,0 +1,5655 @@ +/* +* Copyright (C) 2017, Ulrich Wolffgang +* All rights reserved. +* +* This software may be modified and distributed under the terms +* of the MIT license. See the LICENSE file for details. +*/ + +/* +* COBOL 85 Grammar for ANTLR4 +* +* This is a COBOL 85 grammar, which is part of the COBOL parser at +* https://github.com/uwol/cobol85parser. +* +* The grammar passes the NIST test suite and has successfully been applied to +* numerous COBOL files from banking and insurance. To be used in conjunction +* with the provided preprocessor, which executes COPY and REPLACE statements. +*/ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +grammar Cobol85; + +startRule + : compilationUnit EOF + ; + +compilationUnit + : programUnit+ + ; + +programUnit + : identificationDivision environmentDivision? dataDivision? procedureDivision? programUnit* endProgramStatement? + ; + +endProgramStatement + : END PROGRAM programName DOT_FS + ; + +// --- identification division -------------------------------------------------------------------- + +identificationDivision + : (IDENTIFICATION | ID) DIVISION DOT_FS programIdParagraph identificationDivisionBody* + ; + +identificationDivisionBody + : authorParagraph + | installationParagraph + | dateWrittenParagraph + | dateCompiledParagraph + | securityParagraph + | remarksParagraph + ; + +// - program id paragraph ---------------------------------- + +programIdParagraph + : PROGRAM_ID DOT_FS programName ( + IS? (COMMON | INITIAL | LIBRARY | DEFINITION | RECURSIVE) PROGRAM? + )? DOT_FS? commentEntry? + ; + +// - author paragraph ---------------------------------- + +authorParagraph + : AUTHOR DOT_FS commentEntry? + ; + +// - installation paragraph ---------------------------------- + +installationParagraph + : INSTALLATION DOT_FS commentEntry? + ; + +// - date written paragraph ---------------------------------- + +dateWrittenParagraph + : DATE_WRITTEN DOT_FS commentEntry? + ; + +// - date compiled paragraph ---------------------------------- + +dateCompiledParagraph + : DATE_COMPILED DOT_FS commentEntry? + ; + +// - security paragraph ---------------------------------- + +securityParagraph + : SECURITY DOT_FS commentEntry? + ; + +// - remarks paragraph ---------------------------------- + +remarksParagraph + : REMARKS DOT_FS commentEntry? + ; + +// --- environment division -------------------------------------------------------------------- + +environmentDivision + : ENVIRONMENT DIVISION DOT_FS environmentDivisionBody* + ; + +environmentDivisionBody + : configurationSection + | specialNamesParagraph + | inputOutputSection + ; + +// -- configuration section ---------------------------------- + +configurationSection + : CONFIGURATION SECTION DOT_FS configurationSectionParagraph* + ; + +// - configuration section paragraph ---------------------------------- + +configurationSectionParagraph + : sourceComputerParagraph + | objectComputerParagraph + | specialNamesParagraph + // strictly, specialNamesParagraph does not belong into configurationSectionParagraph, but ibm-cobol allows this + ; + +// - source computer paragraph ---------------------------------- + +sourceComputerParagraph + : SOURCE_COMPUTER DOT_FS computerName (WITH? DEBUGGING MODE)? DOT_FS + ; + +// - object computer paragraph ---------------------------------- + +objectComputerParagraph + : OBJECT_COMPUTER DOT_FS computerName objectComputerClause* DOT_FS + ; + +objectComputerClause + : memorySizeClause + | diskSizeClause + | collatingSequenceClause + | segmentLimitClause + | characterSetClause + ; + +memorySizeClause + : MEMORY SIZE? (integerLiteral | cobolWord) (WORDS | CHARACTERS | MODULES)? + ; + +diskSizeClause + : DISK SIZE? IS? (integerLiteral | cobolWord) (WORDS | MODULES)? + ; + +collatingSequenceClause + : PROGRAM? COLLATING? SEQUENCE (IS? alphabetName+) collatingSequenceClauseAlphanumeric? collatingSequenceClauseNational? + ; + +collatingSequenceClauseAlphanumeric + : FOR? ALPHANUMERIC IS? alphabetName + ; + +collatingSequenceClauseNational + : FOR? NATIONAL IS? alphabetName + ; + +segmentLimitClause + : SEGMENT_LIMIT IS? integerLiteral + ; + +characterSetClause + : CHARACTER SET DOT_FS + ; + +// - special names paragraph ---------------------------------- + +specialNamesParagraph + : SPECIAL_NAMES DOT_FS (specialNameClause+ DOT_FS)? + ; + +specialNameClause + : channelClause + | odtClause + | alphabetClause + | classClause + | currencySignClause + | decimalPointClause + | symbolicCharactersClause + | environmentSwitchNameClause + | defaultDisplaySignClause + | defaultComputationalSignClause + | reserveNetworkClause + ; + +alphabetClause + : alphabetClauseFormat1 + | alphabetClauseFormat2 + ; + +alphabetClauseFormat1 + : ALPHABET alphabetName (FOR ALPHANUMERIC)? IS? ( + EBCDIC + | ASCII + | STANDARD_1 + | STANDARD_2 + | NATIVE + | cobolWord + | alphabetLiterals+ + ) + ; + +alphabetLiterals + : literal (alphabetThrough | alphabetAlso+)? + ; + +alphabetThrough + : (THROUGH | THRU) literal + ; + +alphabetAlso + : ALSO literal+ + ; + +alphabetClauseFormat2 + : ALPHABET alphabetName FOR? NATIONAL IS? (NATIVE | CCSVERSION literal) + ; + +channelClause + : CHANNEL integerLiteral IS? mnemonicName + ; + +classClause + : CLASS className (FOR? (ALPHANUMERIC | NATIONAL))? IS? classClauseThrough+ + ; + +classClauseThrough + : classClauseFrom ((THROUGH | THRU) classClauseTo)? + ; + +classClauseFrom + : identifier + | literal + ; + +classClauseTo + : identifier + | literal + ; + +currencySignClause + : CURRENCY SIGN? IS? literal (WITH? PICTURE SYMBOL literal)? + ; + +decimalPointClause + : DECIMAL_POINT IS? COMMA + ; + +defaultComputationalSignClause + : DEFAULT (COMPUTATIONAL | COMP)? (SIGN IS?)? (LEADING | TRAILING)? (SEPARATE CHARACTER?) + ; + +defaultDisplaySignClause + : DEFAULT_DISPLAY (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? + ; + +environmentSwitchNameClause + : environmentName IS? mnemonicName environmentSwitchNameSpecialNamesStatusPhrase? + | environmentSwitchNameSpecialNamesStatusPhrase + ; + +environmentSwitchNameSpecialNamesStatusPhrase + : ON STATUS? IS? condition (OFF STATUS? IS? condition)? + | OFF STATUS? IS? condition (ON STATUS? IS? condition)? + ; + +odtClause + : ODT IS? mnemonicName + ; + +reserveNetworkClause + : RESERVE WORDS? LIST? IS? NETWORK CAPABLE? + ; + +symbolicCharactersClause + : SYMBOLIC CHARACTERS? (FOR? (ALPHANUMERIC | NATIONAL))? symbolicCharacters+ (IN alphabetName)? + ; + +symbolicCharacters + : symbolicCharacter+ (IS | ARE)? integerLiteral+ + ; + +// -- input output section ---------------------------------- + +inputOutputSection + : INPUT_OUTPUT SECTION DOT_FS inputOutputSectionParagraph* + ; + +// - input output section paragraph ---------------------------------- + +inputOutputSectionParagraph + : fileControlParagraph + | ioControlParagraph + ; + +// - file control paragraph ---------------------------------- + +fileControlParagraph + : FILE_CONTROL (DOT_FS? fileControlEntry)* DOT_FS + ; + +fileControlEntry + : selectClause fileControlClause* + ; + +selectClause + : SELECT OPTIONAL? fileName + ; + +fileControlClause + : assignClause + | reserveClause + | organizationClause + | paddingCharacterClause + | recordDelimiterClause + | accessModeClause + | recordKeyClause + | alternateRecordKeyClause + | fileStatusClause + | passwordClause + | relativeKeyClause + ; + +assignClause + : ASSIGN TO? ( + DISK + | DISPLAY + | KEYBOARD + | PORT + | PRINTER + | READER + | REMOTE + | TAPE + | VIRTUAL + | assignmentName + | literal + ) + ; + +reserveClause + : RESERVE (NO | integerLiteral) ALTERNATE? (AREA | AREAS)? + ; + +organizationClause + : (ORGANIZATION IS?)? (LINE | RECORD BINARY | RECORD | BINARY)? ( + SEQUENTIAL + | RELATIVE + | INDEXED + ) + ; + +paddingCharacterClause + : PADDING CHARACTER? IS? (qualifiedDataName | literal) + ; + +recordDelimiterClause + : RECORD DELIMITER IS? (STANDARD_1 | IMPLICIT | assignmentName) + ; + +accessModeClause + : ACCESS MODE? IS? (SEQUENTIAL | RANDOM | DYNAMIC | EXCLUSIVE) + ; + +recordKeyClause + : RECORD KEY? IS? qualifiedDataName passwordClause? (WITH? DUPLICATES)? + ; + +alternateRecordKeyClause + : ALTERNATE RECORD KEY? IS? qualifiedDataName passwordClause? (WITH? DUPLICATES)? + ; + +passwordClause + : PASSWORD IS? dataName + ; + +fileStatusClause + : FILE? STATUS IS? qualifiedDataName qualifiedDataName? + ; + +relativeKeyClause + : RELATIVE KEY? IS? qualifiedDataName + ; + +// - io control paragraph ---------------------------------- + +ioControlParagraph + : I_O_CONTROL DOT_FS (fileName DOT_FS)? (ioControlClause* DOT_FS)? + ; + +ioControlClause + : rerunClause + | sameClause + | multipleFileClause + | commitmentControlClause + ; + +rerunClause + : RERUN (ON (assignmentName | fileName))? EVERY ( + rerunEveryRecords + | rerunEveryOf + | rerunEveryClock + ) + ; + +rerunEveryRecords + : integerLiteral RECORDS + ; + +rerunEveryOf + : END? OF? (REEL | UNIT) OF fileName + ; + +rerunEveryClock + : integerLiteral CLOCK_UNITS? + ; + +sameClause + : SAME (RECORD | SORT | SORT_MERGE)? AREA? FOR? fileName+ + ; + +multipleFileClause + : MULTIPLE FILE TAPE? CONTAINS? multipleFilePosition+ + ; + +multipleFilePosition + : fileName (POSITION integerLiteral)? + ; + +commitmentControlClause + : COMMITMENT CONTROL FOR? fileName + ; + +// --- data division -------------------------------------------------------------------- + +dataDivision + : DATA DIVISION DOT_FS dataDivisionSection* + ; + +dataDivisionSection + : fileSection + | dataBaseSection + | workingStorageSection + | linkageSection + | communicationSection + | localStorageSection + | screenSection + | reportSection + | programLibrarySection + ; + +// -- file section ---------------------------------- + +fileSection + : FILE SECTION DOT_FS fileDescriptionEntry* + ; + +fileDescriptionEntry + : (FD | SD) fileName (DOT_FS? fileDescriptionEntryClause)* DOT_FS dataDescriptionEntry* + ; + +fileDescriptionEntryClause + : externalClause + | globalClause + | blockContainsClause + | recordContainsClause + | labelRecordsClause + | valueOfClause + | dataRecordsClause + | linageClause + | codeSetClause + | reportClause + | recordingModeClause + ; + +externalClause + : IS? EXTERNAL + ; + +globalClause + : IS? GLOBAL + ; + +blockContainsClause + : BLOCK CONTAINS? integerLiteral blockContainsTo? (RECORDS | CHARACTERS)? + ; + +blockContainsTo + : TO integerLiteral + ; + +recordContainsClause + : RECORD ( + recordContainsClauseFormat1 + | recordContainsClauseFormat2 + | recordContainsClauseFormat3 + ) + ; + +recordContainsClauseFormat1 + : CONTAINS? integerLiteral CHARACTERS? + ; + +recordContainsClauseFormat2 + : IS? VARYING IN? SIZE? (FROM? integerLiteral recordContainsTo? CHARACTERS?)? ( + DEPENDING ON? qualifiedDataName + )? + ; + +recordContainsClauseFormat3 + : CONTAINS? integerLiteral recordContainsTo CHARACTERS? + ; + +recordContainsTo + : TO integerLiteral + ; + +labelRecordsClause + : LABEL (RECORD IS? | RECORDS ARE?) (OMITTED | STANDARD | dataName+) + ; + +valueOfClause + : VALUE OF valuePair+ + ; + +valuePair + : systemName IS? (qualifiedDataName | literal) + ; + +dataRecordsClause + : DATA (RECORD IS? | RECORDS ARE?) dataName+ + ; + +linageClause + : LINAGE IS? (dataName | integerLiteral) LINES? linageAt* + ; + +linageAt + : linageFootingAt + | linageLinesAtTop + | linageLinesAtBottom + ; + +linageFootingAt + : WITH? FOOTING AT? (dataName | integerLiteral) + ; + +linageLinesAtTop + : LINES? AT? TOP (dataName | integerLiteral) + ; + +linageLinesAtBottom + : LINES? AT? BOTTOM (dataName | integerLiteral) + ; + +recordingModeClause + : RECORDING MODE? IS? modeStatement + ; + +modeStatement + : cobolWord + ; + +codeSetClause + : CODE_SET IS? alphabetName + ; + +reportClause + : (REPORT IS? | REPORTS ARE?) reportName+ + ; + +// -- data base section ---------------------------------- + +dataBaseSection + : DATA_BASE SECTION DOT_FS dataBaseSectionEntry* + ; + +dataBaseSectionEntry + : integerLiteral literal INVOKE literal + ; + +// -- working storage section ---------------------------------- + +workingStorageSection + : WORKING_STORAGE SECTION DOT_FS dataDescriptionEntry* + ; + +// -- linkage section ---------------------------------- + +linkageSection + : LINKAGE SECTION DOT_FS dataDescriptionEntry* + ; + +// -- communication section ---------------------------------- + +communicationSection + : COMMUNICATION SECTION DOT_FS (communicationDescriptionEntry | dataDescriptionEntry)* + ; + +communicationDescriptionEntry + : communicationDescriptionEntryFormat1 + | communicationDescriptionEntryFormat2 + | communicationDescriptionEntryFormat3 + ; + +communicationDescriptionEntryFormat1 + : CD cdName FOR? INITIAL? INPUT ( + ( + symbolicQueueClause + | symbolicSubQueueClause + | messageDateClause + | messageTimeClause + | symbolicSourceClause + | textLengthClause + | endKeyClause + | statusKeyClause + | messageCountClause + ) + | dataDescName + )* DOT_FS + ; + +communicationDescriptionEntryFormat2 + : CD cdName FOR? OUTPUT ( + destinationCountClause + | textLengthClause + | statusKeyClause + | destinationTableClause + | errorKeyClause + | symbolicDestinationClause + )* DOT_FS + ; + +communicationDescriptionEntryFormat3 + : CD cdName FOR? INITIAL I_O ( + ( + messageDateClause + | messageTimeClause + | symbolicTerminalClause + | textLengthClause + | endKeyClause + | statusKeyClause + ) + | dataDescName + )* DOT_FS + ; + +destinationCountClause + : DESTINATION COUNT IS? dataDescName + ; + +destinationTableClause + : DESTINATION TABLE OCCURS integerLiteral TIMES (INDEXED BY indexName+)? + ; + +endKeyClause + : END KEY IS? dataDescName + ; + +errorKeyClause + : ERROR KEY IS? dataDescName + ; + +messageCountClause + : MESSAGE? COUNT IS? dataDescName + ; + +messageDateClause + : MESSAGE DATE IS? dataDescName + ; + +messageTimeClause + : MESSAGE TIME IS? dataDescName + ; + +statusKeyClause + : STATUS KEY IS? dataDescName + ; + +symbolicDestinationClause + : SYMBOLIC? DESTINATION IS? dataDescName + ; + +symbolicQueueClause + : SYMBOLIC? QUEUE IS? dataDescName + ; + +symbolicSourceClause + : SYMBOLIC? SOURCE IS? dataDescName + ; + +symbolicTerminalClause + : SYMBOLIC? TERMINAL IS? dataDescName + ; + +symbolicSubQueueClause + : SYMBOLIC? (SUB_QUEUE_1 | SUB_QUEUE_2 | SUB_QUEUE_3) IS? dataDescName + ; + +textLengthClause + : TEXT LENGTH IS? dataDescName + ; + +// -- local storage section ---------------------------------- + +localStorageSection + : LOCAL_STORAGE SECTION DOT_FS (LD localName DOT_FS)? dataDescriptionEntry* + ; + +// -- screen section ---------------------------------- + +screenSection + : SCREEN SECTION DOT_FS screenDescriptionEntry* + ; + +screenDescriptionEntry + : INTEGERLITERAL (FILLER | screenName)? ( + screenDescriptionBlankClause + | screenDescriptionBellClause + | screenDescriptionBlinkClause + | screenDescriptionEraseClause + | screenDescriptionLightClause + | screenDescriptionGridClause + | screenDescriptionReverseVideoClause + | screenDescriptionUnderlineClause + | screenDescriptionSizeClause + | screenDescriptionLineClause + | screenDescriptionColumnClause + | screenDescriptionForegroundColorClause + | screenDescriptionBackgroundColorClause + | screenDescriptionControlClause + | screenDescriptionValueClause + | screenDescriptionPictureClause + | (screenDescriptionFromClause | screenDescriptionUsingClause) + | screenDescriptionUsageClause + | screenDescriptionBlankWhenZeroClause + | screenDescriptionJustifiedClause + | screenDescriptionSignClause + | screenDescriptionAutoClause + | screenDescriptionSecureClause + | screenDescriptionRequiredClause + | screenDescriptionPromptClause + | screenDescriptionFullClause + | screenDescriptionZeroFillClause + )* DOT_FS + ; + +screenDescriptionBlankClause + : BLANK (SCREEN | LINE) + ; + +screenDescriptionBellClause + : BELL + | BEEP + ; + +screenDescriptionBlinkClause + : BLINK + ; + +screenDescriptionEraseClause + : ERASE (EOL | EOS) + ; + +screenDescriptionLightClause + : HIGHLIGHT + | LOWLIGHT + ; + +screenDescriptionGridClause + : GRID + | LEFTLINE + | OVERLINE + ; + +screenDescriptionReverseVideoClause + : REVERSE_VIDEO + ; + +screenDescriptionUnderlineClause + : UNDERLINE + ; + +screenDescriptionSizeClause + : SIZE IS? (identifier | integerLiteral) + ; + +screenDescriptionLineClause + : LINE (NUMBER? IS? (PLUS | PLUSCHAR | MINUSCHAR))? (identifier | integerLiteral) + ; + +screenDescriptionColumnClause + : (COLUMN | COL) (NUMBER? IS? (PLUS | PLUSCHAR | MINUSCHAR))? (identifier | integerLiteral) + ; + +screenDescriptionForegroundColorClause + : (FOREGROUND_COLOR | FOREGROUND_COLOUR) IS? (identifier | integerLiteral) + ; + +screenDescriptionBackgroundColorClause + : (BACKGROUND_COLOR | BACKGROUND_COLOUR) IS? (identifier | integerLiteral) + ; + +screenDescriptionControlClause + : CONTROL IS? identifier + ; + +screenDescriptionValueClause + : (VALUE IS?) literal + ; + +screenDescriptionPictureClause + : (PICTURE | PIC) IS? pictureString + ; + +screenDescriptionFromClause + : FROM (identifier | literal) screenDescriptionToClause? + ; + +screenDescriptionToClause + : TO identifier + ; + +screenDescriptionUsingClause + : USING identifier + ; + +screenDescriptionUsageClause + : (USAGE IS?) (DISPLAY | DISPLAY_1) + ; + +screenDescriptionBlankWhenZeroClause + : BLANK WHEN? ZERO + ; + +screenDescriptionJustifiedClause + : (JUSTIFIED | JUST) RIGHT? + ; + +screenDescriptionSignClause + : (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? + ; + +screenDescriptionAutoClause + : AUTO + | AUTO_SKIP + ; + +screenDescriptionSecureClause + : SECURE + | NO_ECHO + ; + +screenDescriptionRequiredClause + : REQUIRED + | EMPTY_CHECK + ; + +screenDescriptionPromptClause + : PROMPT CHARACTER? IS? (identifier | literal) screenDescriptionPromptOccursClause? + ; + +screenDescriptionPromptOccursClause + : OCCURS integerLiteral TIMES? + ; + +screenDescriptionFullClause + : FULL + | LENGTH_CHECK + ; + +screenDescriptionZeroFillClause + : ZERO_FILL + ; + +// -- report section ---------------------------------- + +reportSection + : REPORT SECTION DOT_FS reportDescription* + ; + +reportDescription + : reportDescriptionEntry reportGroupDescriptionEntry+ + ; + +reportDescriptionEntry + : RD reportName reportDescriptionGlobalClause? ( + reportDescriptionPageLimitClause reportDescriptionHeadingClause? reportDescriptionFirstDetailClause? reportDescriptionLastDetailClause? + reportDescriptionFootingClause? + )? DOT_FS + ; + +reportDescriptionGlobalClause + : IS? GLOBAL + ; + +reportDescriptionPageLimitClause + : PAGE (LIMIT IS? | LIMITS ARE?)? integerLiteral (LINE | LINES)? + ; + +reportDescriptionHeadingClause + : HEADING integerLiteral + ; + +reportDescriptionFirstDetailClause + : FIRST DETAIL integerLiteral + ; + +reportDescriptionLastDetailClause + : LAST DETAIL integerLiteral + ; + +reportDescriptionFootingClause + : FOOTING integerLiteral + ; + +reportGroupDescriptionEntry + : reportGroupDescriptionEntryFormat1 + | reportGroupDescriptionEntryFormat2 + | reportGroupDescriptionEntryFormat3 + ; + +reportGroupDescriptionEntryFormat1 + : integerLiteral dataName reportGroupLineNumberClause? reportGroupNextGroupClause? reportGroupTypeClause reportGroupUsageClause? DOT_FS + ; + +reportGroupDescriptionEntryFormat2 + : integerLiteral dataName? reportGroupLineNumberClause? reportGroupUsageClause DOT_FS + ; + +reportGroupDescriptionEntryFormat3 + : integerLiteral dataName? ( + reportGroupPictureClause + | reportGroupUsageClause + | reportGroupSignClause + | reportGroupJustifiedClause + | reportGroupBlankWhenZeroClause + | reportGroupLineNumberClause + | reportGroupColumnNumberClause + | ( + reportGroupSourceClause + | reportGroupValueClause + | reportGroupSumClause + | reportGroupResetClause + ) + | reportGroupIndicateClause + )* DOT_FS + ; + +reportGroupBlankWhenZeroClause + : BLANK WHEN? ZERO + ; + +reportGroupColumnNumberClause + : COLUMN NUMBER? IS? integerLiteral + ; + +reportGroupIndicateClause + : GROUP INDICATE? + ; + +reportGroupJustifiedClause + : (JUSTIFIED | JUST) RIGHT? + ; + +reportGroupLineNumberClause + : LINE? NUMBER? IS? (reportGroupLineNumberNextPage | reportGroupLineNumberPlus) + ; + +reportGroupLineNumberNextPage + : integerLiteral (ON? NEXT PAGE)? + ; + +reportGroupLineNumberPlus + : PLUS integerLiteral + ; + +reportGroupNextGroupClause + : NEXT GROUP IS? (integerLiteral | reportGroupNextGroupNextPage | reportGroupNextGroupPlus) + ; + +reportGroupNextGroupPlus + : PLUS integerLiteral + ; + +reportGroupNextGroupNextPage + : NEXT PAGE + ; + +reportGroupPictureClause + : (PICTURE | PIC) IS? pictureString + ; + +reportGroupResetClause + : RESET ON? (FINAL | dataName) + ; + +reportGroupSignClause + : SIGN IS? (LEADING | TRAILING) SEPARATE CHARACTER? + ; + +reportGroupSourceClause + : SOURCE IS? identifier + ; + +reportGroupSumClause + : SUM identifier (COMMACHAR? identifier)* (UPON dataName (COMMACHAR? dataName)*)? + ; + +reportGroupTypeClause + : TYPE IS? ( + reportGroupTypeReportHeading + | reportGroupTypePageHeading + | reportGroupTypeControlHeading + | reportGroupTypeDetail + | reportGroupTypeControlFooting + | reportGroupTypePageFooting + | reportGroupTypeReportFooting + ) + ; + +reportGroupTypeReportHeading + : REPORT HEADING + | RH + ; + +reportGroupTypePageHeading + : PAGE HEADING + | PH + ; + +reportGroupTypeControlHeading + : (CONTROL HEADING | CH) (FINAL | dataName) + ; + +reportGroupTypeDetail + : DETAIL + | DE + ; + +reportGroupTypeControlFooting + : (CONTROL FOOTING | CF) (FINAL | dataName) + ; + +reportGroupUsageClause + : (USAGE IS?)? (DISPLAY | DISPLAY_1) + ; + +reportGroupTypePageFooting + : PAGE FOOTING + | PF + ; + +reportGroupTypeReportFooting + : REPORT FOOTING + | RF + ; + +reportGroupValueClause + : VALUE IS? literal + ; + +// -- program library section ---------------------------------- + +programLibrarySection + : PROGRAM_LIBRARY SECTION DOT_FS libraryDescriptionEntry* + ; + +libraryDescriptionEntry + : libraryDescriptionEntryFormat1 + | libraryDescriptionEntryFormat2 + ; + +libraryDescriptionEntryFormat1 + : LD libraryName EXPORT libraryAttributeClauseFormat1? libraryEntryProcedureClauseFormat1? + ; + +libraryDescriptionEntryFormat2 + : LB libraryName IMPORT libraryIsGlobalClause? libraryIsCommonClause? ( + libraryAttributeClauseFormat2 + | libraryEntryProcedureClauseFormat2 + )* + ; + +libraryAttributeClauseFormat1 + : ATTRIBUTE (SHARING IS? (DONTCARE | PRIVATE | SHAREDBYRUNUNIT | SHAREDBYALL))? + ; + +libraryAttributeClauseFormat2 + : ATTRIBUTE libraryAttributeFunction? (LIBACCESS IS? (BYFUNCTION | BYTITLE))? libraryAttributeParameter? libraryAttributeTitle? + ; + +libraryAttributeFunction + : FUNCTIONNAME IS literal + ; + +libraryAttributeParameter + : LIBPARAMETER IS? literal + ; + +libraryAttributeTitle + : TITLE IS? literal + ; + +libraryEntryProcedureClauseFormat1 + : ENTRY_PROCEDURE programName libraryEntryProcedureForClause? + ; + +libraryEntryProcedureClauseFormat2 + : ENTRY_PROCEDURE programName libraryEntryProcedureForClause? libraryEntryProcedureWithClause? libraryEntryProcedureUsingClause? + libraryEntryProcedureGivingClause? + ; + +libraryEntryProcedureForClause + : FOR literal + ; + +libraryEntryProcedureGivingClause + : GIVING dataName + ; + +libraryEntryProcedureUsingClause + : USING libraryEntryProcedureUsingName+ + ; + +libraryEntryProcedureUsingName + : dataName + | fileName + ; + +libraryEntryProcedureWithClause + : WITH libraryEntryProcedureWithName+ + ; + +libraryEntryProcedureWithName + : localName + | fileName + ; + +libraryIsCommonClause + : IS? COMMON + ; + +libraryIsGlobalClause + : IS? GLOBAL + ; + +// data description entry ---------------------------------- + +dataDescriptionEntry + : dataDescriptionEntryFormat1 + | dataDescriptionEntryFormat2 + | dataDescriptionEntryFormat3 + | dataDescriptionEntryExecSql + ; + +dataDescriptionEntryFormat1 + : (INTEGERLITERAL | LEVEL_NUMBER_77) (FILLER | dataName)? ( + dataRedefinesClause + | dataIntegerStringClause + | dataExternalClause + | dataGlobalClause + | dataTypeDefClause + | dataThreadLocalClause + | dataPictureClause + | dataCommonOwnLocalClause + | dataTypeClause + | dataUsingClause + | dataUsageClause + | dataValueClause + | dataReceivedByClause + | dataOccursClause + | dataSignClause + | dataSynchronizedClause + | dataJustifiedClause + | dataBlankWhenZeroClause + | dataWithLowerBoundsClause + | dataAlignedClause + | dataRecordAreaClause + )* DOT_FS + ; + +dataDescriptionEntryFormat2 + : LEVEL_NUMBER_66 dataName dataRenamesClause DOT_FS + ; + +dataDescriptionEntryFormat3 + : LEVEL_NUMBER_88 conditionName dataValueClause DOT_FS + ; + +dataDescriptionEntryExecSql + : EXECSQLLINE+ DOT_FS? + ; + +dataAlignedClause + : ALIGNED + ; + +dataBlankWhenZeroClause + : BLANK WHEN? (ZERO | ZEROS | ZEROES) + ; + +dataCommonOwnLocalClause + : COMMON + | OWN + | LOCAL + ; + +dataExternalClause + : IS? EXTERNAL (BY literal)? + ; + +dataGlobalClause + : IS? GLOBAL + ; + +dataIntegerStringClause + : INTEGER + | STRING + ; + +dataJustifiedClause + : (JUSTIFIED | JUST) RIGHT? + ; + +dataOccursClause + : OCCURS integerLiteral dataOccursTo? TIMES? (DEPENDING ON? qualifiedDataName)? dataOccursSort* ( + INDEXED BY? LOCAL? indexName+ + )? + ; + +dataOccursTo + : TO integerLiteral + ; + +dataOccursSort + : (ASCENDING | DESCENDING) KEY? IS? qualifiedDataName+ + ; + +dataPictureClause + : (PICTURE | PIC) IS? pictureString + ; + +pictureString + : (pictureChars+ pictureCardinality?)+ + ; + +pictureChars + : DOLLARCHAR + | IDENTIFIER + | NUMERICLITERAL + | SLASHCHAR + | COMMACHAR + | DOT + | COLONCHAR + | ASTERISKCHAR + | DOUBLEASTERISKCHAR + | LPARENCHAR + | RPARENCHAR + | PLUSCHAR + | MINUSCHAR + | LESSTHANCHAR + | MORETHANCHAR + | integerLiteral + ; + +pictureCardinality + : LPARENCHAR integerLiteral RPARENCHAR + ; + +dataReceivedByClause + : RECEIVED? BY? (CONTENT | REFERENCE | REF) + ; + +dataRecordAreaClause + : RECORD AREA + ; + +dataRedefinesClause + : REDEFINES dataName + ; + +dataRenamesClause + : RENAMES qualifiedDataName ((THROUGH | THRU) qualifiedDataName)? + ; + +dataSignClause + : (SIGN IS?)? (LEADING | TRAILING) (SEPARATE CHARACTER?)? + ; + +dataSynchronizedClause + : (SYNCHRONIZED | SYNC) (LEFT | RIGHT)? + ; + +dataThreadLocalClause + : IS? THREAD_LOCAL + ; + +dataTypeClause + : TYPE IS? (SHORT_DATE | LONG_DATE | NUMERIC_DATE | NUMERIC_TIME | LONG_TIME) + ; + +dataTypeDefClause + : IS? TYPEDEF + ; + +dataUsageClause + : (USAGE IS?)? ( + BINARY (TRUNCATED | EXTENDED)? + | BIT + | COMP + | COMP_1 + | COMP_2 + | COMP_3 + | COMP_4 + | COMP_5 + | COMPUTATIONAL + | COMPUTATIONAL_1 + | COMPUTATIONAL_2 + | COMPUTATIONAL_3 + | COMPUTATIONAL_4 + | COMPUTATIONAL_5 + | CONTROL_POINT + | DATE + | DISPLAY + | DISPLAY_1 + | DOUBLE + | EVENT + | FUNCTION_POINTER + | INDEX + | KANJI + | LOCK + | NATIONAL + | PACKED_DECIMAL + | POINTER + | PROCEDURE_POINTER + | REAL + | TASK + ) + ; + +dataUsingClause + : USING (LANGUAGE | CONVENTION) OF? (cobolWord | dataName) + ; + +dataValueClause + : (VALUE IS? | VALUES ARE?)? dataValueInterval (COMMACHAR? dataValueInterval)* + ; + +dataValueInterval + : dataValueIntervalFrom dataValueIntervalTo? + ; + +dataValueIntervalFrom + : literal + | cobolWord + ; + +dataValueIntervalTo + : (THROUGH | THRU) literal + ; + +dataWithLowerBoundsClause + : WITH? LOWER BOUNDS + ; + +// --- procedure division -------------------------------------------------------------------- + +procedureDivision + : PROCEDURE DIVISION procedureDivisionUsingClause? procedureDivisionGivingClause? DOT_FS procedureDeclaratives? procedureDivisionBody + ; + +procedureDivisionUsingClause + : (USING | CHAINING) procedureDivisionUsingParameter+ + ; + +procedureDivisionGivingClause + : (GIVING | RETURNING) dataName + ; + +procedureDivisionUsingParameter + : procedureDivisionByReferencePhrase + | procedureDivisionByValuePhrase + ; + +procedureDivisionByReferencePhrase + : (BY? REFERENCE)? procedureDivisionByReference+ + ; + +procedureDivisionByReference + : (OPTIONAL? (identifier | fileName)) + | ANY + ; + +procedureDivisionByValuePhrase + : BY? VALUE procedureDivisionByValue+ + ; + +procedureDivisionByValue + : identifier + | literal + | ANY + ; + +procedureDeclaratives + : DECLARATIVES DOT_FS procedureDeclarative+ END DECLARATIVES DOT_FS + ; + +procedureDeclarative + : procedureSectionHeader DOT_FS useStatement DOT_FS paragraphs + ; + +procedureSectionHeader + : sectionName SECTION integerLiteral? + ; + +procedureDivisionBody + : paragraphs procedureSection* + ; + +// -- procedure section ---------------------------------- + +procedureSection + : procedureSectionHeader DOT_FS paragraphs + ; + +paragraphs + : sentence* paragraph* + ; + +paragraph + : paragraphName DOT_FS (alteredGoTo | sentence*) + ; + +sentence + : statement* DOT_FS + ; + +statement + : acceptStatement + | addStatement + | alterStatement + | callStatement + | cancelStatement + | closeStatement + | computeStatement + | continueStatement + | deleteStatement + | disableStatement + | displayStatement + | divideStatement + | enableStatement + | entryStatement + | evaluateStatement + | exhibitStatement + | execCicsStatement + | execSqlStatement + | execSqlImsStatement + | exitStatement + | generateStatement + | gobackStatement + | goToStatement + | ifStatement + | initializeStatement + | initiateStatement + | inspectStatement + | mergeStatement + | moveStatement + | multiplyStatement + | openStatement + | performStatement + | purgeStatement + | readStatement + | receiveStatement + | releaseStatement + | returnStatement + | rewriteStatement + | searchStatement + | sendStatement + | setStatement + | sortStatement + | startStatement + | stopStatement + | stringStatement + | subtractStatement + | terminateStatement + | unstringStatement + | writeStatement + ; + +// accept statement + +acceptStatement + : ACCEPT identifier ( + acceptFromDateStatement + | acceptFromEscapeKeyStatement + | acceptFromMnemonicStatement + | acceptMessageCountStatement + )? onExceptionClause? notOnExceptionClause? END_ACCEPT? + ; + +acceptFromDateStatement + : FROM ( + DATE YYYYMMDD? + | DAY YYYYDDD? + | DAY_OF_WEEK + | TIME + | TIMER + | TODAYS_DATE MMDDYYYY? + | TODAYS_NAME + | YEAR + | YYYYMMDD + | YYYYDDD + ) + ; + +acceptFromMnemonicStatement + : FROM mnemonicName + ; + +acceptFromEscapeKeyStatement + : FROM ESCAPE KEY + ; + +acceptMessageCountStatement + : MESSAGE? COUNT + ; + +// add statement + +addStatement + : ADD (addToStatement | addToGivingStatement | addCorrespondingStatement) onSizeErrorPhrase? notOnSizeErrorPhrase? END_ADD? + ; + +addToStatement + : addFrom+ TO addTo+ + ; + +addToGivingStatement + : addFrom+ (TO addToGiving+)? GIVING addGiving+ + ; + +addCorrespondingStatement + : (CORRESPONDING | CORR) identifier TO addTo + ; + +addFrom + : identifier + | literal + ; + +addTo + : identifier ROUNDED? + ; + +addToGiving + : identifier + | literal + ; + +addGiving + : identifier ROUNDED? + ; + +// altered go to statement + +alteredGoTo + : GO TO? DOT_FS + ; + +// alter statement + +alterStatement + : ALTER alterProceedTo+ + ; + +alterProceedTo + : procedureName TO (PROCEED TO)? procedureName + ; + +// call statement + +callStatement + : CALL (identifier | literal) callUsingPhrase? callGivingPhrase? onOverflowPhrase? onExceptionClause? notOnExceptionClause? END_CALL? + ; + +callUsingPhrase + : USING callUsingParameter+ + ; + +callUsingParameter + : callByReferencePhrase + | callByValuePhrase + | callByContentPhrase + ; + +callByReferencePhrase + : (BY? REFERENCE)? callByReference+ + ; + +callByReference + : ((ADDRESS OF | INTEGER | STRING)? identifier | literal | fileName) + | OMITTED + ; + +callByValuePhrase + : BY? VALUE callByValue+ + ; + +callByValue + : (ADDRESS OF | LENGTH OF?)? (identifier | literal) + ; + +callByContentPhrase + : BY? CONTENT callByContent+ + ; + +callByContent + : (ADDRESS OF | LENGTH OF?)? identifier + | literal + | OMITTED + ; + +callGivingPhrase + : (GIVING | RETURNING) identifier + ; + +// cancel statement + +cancelStatement + : CANCEL cancelCall+ + ; + +cancelCall + : libraryName (BYTITLE | BYFUNCTION) + | identifier + | literal + ; + +// close statement + +closeStatement + : CLOSE closeFile+ + ; + +closeFile + : fileName (closeReelUnitStatement | closeRelativeStatement | closePortFileIOStatement)? + ; + +closeReelUnitStatement + : (REEL | UNIT) (FOR? REMOVAL)? (WITH? (NO REWIND | LOCK))? + ; + +closeRelativeStatement + : WITH? (NO REWIND | LOCK) + ; + +closePortFileIOStatement + : (WITH? NO WAIT | WITH WAIT) (USING closePortFileIOUsing+)? + ; + +closePortFileIOUsing + : closePortFileIOUsingCloseDisposition + | closePortFileIOUsingAssociatedData + | closePortFileIOUsingAssociatedDataLength + ; + +closePortFileIOUsingCloseDisposition + : CLOSE_DISPOSITION OF? (ABORT | ORDERLY) + ; + +closePortFileIOUsingAssociatedData + : ASSOCIATED_DATA (identifier | integerLiteral) + ; + +closePortFileIOUsingAssociatedDataLength + : ASSOCIATED_DATA_LENGTH OF? (identifier | integerLiteral) + ; + +// compute statement + +computeStatement + : COMPUTE computeStore+ (EQUALCHAR | EQUAL) arithmeticExpression onSizeErrorPhrase? notOnSizeErrorPhrase? END_COMPUTE? + ; + +computeStore + : identifier ROUNDED? + ; + +// continue statement + +continueStatement + : CONTINUE + ; + +// delete statement + +deleteStatement + : DELETE fileName RECORD? invalidKeyPhrase? notInvalidKeyPhrase? END_DELETE? + ; + +// disable statement + +disableStatement + : DISABLE (INPUT TERMINAL? | I_O TERMINAL | OUTPUT) cdName WITH? KEY (identifier | literal) + ; + +// display statement + +displayStatement + : DISPLAY displayOperand+ displayAt? displayUpon? displayWith? + ; + +displayOperand + : identifier + | literal + ; + +displayAt + : AT (identifier | literal) + ; + +displayUpon + : UPON (mnemonicName | environmentName) + ; + +displayWith + : WITH? NO ADVANCING + ; + +// divide statement + +divideStatement + : DIVIDE (identifier | literal) ( + divideIntoStatement + | divideIntoGivingStatement + | divideByGivingStatement + ) divideRemainder? onSizeErrorPhrase? notOnSizeErrorPhrase? END_DIVIDE? + ; + +divideIntoStatement + : INTO divideInto+ + ; + +divideIntoGivingStatement + : INTO (identifier | literal) divideGivingPhrase? + ; + +divideByGivingStatement + : BY (identifier | literal) divideGivingPhrase? + ; + +divideGivingPhrase + : GIVING divideGiving+ + ; + +divideInto + : identifier ROUNDED? + ; + +divideGiving + : identifier ROUNDED? + ; + +divideRemainder + : REMAINDER identifier + ; + +// enable statement + +enableStatement + : ENABLE (INPUT TERMINAL? | I_O TERMINAL | OUTPUT) cdName WITH? KEY (literal | identifier) + ; + +// entry statement + +entryStatement + : ENTRY literal (USING identifier+)? + ; + +// evaluate statement + +evaluateStatement + : EVALUATE evaluateSelect evaluateAlsoSelect* evaluateWhenPhrase+ evaluateWhenOther? END_EVALUATE? + ; + +evaluateSelect + : identifier + | literal + | arithmeticExpression + | condition + ; + +evaluateAlsoSelect + : ALSO evaluateSelect + ; + +evaluateWhenPhrase + : evaluateWhen+ statement* + ; + +evaluateWhen + : WHEN evaluateCondition evaluateAlsoCondition* + ; + +evaluateCondition + : ANY + | NOT? evaluateValue evaluateThrough? + | condition + | booleanLiteral + ; + +evaluateThrough + : (THROUGH | THRU) evaluateValue + ; + +evaluateAlsoCondition + : ALSO evaluateCondition + ; + +evaluateWhenOther + : WHEN OTHER statement* + ; + +evaluateValue + : identifier + | literal + | arithmeticExpression + ; + +// exec cics statement + +execCicsStatement + : EXECCICSLINE+ + ; + +// exec sql statement + +execSqlStatement + : EXECSQLLINE+ + ; + +// exec sql ims statement + +execSqlImsStatement + : EXECSQLIMSLINE+ + ; + +// exhibit statement + +exhibitStatement + : EXHIBIT NAMED? CHANGED? exhibitOperand+ + ; + +exhibitOperand + : identifier + | literal + ; + +// exit statement + +exitStatement + : EXIT PROGRAM? + ; + +// generate statement + +generateStatement + : GENERATE reportName + ; + +// goback statement + +gobackStatement + : GOBACK + ; + +// goto statement + +goToStatement + : GO TO? (goToStatementSimple | goToDependingOnStatement) + ; + +goToStatementSimple + : procedureName + ; + +goToDependingOnStatement + : MORE_LABELS + | procedureName+ (DEPENDING ON? identifier)? + ; + +// if statement + +ifStatement + : IF condition ifThen ifElse? END_IF? + ; + +ifThen + : THEN? (NEXT SENTENCE | statement*) + ; + +ifElse + : ELSE (NEXT SENTENCE | statement*) + ; + +// initialize statement + +initializeStatement + : INITIALIZE identifier+ initializeReplacingPhrase? + ; + +initializeReplacingPhrase + : REPLACING initializeReplacingBy+ + ; + +initializeReplacingBy + : ( + ALPHABETIC + | ALPHANUMERIC + | ALPHANUMERIC_EDITED + | NATIONAL + | NATIONAL_EDITED + | NUMERIC + | NUMERIC_EDITED + | DBCS + | EGCS + ) DATA? BY (identifier | literal) + ; + +// initiate statement + +initiateStatement + : INITIATE reportName+ + ; + +// inspect statement + +inspectStatement + : INSPECT identifier ( + inspectTallyingPhrase + | inspectReplacingPhrase + | inspectTallyingReplacingPhrase + | inspectConvertingPhrase + ) + ; + +inspectTallyingPhrase + : TALLYING inspectFor+ + ; + +inspectReplacingPhrase + : REPLACING (inspectReplacingCharacters | inspectReplacingAllLeadings)+ + ; + +inspectTallyingReplacingPhrase + : TALLYING inspectFor+ inspectReplacingPhrase+ + ; + +inspectConvertingPhrase + : CONVERTING (identifier | literal) inspectTo inspectBeforeAfter* + ; + +inspectFor + : identifier FOR (inspectCharacters | inspectAllLeadings)+ + ; + +inspectCharacters + : CHARACTERS inspectBeforeAfter* + ; + +inspectReplacingCharacters + : CHARACTERS inspectBy inspectBeforeAfter* + ; + +inspectAllLeadings + : (ALL | LEADING) inspectAllLeading+ + ; + +inspectReplacingAllLeadings + : (ALL | LEADING | FIRST) inspectReplacingAllLeading+ + ; + +inspectAllLeading + : (identifier | literal) inspectBeforeAfter* + ; + +inspectReplacingAllLeading + : (identifier | literal) inspectBy inspectBeforeAfter* + ; + +inspectBy + : BY (identifier | literal) + ; + +inspectTo + : TO (identifier | literal) + ; + +inspectBeforeAfter + : (BEFORE | AFTER) INITIAL? (identifier | literal) + ; + +// merge statement + +mergeStatement + : MERGE fileName mergeOnKeyClause+ mergeCollatingSequencePhrase? mergeUsing* mergeOutputProcedurePhrase? mergeGivingPhrase* + ; + +mergeOnKeyClause + : ON? (ASCENDING | DESCENDING) KEY? qualifiedDataName+ + ; + +mergeCollatingSequencePhrase + : COLLATING? SEQUENCE IS? alphabetName+ mergeCollatingAlphanumeric? mergeCollatingNational? + ; + +mergeCollatingAlphanumeric + : FOR? ALPHANUMERIC IS alphabetName + ; + +mergeCollatingNational + : FOR? NATIONAL IS? alphabetName + ; + +mergeUsing + : USING fileName+ + ; + +mergeOutputProcedurePhrase + : OUTPUT PROCEDURE IS? procedureName mergeOutputThrough? + ; + +mergeOutputThrough + : (THROUGH | THRU) procedureName + ; + +mergeGivingPhrase + : GIVING mergeGiving+ + ; + +mergeGiving + : fileName (LOCK | SAVE | NO REWIND | CRUNCH | RELEASE | WITH REMOVE CRUNCH)? + ; + +// move statement + +moveStatement + : MOVE ALL? (moveToStatement | moveCorrespondingToStatement) + ; + +moveToStatement + : moveToSendingArea TO identifier+ + ; + +moveToSendingArea + : identifier + | literal + ; + +moveCorrespondingToStatement + : (CORRESPONDING | CORR) moveCorrespondingToSendingArea TO identifier+ + ; + +moveCorrespondingToSendingArea + : identifier + ; + +// multiply statement + +multiplyStatement + : MULTIPLY (identifier | literal) BY (multiplyRegular | multiplyGiving) onSizeErrorPhrase? notOnSizeErrorPhrase? END_MULTIPLY? + ; + +multiplyRegular + : multiplyRegularOperand+ + ; + +multiplyRegularOperand + : identifier ROUNDED? + ; + +multiplyGiving + : multiplyGivingOperand GIVING multiplyGivingResult+ + ; + +multiplyGivingOperand + : identifier + | literal + ; + +multiplyGivingResult + : identifier ROUNDED? + ; + +// open statement + +openStatement + : OPEN (openInputStatement | openOutputStatement | openIOStatement | openExtendStatement)+ + ; + +openInputStatement + : INPUT openInput+ + ; + +openInput + : fileName (REVERSED | WITH? NO REWIND)? + ; + +openOutputStatement + : OUTPUT openOutput+ + ; + +openOutput + : fileName (WITH? NO REWIND)? + ; + +openIOStatement + : I_O fileName+ + ; + +openExtendStatement + : EXTEND fileName+ + ; + +// perform statement + +performStatement + : PERFORM (performInlineStatement | performProcedureStatement) + ; + +performInlineStatement + : performType? statement* END_PERFORM + ; + +performProcedureStatement + : procedureName ((THROUGH | THRU) procedureName)? performType? + ; + +performType + : performTimes + | performUntil + | performVarying + ; + +performTimes + : (identifier | integerLiteral) TIMES + ; + +performUntil + : performTestClause? UNTIL condition + ; + +performVarying + : performTestClause performVaryingClause + | performVaryingClause performTestClause? + ; + +performVaryingClause + : VARYING performVaryingPhrase performAfter* + ; + +performVaryingPhrase + : (identifier | literal) performFrom performBy performUntil + ; + +performAfter + : AFTER performVaryingPhrase + ; + +performFrom + : FROM (identifier | literal | arithmeticExpression) + ; + +performBy + : BY (identifier | literal | arithmeticExpression) + ; + +performTestClause + : WITH? TEST (BEFORE | AFTER) + ; + +// purge statement + +purgeStatement + : PURGE cdName+ + ; + +// read statement + +readStatement + : READ fileName NEXT? RECORD? readInto? readWith? readKey? invalidKeyPhrase? notInvalidKeyPhrase? atEndPhrase? notAtEndPhrase? END_READ? + ; + +readInto + : INTO identifier + ; + +readWith + : WITH? ((KEPT | NO) LOCK | WAIT) + ; + +readKey + : KEY IS? qualifiedDataName + ; + +// receive statement + +receiveStatement + : RECEIVE (receiveFromStatement | receiveIntoStatement) onExceptionClause? notOnExceptionClause? END_RECEIVE? + ; + +receiveFromStatement + : dataName FROM receiveFrom ( + receiveBefore + | receiveWith + | receiveThread + | receiveSize + | receiveStatus + )* + ; + +receiveFrom + : THREAD dataName + | LAST THREAD + | ANY THREAD + ; + +receiveIntoStatement + : cdName (MESSAGE | SEGMENT) INTO? identifier receiveNoData? receiveWithData? + ; + +receiveNoData + : NO DATA statement* + ; + +receiveWithData + : WITH DATA statement* + ; + +receiveBefore + : BEFORE TIME? (numericLiteral | identifier) + ; + +receiveWith + : WITH? NO WAIT + ; + +receiveThread + : THREAD IN? dataName + ; + +receiveSize + : SIZE IN? (numericLiteral | identifier) + ; + +receiveStatus + : STATUS IN? (identifier) + ; + +// release statement + +releaseStatement + : RELEASE recordName (FROM qualifiedDataName)? + ; + +// return statement + +returnStatement + : RETURN fileName RECORD? returnInto? atEndPhrase notAtEndPhrase? END_RETURN? + ; + +returnInto + : INTO qualifiedDataName + ; + +// rewrite statement + +rewriteStatement + : REWRITE recordName rewriteFrom? invalidKeyPhrase? notInvalidKeyPhrase? END_REWRITE? + ; + +rewriteFrom + : FROM identifier + ; + +// search statement + +searchStatement + : SEARCH ALL? qualifiedDataName searchVarying? atEndPhrase? searchWhen+ END_SEARCH? + ; + +searchVarying + : VARYING qualifiedDataName + ; + +searchWhen + : WHEN condition (NEXT SENTENCE | statement*) + ; + +// send statement + +sendStatement + : SEND (sendStatementSync | sendStatementAsync) onExceptionClause? notOnExceptionClause? + ; + +sendStatementSync + : (identifier | literal) sendFromPhrase? sendWithPhrase? sendReplacingPhrase? sendAdvancingPhrase? + ; + +sendStatementAsync + : TO (TOP | BOTTOM) identifier + ; + +sendFromPhrase + : FROM identifier + ; + +sendWithPhrase + : WITH (EGI | EMI | ESI | identifier) + ; + +sendReplacingPhrase + : REPLACING LINE? + ; + +sendAdvancingPhrase + : (BEFORE | AFTER) ADVANCING? (sendAdvancingPage | sendAdvancingLines | sendAdvancingMnemonic) + ; + +sendAdvancingPage + : PAGE + ; + +sendAdvancingLines + : (identifier | literal) (LINE | LINES)? + ; + +sendAdvancingMnemonic + : mnemonicName + ; + +// set statement + +setStatement + : SET (setToStatement+ | setUpDownByStatement) + ; + +setToStatement + : setTo+ TO setToValue+ + ; + +setUpDownByStatement + : setTo+ (UP BY | DOWN BY) setByValue + ; + +setTo + : identifier + ; + +setToValue + : ON + | OFF + | ENTRY (identifier | literal) + | identifier + | literal + ; + +setByValue + : identifier + | literal + ; + +// sort statement + +sortStatement + : SORT fileName sortOnKeyClause+ sortDuplicatesPhrase? sortCollatingSequencePhrase? sortInputProcedurePhrase? sortUsing* sortOutputProcedurePhrase + ? sortGivingPhrase* + ; + +sortOnKeyClause + : ON? (ASCENDING | DESCENDING) KEY? qualifiedDataName+ + ; + +sortDuplicatesPhrase + : WITH? DUPLICATES IN? ORDER? + ; + +sortCollatingSequencePhrase + : COLLATING? SEQUENCE IS? alphabetName+ sortCollatingAlphanumeric? sortCollatingNational? + ; + +sortCollatingAlphanumeric + : FOR? ALPHANUMERIC IS alphabetName + ; + +sortCollatingNational + : FOR? NATIONAL IS? alphabetName + ; + +sortInputProcedurePhrase + : INPUT PROCEDURE IS? procedureName sortInputThrough? + ; + +sortInputThrough + : (THROUGH | THRU) procedureName + ; + +sortUsing + : USING fileName+ + ; + +sortOutputProcedurePhrase + : OUTPUT PROCEDURE IS? procedureName sortOutputThrough? + ; + +sortOutputThrough + : (THROUGH | THRU) procedureName + ; + +sortGivingPhrase + : GIVING sortGiving+ + ; + +sortGiving + : fileName (LOCK | SAVE | NO REWIND | CRUNCH | RELEASE | WITH REMOVE CRUNCH)? + ; + +// start statement + +startStatement + : START fileName startKey? invalidKeyPhrase? notInvalidKeyPhrase? END_START? + ; + +startKey + : KEY IS? ( + EQUAL TO? + | EQUALCHAR + | GREATER THAN? + | MORETHANCHAR + | NOT LESS THAN? + | NOT LESSTHANCHAR + | GREATER THAN? OR EQUAL TO? + | MORETHANOREQUAL + ) qualifiedDataName + ; + +// stop statement + +stopStatement + : STOP (RUN | literal) + ; + +// string statement + +stringStatement + : STRING stringSendingPhrase+ stringIntoPhrase stringWithPointerPhrase? onOverflowPhrase? notOnOverflowPhrase? END_STRING? + ; + +stringSendingPhrase + : stringSending+ (stringDelimitedByPhrase | stringForPhrase) + ; + +stringSending + : identifier + | literal + ; + +stringDelimitedByPhrase + : DELIMITED BY? (SIZE | identifier | literal) + ; + +stringForPhrase + : FOR (identifier | literal) + ; + +stringIntoPhrase + : INTO identifier + ; + +stringWithPointerPhrase + : WITH? POINTER qualifiedDataName + ; + +// subtract statement + +subtractStatement + : SUBTRACT ( + subtractFromStatement + | subtractFromGivingStatement + | subtractCorrespondingStatement + ) onSizeErrorPhrase? notOnSizeErrorPhrase? END_SUBTRACT? + ; + +subtractFromStatement + : subtractSubtrahend+ FROM subtractMinuend+ + ; + +subtractFromGivingStatement + : subtractSubtrahend+ FROM subtractMinuendGiving GIVING subtractGiving+ + ; + +subtractCorrespondingStatement + : (CORRESPONDING | CORR) qualifiedDataName FROM subtractMinuendCorresponding + ; + +subtractSubtrahend + : identifier + | literal + ; + +subtractMinuend + : identifier ROUNDED? + ; + +subtractMinuendGiving + : identifier + | literal + ; + +subtractGiving + : identifier ROUNDED? + ; + +subtractMinuendCorresponding + : qualifiedDataName ROUNDED? + ; + +// terminate statement + +terminateStatement + : TERMINATE reportName + ; + +// unstring statement + +unstringStatement + : UNSTRING unstringSendingPhrase unstringIntoPhrase unstringWithPointerPhrase? unstringTallyingPhrase? onOverflowPhrase? notOnOverflowPhrase? + END_UNSTRING? + ; + +unstringSendingPhrase + : identifier (unstringDelimitedByPhrase unstringOrAllPhrase*)? + ; + +unstringDelimitedByPhrase + : DELIMITED BY? ALL? (identifier | literal) + ; + +unstringOrAllPhrase + : OR ALL? (identifier | literal) + ; + +unstringIntoPhrase + : INTO unstringInto+ + ; + +unstringInto + : identifier unstringDelimiterIn? unstringCountIn? + ; + +unstringDelimiterIn + : DELIMITER IN? identifier + ; + +unstringCountIn + : COUNT IN? identifier + ; + +unstringWithPointerPhrase + : WITH? POINTER qualifiedDataName + ; + +unstringTallyingPhrase + : TALLYING IN? qualifiedDataName + ; + +// use statement + +useStatement + : USE (useAfterClause | useDebugClause) + ; + +useAfterClause + : GLOBAL? AFTER STANDARD? (EXCEPTION | ERROR) PROCEDURE ON? useAfterOn + ; + +useAfterOn + : INPUT + | OUTPUT + | I_O + | EXTEND + | fileName+ + ; + +useDebugClause + : FOR? DEBUGGING ON? useDebugOn+ + ; + +useDebugOn + : ALL PROCEDURES + | ALL REFERENCES? OF? identifier + | procedureName + | fileName + ; + +// write statement + +writeStatement + : WRITE recordName writeFromPhrase? writeAdvancingPhrase? writeAtEndOfPagePhrase? writeNotAtEndOfPagePhrase? invalidKeyPhrase? notInvalidKeyPhrase + ? END_WRITE? + ; + +writeFromPhrase + : FROM (identifier | literal) + ; + +writeAdvancingPhrase + : (BEFORE | AFTER) ADVANCING? ( + writeAdvancingPage + | writeAdvancingLines + | writeAdvancingMnemonic + ) + ; + +writeAdvancingPage + : PAGE + ; + +writeAdvancingLines + : (identifier | literal) (LINE | LINES)? + ; + +writeAdvancingMnemonic + : mnemonicName + ; + +writeAtEndOfPagePhrase + : AT? (END_OF_PAGE | EOP) statement* + ; + +writeNotAtEndOfPagePhrase + : NOT AT? (END_OF_PAGE | EOP) statement* + ; + +// statement phrases ---------------------------------- + +atEndPhrase + : AT? END statement* + ; + +notAtEndPhrase + : NOT AT? END statement* + ; + +invalidKeyPhrase + : INVALID KEY? statement* + ; + +notInvalidKeyPhrase + : NOT INVALID KEY? statement* + ; + +onOverflowPhrase + : ON? OVERFLOW statement* + ; + +notOnOverflowPhrase + : NOT ON? OVERFLOW statement* + ; + +onSizeErrorPhrase + : ON? SIZE ERROR statement* + ; + +notOnSizeErrorPhrase + : NOT ON? SIZE ERROR statement* + ; + +// statement clauses ---------------------------------- + +onExceptionClause + : ON? EXCEPTION statement* + ; + +notOnExceptionClause + : NOT ON? EXCEPTION statement* + ; + +// arithmetic expression ---------------------------------- + +arithmeticExpression + : multDivs plusMinus* + ; + +plusMinus + : (PLUSCHAR | MINUSCHAR) multDivs + ; + +multDivs + : powers multDiv* + ; + +multDiv + : (ASTERISKCHAR | SLASHCHAR) powers + ; + +powers + : (PLUSCHAR | MINUSCHAR)? basis power* + ; + +power + : DOUBLEASTERISKCHAR basis + ; + +basis + : LPARENCHAR arithmeticExpression RPARENCHAR + | identifier + | literal + ; + +// condition ---------------------------------- + +condition + : combinableCondition andOrCondition* + ; + +andOrCondition + : (AND | OR) (combinableCondition | abbreviation+) + ; + +combinableCondition + : NOT? simpleCondition + ; + +simpleCondition + : LPARENCHAR condition RPARENCHAR + | relationCondition + | classCondition + | conditionNameReference + ; + +classCondition + : identifier IS? NOT? ( + NUMERIC + | ALPHABETIC + | ALPHABETIC_LOWER + | ALPHABETIC_UPPER + | DBCS + | KANJI + | className + ) + ; + +conditionNameReference + : conditionName (inData* inFile? conditionNameSubscriptReference* | inMnemonic*) + ; + +conditionNameSubscriptReference + : LPARENCHAR subscript_ (COMMACHAR? subscript_)* RPARENCHAR + ; + +// relation ---------------------------------- + +relationCondition + : relationSignCondition + | relationArithmeticComparison + | relationCombinedComparison + ; + +relationSignCondition + : arithmeticExpression IS? NOT? (POSITIVE | NEGATIVE | ZERO) + ; + +relationArithmeticComparison + : arithmeticExpression relationalOperator arithmeticExpression + ; + +relationCombinedComparison + : arithmeticExpression relationalOperator LPARENCHAR relationCombinedCondition RPARENCHAR + ; + +relationCombinedCondition + : arithmeticExpression ((AND | OR) arithmeticExpression)+ + ; + +relationalOperator + : (IS | ARE)? ( + NOT? (GREATER THAN? | MORETHANCHAR | LESS THAN? | LESSTHANCHAR | EQUAL TO? | EQUALCHAR) + | NOTEQUALCHAR + | GREATER THAN? OR EQUAL TO? + | MORETHANOREQUAL + | LESS THAN? OR EQUAL TO? + | LESSTHANOREQUAL + ) + ; + +abbreviation + : NOT? relationalOperator? ( + arithmeticExpression + | LPARENCHAR arithmeticExpression abbreviation RPARENCHAR + ) + ; + +// identifier ---------------------------------- + +identifier + : qualifiedDataName + | tableCall + | functionCall + | specialRegister + ; + +tableCall + : qualifiedDataName (LPARENCHAR subscript_ (COMMACHAR? subscript_)* RPARENCHAR)* referenceModifier? + ; + +functionCall + : FUNCTION functionName (LPARENCHAR argument (COMMACHAR? argument)* RPARENCHAR)* referenceModifier? + ; + +referenceModifier + : LPARENCHAR characterPosition COLONCHAR length? RPARENCHAR + ; + +characterPosition + : arithmeticExpression + ; + +length + : arithmeticExpression + ; + +subscript_ + : ALL + | integerLiteral + | qualifiedDataName integerLiteral? + | indexName integerLiteral? + | arithmeticExpression + ; + +argument + : literal + | identifier + | qualifiedDataName integerLiteral? + | indexName integerLiteral? + | arithmeticExpression + ; + +// qualified data name ---------------------------------- + +qualifiedDataName + : qualifiedDataNameFormat1 + | qualifiedDataNameFormat2 + | qualifiedDataNameFormat3 + | qualifiedDataNameFormat4 + ; + +qualifiedDataNameFormat1 + : (dataName | conditionName) (qualifiedInData+ inFile? | inFile)? + ; + +qualifiedDataNameFormat2 + : paragraphName inSection + ; + +qualifiedDataNameFormat3 + : textName inLibrary + ; + +qualifiedDataNameFormat4 + : LINAGE_COUNTER inFile + ; + +qualifiedInData + : inData + | inTable + ; + +// in ---------------------------------- + +inData + : (IN | OF) dataName + ; + +inFile + : (IN | OF) fileName + ; + +inMnemonic + : (IN | OF) mnemonicName + ; + +inSection + : (IN | OF) sectionName + ; + +inLibrary + : (IN | OF) libraryName + ; + +inTable + : (IN | OF) tableCall + ; + +// names ---------------------------------- + +alphabetName + : cobolWord + ; + +assignmentName + : systemName + ; + +basisName + : programName + ; + +cdName + : cobolWord + ; + +className + : cobolWord + ; + +computerName + : systemName + ; + +conditionName + : cobolWord + ; + +dataName + : cobolWord + ; + +dataDescName + : FILLER + | CURSOR + | dataName + ; + +environmentName + : systemName + ; + +fileName + : cobolWord + ; + +functionName + : INTEGER + | LENGTH + | RANDOM + | SUM + | WHEN_COMPILED + | cobolWord + ; + +indexName + : cobolWord + ; + +languageName + : systemName + ; + +libraryName + : cobolWord + ; + +localName + : cobolWord + ; + +mnemonicName + : cobolWord + ; + +paragraphName + : cobolWord + | integerLiteral + ; + +procedureName + : paragraphName inSection? + | sectionName + ; + +programName + : NONNUMERICLITERAL + | cobolWord + ; + +recordName + : qualifiedDataName + ; + +reportName + : qualifiedDataName + ; + +routineName + : cobolWord + ; + +screenName + : cobolWord + ; + +sectionName + : cobolWord + | integerLiteral + ; + +systemName + : cobolWord + ; + +symbolicCharacter + : cobolWord + ; + +textName + : cobolWord + ; + +// literal ---------------------------------- + +cobolWord + : IDENTIFIER + | COBOL + | PROGRAM + | ABORT + | AS + | ASCII + | ASSOCIATED_DATA + | ASSOCIATED_DATA_LENGTH + | ATTRIBUTE + | AUTO + | AUTO_SKIP + | BACKGROUND_COLOR + | BACKGROUND_COLOUR + | BEEP + | BELL + | BINARY + | BIT + | BLINK + | BOUNDS + | CAPABLE + | CCSVERSION + | CHANGED + | CHANNEL + | CLOSE_DISPOSITION + | COMMITMENT + | CONTROL_POINT + | CONVENTION + | CRUNCH + | CURSOR + | DEFAULT + | DEFAULT_DISPLAY + | DEFINITION + | DFHRESP + | DFHVALUE + | DISK + | DONTCARE + | DOUBLE + | EBCDIC + | EMPTY_CHECK + | ENTER + | ENTRY_PROCEDURE + | EOL + | EOS + | ERASE + | ESCAPE + | EVENT + | EXCLUSIVE + | EXPORT + | EXTENDED + | FOREGROUND_COLOR + | FOREGROUND_COLOUR + | FULL + | FUNCTIONNAME + | FUNCTION_POINTER + | GRID + | HIGHLIGHT + | IMPLICIT + | IMPORT + | INTEGER + | KEPT + | KEYBOARD + | LANGUAGE + | LB + | LD + | LEFTLINE + | LENGTH_CHECK + | LIBACCESS + | LIBPARAMETER + | LIBRARY + | LIST + | LOCAL + | LONG_DATE + | LONG_TIME + | LOWER + | LOWLIGHT + | MMDDYYYY + | NAMED + | NATIONAL + | NATIONAL_EDITED + | NETWORK + | NO_ECHO + | NUMERIC_DATE + | NUMERIC_TIME + | ODT + | ORDERLY + | OVERLINE + | OWN + | PASSWORD + | PORT + | PRINTER + | PRIVATE + | PROCESS + | PROMPT + | READER + | REAL + | RECEIVED + | RECURSIVE + | REF + | REMOTE + | REMOVE + | REQUIRED + | REVERSE_VIDEO + | SAVE + | SECURE + | SHARED + | SHAREDBYALL + | SHAREDBYRUNUNIT + | SHARING + | SHORT_DATE + | SYMBOL + | TASK + | THREAD + | THREAD_LOCAL + | TIMER + | TODAYS_DATE + | TODAYS_NAME + | TRUNCATED + | TYPEDEF + | UNDERLINE + | VIRTUAL + | WAIT + | YEAR + | YYYYMMDD + | YYYYDDD + | ZERO_FILL + ; + +literal + : NONNUMERICLITERAL + | figurativeConstant + | numericLiteral + | booleanLiteral + | cicsDfhRespLiteral + | cicsDfhValueLiteral + ; + +booleanLiteral + : TRUE + | FALSE + ; + +numericLiteral + : NUMERICLITERAL + | ZERO + | integerLiteral + ; + +integerLiteral + : INTEGERLITERAL + | LEVEL_NUMBER_66 + | LEVEL_NUMBER_77 + | LEVEL_NUMBER_88 + ; + +cicsDfhRespLiteral + : DFHRESP LPARENCHAR (cobolWord | literal) RPARENCHAR + ; + +cicsDfhValueLiteral + : DFHVALUE LPARENCHAR (cobolWord | literal) RPARENCHAR + ; + +// keywords ---------------------------------- + +figurativeConstant + : ALL literal + | HIGH_VALUE + | HIGH_VALUES + | LOW_VALUE + | LOW_VALUES + | NULL_ + | NULLS + | QUOTE + | QUOTES + | SPACE + | SPACES + | ZERO + | ZEROS + | ZEROES + ; + +specialRegister + : ADDRESS OF identifier + | DATE + | DAY + | DAY_OF_WEEK + | DEBUG_CONTENTS + | DEBUG_ITEM + | DEBUG_LINE + | DEBUG_NAME + | DEBUG_SUB_1 + | DEBUG_SUB_2 + | DEBUG_SUB_3 + | LENGTH OF? identifier + | LINAGE_COUNTER + | LINE_COUNTER + | PAGE_COUNTER + | RETURN_CODE + | SHIFT_IN + | SHIFT_OUT + | SORT_CONTROL + | SORT_CORE_SIZE + | SORT_FILE_SIZE + | SORT_MESSAGE + | SORT_MODE_SIZE + | SORT_RETURN + | TALLY + | TIME + | WHEN_COMPILED + ; + +// comment entry + +commentEntry + : COMMENTENTRYLINE+ + ; + +// lexer rules -------------------------------------------------------------------------------- + +// keywords +ABORT + : A B O R T + ; + +ACCEPT + : A C C E P T + ; + +ACCESS + : A C C E S S + ; + +ADD + : A D D + ; + +ADDRESS + : A D D R E S S + ; + +ADVANCING + : A D V A N C I N G + ; + +AFTER + : A F T E R + ; + +ALIGNED + : A L I G N E D + ; + +ALL + : A L L + ; + +ALPHABET + : A L P H A B E T + ; + +ALPHABETIC + : A L P H A B E T I C + ; + +ALPHABETIC_LOWER + : A L P H A B E T I C MINUSCHAR L O W E R + ; + +ALPHABETIC_UPPER + : A L P H A B E T I C MINUSCHAR U P P E R + ; + +ALPHANUMERIC + : A L P H A N U M E R I C + ; + +ALPHANUMERIC_EDITED + : A L P H A N U M E R I C MINUSCHAR E D I T E D + ; + +ALSO + : A L S O + ; + +ALTER + : A L T E R + ; + +ALTERNATE + : A L T E R N A T E + ; + +AND + : A N D + ; + +ANY + : A N Y + ; + +ARE + : A R E + ; + +AREA + : A R E A + ; + +AREAS + : A R E A S + ; + +AS + : A S + ; + +ASCENDING + : A S C E N D I N G + ; + +ASCII + : A S C I I + ; + +ASSIGN + : A S S I G N + ; + +ASSOCIATED_DATA + : A S S O C I A T E D MINUSCHAR D A T A + ; + +ASSOCIATED_DATA_LENGTH + : A S S O C I A T E D MINUSCHAR D A T A MINUSCHAR L E N G T H + ; + +AT + : A T + ; + +ATTRIBUTE + : A T T R I B U T E + ; + +AUTHOR + : A U T H O R + ; + +AUTO + : A U T O + ; + +AUTO_SKIP + : A U T O MINUSCHAR S K I P + ; + +BACKGROUND_COLOR + : B A C K G R O U N D MINUSCHAR C O L O R + ; + +BACKGROUND_COLOUR + : B A C K G R O U N D MINUSCHAR C O L O U R + ; + +BASIS + : B A S I S + ; + +BEEP + : B E E P + ; + +BEFORE + : B E F O R E + ; + +BEGINNING + : B E G I N N I N G + ; + +BELL + : B E L L + ; + +BINARY + : B I N A R Y + ; + +BIT + : B I T + ; + +BLANK + : B L A N K + ; + +BLINK + : B L I N K + ; + +BLOCK + : B L O C K + ; + +BOUNDS + : B O U N D S + ; + +BOTTOM + : B O T T O M + ; + +BY + : B Y + ; + +BYFUNCTION + : B Y F U N C T I O N + ; + +BYTITLE + : B Y T I T L E + ; + +CALL + : C A L L + ; + +CANCEL + : C A N C E L + ; + +CAPABLE + : C A P A B L E + ; + +CCSVERSION + : C C S V E R S I O N + ; + +CD + : C D + ; + +CF + : C F + ; + +CH + : C H + ; + +CHAINING + : C H A I N I N G + ; + +CHANGED + : C H A N G E D + ; + +CHANNEL + : C H A N N E L + ; + +CHARACTER + : C H A R A C T E R + ; + +CHARACTERS + : C H A R A C T E R S + ; + +CLASS + : C L A S S + ; + +CLASS_ID + : C L A S S MINUSCHAR I D + ; + +CLOCK_UNITS + : C L O C K MINUSCHAR U N I T S + ; + +CLOSE + : C L O S E + ; + +CLOSE_DISPOSITION + : C L O S E MINUSCHAR D I S P O S I T I O N + ; + +COBOL + : C O B O L + ; + +CODE + : C O D E + ; + +CODE_SET + : C O D E MINUSCHAR S E T + ; + +COLLATING + : C O L L A T I N G + ; + +COL + : C O L + ; + +COLUMN + : C O L U M N + ; + +COM_REG + : C O M MINUSCHAR R E G + ; + +COMMA + : C O M M A + ; + +COMMITMENT + : C O M M I T M E N T + ; + +COMMON + : C O M M O N + ; + +COMMUNICATION + : C O M M U N I C A T I O N + ; + +COMP + : C O M P + ; + +COMP_1 + : C O M P MINUSCHAR '1' + ; + +COMP_2 + : C O M P MINUSCHAR '2' + ; + +COMP_3 + : C O M P MINUSCHAR '3' + ; + +COMP_4 + : C O M P MINUSCHAR '4' + ; + +COMP_5 + : C O M P MINUSCHAR '5' + ; + +COMPUTATIONAL + : C O M P U T A T I O N A L + ; + +COMPUTATIONAL_1 + : C O M P U T A T I O N A L MINUSCHAR '1' + ; + +COMPUTATIONAL_2 + : C O M P U T A T I O N A L MINUSCHAR '2' + ; + +COMPUTATIONAL_3 + : C O M P U T A T I O N A L MINUSCHAR '3' + ; + +COMPUTATIONAL_4 + : C O M P U T A T I O N A L MINUSCHAR '4' + ; + +COMPUTATIONAL_5 + : C O M P U T A T I O N A L MINUSCHAR '5' + ; + +COMPUTE + : C O M P U T E + ; + +CONFIGURATION + : C O N F I G U R A T I O N + ; + +CONTAINS + : C O N T A I N S + ; + +CONTENT + : C O N T E N T + ; + +CONTINUE + : C O N T I N U E + ; + +CONTROL + : C O N T R O L + ; + +CONTROL_POINT + : C O N T R O L MINUSCHAR P O I N T + ; + +CONTROLS + : C O N T R O L S + ; + +CONVENTION + : C O N V E N T I O N + ; + +CONVERTING + : C O N V E R T I N G + ; + +COPY + : C O P Y + ; + +CORR + : C O R R + ; + +CORRESPONDING + : C O R R E S P O N D I N G + ; + +COUNT + : C O U N T + ; + +CRUNCH + : C R U N C H + ; + +CURRENCY + : C U R R E N C Y + ; + +CURSOR + : C U R S O R + ; + +DATA + : D A T A + ; + +DATA_BASE + : D A T A MINUSCHAR B A S E + ; + +DATE + : D A T E + ; + +DATE_COMPILED + : D A T E MINUSCHAR C O M P I L E D + ; + +DATE_WRITTEN + : D A T E MINUSCHAR W R I T T E N + ; + +DAY + : D A Y + ; + +DAY_OF_WEEK + : D A Y MINUSCHAR O F MINUSCHAR W E E K + ; + +DBCS + : D B C S + ; + +DE + : D E + ; + +DEBUG_CONTENTS + : D E B U G MINUSCHAR C O N T E N T S + ; + +DEBUG_ITEM + : D E B U G MINUSCHAR I T E M + ; + +DEBUG_LINE + : D E B U G MINUSCHAR L I N E + ; + +DEBUG_NAME + : D E B U G MINUSCHAR N A M E + ; + +DEBUG_SUB_1 + : D E B U G MINUSCHAR S U B MINUSCHAR '1' + ; + +DEBUG_SUB_2 + : D E B U G MINUSCHAR S U B MINUSCHAR '2' + ; + +DEBUG_SUB_3 + : D E B U G MINUSCHAR S U B MINUSCHAR '3' + ; + +DEBUGGING + : D E B U G G I N G + ; + +DECIMAL_POINT + : D E C I M A L MINUSCHAR P O I N T + ; + +DECLARATIVES + : D E C L A R A T I V E S + ; + +DEFAULT + : D E F A U L T + ; + +DEFAULT_DISPLAY + : D E F A U L T MINUSCHAR D I S P L A Y + ; + +DEFINITION + : D E F I N I T I O N + ; + +DELETE + : D E L E T E + ; + +DELIMITED + : D E L I M I T E D + ; + +DELIMITER + : D E L I M I T E R + ; + +DEPENDING + : D E P E N D I N G + ; + +DESCENDING + : D E S C E N D I N G + ; + +DESTINATION + : D E S T I N A T I O N + ; + +DETAIL + : D E T A I L + ; + +DFHRESP + : D F H R E S P + ; + +DFHVALUE + : D F H V A L U E + ; + +DISABLE + : D I S A B L E + ; + +DISK + : D I S K + ; + +DISPLAY + : D I S P L A Y + ; + +DISPLAY_1 + : D I S P L A Y MINUSCHAR '1' + ; + +DIVIDE + : D I V I D E + ; + +DIVISION + : D I V I S I O N + ; + +DONTCARE + : D O N T C A R E + ; + +DOUBLE + : D O U B L E + ; + +DOWN + : D O W N + ; + +DUPLICATES + : D U P L I C A T E S + ; + +DYNAMIC + : D Y N A M I C + ; + +EBCDIC + : E B C D I C + ; + +EGCS + : E G C S + ; // E X T E N S I O N + +EGI + : E G I + ; + +ELSE + : E L S E + ; + +EMI + : E M I + ; + +EMPTY_CHECK + : E M P T Y MINUSCHAR C H E C K + ; + +ENABLE + : E N A B L E + ; + +END + : E N D + ; + +END_ACCEPT + : E N D MINUSCHAR A C C E P T + ; + +END_ADD + : E N D MINUSCHAR A D D + ; + +END_CALL + : E N D MINUSCHAR C A L L + ; + +END_COMPUTE + : E N D MINUSCHAR C O M P U T E + ; + +END_DELETE + : E N D MINUSCHAR D E L E T E + ; + +END_DIVIDE + : E N D MINUSCHAR D I V I D E + ; + +END_EVALUATE + : E N D MINUSCHAR E V A L U A T E + ; + +END_IF + : E N D MINUSCHAR I F + ; + +END_MULTIPLY + : E N D MINUSCHAR M U L T I P L Y + ; + +END_OF_PAGE + : E N D MINUSCHAR O F MINUSCHAR P A G E + ; + +END_PERFORM + : E N D MINUSCHAR P E R F O R M + ; + +END_READ + : E N D MINUSCHAR R E A D + ; + +END_RECEIVE + : E N D MINUSCHAR R E C E I V E + ; + +END_RETURN + : E N D MINUSCHAR R E T U R N + ; + +END_REWRITE + : E N D MINUSCHAR R E W R I T E + ; + +END_SEARCH + : E N D MINUSCHAR S E A R C H + ; + +END_START + : E N D MINUSCHAR S T A R T + ; + +END_STRING + : E N D MINUSCHAR S T R I N G + ; + +END_SUBTRACT + : E N D MINUSCHAR S U B T R A C T + ; + +END_UNSTRING + : E N D MINUSCHAR U N S T R I N G + ; + +END_WRITE + : E N D MINUSCHAR W R I T E + ; + +ENDING + : E N D I N F + ; + +ENTER + : E N T E R + ; + +ENTRY + : E N T R Y + ; + +ENTRY_PROCEDURE + : E N T R Y MINUSCHAR P R O C E D U R E + ; + +ENVIRONMENT + : E N V I R O N M E N T + ; + +EOP + : E O P + ; + +EQUAL + : E Q U A L + ; + +ERASE + : E R A S E + ; + +ERROR + : E R R O R + ; + +EOL + : E O L + ; + +EOS + : E O S + ; + +ESCAPE + : E S C A P E + ; + +ESI + : E S I + ; + +EVALUATE + : E V A L U A T E + ; + +EVENT + : E V E N T + ; + +EVERY + : E V E R Y + ; + +EXCEPTION + : E X C E P T I O N + ; + +EXCLUSIVE + : E X C L U S I V E + ; + +EXHIBIT + : E X H I B I T + ; + +EXIT + : E X I T + ; + +EXPORT + : E X P O R T + ; + +EXTEND + : E X T E N D + ; + +EXTENDED + : E X T E N D E D + ; + +EXTERNAL + : E X T E R N A L + ; + +FALSE + : F A L S E + ; + +FD + : F D + ; + +FILE + : F I L E + ; + +FILE_CONTROL + : F I L E MINUSCHAR C O N T R O L + ; + +FILLER + : F I L L E R + ; + +FINAL + : F I N A L + ; + +FIRST + : F I R S T + ; + +FOOTING + : F O O T I N G + ; + +FOR + : F O R + ; + +FOREGROUND_COLOR + : F O R E G R O U N D MINUSCHAR C O L O R + ; + +FOREGROUND_COLOUR + : F O R E G R O U N D MINUSCHAR C O L O U R + ; + +FROM + : F R O M + ; + +FULL + : F U L L + ; + +FUNCTION + : F U N C T I O N + ; + +FUNCTIONNAME + : F U N C T I O N N A M E + ; + +FUNCTION_POINTER + : F U N C T I O N MINUSCHAR P O I N T E R + ; + +GENERATE + : G E N E R A T E + ; + +GOBACK + : G O B A C K + ; + +GIVING + : G I V I N G + ; + +GLOBAL + : G L O B A L + ; + +GO + : G O + ; + +GREATER + : G R E A T E R + ; + +GRID + : G R I D + ; + +GROUP + : G R O U P + ; + +HEADING + : H E A D I N G + ; + +HIGHLIGHT + : H I G H L I G H T + ; + +HIGH_VALUE + : H I G H MINUSCHAR V A L U E + ; + +HIGH_VALUES + : H I G H MINUSCHAR V A L U E S + ; + +I_O + : I MINUSCHAR O + ; + +I_O_CONTROL + : I MINUSCHAR O MINUSCHAR C O N T R O L + ; + +ID + : I D + ; + +IDENTIFICATION + : I D E N T I F I C A T I O N + ; + +IF + : I F + ; + +IMPLICIT + : I M P L I C I T + ; + +IMPORT + : I M P O R T + ; + +IN + : I N + ; + +INDEX + : I N D E X + ; + +INDEXED + : I N D E X E D + ; + +INDICATE + : I N D I C A T E + ; + +INITIAL + : I N I T I A L + ; + +INITIALIZE + : I N I T I A L I Z E + ; + +INITIATE + : I N I T I A T E + ; + +INPUT + : I N P U T + ; + +INPUT_OUTPUT + : I N P U T MINUSCHAR O U T P U T + ; + +INSPECT + : I N S P E C T + ; + +INSTALLATION + : I N S T A L L A T I O N + ; + +INTEGER + : I N T E G E R + ; + +INTO + : I N T O + ; + +INVALID + : I N V A L I D + ; + +INVOKE + : I N V O K E + ; + +IS + : I S + ; + +JUST + : J U S T + ; + +JUSTIFIED + : J U S T I F I E D + ; + +KANJI + : K A N J I + ; + +KEPT + : K E P T + ; + +KEY + : K E Y + ; + +KEYBOARD + : K E Y B O A R D + ; + +LABEL + : L A B E L + ; + +LANGUAGE + : L A N G U A G E + ; + +LAST + : L A S T + ; + +LB + : L B + ; + +LD + : L D + ; + +LEADING + : L E A D I N G + ; + +LEFT + : L E F T + ; + +LEFTLINE + : L E F T L I N E + ; + +LENGTH + : L E N G T H + ; + +LENGTH_CHECK + : L E N G T H MINUSCHAR C H E C K + ; + +LESS + : L E S S + ; + +LIBACCESS + : L I B A C C E S S + ; + +LIBPARAMETER + : L I B P A R A M E T E R + ; + +LIBRARY + : L I B R A R Y + ; + +LIMIT + : L I M I T + ; + +LIMITS + : L I M I T S + ; + +LINAGE + : L I N A G E + ; + +LINAGE_COUNTER + : L I N A G E MINUSCHAR C O U N T E R + ; + +LINE + : L I N E + ; + +LINES + : L I N E S + ; + +LINE_COUNTER + : L I N E MINUSCHAR C O U N T E R + ; + +LINKAGE + : L I N K A G E + ; + +LIST + : L I S T + ; + +LOCAL + : L O C A L + ; + +LOCAL_STORAGE + : L O C A L MINUSCHAR S T O R A G E + ; + +LOCK + : L O C K + ; + +LONG_DATE + : L O N G MINUSCHAR D A T E + ; + +LONG_TIME + : L O N G MINUSCHAR T I M E + ; + +LOWER + : L O W E R + ; + +LOWLIGHT + : L O W L I G H T + ; + +LOW_VALUE + : L O W MINUSCHAR V A L U E + ; + +LOW_VALUES + : L O W MINUSCHAR V A L U E S + ; + +MEMORY + : M E M O R Y + ; + +MERGE + : M E R G E + ; + +MESSAGE + : M E S S A G E + ; + +MMDDYYYY + : M M D D Y Y Y Y + ; + +MODE + : M O D E + ; + +MODULES + : M O D U L E S + ; + +MORE_LABELS + : M O R E MINUSCHAR L A B E L S + ; + +MOVE + : M O V E + ; + +MULTIPLE + : M U L T I P L E + ; + +MULTIPLY + : M U L T I P L Y + ; + +NAMED + : N A M E D + ; + +NATIONAL + : N A T I O N A L + ; + +NATIONAL_EDITED + : N A T I O N A L MINUSCHAR E D I T E D + ; + +NATIVE + : N A T I V E + ; + +NEGATIVE + : N E G A T I V E + ; + +NETWORK + : N E T W O R K + ; + +NEXT + : N E X T + ; + +NO + : N O + ; + +NO_ECHO + : N O MINUSCHAR E C H O + ; + +NOT + : N O T + ; + +NULL_ + : N U L L + ; + +NULLS + : N U L L S + ; + +NUMBER + : N U M B E R + ; + +NUMERIC + : N U M E R I C + ; + +NUMERIC_DATE + : N U M E R I C MINUSCHAR D A T E + ; + +NUMERIC_EDITED + : N U M E R I C MINUSCHAR E D I T E D + ; + +NUMERIC_TIME + : N U M E R I C MINUSCHAR T I M E + ; + +OBJECT_COMPUTER + : O B J E C T MINUSCHAR C O M P U T E R + ; + +OCCURS + : O C C U R S + ; + +ODT + : O D T + ; + +OF + : O F + ; + +OFF + : O F F + ; + +OMITTED + : O M I T T E D + ; + +ON + : O N + ; + +OPEN + : O P E N + ; + +OPTIONAL + : O P T I O N A L + ; + +OR + : O R + ; + +ORDER + : O R D E R + ; + +ORDERLY + : O R D E R L Y + ; + +ORGANIZATION + : O R G A N I Z A T I O N + ; + +OTHER + : O T H E R + ; + +OUTPUT + : O U T P U T + ; + +OVERFLOW + : O V E R F L O W + ; + +OVERLINE + : O V E R L I N E + ; + +OWN + : O W N + ; + +PACKED_DECIMAL + : P A C K E D MINUSCHAR D E C I M A L + ; + +PADDING + : P A D D I N G + ; + +PAGE + : P A G E + ; + +PAGE_COUNTER + : P A G E MINUSCHAR C O U N T E R + ; + +PASSWORD + : P A S S W O R D + ; + +PERFORM + : P E R F O R M + ; + +PF + : P F + ; + +PH + : P H + ; + +PIC + : P I C + ; + +PICTURE + : P I C T U R E + ; + +PLUS + : P L U S + ; + +POINTER + : P O I N T E R + ; + +POSITION + : P O S I T I O N + ; + +POSITIVE + : P O S I T I V E + ; + +PORT + : P O R T + ; + +PRINTER + : P R I N T E R + ; + +PRINTING + : P R I N T I N G + ; + +PRIVATE + : P R I V A T E + ; + +PROCEDURE + : P R O C E D U R E + ; + +PROCEDURE_POINTER + : P R O C E D U R E MINUSCHAR P O I N T E R + ; + +PROCEDURES + : P R O C E D U R E S + ; + +PROCEED + : P R O C E E D + ; + +PROCESS + : P R O C E S S + ; + +PROGRAM + : P R O G R A M + ; + +PROGRAM_ID + : P R O G R A M MINUSCHAR I D + ; + +PROGRAM_LIBRARY + : P R O G R A M MINUSCHAR L I B R A R Y + ; + +PROMPT + : P R O M P T + ; + +PURGE + : P U R G E + ; + +QUEUE + : Q U E U E + ; + +QUOTE + : Q U O T E + ; + +QUOTES + : Q U O T E S + ; + +RANDOM + : R A N D O M + ; + +READER + : R E A D E R + ; + +REMOTE + : R E M O T E + ; + +RD + : R D + ; + +REAL + : R E A L + ; + +READ + : R E A D + ; + +RECEIVE + : R E C E I V E + ; + +RECEIVED + : R E C E I V E D + ; + +RECORD + : R E C O R D + ; + +RECORDING + : R E C O R D I N G + ; + +RECORDS + : R E C O R D S + ; + +RECURSIVE + : R E C U R S I V E + ; + +REDEFINES + : R E D E F I N E S + ; + +REEL + : R E E L + ; + +REF + : R E F + ; + +REFERENCE + : R E F E R E N C E + ; + +REFERENCES + : R E F E R E N C E S + ; + +RELATIVE + : R E L A T I V E + ; + +RELEASE + : R E L E A S E + ; + +REMAINDER + : R E M A I N D E R + ; + +REMARKS + : R E M A R K S + ; + +REMOVAL + : R E M O V A L + ; + +REMOVE + : R E M O V E + ; + +RENAMES + : R E N A M E S + ; + +REPLACE + : R E P L A C E + ; + +REPLACING + : R E P L A C I N G + ; + +REPORT + : R E P O R T + ; + +REPORTING + : R E P O R T I N G + ; + +REPORTS + : R E P O R T S + ; + +REQUIRED + : R E Q U I R E D + ; + +RERUN + : R E R U N + ; + +RESERVE + : R E S E R V E + ; + +REVERSE_VIDEO + : R E S E R V E MINUSCHAR V I D E O + ; + +RESET + : R E S E T + ; + +RETURN + : R E T U R N + ; + +RETURN_CODE + : R E T U R N MINUSCHAR C O D E + ; + +RETURNING + : R E T U R N I N G + ; + +REVERSED + : R E V E R S E D + ; + +REWIND + : R E W I N D + ; + +REWRITE + : R E W R I T E + ; + +RF + : R F + ; + +RH + : R H + ; + +RIGHT + : R I G H T + ; + +ROUNDED + : R O U N D E D + ; + +RUN + : R U N + ; + +SAME + : S A M E + ; + +SAVE + : S A V E + ; + +SCREEN + : S C R E E N + ; + +SD + : S D + ; + +SEARCH + : S E A R C H + ; + +SECTION + : S E C T I O N + ; + +SECURE + : S E C U R E + ; + +SECURITY + : S E C U R I T Y + ; + +SEGMENT + : S E G M E N T + ; + +SEGMENT_LIMIT + : S E G M E N T MINUSCHAR L I M I T + ; + +SELECT + : S E L E C T + ; + +SEND + : S E N D + ; + +SENTENCE + : S E N T E N C E + ; + +SEPARATE + : S E P A R A T E + ; + +SEQUENCE + : S E Q U E N C E + ; + +SEQUENTIAL + : S E Q U E N T I A L + ; + +SET + : S E T + ; + +SHARED + : S H A R E D + ; + +SHAREDBYALL + : S H A R E D B Y A L L + ; + +SHAREDBYRUNUNIT + : S H A R E D B Y R U N U N I T + ; + +SHARING + : S H A R I N G + ; + +SHIFT_IN + : S H I F T MINUSCHAR I N + ; + +SHIFT_OUT + : S H I F T MINUSCHAR O U T + ; + +SHORT_DATE + : S H O R T MINUSCHAR D A T E + ; + +SIGN + : S I G N + ; + +SIZE + : S I Z E + ; + +SORT + : S O R T + ; + +SORT_CONTROL + : S O R T MINUSCHAR C O N T R O L + ; + +SORT_CORE_SIZE + : S O R T MINUSCHAR C O R E MINUSCHAR S I Z E + ; + +SORT_FILE_SIZE + : S O R T MINUSCHAR F I L E MINUSCHAR S I Z E + ; + +SORT_MERGE + : S O R T MINUSCHAR M E R G E + ; + +SORT_MESSAGE + : S O R T MINUSCHAR M E S S A G E + ; + +SORT_MODE_SIZE + : S O R T MINUSCHAR M O D E MINUSCHAR S I Z E + ; + +SORT_RETURN + : S O R T MINUSCHAR R E T U R N + ; + +SOURCE + : S O U R C E + ; + +SOURCE_COMPUTER + : S O U R C E MINUSCHAR C O M P U T E R + ; + +SPACE + : S P A C E + ; + +SPACES + : S P A C E S + ; + +SPECIAL_NAMES + : S P E C I A L MINUSCHAR N A M E S + ; + +STANDARD + : S T A N D A R D + ; + +STANDARD_1 + : S T A N D A R D MINUSCHAR '1' + ; + +STANDARD_2 + : S T A N D A R D MINUSCHAR '2' + ; + +START + : S T A R T + ; + +STATUS + : S T A T U S + ; + +STOP + : S T O P + ; + +STRING + : S T R I N G + ; + +SUB_QUEUE_1 + : S U B MINUSCHAR Q U E U E MINUSCHAR '1' + ; + +SUB_QUEUE_2 + : S U B MINUSCHAR Q U E U E MINUSCHAR '2' + ; + +SUB_QUEUE_3 + : S U B MINUSCHAR Q U E U E MINUSCHAR '3' + ; + +SUBTRACT + : S U B T R A C T + ; + +SUM + : S U M + ; + +SUPPRESS + : S U P P R E S S + ; + +SYMBOL + : S Y M B O L + ; + +SYMBOLIC + : S Y M B O L I C + ; + +SYNC + : S Y N C + ; + +SYNCHRONIZED + : S Y N C H R O N I Z E D + ; + +TABLE + : T A B L E + ; + +TALLY + : T A L L Y + ; + +TALLYING + : T A L L Y I N G + ; + +TASK + : T A S K + ; + +TAPE + : T A P E + ; + +TERMINAL + : T E R M I N A L + ; + +TERMINATE + : T E R M I N A T E + ; + +TEST + : T E S T + ; + +TEXT + : T E X T + ; + +THAN + : T H A N + ; + +THEN + : T H E N + ; + +THREAD + : T H R E A D + ; + +THREAD_LOCAL + : T H R E A D MINUSCHAR L O C A L + ; + +THROUGH + : T H R O U G H + ; + +THRU + : T H R U + ; + +TIME + : T I M E + ; + +TIMER + : T I M E R + ; + +TIMES + : T I M E S + ; + +TITLE + : T I T L E + ; + +TO + : T O + ; + +TODAYS_DATE + : T O D A Y S MINUSCHAR D A T E + ; + +TODAYS_NAME + : T O D A Y S MINUSCHAR N A M E + ; + +TOP + : T O P + ; + +TRAILING + : T R A I L I N G + ; + +TRUE + : T R U E + ; + +TRUNCATED + : T R U N C A T E D + ; + +TYPE + : T Y P E + ; + +TYPEDEF + : T Y P E D E F + ; + +UNDERLINE + : U N D E R L I N E + ; + +UNIT + : U N I T + ; + +UNSTRING + : U N S T R I N G + ; + +UNTIL + : U N T I L + ; + +UP + : U P + ; + +UPON + : U P O N + ; + +USAGE + : U S A G E + ; + +USE + : U S E + ; + +USING + : U S I N G + ; + +VALUE + : V A L U E + ; + +VALUES + : V A L U E S + ; + +VARYING + : V A R Y I N G + ; + +VIRTUAL + : V I R T U A L + ; + +WAIT + : W A I T + ; + +WHEN + : W H E N + ; + +WHEN_COMPILED + : W H E N MINUSCHAR C O M P I L E D + ; + +WITH + : W I T H + ; + +WORDS + : W O R D S + ; + +WORKING_STORAGE + : W O R K I N G MINUSCHAR S T O R A G E + ; + +WRITE + : W R I T E + ; + +YEAR + : Y E A R + ; + +YYYYMMDD + : Y Y Y Y M M D D + ; + +YYYYDDD + : Y Y Y Y D D D + ; + +ZERO + : Z E R O + ; + +ZERO_FILL + : Z E R O MINUSCHAR F I L L + ; + +ZEROS + : Z E R O S + ; + +ZEROES + : Z E R O E S + ; + +// symbols +AMPCHAR + : '&' + ; + +ASTERISKCHAR + : '*' + ; + +DOUBLEASTERISKCHAR + : '**' + ; + +COLONCHAR + : ':' + ; + +COMMACHAR + : ',' + ; + +COMMENTENTRYTAG + : '*>CE' + ; + +COMMENTTAG + : '*>' + ; + +DOLLARCHAR + : '$' + ; + +DOUBLEQUOTE + : '"' + ; + +// period full stop +DOT_FS + : '.' ('\r' | '\n' | '\f' | '\t' | ' ')+ + | '.' EOF + ; + +DOT + : '.' + ; + +EQUALCHAR + : '=' + ; + +EXECCICSTAG + : '*>EXECCICS' + ; + +EXECSQLTAG + : '*>EXECSQL' + ; + +EXECSQLIMSTAG + : '*>EXECSQLIMS' + ; + +LESSTHANCHAR + : '<' + ; + +LESSTHANOREQUAL + : '<=' + ; + +LPARENCHAR + : '(' + ; + +MINUSCHAR + : '-' + ; + +MORETHANCHAR + : '>' + ; + +MORETHANOREQUAL + : '>=' + ; + +NOTEQUALCHAR + : '<>' + ; + +PLUSCHAR + : '+' + ; + +SINGLEQUOTE + : '\'' + ; + +RPARENCHAR + : ')' + ; + +SLASHCHAR + : '/' + ; + +// literals +NONNUMERICLITERAL + : STRINGLITERAL + | DBCSLITERAL + | HEXNUMBER + | NULLTERMINATED + ; + +fragment HEXNUMBER + : X '"' [0-9A-F]+ '"' + | X '\'' [0-9A-F]+ '\'' + ; + +fragment NULLTERMINATED + : Z '"' (~["\n\r] | '""' | '\'')* '"' + | Z '\'' (~['\n\r] | '\'\'' | '"')* '\'' + ; + +fragment STRINGLITERAL + : '"' (~["\n\r] | '""' | '\'')* '"' + | '\'' (~['\n\r] | '\'\'' | '"')* '\'' + ; + +fragment DBCSLITERAL + : [GN] '"' (~["\n\r] | '""' | '\'')* '"' + | [GN] '\'' (~['\n\r] | '\'\'' | '"')* '\'' + ; + +LEVEL_NUMBER_66 + : '66' + ; + +LEVEL_NUMBER_77 + : '77' + ; + +LEVEL_NUMBER_88 + : '88' + ; + +INTEGERLITERAL + : (PLUSCHAR | MINUSCHAR)? [0-9]+ + ; + +NUMERICLITERAL + : (PLUSCHAR | MINUSCHAR)? [0-9]* (DOT | COMMACHAR) [0-9]+ ( + ('e' | 'E') (PLUSCHAR | MINUSCHAR)? [0-9]+ + )? + ; + +IDENTIFIER + : [a-zA-Z0-9]+ ([-_]+ [a-zA-Z0-9]+)* + ; + +// whitespace, line breaks, comments, ... +NEWLINE + : '\r'? '\n' -> channel(HIDDEN) + ; + +EXECCICSLINE + : EXECCICSTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}') + ; + +EXECSQLIMSLINE + : EXECSQLIMSTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}') + ; + +EXECSQLLINE + : EXECSQLTAG WS ~('\n' | '\r' | '}')* ('\n' | '\r' | '}') + ; + +COMMENTENTRYLINE + : COMMENTENTRYTAG WS ~('\n' | '\r')* + ; + +COMMENTLINE + : COMMENTTAG WS ~('\n' | '\r')* -> channel(HIDDEN) + ; + +WS + : [ \t\f;]+ -> channel(HIDDEN) + ; + +SEPARATOR + : ', ' -> channel(HIDDEN) + ; + +// case insensitive chars +fragment A + : ('a' | 'A') + ; + +fragment B + : ('b' | 'B') + ; + +fragment C + : ('c' | 'C') + ; + +fragment D + : ('d' | 'D') + ; + +fragment E + : ('e' | 'E') + ; + +fragment F + : ('f' | 'F') + ; + +fragment G + : ('g' | 'G') + ; + +fragment H + : ('h' | 'H') + ; + +fragment I + : ('i' | 'I') + ; + +fragment J + : ('j' | 'J') + ; + +fragment K + : ('k' | 'K') + ; + +fragment L + : ('l' | 'L') + ; + +fragment M + : ('m' | 'M') + ; + +fragment N + : ('n' | 'N') + ; + +fragment O + : ('o' | 'O') + ; + +fragment P + : ('p' | 'P') + ; + +fragment Q + : ('q' | 'Q') + ; + +fragment R + : ('r' | 'R') + ; + +fragment S + : ('s' | 'S') + ; + +fragment T + : ('t' | 'T') + ; + +fragment U + : ('u' | 'U') + ; + +fragment V + : ('v' | 'V') + ; + +fragment W + : ('w' | 'W') + ; + +fragment X + : ('x' | 'X') + ; + +fragment Y + : ('y' | 'Y') + ; + +fragment Z + : ('z' | 'Z') + ; \ No newline at end of file diff --git a/src/main/antlr/cobol/Cobol85Preprocessor.g4 b/src/main/antlr/cobol/Cobol85Preprocessor.g4 new file mode 100644 index 0000000..6425486 --- /dev/null +++ b/src/main/antlr/cobol/Cobol85Preprocessor.g4 @@ -0,0 +1,1903 @@ +/* +* Copyright (C) 2017, Ulrich Wolffgang +* All rights reserved. +* +* This software may be modified and distributed under the terms +* of the MIT license. See the LICENSE file for details. +*/ + +/* +* Cobol 85 Preprocessor Grammar for ANTLR4 +* +* This is a preprocessor grammar for Cobol 85. +*/ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +grammar Cobol85Preprocessor; + +startRule + : ( + compilerOptions + | copyStatement + | execCicsStatement + | execSqlStatement + | execSqlImsStatement + | replaceOffStatement + | replaceArea + | ejectStatement + | skipStatement + | titleStatement + | charDataLine + | NEWLINE + )* EOF + ; + +// compiler options + +compilerOptions + : (PROCESS | CBL) (COMMACHAR? compilerOption | compilerXOpts)+ + ; + +compilerXOpts + : XOPTS LPARENCHAR compilerOption (COMMACHAR? compilerOption)* RPARENCHAR + ; + +compilerOption + : ADATA + | ADV + | APOST + | (ARITH | AR) LPARENCHAR (EXTEND | E_CHAR | COMPAT | C_CHAR) RPARENCHAR + | AWO + | BLOCK0 + | (BUFSIZE | BUF) LPARENCHAR literal RPARENCHAR + | CBLCARD + | CICS (LPARENCHAR literal RPARENCHAR)? + | COBOL2 + | COBOL3 + | (CODEPAGE | CP) LPARENCHAR literal RPARENCHAR + | (COMPILE | C_CHAR) + | CPP + | CPSM + | (CURRENCY | CURR) LPARENCHAR literal RPARENCHAR + | DATA LPARENCHAR literal RPARENCHAR + | (DATEPROC | DP) (LPARENCHAR (FLAG | NOFLAG)? COMMACHAR? (TRIG | NOTRIG)? RPARENCHAR)? + | DBCS + | (DECK | D_CHAR) + | DEBUG + | (DIAGTRUNC | DTR) + | DLL + | (DUMP | DU) + | (DYNAM | DYN) + | EDF + | EPILOG + | EXIT + | (EXPORTALL | EXP) + | (FASTSRT | FSRT) + | FEPI + | (FLAG | F_CHAR) LPARENCHAR (E_CHAR | I_CHAR | S_CHAR | U_CHAR | W_CHAR) ( + COMMACHAR (E_CHAR | I_CHAR | S_CHAR | U_CHAR | W_CHAR) + )? RPARENCHAR + | FLAGSTD LPARENCHAR (M_CHAR | I_CHAR | H_CHAR) ( + COMMACHAR (D_CHAR | DD | N_CHAR | NN | S_CHAR | SS) + )? RPARENCHAR + | GDS + | GRAPHIC + | INTDATE LPARENCHAR (ANSI | LILIAN) RPARENCHAR + | (LANGUAGE | LANG) LPARENCHAR (ENGLISH | CS | EN | JA | JP | KA | UE) RPARENCHAR + | LEASM + | LENGTH + | LIB + | LIN + | (LINECOUNT | LC) LPARENCHAR literal RPARENCHAR + | LINKAGE + | LIST + | MAP + | MARGINS LPARENCHAR literal COMMACHAR literal (COMMACHAR literal)? RPARENCHAR + | (MDECK | MD) (LPARENCHAR (C_CHAR | COMPILE | NOC | NOCOMPILE) RPARENCHAR)? + | NAME (LPARENCHAR (ALIAS | NOALIAS) RPARENCHAR)? + | NATLANG LPARENCHAR (CS | EN | KA) RPARENCHAR + | NOADATA + | NOADV + | NOAWO + | NOBLOCK0 + | NOCBLCARD + | NOCICS + | NOCMPR2 + | (NOCOMPILE | NOC) (LPARENCHAR (S_CHAR | E_CHAR | W_CHAR) RPARENCHAR)? + | NOCPSM + | (NOCURRENCY | NOCURR) + | (NODATEPROC | NODP) + | NODBCS + | NODEBUG + | (NODECK | NOD) + | NODLL + | NODE + | (NODUMP | NODU) + | (NODIAGTRUNC | NODTR) + | (NODYNAM | NODYN) + | NOEDF + | NOEPILOG + | NOEXIT + | (NOEXPORTALL | NOEXP) + | (NOFASTSRT | NOFSRT) + | NOFEPI + | (NOFLAG | NOF) + | NOFLAGMIG + | NOFLAGSTD + | NOGRAPHIC + | NOLENGTH + | NOLIB + | NOLINKAGE + | NOLIST + | NOMAP + | (NOMDECK | NOMD) + | NONAME + | (NONUMBER | NONUM) + | (NOOBJECT | NOOBJ) + | (NOOFFSET | NOOFF) + | NOOPSEQUENCE + | (NOOPTIMIZE | NOOPT) + | NOOPTIONS + | NOP + | NOPROLOG + | NORENT + | (NOSEQUENCE | NOSEQ) + | (NOSOURCE | NOS) + | NOSPIE + | NOSQL + | (NOSQLCCSID | NOSQLC) + | (NOSSRANGE | NOSSR) + | NOSTDTRUNC + | (NOTERMINAL | NOTERM) + | NOTEST + | NOTHREAD + | NOVBREF + | (NOWORD | NOWD) + | NSEQ + | (NSYMBOL | NS) LPARENCHAR (NATIONAL | NAT | DBCS) RPARENCHAR + | NOVBREF + | (NOXREF | NOX) + | NOZWB + | (NUMBER | NUM) + | NUMPROC LPARENCHAR (MIG | NOPFD | PFD) RPARENCHAR + | (OBJECT | OBJ) + | (OFFSET | OFF) + | OPMARGINS LPARENCHAR literal COMMACHAR literal (COMMACHAR literal)? RPARENCHAR + | OPSEQUENCE LPARENCHAR literal COMMACHAR literal RPARENCHAR + | (OPTIMIZE | OPT) (LPARENCHAR (FULL | STD) RPARENCHAR)? + | OPTFILE + | OPTIONS + | OP + | (OUTDD | OUT) LPARENCHAR cobolWord RPARENCHAR + | (PGMNAME | PGMN) LPARENCHAR ( + CO + | COMPAT + | LM + | LONGMIXED + | LONGUPPER + | LU + | M_CHAR + | MIXED + | U_CHAR + | UPPER + ) RPARENCHAR + | PROLOG + | (QUOTE | Q_CHAR) + | RENT + | RMODE LPARENCHAR (ANY | AUTO | literal) RPARENCHAR + | (SEQUENCE | SEQ) (LPARENCHAR literal COMMACHAR literal RPARENCHAR)? + | (SIZE | SZ) LPARENCHAR (MAX | literal) RPARENCHAR + | (SOURCE | S_CHAR) + | SP + | SPACE LPARENCHAR literal RPARENCHAR + | SPIE + | SQL (LPARENCHAR literal RPARENCHAR)? + | (SQLCCSID | SQLC) + | (SSRANGE | SSR) + | SYSEIB + | (TERMINAL | TERM) + | TEST ( + LPARENCHAR (HOOK | NOHOOK)? COMMACHAR? (SEP | SEPARATE | NOSEP | NOSEPARATE)? COMMACHAR? ( + EJPD + | NOEJPD + )? RPARENCHAR + )? + | THREAD + | TRUNC LPARENCHAR (BIN | OPT | STD) RPARENCHAR + | VBREF + | (WORD | WD) LPARENCHAR cobolWord RPARENCHAR + | (XMLPARSE | XP) LPARENCHAR (COMPAT | C_CHAR | XMLSS | X_CHAR) RPARENCHAR + | (XREF | X_CHAR) (LPARENCHAR (FULL | SHORT)? RPARENCHAR)? + | (YEARWINDOW | YW) LPARENCHAR literal RPARENCHAR + | ZWB + ; + +// exec cics statement + +execCicsStatement + : EXEC CICS charData END_EXEC DOT? + ; + +// exec sql statement + +execSqlStatement + : EXEC SQL charDataSql END_EXEC DOT? + ; + +// exec sql ims statement + +execSqlImsStatement + : EXEC SQLIMS charData END_EXEC DOT? + ; + +// copy statement + +copyStatement + : COPY copySource (NEWLINE* (directoryPhrase | familyPhrase | replacingPhrase | SUPPRESS))* NEWLINE* DOT + ; + +copySource + : (literal | cobolWord | filename) ((OF | IN) copyLibrary)? + ; + +copyLibrary + : literal + | cobolWord + ; + +replacingPhrase + : REPLACING NEWLINE* replaceClause (NEWLINE+ replaceClause)* + ; + +// replace statement + +replaceArea + : replaceByStatement (copyStatement | charData)* replaceOffStatement? + ; + +replaceByStatement + : REPLACE (NEWLINE* replaceClause)+ DOT + ; + +replaceOffStatement + : REPLACE OFF DOT + ; + +replaceClause + : replaceable NEWLINE* BY NEWLINE* replacement (NEWLINE* directoryPhrase)? ( + NEWLINE* familyPhrase + )? + ; + +directoryPhrase + : (OF | IN) NEWLINE* (literal | cobolWord) + ; + +familyPhrase + : ON NEWLINE* (literal | cobolWord) + ; + +replaceable + : literal + | cobolWord + | pseudoText + | charDataLine + ; + +replacement + : literal + | cobolWord + | pseudoText + | charDataLine + ; + +// eject statement + +ejectStatement + : EJECT DOT? + ; + +// skip statement + +skipStatement + : (SKIP1 | SKIP2 | SKIP3) DOT? + ; + +// title statement + +titleStatement + : TITLE literal DOT? + ; + +// literal ---------------------------------- + +pseudoText + : DOUBLEEQUALCHAR charData? DOUBLEEQUALCHAR + ; + +charData + : (charDataLine | NEWLINE)+ + ; + +charDataSql + : (charDataLine | COPY | REPLACE | NEWLINE)+ + ; + +charDataLine + : (cobolWord | literal | filename | TEXT | DOT | LPARENCHAR | RPARENCHAR)+ + ; + +cobolWord + : IDENTIFIER + | charDataKeyword + ; + +literal + : NONNUMERICLITERAL + | NUMERICLITERAL + ; + +filename + : FILENAME + ; + +// keywords ---------------------------------- + +charDataKeyword + : ADATA + | ADV + | ALIAS + | ANSI + | ANY + | APOST + | AR + | ARITH + | AUTO + | AWO + | BIN + | BLOCK0 + | BUF + | BUFSIZE + | BY + | CBL + | CBLCARD + | CO + | COBOL2 + | COBOL3 + | CODEPAGE + | COMMACHAR + | COMPAT + | COMPILE + | CP + | CPP + | CPSM + | CS + | CURR + | CURRENCY + | DATA + | DATEPROC + | DBCS + | DD + | DEBUG + | DECK + | DIAGTRUNC + | DLI + | DLL + | DP + | DTR + | DU + | DUMP + | DYN + | DYNAM + | EDF + | EJECT + | EJPD + | EN + | ENGLISH + | EPILOG + | EXCI + | EXIT + | EXP + | EXPORTALL + | EXTEND + | FASTSRT + | FLAG + | FLAGSTD + | FULL + | FSRT + | GDS + | GRAPHIC + | HOOK + | IN + | INTDATE + | JA + | JP + | KA + | LANG + | LANGUAGE + | LC + | LENGTH + | LIB + | LILIAN + | LIN + | LINECOUNT + | LINKAGE + | LIST + | LM + | LONGMIXED + | LONGUPPER + | LU + | MAP + | MARGINS + | MAX + | MD + | MDECK + | MIG + | MIXED + | NAME + | NAT + | NATIONAL + | NATLANG + | NN + | NO + | NOADATA + | NOADV + | NOALIAS + | NOAWO + | NOBLOCK0 + | NOC + | NOCBLCARD + | NOCICS + | NOCMPR2 + | NOCOMPILE + | NOCPSM + | NOCURR + | NOCURRENCY + | NOD + | NODATEPROC + | NODBCS + | NODE + | NODEBUG + | NODECK + | NODIAGTRUNC + | NODLL + | NODU + | NODUMP + | NODP + | NODTR + | NODYN + | NODYNAM + | NOEDF + | NOEJPD + | NOEPILOG + | NOEXIT + | NOEXP + | NOEXPORTALL + | NOF + | NOFASTSRT + | NOFEPI + | NOFLAG + | NOFLAGMIG + | NOFLAGSTD + | NOFSRT + | NOGRAPHIC + | NOHOOK + | NOLENGTH + | NOLIB + | NOLINKAGE + | NOLIST + | NOMAP + | NOMD + | NOMDECK + | NONAME + | NONUM + | NONUMBER + | NOOBJ + | NOOBJECT + | NOOFF + | NOOFFSET + | NOOPSEQUENCE + | NOOPT + | NOOPTIMIZE + | NOOPTIONS + | NOP + | NOPFD + | NOPROLOG + | NORENT + | NOS + | NOSEP + | NOSEPARATE + | NOSEQ + | NOSEQUENCE + | NOSOURCE + | NOSPIE + | NOSQL + | NOSQLC + | NOSQLCCSID + | NOSSR + | NOSSRANGE + | NOSTDTRUNC + | NOTERM + | NOTERMINAL + | NOTEST + | NOTHREAD + | NOTRIG + | NOVBREF + | NOWORD + | NOX + | NOXREF + | NOZWB + | NSEQ + | NSYMBOL + | NS + | NUM + | NUMBER + | NUMPROC + | OBJ + | OBJECT + | ON + | OF + | OFF + | OFFSET + | OPMARGINS + | OPSEQUENCE + | OPTIMIZE + | OP + | OPT + | OPTFILE + | OPTIONS + | OUT + | OUTDD + | PFD + | PGMN + | PGMNAME + | PPTDBG + | PROCESS + | PROLOG + | QUOTE + | RENT + | REPLACING + | RMODE + | SEQ + | SEQUENCE + | SEP + | SEPARATE + | SHORT + | SIZE + | SOURCE + | SP + | SPACE + | SPIE + | SQL + | SQLC + | SQLCCSID + | SS + | SSR + | SSRANGE + | STD + | SYSEIB + | SZ + | TERM + | TERMINAL + | TEST + | THREAD + | TITLE + | TRIG + | TRUNC + | UE + | UPPER + | VBREF + | WD + | XMLPARSE + | XMLSS + | XOPTS + | XREF + | YEARWINDOW + | YW + | ZWB + | C_CHAR + | D_CHAR + | E_CHAR + | F_CHAR + | H_CHAR + | I_CHAR + | M_CHAR + | N_CHAR + | Q_CHAR + | S_CHAR + | U_CHAR + | W_CHAR + | X_CHAR + ; + +// lexer rules -------------------------------------------------------------------------------- + +// keywords +ADATA + : A D A T A + ; + +ADV + : A D V + ; + +ALIAS + : A L I A S + ; + +ANSI + : A N S I + ; + +ANY + : A N Y + ; + +APOST + : A P O S T + ; + +AR + : A R + ; + +ARITH + : A R I T H + ; + +AUTO + : A U T O + ; + +AWO + : A W O + ; + +BIN + : B I N + ; + +BLOCK0 + : B L O C K '0' + ; + +BUF + : B U F + ; + +BUFSIZE + : B U F S I Z E + ; + +BY + : B Y + ; + +CBL + : C B L + ; + +CBLCARD + : C B L C A R D + ; + +CICS + : C I C S + ; + +CO + : C O + ; + +COBOL2 + : C O B O L '2' + ; + +COBOL3 + : C O B O L '3' + ; + +CODEPAGE + : C O D E P A G E + ; + +COMPAT + : C O M P A T + ; + +COMPILE + : C O M P I L E + ; + +COPY + : C O P Y + ; + +CP + : C P + ; + +CPP + : C P P + ; + +CPSM + : C P S M + ; + +CS + : C S + ; + +CURR + : C U R R + ; + +CURRENCY + : C U R R E N C Y + ; + +DATA + : D A T A + ; + +DATEPROC + : D A T E P R O C + ; + +DBCS + : D B C S + ; + +DD + : D D + ; + +DEBUG + : D E B U G + ; + +DECK + : D E C K + ; + +DIAGTRUNC + : D I A G T R U N C + ; + +DLI + : D L I + ; + +DLL + : D L L + ; + +DP + : D P + ; + +DTR + : D T R + ; + +DU + : D U + ; + +DUMP + : D U M P + ; + +DYN + : D Y N + ; + +DYNAM + : D Y N A M + ; + +EDF + : E D F + ; + +EJECT + : E J E C T + ; + +EJPD + : E J P D + ; + +EN + : E N + ; + +ENGLISH + : E N G L I S H + ; + +END_EXEC + : E N D '-' E X E C + ; + +EPILOG + : E P I L O G + ; + +EXCI + : E X C I + ; + +EXEC + : E X E C + ; + +EXIT + : E X I T + ; + +EXP + : E X P + ; + +EXPORTALL + : E X P O R T A L L + ; + +EXTEND + : E X T E N D + ; + +FASTSRT + : F A S T S R T + ; + +FEPI + : F E P I + ; + +FLAG + : F L A G + ; + +FLAGSTD + : F L A G S T D + ; + +FSRT + : F S R T + ; + +FULL + : F U L L + ; + +GDS + : G D S + ; + +GRAPHIC + : G R A P H I C + ; + +HOOK + : H O O K + ; + +IN + : I N + ; + +INTDATE + : I N T D A T E + ; + +JA + : J A + ; + +JP + : J P + ; + +KA + : K A + ; + +LANG + : L A N G + ; + +LANGUAGE + : L A N G U A G E + ; + +LC + : L C + ; + +LEASM + : L E A S M + ; + +LENGTH + : L E N G T H + ; + +LIB + : L I B + ; + +LILIAN + : L I L I A N + ; + +LIN + : L I N + ; + +LINECOUNT + : L I N E C O U N T + ; + +LINKAGE + : L I N K A G E + ; + +LIST + : L I S T + ; + +LM + : L M + ; + +LONGMIXED + : L O N G M I X E D + ; + +LONGUPPER + : L O N G U P P E R + ; + +LPARENCHAR + : '(' + ; + +LU + : L U + ; + +MAP + : M A P + ; + +MARGINS + : M A R G I N S + ; + +MAX + : M A X + ; + +MD + : M D + ; + +MDECK + : M D E C K + ; + +MIG + : M I G + ; + +MIXED + : M I X E D + ; + +NAME + : N A M E + ; + +NAT + : N A T + ; + +NATIONAL + : N A T I O N A L + ; + +NATLANG + : N A T L A N G + ; + +NN + : N N + ; + +NO + : N O + ; + +NOADATA + : N O A D A T A + ; + +NOADV + : N O A D V + ; + +NOALIAS + : N O A L I A S + ; + +NOAWO + : N O A W O + ; + +NOBLOCK0 + : N O B L O C K '0' + ; + +NOC + : N O C + ; + +NOCBLCARD + : N O C B L C A R D + ; + +NOCICS + : N O C I C S + ; + +NOCMPR2 + : N O C M P R '2' + ; + +NOCOMPILE + : N O C O M P I L E + ; + +NOCPSM + : N O C P S M + ; + +NOCURR + : N O C U R R + ; + +NOCURRENCY + : N O C U R R E N C Y + ; + +NOD + : N O D + ; + +NODATEPROC + : N O D A T E P R O C + ; + +NODBCS + : N O D B C S + ; + +NODE + : N O D E + ; + +NODEBUG + : N O D E B U G + ; + +NODECK + : N O D E C K + ; + +NODIAGTRUNC + : N O D I A G T R U N C + ; + +NODLL + : N O D L L + ; + +NODU + : N O D U + ; + +NODUMP + : N O D U M P + ; + +NODP + : N O D P + ; + +NODTR + : N O D T R + ; + +NODYN + : N O D Y N + ; + +NODYNAM + : N O D Y N A M + ; + +NOEDF + : N O E D F + ; + +NOEJPD + : N O E J P D + ; + +NOEPILOG + : N O E P I L O G + ; + +NOEXIT + : N O E X I T + ; + +NOEXP + : N O E X P + ; + +NOEXPORTALL + : N O E X P O R T A L L + ; + +NOF + : N O F + ; + +NOFASTSRT + : N O F A S T S R T + ; + +NOFEPI + : N O F E P I + ; + +NOFLAG + : N O F L A G + ; + +NOFLAGMIG + : N O F L A G M I G + ; + +NOFLAGSTD + : N O F L A G S T D + ; + +NOFSRT + : N O F S R T + ; + +NOGRAPHIC + : N O G R A P H I C + ; + +NOHOOK + : N O H O O K + ; + +NOLENGTH + : N O L E N G T H + ; + +NOLIB + : N O L I B + ; + +NOLINKAGE + : N O L I N K A G E + ; + +NOLIST + : N O L I S T + ; + +NOMAP + : N O M A P + ; + +NOMD + : N O M D + ; + +NOMDECK + : N O M D E C K + ; + +NONAME + : N O N A M E + ; + +NONUM + : N O N U M + ; + +NONUMBER + : N O N U M B E R + ; + +NOOBJ + : N O O B J + ; + +NOOBJECT + : N O O B J E C T + ; + +NOOFF + : N O O F F + ; + +NOOFFSET + : N O O F F S E T + ; + +NOOPSEQUENCE + : N O O P S E Q U E N C E + ; + +NOOPT + : N O O P T + ; + +NOOPTIMIZE + : N O O P T I M I Z E + ; + +NOOPTIONS + : N O O P T I O N S + ; + +NOP + : N O P + ; + +NOPFD + : N O P F D + ; + +NOPROLOG + : N O P R O L O G + ; + +NORENT + : N O R E N T + ; + +NOS + : N O S + ; + +NOSEP + : N O S E P + ; + +NOSEPARATE + : N O S E P A R A T E + ; + +NOSEQ + : N O S E Q + ; + +NOSOURCE + : N O S O U R C E + ; + +NOSPIE + : N O S P I E + ; + +NOSQL + : N O S Q L + ; + +NOSQLC + : N O S Q L C + ; + +NOSQLCCSID + : N O S Q L C C S I D + ; + +NOSSR + : N O S S R + ; + +NOSSRANGE + : N O S S R A N G E + ; + +NOSTDTRUNC + : N O S T D T R U N C + ; + +NOSEQUENCE + : N O S E Q U E N C E + ; + +NOTERM + : N O T E R M + ; + +NOTERMINAL + : N O T E R M I N A L + ; + +NOTEST + : N O T E S T + ; + +NOTHREAD + : N O T H R E A D + ; + +NOTRIG + : N O T R I G + ; + +NOVBREF + : N O V B R E F + ; + +NOWD + : N O W D + ; + +NOWORD + : N O W O R D + ; + +NOX + : N O X + ; + +NOXREF + : N O X R E F + ; + +NOZWB + : N O Z W B + ; + +NS + : N S + ; + +NSEQ + : N S E Q + ; + +NSYMBOL + : N S Y M B O L + ; + +NUM + : N U M + ; + +NUMBER + : N U M B E R + ; + +NUMPROC + : N U M P R O C + ; + +OBJ + : O B J + ; + +OBJECT + : O B J E C T + ; + +OF + : O F + ; + +OFF + : O F F + ; + +OFFSET + : O F F S E T + ; + +ON + : O N + ; + +OP + : O P + ; + +OPMARGINS + : O P M A R G I N S + ; + +OPSEQUENCE + : O P S E Q U E N C E + ; + +OPT + : O P T + ; + +OPTFILE + : O P T F I L E + ; + +OPTIMIZE + : O P T I M I Z E + ; + +OPTIONS + : O P T I O N S + ; + +OUT + : O U T + ; + +OUTDD + : O U T D D + ; + +PFD + : P F D + ; + +PPTDBG + : P P T D B G + ; + +PGMN + : P G M N + ; + +PGMNAME + : P G M N A M E + ; + +PROCESS + : P R O C E S S + ; + +PROLOG + : P R O L O G + ; + +QUOTE + : Q U O T E + ; + +RENT + : R E N T + ; + +REPLACE + : R E P L A C E + ; + +REPLACING + : R E P L A C I N G + ; + +RMODE + : R M O D E + ; + +RPARENCHAR + : ')' + ; + +SEP + : S E P + ; + +SEPARATE + : S E P A R A T E + ; + +SEQ + : S E Q + ; + +SEQUENCE + : S E Q U E N C E + ; + +SHORT + : S H O R T + ; + +SIZE + : S I Z E + ; + +SOURCE + : S O U R C E + ; + +SP + : S P + ; + +SPACE + : S P A C E + ; + +SPIE + : S P I E + ; + +SQL + : S Q L + ; + +SQLC + : S Q L C + ; + +SQLCCSID + : S Q L C C S I D + ; + +SQLIMS + : S Q L I M S + ; + +SKIP1 + : S K I P '1' + ; + +SKIP2 + : S K I P '2' + ; + +SKIP3 + : S K I P '3' + ; + +SS + : S S + ; + +SSR + : S S R + ; + +SSRANGE + : S S R A N G E + ; + +STD + : S T D + ; + +SUPPRESS + : S U P P R E S S + ; + +SYSEIB + : S Y S E I B + ; + +SZ + : S Z + ; + +TERM + : T E R M + ; + +TERMINAL + : T E R M I N A L + ; + +TEST + : T E S T + ; + +THREAD + : T H R E A D + ; + +TITLE + : T I T L E + ; + +TRIG + : T R I G + ; + +TRUNC + : T R U N C + ; + +UE + : U E + ; + +UPPER + : U P P E R + ; + +VBREF + : V B R E F + ; + +WD + : W D + ; + +WORD + : W O R D + ; + +XMLPARSE + : X M L P A R S E + ; + +XMLSS + : X M L S S + ; + +XOPTS + : X O P T S + ; + +XP + : X P + ; + +XREF + : X R E F + ; + +YEARWINDOW + : Y E A R W I N D O W + ; + +YW + : Y W + ; + +ZWB + : Z W B + ; + +C_CHAR + : C + ; + +D_CHAR + : D + ; + +E_CHAR + : E + ; + +F_CHAR + : F + ; + +H_CHAR + : H + ; + +I_CHAR + : I + ; + +M_CHAR + : M + ; + +N_CHAR + : N + ; + +Q_CHAR + : Q + ; + +S_CHAR + : S + ; + +U_CHAR + : U + ; + +W_CHAR + : W + ; + +X_CHAR + : X + ; + +// symbols +COMMENTTAG + : '*>' + ; + +COMMACHAR + : ',' + ; + +DOT + : '.' + ; + +DOUBLEEQUALCHAR + : '==' + ; + +// literals +NONNUMERICLITERAL + : STRINGLITERAL + | HEXNUMBER + ; + +NUMERICLITERAL + : [0-9]+ + ; + +fragment HEXNUMBER + : X '"' [0-9A-F]+ '"' + | X '\'' [0-9A-F]+ '\'' + ; + +fragment STRINGLITERAL + : '"' (~["\n\r] | '""' | '\'')* '"' + | '\'' (~['\n\r] | '\'\'' | '"')* '\'' + ; + +IDENTIFIER + : [a-zA-Z0-9]+ ([-_]+ [a-zA-Z0-9]+)* + ; + +FILENAME + : [a-zA-Z0-9]+ '.' [a-zA-Z0-9]+ + ; + +// whitespace, line breaks, comments, ... +NEWLINE + : '\r'? '\n' + ; + +COMMENTLINE + : COMMENTTAG ~('\n' | '\r')* -> channel(HIDDEN) + ; + +WS + : [ \t\f;]+ -> channel(HIDDEN) + ; + +TEXT + : ~('\n' | '\r') + ; + +// case insensitive chars +fragment A + : ('a' | 'A') + ; + +fragment B + : ('b' | 'B') + ; + +fragment C + : ('c' | 'C') + ; + +fragment D + : ('d' | 'D') + ; + +fragment E + : ('e' | 'E') + ; + +fragment F + : ('f' | 'F') + ; + +fragment G + : ('g' | 'G') + ; + +fragment H + : ('h' | 'H') + ; + +fragment I + : ('i' | 'I') + ; + +fragment J + : ('j' | 'J') + ; + +fragment K + : ('k' | 'K') + ; + +fragment L + : ('l' | 'L') + ; + +fragment M + : ('m' | 'M') + ; + +fragment N + : ('n' | 'N') + ; + +fragment O + : ('o' | 'O') + ; + +fragment P + : ('p' | 'P') + ; + +fragment Q + : ('q' | 'Q') + ; + +fragment R + : ('r' | 'R') + ; + +fragment S + : ('s' | 'S') + ; + +fragment T + : ('t' | 'T') + ; + +fragment U + : ('u' | 'U') + ; + +fragment V + : ('v' | 'V') + ; + +fragment W + : ('w' | 'W') + ; + +fragment X + : ('x' | 'X') + ; + +fragment Y + : ('y' | 'Y') + ; + +fragment Z + : ('z' | 'Z') + ; \ No newline at end of file diff --git a/src/main/antlr/PlSqlLexer.g4 b/src/main/antlr/sql/PlSqlLexer.g4 similarity index 100% rename from src/main/antlr/PlSqlLexer.g4 rename to src/main/antlr/sql/PlSqlLexer.g4 diff --git a/src/main/antlr/PlSqlParser.g4 b/src/main/antlr/sql/PlSqlParser.g4 similarity index 100% rename from src/main/antlr/PlSqlParser.g4 rename to src/main/antlr/sql/PlSqlParser.g4 diff --git a/src/main/antlr/TSqlLexer.g4 b/src/main/antlr/sql/TSqlLexer.g4 similarity index 100% rename from src/main/antlr/TSqlLexer.g4 rename to src/main/antlr/sql/TSqlLexer.g4 diff --git a/src/main/antlr/TSqlParser.g4 b/src/main/antlr/sql/TSqlParser.g4 similarity index 100% rename from src/main/antlr/TSqlParser.g4 rename to src/main/antlr/sql/TSqlParser.g4 diff --git a/src/main/java/org/dxworks/codeframe/App.java b/src/main/java/org/dxworks/codeframe/App.java index b0047e5..5433bab 100644 --- a/src/main/java/org/dxworks/codeframe/App.java +++ b/src/main/java/org/dxworks/codeframe/App.java @@ -2,35 +2,42 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.dxworks.codeframe.analyzer.*; +import org.dxworks.codeframe.analyzer.cobol.COBOLAnalyzer; +import org.dxworks.codeframe.analyzer.cobol.CobolCopybookRepository; import org.dxworks.codeframe.analyzer.sql.SQLAnalyzer; import org.dxworks.codeframe.model.Analysis; -import org.dxworks.codeframe.model.sql.SQLFileAnalysis; -import org.dxworks.codeframe.model.sql.CreateTableOperation; import org.dxworks.codeframe.model.sql.AlterTableOperation; +import org.dxworks.codeframe.model.sql.CreateTableOperation; +import org.dxworks.codeframe.model.sql.SQLFileAnalysis; +import org.dxworks.utils.ignorer.Ignorer; +import org.dxworks.utils.ignorer.IgnorerBuilder; import org.treesitter.*; import java.io.BufferedWriter; -import java.io.InputStream; +import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.nio.file.*; import java.time.Instant; import java.util.*; -import org.dxworks.ignorerLibrary.Ignorer; -import org.dxworks.ignorerLibrary.IgnorerBuilder; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; public class App { - private static final ObjectMapper MAPPER = new ObjectMapper(); - + private static final ObjectMapper MAPPER = new ObjectMapper() + .setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY); + private static final Map TREE_SITTER_LANGUAGES = new HashMap<>(); - private static final Map ANALYZERS = new HashMap<>(); - + + /** + * Built per run (in main) because COBOL needs run-scoped copybook dependencies. + * Also initialized in tests via initAnalyzersForTests(...). + */ + private static volatile Map ANALYZERS = Map.of(); + static { - // Initialize Tree-sitter languages + // Initialize Tree-sitter languages (stable, can remain static) try { TREE_SITTER_LANGUAGES.put(Language.JAVA, new TreeSitterJava()); TREE_SITTER_LANGUAGES.put(Language.JAVASCRIPT, (TSLanguage) Class.forName("org.treesitter.TreeSitterJavascript").getDeclaredConstructor().newInstance()); @@ -43,17 +50,33 @@ public class App { } catch (Exception e) { throw new RuntimeException("Failed to initialize Tree-sitter languages", e); } - - // Initialize analyzers - ANALYZERS.put(Language.JAVA, new JavaAnalyzer()); - ANALYZERS.put(Language.JAVASCRIPT, new JavaScriptAnalyzer()); - ANALYZERS.put(Language.TYPESCRIPT, new TypeScriptAnalyzer()); - ANALYZERS.put(Language.PYTHON, new PythonAnalyzer()); - ANALYZERS.put(Language.CSHARP, new CSharpAnalyzer()); - ANALYZERS.put(Language.PHP, new PHPAnalyzer()); - ANALYZERS.put(Language.SQL, new SQLAnalyzer()); - ANALYZERS.put(Language.RUBY, new RubyAnalyzer()); - ANALYZERS.put(Language.RUST, new RustAnalyzer()); + } + + private static Map buildAnalyzers(CobolCopybookRepository cobolCopybooks) { + Map analyzers = new HashMap<>(); + + analyzers.put(Language.JAVA, new JavaAnalyzer()); + analyzers.put(Language.JAVASCRIPT, new JavaScriptAnalyzer()); + analyzers.put(Language.TYPESCRIPT, new TypeScriptAnalyzer()); + analyzers.put(Language.PYTHON, new PythonAnalyzer()); + analyzers.put(Language.CSHARP, new CSharpAnalyzer()); + analyzers.put(Language.PHP, new PHPAnalyzer()); + analyzers.put(Language.SQL, new SQLAnalyzer()); + + // COBOL analyzer gets the run-scoped repository (constructor injection) + analyzers.put(Language.COBOL, new COBOLAnalyzer(cobolCopybooks)); + + analyzers.put(Language.RUBY, new RubyAnalyzer()); + analyzers.put(Language.RUST, new RustAnalyzer()); + + return Collections.unmodifiableMap(analyzers); + } + + /** + * Convenience overload for tests: pass copybook paths. + */ + public static void initAnalyzersForTestsFromPaths(List copybookPaths) { + ANALYZERS = buildAnalyzers(new CobolCopybookRepository(copybookPaths.stream().map(Path::toFile).toList())); } public static void main(String[] args) throws Exception { @@ -61,18 +84,17 @@ public static void main(String[] args) throws Exception { System.err.println("Usage: java -jar codeframe.jar "); System.err.println(" : Path to source code directory or file"); System.err.println(" : Path to output JSONL file"); - System.err.println("Supported languages: Java, JavaScript, TypeScript, Python, C#, PHP, SQL, Ruby, Rust"); + System.err.println("Supported languages: Java, JavaScript, TypeScript, Python, C#, PHP, SQL, COBOL, Ruby, Rust"); System.exit(2); } - + Path input = Paths.get(args[0]); if (!Files.exists(input)) { System.err.println("Error: Input path does not exist: " + input); System.exit(1); } - + Path jsonlOutput = Paths.get(args[1]); - // Create parent directories if they don't exist if (jsonlOutput.getParent() != null) { Files.createDirectories(jsonlOutput.getParent()); } @@ -84,15 +106,44 @@ public static void main(String[] args) throws Exception { int maxFileLines = config.getMaxFileLines(); System.out.println("Configuration: maxFileLines=" + maxFileLines + ", hideSqlTableColumns=" + config.isHideSqlTableColumns()); - List files = collectSourceFiles(input, maxFileLines); + + // 1) Collect run-scoped files (includes analyzable sources + potential COBOL copybooks) + List scopedFiles = collectSourceFiles(input, maxFileLines); + + // 2) Split: analyzable targets (anything with a Language) vs copybooks (Option A) + List files = + scopedFiles.stream() + .filter(p -> LanguageDetector.detectLanguage(p).isPresent()) + .toList(); + + // Determine whether we have any COBOL "program" files in scope. + // If none, do not treat .cpy files as copybooks (they might belong to other ecosystems). + boolean hasCobolPrograms = + files.stream() + .anyMatch(p -> LanguageDetector.detectLanguage(p).orElse(null) == Language.COBOL); + + List copyFilesForRun = hasCobolPrograms + ? scopedFiles.stream().filter(LanguageDetector::isCobolCopybook).toList() + : List.of(); + + // 3) Build run-scoped copybook repository (only if COBOL programs exist) + CobolCopybookRepository cobolCopybooks = new CobolCopybookRepository( + copyFilesForRun.stream().map(Path::toFile).toList() + ); + + // 4) Register analyzers for this run (COBOL gets the repository) + ANALYZERS = buildAnalyzers(cobolCopybooks); + System.out.println("Found " + files.size() + " source files with at most " + maxFileLines + " lines"); - + if (!copyFilesForRun.isEmpty()) { + System.out.println("Found " + copyFilesForRun.size() + " COBOL copybooks in scope"); + } + Instant startTime = Instant.now(); AtomicInteger successCount = new AtomicInteger(0); AtomicInteger errorCount = new AtomicInteger(0); AtomicInteger progressCounter = new AtomicInteger(0); - - // Write metadata header + try (BufferedWriter writer = Files.newBufferedWriter(jsonlOutput, StandardCharsets.UTF_8)) { Map runInfo = new HashMap<>(); runInfo.put("kind", "run"); @@ -101,32 +152,30 @@ public static void main(String[] args) throws Exception { runInfo.put("total_files", files.size()); writer.write(MAPPER.writeValueAsString(runInfo)); writer.newLine(); - - // Process files in parallel with progress reporting + files.parallelStream().forEach(file -> { Optional langOpt = LanguageDetector.detectLanguage(file); if (langOpt.isEmpty()) { - return; // Skip unsupported files + return; } - + Language language = langOpt.get(); int current = progressCounter.incrementAndGet(); - + synchronized (System.out) { - System.out.println("[" + current + "/" + files.size() + "] Analyzing " + - language.getName() + ": " + file.getFileName()); + System.out.println("[" + current + "/" + files.size() + "] Analyzing " + + language.getName() + ": " + file.getFileName()); } - + try { Analysis analysis = analyzeFile(file, language, config); - - // Write result immediately (synchronized to avoid concurrent writes) + synchronized (writer) { writer.write(MAPPER.writeValueAsString(analysis)); writer.newLine(); writer.flush(); } - + successCount.incrementAndGet(); } catch (Exception e) { Map error = new HashMap<>(); @@ -134,7 +183,7 @@ public static void main(String[] args) throws Exception { error.put("file", file.toString()); error.put("language", language.getName()); error.put("error", e.getMessage()); - + try { synchronized (writer) { writer.write(MAPPER.writeValueAsString(error)); @@ -144,26 +193,26 @@ public static void main(String[] args) throws Exception { } catch (IOException ioException) { System.err.println("Failed to write error for " + file + ": " + ioException.getMessage()); } - + errorCount.incrementAndGet(); synchronized (System.err) { System.err.println(" Error analyzing " + file.getFileName() + ": " + e.getMessage()); } } }); - + Instant endTime = Instant.now(); Map doneInfo = new HashMap<>(); doneInfo.put("kind", "done"); doneInfo.put("ended_at", endTime.toString()); doneInfo.put("files_analyzed", successCount.get()); doneInfo.put("files_with_errors", errorCount.get()); - doneInfo.put("duration_seconds", - java.time.Duration.between(startTime, endTime).getSeconds()); + doneInfo.put("duration_seconds", + java.time.Duration.between(startTime, endTime).getSeconds()); writer.write(MAPPER.writeValueAsString(doneInfo)); writer.newLine(); } - + System.out.println("\n" + "=".repeat(60)); System.out.println("Analysis complete!"); System.out.println("Successfully analyzed: " + successCount.get() + " files"); @@ -177,26 +226,26 @@ public static void main(String[] args) throws Exception { private static List collectSourceFiles(Path input, int maxFileLines) throws IOException { List files = new ArrayList<>(); Ignorer ignorer = new IgnorerBuilder(Paths.get(".ignore")).compile(); - + if (Files.isDirectory(input)) { try (Stream stream = Files.walk(input)) { stream.filter(Files::isRegularFile) - .filter(p -> ignorer.accepts(p.toAbsolutePath().toString())) - .filter(p -> LanguageDetector.detectLanguage(p).isPresent()) - .filter(p -> withinMaxLines(p, maxFileLines)) - .forEach(files::add); + .filter(p -> ignorer.accepts(p.toAbsolutePath().toString())) + .filter(LanguageDetector::isRelevantSourceOrDependency) + .filter(p -> withinMaxLines(p, maxFileLines)) + .forEach(files::add); } } else if (Files.isRegularFile(input)) { if (ignorer.accepts(input.toAbsolutePath().toString()) - && LanguageDetector.detectLanguage(input).isPresent() + && LanguageDetector.isRelevantSourceOrDependency(input) && withinMaxLines(input, maxFileLines)) { files.add(input); } } - + return files; } - + private static boolean withinMaxLines(Path path, int maxFileLines) { try (InputStream in = Files.newInputStream(path)) { int count = 0; @@ -214,7 +263,7 @@ private static boolean withinMaxLines(Path path, int maxFileLines) { return true; } } - + public static Analysis analyzeFile(Path filePath, Language language) throws IOException { CodeframeConfig config = CodeframeConfig.load(); return analyzeFile(filePath, language, config); @@ -223,19 +272,20 @@ public static Analysis analyzeFile(Path filePath, Language language) throws IOEx public static Analysis analyzeFile(Path filePath, Language language, CodeframeConfig config) throws IOException { String sourceCode = Files.readString(filePath, StandardCharsets.UTF_8); - // Remove BOM if present (common in C# files) if (sourceCode.startsWith("\uFEFF")) { sourceCode = sourceCode.substring(1); } LanguageAnalyzer analyzer = ANALYZERS.get(language); if (analyzer == null) { - throw new IllegalArgumentException("No analyzer available for: " + language); + throw new IllegalStateException( + "Analyzers not initialized or no analyzer available for: " + language + ); } Analysis analysis; - if (language == Language.SQL) { + if (language == Language.SQL || language == Language.COBOL) { analysis = analyzer.analyze(filePath.toString(), sourceCode, null); } else { TSLanguage tsLanguage = TREE_SITTER_LANGUAGES.get(language); @@ -253,7 +303,6 @@ public static Analysis analyzeFile(Path filePath, Language language, CodeframeCo } filterSqlColumnsIfNeeded(analysis, config); - return analysis; } @@ -261,7 +310,6 @@ private static void filterSqlColumnsIfNeeded(Analysis analysis, CodeframeConfig if (!(analysis instanceof SQLFileAnalysis)) { return; } - if (!config.isHideSqlTableColumns()) { return; } @@ -271,7 +319,6 @@ private static void filterSqlColumnsIfNeeded(Analysis analysis, CodeframeConfig for (CreateTableOperation op : sqlAnalysis.createTables) { op.columns.clear(); } - for (AlterTableOperation op : sqlAnalysis.alterTables) { op.addedColumns.clear(); } diff --git a/src/main/java/org/dxworks/codeframe/Language.java b/src/main/java/org/dxworks/codeframe/Language.java index edf47fa..ecd7f68 100644 --- a/src/main/java/org/dxworks/codeframe/Language.java +++ b/src/main/java/org/dxworks/codeframe/Language.java @@ -8,6 +8,7 @@ public enum Language { CSHARP("csharp"), PHP("php"), SQL("sql"), + COBOL("cobol"), RUBY("ruby"), RUST("rust"); diff --git a/src/main/java/org/dxworks/codeframe/LanguageDetector.java b/src/main/java/org/dxworks/codeframe/LanguageDetector.java index 69cac8d..61b7594 100644 --- a/src/main/java/org/dxworks/codeframe/LanguageDetector.java +++ b/src/main/java/org/dxworks/codeframe/LanguageDetector.java @@ -22,6 +22,8 @@ public static Optional detectLanguage(Path filePath) { return Optional.of(Language.PHP); } else if (fileName.endsWith(".sql")) { return Optional.of(Language.SQL); + } else if (fileName.endsWith(".cbl") || fileName.endsWith(".cob") || fileName.endsWith(".cobol")) { + return Optional.of(Language.COBOL); } else if (fileName.endsWith(".rb")) { return Optional.of(Language.RUBY); } else if (fileName.endsWith(".rs")) { @@ -30,4 +32,13 @@ public static Optional detectLanguage(Path filePath) { return Optional.empty(); } + + public static boolean isCobolCopybook(Path filePath) { + String fileName = filePath.getFileName().toString().toLowerCase(); + return fileName.endsWith(".cpy"); + } + + public static boolean isRelevantSourceOrDependency(Path p) { + return detectLanguage(p).isPresent() || isCobolCopybook(p); + } } diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzer.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzer.java new file mode 100644 index 0000000..bba384e --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzer.java @@ -0,0 +1,1381 @@ +package org.dxworks.codeframe.analyzer.cobol; + +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.Interval; +import org.antlr.v4.runtime.tree.*; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85BaseVisitor; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85Lexer; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85Parser; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.impl.CobolPreprocessorImpl; +import org.dxworks.codeframe.analyzer.LanguageAnalyzer; +import org.dxworks.codeframe.model.Analysis; +import org.dxworks.codeframe.model.cobol.COBOLControlFlowStatement; +import org.dxworks.codeframe.model.cobol.COBOLDataItem; +import org.dxworks.codeframe.model.cobol.COBOLExternalCall; +import org.dxworks.codeframe.model.cobol.COBOLFileAnalysis; +import org.dxworks.codeframe.model.cobol.COBOLFileControl; +import org.dxworks.codeframe.model.cobol.COBOLFileDefinition; +import org.dxworks.codeframe.model.cobol.COBOLFileOperation; +import org.dxworks.codeframe.model.cobol.COBOLParagraph; +import org.dxworks.codeframe.model.cobol.COBOLPerformCall; +import org.dxworks.codeframe.model.cobol.COBOLSection; +import org.treesitter.TSNode; + +import java.util.ArrayList; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.List; +import java.util.Locale; +import java.io.File; + +public class COBOLAnalyzer implements LanguageAnalyzer { + + private static final String PROCEDURE_DIVISION_PROLOGUE_PARAGRAPH = "__PROCEDURE_DIVISION_PROLOGUE__"; + + private final CobolCopybookRepository copybookRepository; + + public COBOLAnalyzer(CobolCopybookRepository copybookRepository) { + this.copybookRepository = copybookRepository; + } + + @Override + public Analysis analyze(String filePath, String sourceCode, TSNode rootNode) { + COBOLFileAnalysis analysis = new COBOLFileAnalysis(); + analysis.filePath = filePath; + + CobolPreprocessorImpl preprocessor = new CobolPreprocessorImpl(); + String preprocessedSource = preprocessSource(sourceCode, preprocessor); + CommonTokenStream tokens = tokenize(preprocessedSource); + Cobol85Parser.StartRuleContext tree = parse(tokens); + + ExtractionVisitor visitor = new ExtractionVisitor(analysis, tokens); + visitParseTree(tree, visitor, filePath); + + applyVisitorResults(analysis, visitor); + populateExecFlags(analysis, sourceCode); + analysis.copyStatements.addAll(preprocessor.copyStatements()); + + return analysis; + } + + private String preprocessSource(String sourceCode, CobolPreprocessorImpl preprocessor) { + // Convert repository files to the List expected by the preprocessor API + List copyFiles = copybookRepository != null + ? List.copyOf(copybookRepository.copyFiles()) + : List.of(); + return preprocessor.process( + sourceCode, + copyFiles, + org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum.FIXED + ); + } + + private void visitParseTree(Cobol85Parser.StartRuleContext tree, ExtractionVisitor visitor, String filePath) { + if (tree == null) { + System.err.println("[COBOLAnalyzer] parse returned null for: " + filePath); + return; + } + visitor.visit(tree); + } + + private void applyVisitorResults(COBOLFileAnalysis analysis, ExtractionVisitor visitor) { + analysis.programId = visitor.programId; + analysis.fileControls.addAll(visitor.fileControls); + analysis.fileDefinitions.addAll(visitor.fileDefinitions); + analysis.dataItems.addAll(visitor.workingStorageDataItems); + analysis.dataItems.addAll(visitor.linkageDataItems); + analysis.dataItems.addAll(visitor.localStorageDataItems); + analysis.dataItems.addAll(visitor.fileSectionDataItems); + analysis.sections.addAll(visitor.sections); + analysis.paragraphs.addAll(visitor.paragraphs); + analysis.procedureParameters.addAll(visitor.procedureParameters); + } + + private void populateExecFlags(COBOLFileAnalysis analysis, String sourceCode) { + analysis.hasExecSql = containsExecBlock(sourceCode, "SQL"); + analysis.hasExecCics = containsExecBlock(sourceCode, "CICS"); + analysis.hasExecSqlIms = containsExecBlock(sourceCode, "SQLIMS"); + } + + // Simple regex-based EXEC block detection. + private static boolean containsExecBlock(String sourceCode, String kind) { + return sourceCode.matches("(?is).*\\bEXEC\\s+" + kind + "\\b.*"); + } + + // Tokenize for parser (preprocessed or raw source). + private CommonTokenStream tokenize(String sourceCode) { + Cobol85Lexer lexer = new Cobol85Lexer(CharStreams.fromString(sourceCode == null ? "" : sourceCode)); + lexer.removeErrorListeners(); + lexer.addErrorListener(QUIET_LISTENER); + CommonTokenStream tokens = new CommonTokenStream(lexer); + tokens.fill(); + return tokens; + } + + // Parse preprocessed tokens. + private Cobol85Parser.StartRuleContext parse(CommonTokenStream tokens) { + Cobol85Parser parser = new Cobol85Parser(tokens); + parser.removeErrorListeners(); + parser.addErrorListener(QUIET_LISTENER); + parser.setErrorHandler(new DefaultErrorStrategy()); + + try { + return parser.startRule(); + } catch (Exception e) { + System.err.println("[COBOLAnalyzer] Parse exception: " + e.getMessage()); + return null; + } + } + + // Normalize identifier/copybook names (strip quotes, trim whitespace). + private static String normalizeName(String raw) { + if (raw == null) { + return null; + } + String text = raw.trim(); + if (text.isEmpty()) { + return null; + } + if ((text.startsWith("\"") && text.endsWith("\"")) || (text.startsWith("'") && text.endsWith("'"))) { + text = text.substring(1, text.length() - 1).trim(); + } + return text; + } + + // Best-effort parsing: ignore syntax errors to extract as much structure as possible. + private static final BaseErrorListener QUIET_LISTENER = new BaseErrorListener() { + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, + int line, int charPositionInLine, String msg, + RecognitionException e) { + // best-effort parsing + } + }; + + // Visitor extracts structure from preprocessed parse tree (EXEC blocks tagged, comment entries handled, COPY/REPLACE removed by reference preprocessor). + private static class ExtractionVisitor extends Cobol85BaseVisitor { + private final COBOLFileAnalysis analysis; + private final CommonTokenStream tokens; + private String programId; + private final List workingStorageDataItems = new ArrayList<>(); + private final List linkageDataItems = new ArrayList<>(); + private final List localStorageDataItems = new ArrayList<>(); + private final List fileSectionDataItems = new ArrayList<>(); + private final List fileControls = new ArrayList<>(); + private final List fileDefinitions = new ArrayList<>(); + private final List sections = new ArrayList<>(); + private final List paragraphs = new ArrayList<>(); + private final List procedureParameters = new ArrayList<>(); + private final Deque hierarchy = new ArrayDeque<>(); + private Cobol85Parser.FileDescriptionEntryContext currentFdContext = null; + private boolean hasFdEntries = false; // Track if we have FD entries + + // Constructor receives analysis object (flags are detected from raw source since preprocessor removes EXEC blocks). + public ExtractionVisitor(COBOLFileAnalysis analysis, CommonTokenStream tokens) { + this.analysis = analysis; + this.tokens = tokens; + } + // Scope tracking for data division sections and procedure division context. + private DataSection currentDataSection = null; + private boolean inProcedureDivision; + private COBOLSection currentSection; + private COBOLParagraph currentParagraph; + private COBOLParagraph procedureDivisionPrologueParagraph; + + @Override + public Void visitProcedureDivision(Cobol85Parser.ProcedureDivisionContext ctx) { + boolean previousInProcedureDivision = inProcedureDivision; + COBOLParagraph previousPrologueParagraph = procedureDivisionPrologueParagraph; + + inProcedureDivision = true; + procedureDivisionPrologueParagraph = null; + + extractProcedureDivisionUsingParameters(ctx); + + super.visitProcedureDivision(ctx); + + if (hasCapturedContent(procedureDivisionPrologueParagraph)) { + paragraphs.add(0, procedureDivisionPrologueParagraph); + } + + inProcedureDivision = previousInProcedureDivision; + procedureDivisionPrologueParagraph = previousPrologueParagraph; + return null; + } + + private void extractProcedureDivisionUsingParameters(ParseTree node) { + if (node == null) { + return; + } + + if (node instanceof Cobol85Parser.ProcedureDivisionUsingClauseContext) { + collectProcedureParametersFromUsingClause((Cobol85Parser.ProcedureDivisionUsingClauseContext) node); + } + + for (int i = 0; i < node.getChildCount(); i++) { + extractProcedureDivisionUsingParameters(node.getChild(i)); + } + } + + private void collectProcedureParametersFromUsingClause(Cobol85Parser.ProcedureDivisionUsingClauseContext usingClause) { + for (Cobol85Parser.ProcedureDivisionUsingParameterContext parameterCtx : usingClause.procedureDivisionUsingParameter()) { + collectProcedureParameterNames(parameterCtx); + } + } + + private void collectProcedureParameterNames(ParseTree node) { + if (node == null) { + return; + } + + if (node instanceof Cobol85Parser.IdentifierContext) { + addProcedureParameter(node.getText()); + } else if (node instanceof Cobol85Parser.FileNameContext) { + addProcedureParameter(node.getText()); + } + + for (int i = 0; i < node.getChildCount(); i++) { + collectProcedureParameterNames(node.getChild(i)); + } + } + + private void addProcedureParameter(String rawName) { + String paramName = normalizeName(rawName); + if (paramName != null && !paramName.isEmpty() && !procedureParameters.contains(paramName)) { + procedureParameters.add(paramName); + } + } + + private static boolean hasCapturedContent(COBOLParagraph paragraph) { + if (paragraph == null) { + return false; + } + return !paragraph.performCalls.isEmpty() + || !paragraph.externalCalls.isEmpty() + || !paragraph.fileOperations.isEmpty() + || !paragraph.controlFlowStatements.isEmpty() + || !paragraph.dataReferences.isEmpty(); + } + + private COBOLParagraph targetParagraph() { + if (currentParagraph != null) { + return currentParagraph; + } + if (!inProcedureDivision) { + return null; + } + if (procedureDivisionPrologueParagraph == null) { + procedureDivisionPrologueParagraph = new COBOLParagraph(); + procedureDivisionPrologueParagraph.name = PROCEDURE_DIVISION_PROLOGUE_PARAGRAPH; + } + return procedureDivisionPrologueParagraph; + } + + private enum DataSection { + WORKING_STORAGE("WORKING-STORAGE"), + LINKAGE("LINKAGE"), + LOCAL_STORAGE("LOCAL-STORAGE"), + FILE("FILE"); + + final String label; + DataSection(String label) { this.label = label; } + } + + private Void withDataSection(DataSection section, Runnable visitBody) { + DataSection previous = currentDataSection; + currentDataSection = section; + hierarchy.clear(); + + visitBody.run(); + + hierarchy.clear(); + currentDataSection = previous; + return null; + } + + // Track WORKING-STORAGE section scope and clear hierarchy before/after. + @Override + public Void visitWorkingStorageSection(Cobol85Parser.WorkingStorageSectionContext ctx) { + return withDataSection(DataSection.WORKING_STORAGE, () -> super.visitWorkingStorageSection(ctx)); + } + + // Track LINKAGE section scope and clear hierarchy before/after. + @Override + public Void visitLinkageSection(Cobol85Parser.LinkageSectionContext ctx) { + return withDataSection(DataSection.LINKAGE, () -> super.visitLinkageSection(ctx)); + } + + // Track LOCAL-STORAGE section scope and clear hierarchy before/after. + @Override + public Void visitLocalStorageSection(Cobol85Parser.LocalStorageSectionContext ctx) { + return withDataSection(DataSection.LOCAL_STORAGE, () -> super.visitLocalStorageSection(ctx)); + } + + // Track FILE SECTION scope and clear hierarchy before/after. + @Override + public Void visitFileSection(Cobol85Parser.FileSectionContext ctx) { + return withDataSection(DataSection.FILE, () -> super.visitFileSection(ctx)); + } + + // Extract FD entries for files without SELECT clauses (basic metadata only) and populate fileDefinitions + @Override + public Void visitFileDescriptionEntry(Cobol85Parser.FileDescriptionEntryContext ctx) { + if (ctx.fileName() != null) { + String fileName = normalizeName(ctx.fileName().getText()); + + // Mark that we have FD entries + hasFdEntries = true; + + // Set current FD context for record extraction + currentFdContext = ctx; + + // Populate fileDefinitions with FD entries and record layouts + COBOLFileDefinition fileDef = new COBOLFileDefinition(); + fileDef.name = fileName; + + // Extract record layouts (01-level entries under this specific FD) + extractRecordLayouts(ctx, fileDef); + + fileDefinitions.add(fileDef); + + // Clear current FD context after processing + currentFdContext = null; + } + return super.visitFileDescriptionEntry(ctx); + } + + // Helper method to extract record layouts from FD entries (FD-scoped extraction) + private void extractRecordLayouts(Cobol85Parser.FileDescriptionEntryContext ctx, COBOLFileDefinition fileDef) { + // Extract only 01-level records that belong to this specific FD + // by visiting the data description entries that are children of this FD + for (Cobol85Parser.DataDescriptionEntryContext dataDescCtx : ctx.dataDescriptionEntry()) { + if (dataDescCtx.dataDescriptionEntryFormat1() != null) { + COBOLDataItem dataItem = toDataItem(dataDescCtx.dataDescriptionEntryFormat1()); + if (dataItem != null && dataItem.level == 1 && dataItem.name != null) { + // Create a copy of the record for this file definition + COBOLDataItem record = new COBOLDataItem(); + record.name = dataItem.name; + record.level = dataItem.level; + record.picture = dataItem.picture; + record.section = "FILE SECTION"; + record.usage = dataItem.usage; + record.children = new ArrayList<>(); + + // Copy the children (sub-fields) by processing the data description entry + processChildrenForRecord(dataDescCtx.dataDescriptionEntryFormat1(), record); + + fileDef.records.add(record); + } + } + } + } + + // Helper method to process children of a record data item + private void processChildrenForRecord(Cobol85Parser.DataDescriptionEntryFormat1Context ctx, COBOLDataItem parentRecord) { + // Find the index of this record in the FD's data description entries + if (currentFdContext == null) return; + + List dataEntries = currentFdContext.dataDescriptionEntry(); + int parentIndex = -1; + + // Find the parent record's position + for (int i = 0; i < dataEntries.size(); i++) { + Cobol85Parser.DataDescriptionEntryContext dataDescCtx = dataEntries.get(i); + if (dataDescCtx.dataDescriptionEntryFormat1() != null) { + COBOLDataItem dataItem = toDataItem(dataDescCtx.dataDescriptionEntryFormat1()); + if (dataItem != null && dataItem.name != null && dataItem.name.equals(parentRecord.name)) { + parentIndex = i; + break; + } + } + } + + if (parentIndex == -1) return; // Parent not found + + // Process subsequent entries as children until we hit another level 1 record or end of FD + Deque hierarchy = new ArrayDeque<>(); + hierarchy.push(parentRecord); + + for (int i = parentIndex + 1; i < dataEntries.size(); i++) { + Cobol85Parser.DataDescriptionEntryContext dataDescCtx = dataEntries.get(i); + if (dataDescCtx.dataDescriptionEntryFormat1() != null) { + COBOLDataItem dataItem = toDataItem(dataDescCtx.dataDescriptionEntryFormat1()); + if (dataItem != null && dataItem.name != null) { + // Stop if we hit another level 1 record (different record) + if (dataItem.level <= 1) { + break; + } + + // Maintain hierarchy based on levels + while (!hierarchy.isEmpty() && dataItem.level <= hierarchy.peek().level) { + hierarchy.pop(); + } + + // Add as child if we have a parent + if (!hierarchy.isEmpty()) { + hierarchy.peek().children.add(dataItem); + hierarchy.push(dataItem); + } + } + } + } + } + + // Extract FILE-CONTROL metadata from SELECT clauses. + @Override + public Void visitSelectClause(Cobol85Parser.SelectClauseContext ctx) { + if (ctx.fileName() != null) { + String fileName = normalizeName(ctx.fileName().getText()); + COBOLFileControl fileControl = findOrCreateFileControl(fileName); + + if (fileControl == null) { + return super.visitSelectClause(ctx); + } + + if (ctx.getParent() instanceof Cobol85Parser.FileControlEntryContext) { + Cobol85Parser.FileControlEntryContext fileControlCtx = + (Cobol85Parser.FileControlEntryContext) ctx.getParent(); + populateFileControlMetadata(fileControl, fileControlCtx); + } + } + return super.visitSelectClause(ctx); + } + + private COBOLFileControl findOrCreateFileControl(String fileName) { + if (fileName == null) { + return null; + } + + COBOLFileControl fileControl = fileControls.stream() + .filter(fc -> fileName.equals(fc.name)) + .findFirst() + .orElse(null); + + if (fileControl != null) { + return fileControl; + } + + fileControl = new COBOLFileControl(); + fileControl.name = fileName; + fileControls.add(fileControl); + return fileControl; + } + + private void populateFileControlMetadata(COBOLFileControl fileControl, + Cobol85Parser.FileControlEntryContext fileControlCtx) { + for (Cobol85Parser.FileControlClauseContext clause : fileControlCtx.fileControlClause()) { + if (clause.organizationClause() != null) { + fileControl.organization = extractOrganization(clause.organizationClause()); + } + if (clause.accessModeClause() != null) { + fileControl.accessMode = extractAccessMode(clause.accessModeClause()); + } + if (clause.recordKeyClause() != null) { + fileControl.hasKey = true; + } + } + } + + private String extractOrganization(Cobol85Parser.OrganizationClauseContext ctx) { + if (ctx.SEQUENTIAL() != null) return "SEQUENTIAL"; + if (ctx.RELATIVE() != null) return "RELATIVE"; + if (ctx.INDEXED() != null) return "INDEXED"; + return null; + } + + private String extractAccessMode(Cobol85Parser.AccessModeClauseContext ctx) { + if (ctx.SEQUENTIAL() != null) return "SEQUENTIAL"; + if (ctx.RANDOM() != null) return "RANDOM"; + if (ctx.DYNAMIC() != null) return "DYNAMIC"; + if (ctx.EXCLUSIVE() != null) return "EXCLUSIVE"; + return null; + } + + // Extract PROGRAM-ID from IDENTIFICATION DIVISION. + @Override + public Void visitProgramIdParagraph(Cobol85Parser.ProgramIdParagraphContext ctx) { + if (programId == null && ctx.programName() != null) { + programId = normalizeName(ctx.programName().getText()); + } + return null; + } + + // Track PROCEDURE DIVISION sections and their paragraphs. + @Override + public Void visitProcedureSection(Cobol85Parser.ProcedureSectionContext ctx) { + if (ctx.procedureSectionHeader() == null) { + return super.visitProcedureSection(ctx); + } + + Cobol85Parser.ProcedureSectionHeaderContext header = ctx.procedureSectionHeader(); + String headerText = getOriginalText(header); + if (header.sectionName() == null || headerText == null || !headerText.toUpperCase(Locale.ROOT).contains("SECTION")) { + return super.visitProcedureSection(ctx); + } + + COBOLSection previousSection = currentSection; + + COBOLSection section = new COBOLSection(); + section.name = normalizeName(header.sectionName().getText()); + if (section.name == null) { + return super.visitProcedureSection(ctx); + } + sections.add(section); + currentSection = section; + + super.visitProcedureSection(ctx); + + currentSection = previousSection; + return null; + } + + // Track paragraphs and their calls/operations/data-references. + @Override + public Void visitParagraph(Cobol85Parser.ParagraphContext ctx) { + if (ctx.paragraphName() == null) { + return null; + } + + COBOLParagraph paragraph = new COBOLParagraph(); + paragraph.name = normalizeName(ctx.paragraphName().getText()); + + COBOLParagraph previousParagraph = currentParagraph; + currentParagraph = paragraph; + + // Always add to top-level paragraphs list (for paragraphs outside sections) + if (currentSection == null) { + paragraphs.add(paragraph); + } else { + // Add to section paragraphs if inside a section + currentSection.paragraphs.add(paragraph); + } + + super.visitParagraph(ctx); + + currentParagraph = previousParagraph; + return null; + } + + // Extract PERFORM calls (target paragraph and optional THRU paragraph). + @Override + public Void visitPerformStatement(Cobol85Parser.PerformStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph == null) { + return super.visitPerformStatement(ctx); + } + + COBOLPerformCall performCall = new COBOLPerformCall(); + + if (ctx.performProcedureStatement() != null) { + Cobol85Parser.PerformProcedureStatementContext proc = ctx.performProcedureStatement(); + if (!proc.procedureName().isEmpty()) { + performCall.targetParagraph = normalizeName(proc.procedureName(0).getText()); + } + if ((proc.THROUGH() != null || proc.THRU() != null) && proc.procedureName().size() > 1) { + performCall.thruParagraph = normalizeName(proc.procedureName(1).getText()); + } + } + + // Only add PERFORM calls with valid targets (skip control flow PERFORMs) + if (performCall.targetParagraph != null && !performCall.targetParagraph.isEmpty()) { + paragraph.performCalls.add(performCall); + } + return super.visitPerformStatement(ctx); + } + + // Extract external calls and data references from CALL statements. + @Override + public Void visitCallStatement(Cobol85Parser.CallStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + COBOLExternalCall externalCall = new COBOLExternalCall(); + if (ctx.literal() != null) { + externalCall.programName = normalizeName(ctx.literal().getText()); + externalCall.isDynamic = false; + } else if (ctx.identifier() != null) { + externalCall.programName = normalizeName(ctx.identifier().getText()); + externalCall.isDynamic = true; + } + + if (ctx.callUsingPhrase() != null) { + externalCall.parameterCount = countCallUsingParameters(ctx.callUsingPhrase()); + // Extract CALL USING argument identifiers into dataReferences + if (paragraph != null) { + paragraph.dataReferences.addAll(extractCallUsingIdentifiers(ctx.callUsingPhrase())); + } + } + + if (paragraph != null) { + paragraph.externalCalls.add(externalCall); + } + // Note: CALL statements outside paragraphs are handled by prologue mechanism + + return super.visitCallStatement(ctx); + } + + private void addFileOperation(COBOLParagraph paragraph, String verb, String rawFileName) { + if (paragraph == null || rawFileName == null) { + return; + } + COBOLFileOperation op = new COBOLFileOperation(); + op.verb = verb; + op.target = normalizeName(rawFileName); + paragraph.fileOperations.add(op); + } + + private void addOpenInputOperations(COBOLParagraph paragraph, + List inputStatements) { + for (Cobol85Parser.OpenInputStatementContext inputStmt : inputStatements) { + for (Cobol85Parser.OpenInputContext input : inputStmt.openInput()) { + if (input.fileName() != null) { + addFileOperation(paragraph, "OPEN", input.fileName().getText()); + } + } + } + } + + private void addOpenOutputOperations(COBOLParagraph paragraph, + List outputStatements) { + for (Cobol85Parser.OpenOutputStatementContext outputStmt : outputStatements) { + for (Cobol85Parser.OpenOutputContext output : outputStmt.openOutput()) { + if (output.fileName() != null) { + addFileOperation(paragraph, "OPEN", output.fileName().getText()); + } + } + } + } + + private void addOpenOperationsFromFileNames(COBOLParagraph paragraph, + List fileNames) { + for (Cobol85Parser.FileNameContext fileName : fileNames) { + if (fileName != null) { + addFileOperation(paragraph, "OPEN", fileName.getText()); + } + } + } + + // Extract READ file operations (verb and file name). + @Override + public Void visitReadStatement(Cobol85Parser.ReadStatementContext ctx) { + addSimpleFileOperation(ctx.fileName(), "READ"); + return super.visitReadStatement(ctx); + } + + // Extract WRITE file operations (verb and record name). + @Override + public Void visitWriteStatement(Cobol85Parser.WriteStatementContext ctx) { + addSimpleFileOperation(ctx.recordName(), "WRITE"); + return super.visitWriteStatement(ctx); + } + + // Extract OPEN file operations (verb and file name). + @Override + public Void visitOpenStatement(Cobol85Parser.OpenStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + addOpenInputOperations(paragraph, ctx.openInputStatement()); + addOpenOutputOperations(paragraph, ctx.openOutputStatement()); + + for (Cobol85Parser.OpenIOStatementContext ioStmt : ctx.openIOStatement()) { + addOpenOperationsFromFileNames(paragraph, ioStmt.fileName()); + } + + for (Cobol85Parser.OpenExtendStatementContext extendStmt : ctx.openExtendStatement()) { + addOpenOperationsFromFileNames(paragraph, extendStmt.fileName()); + } + } + return super.visitOpenStatement(ctx); + } + + // Extract CLOSE file operations (verb and file name). + @Override + public Void visitCloseStatement(Cobol85Parser.CloseStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + for (Cobol85Parser.CloseFileContext fileCtx : ctx.closeFile()) { + if (fileCtx.fileName() != null) { + addFileOperation(paragraph, "CLOSE", fileCtx.fileName().getText()); + } + } + } + return super.visitCloseStatement(ctx); + } + + // Extract REWRITE file operations (verb and record name). + @Override + public Void visitRewriteStatement(Cobol85Parser.RewriteStatementContext ctx) { + addSimpleFileOperation(ctx.recordName(), "REWRITE"); + return super.visitRewriteStatement(ctx); + } + + // Extract DELETE file operations (verb and file name). + @Override + public Void visitDeleteStatement(Cobol85Parser.DeleteStatementContext ctx) { + addSimpleFileOperation(ctx.fileName(), "DELETE"); + return super.visitDeleteStatement(ctx); + } + + // Extract START file operations (verb and file name). + @Override + public Void visitStartStatement(Cobol85Parser.StartStatementContext ctx) { + addSimpleFileOperation(ctx.fileName(), "START"); + return super.visitStartStatement(ctx); + } + + // Extract data references from MOVE statements (both source and target identifiers). + @Override + public Void visitMoveStatement(Cobol85Parser.MoveStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + if (ctx.moveToStatement() != null) { + Cobol85Parser.MoveToStatementContext moveTo = ctx.moveToStatement(); + + // Extract source identifier from moveToSendingArea + if (moveTo.moveToSendingArea() != null && moveTo.moveToSendingArea().identifier() != null) { + addDataReference(paragraph, moveTo.moveToSendingArea().identifier()); + } + + // Extract target identifiers + for (Cobol85Parser.IdentifierContext id : moveTo.identifier()) { + addDataReference(paragraph, id); + } + } + } + + if (ctx.moveCorrespondingToStatement() != null) { + Cobol85Parser.MoveCorrespondingToStatementContext moveCorr = ctx.moveCorrespondingToStatement(); + + // Extract source identifier from moveCorrespondingToSendingArea + if (moveCorr.moveCorrespondingToSendingArea() != null && moveCorr.moveCorrespondingToSendingArea().identifier() != null) { + addDataReference(paragraph, moveCorr.moveCorrespondingToSendingArea().identifier()); + } + + // Extract target identifiers + for (Cobol85Parser.IdentifierContext id : moveCorr.identifier()) { + addDataReference(paragraph, id); + } + } + + return super.visitMoveStatement(ctx); + } + + // Extract data references from COMPUTE statements (simplified). + @Override + public Void visitComputeStatement(Cobol85Parser.ComputeStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + // Extract identifiers from computeStore (left side targets) + for (Cobol85Parser.ComputeStoreContext store : ctx.computeStore()) { + if (store.identifier() != null) { + addDataReference(paragraph, store.identifier()); + } + } + } + return super.visitComputeStatement(ctx); + } + + // Extract data references from ADD statements (simplified). + @Override + public Void visitAddStatement(Cobol85Parser.AddStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + if (ctx.addToStatement() != null) { + Cobol85Parser.AddToStatementContext addTo = ctx.addToStatement(); + // Extract from addFrom (source operands) + for (Cobol85Parser.AddFromContext from : addTo.addFrom()) { + if (from.identifier() != null) { + addDataReference(paragraph, from.identifier()); + } + } + // Extract from addTo (target operands) + for (Cobol85Parser.AddToContext to : addTo.addTo()) { + if (to.identifier() != null) { + addDataReference(paragraph, to.identifier()); + } + } + } + } + return super.visitAddStatement(ctx); + } + + // Extract data references from SUBTRACT statements (simplified). + @Override + public Void visitSubtractStatement(Cobol85Parser.SubtractStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + if (ctx.subtractFromStatement() != null) { + Cobol85Parser.SubtractFromStatementContext subtractFrom = ctx.subtractFromStatement(); + for (Cobol85Parser.SubtractSubtrahendContext subtrahend : subtractFrom.subtractSubtrahend()) { + if (subtrahend.identifier() != null) { + addDataReference(paragraph, subtrahend.identifier()); + } + } + for (Cobol85Parser.SubtractMinuendContext minuend : subtractFrom.subtractMinuend()) { + if (minuend.identifier() != null) { + addDataReference(paragraph, minuend.identifier()); + } + } + } + + if (ctx.subtractFromGivingStatement() != null) { + Cobol85Parser.SubtractFromGivingStatementContext giving = ctx.subtractFromGivingStatement(); + for (Cobol85Parser.SubtractSubtrahendContext subtrahend : giving.subtractSubtrahend()) { + if (subtrahend.identifier() != null) { + addDataReference(paragraph, subtrahend.identifier()); + } + } + if (giving.subtractMinuendGiving().identifier() != null) { + addDataReference(paragraph, giving.subtractMinuendGiving().identifier()); + } + for (Cobol85Parser.SubtractGivingContext result : giving.subtractGiving()) { + if (result.identifier() != null) { + addDataReference(paragraph, result.identifier()); + } + } + } + + if (ctx.subtractCorrespondingStatement() != null) { + Cobol85Parser.SubtractCorrespondingStatementContext corresponding = ctx.subtractCorrespondingStatement(); + addQualifiedNameReference(paragraph, corresponding.qualifiedDataName()); + if (corresponding.subtractMinuendCorresponding() != null) { + addQualifiedNameReference(paragraph, corresponding.subtractMinuendCorresponding().qualifiedDataName()); + } + } + } + return super.visitSubtractStatement(ctx); + } + + // Extract data references from MULTIPLY statements (simplified). + @Override + public Void visitMultiplyStatement(Cobol85Parser.MultiplyStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + if (ctx.identifier() != null) { + addDataReference(paragraph, ctx.identifier()); + } + + if (ctx.multiplyRegular() != null) { + for (Cobol85Parser.MultiplyRegularOperandContext operand : ctx.multiplyRegular().multiplyRegularOperand()) { + if (operand.identifier() != null) { + addDataReference(paragraph, operand.identifier()); + } + } + } + + if (ctx.multiplyGiving() != null) { + if (ctx.multiplyGiving().multiplyGivingOperand().identifier() != null) { + addDataReference(paragraph, ctx.multiplyGiving().multiplyGivingOperand().identifier()); + } + for (Cobol85Parser.MultiplyGivingResultContext result : ctx.multiplyGiving().multiplyGivingResult()) { + if (result.identifier() != null) { + addDataReference(paragraph, result.identifier()); + } + } + } + } + return super.visitMultiplyStatement(ctx); + } + + // Extract data references from DIVIDE statements (simplified). + @Override + public Void visitDivideStatement(Cobol85Parser.DivideStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + if (ctx.identifier() != null) { + addDataReference(paragraph, ctx.identifier()); + } + + if (ctx.divideIntoStatement() != null) { + for (Cobol85Parser.DivideIntoContext into : ctx.divideIntoStatement().divideInto()) { + if (into.identifier() != null) { + addDataReference(paragraph, into.identifier()); + } + } + } + + if (ctx.divideIntoGivingStatement() != null) { + Cobol85Parser.DivideIntoGivingStatementContext intoGiving = ctx.divideIntoGivingStatement(); + if (intoGiving.identifier() != null) { + addDataReference(paragraph, intoGiving.identifier()); + } + if (intoGiving.divideGivingPhrase() != null) { + for (Cobol85Parser.DivideGivingContext giving : intoGiving.divideGivingPhrase().divideGiving()) { + if (giving.identifier() != null) { + addDataReference(paragraph, giving.identifier()); + } + } + } + } + + if (ctx.divideByGivingStatement() != null) { + Cobol85Parser.DivideByGivingStatementContext byGiving = ctx.divideByGivingStatement(); + if (byGiving.identifier() != null) { + addDataReference(paragraph, byGiving.identifier()); + } + if (byGiving.divideGivingPhrase() != null) { + for (Cobol85Parser.DivideGivingContext giving : byGiving.divideGivingPhrase().divideGiving()) { + if (giving.identifier() != null) { + addDataReference(paragraph, giving.identifier()); + } + } + } + } + + if (ctx.divideRemainder() != null) { + if (ctx.divideRemainder().identifier() != null) { + addDataReference(paragraph, ctx.divideRemainder().identifier()); + } + } + } + return super.visitDivideStatement(ctx); + } + + // Extract data references from SET statements (simplified). + @Override + public Void visitSetStatement(Cobol85Parser.SetStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + for (Cobol85Parser.SetToStatementContext setToStatement : ctx.setToStatement()) { + for (Cobol85Parser.SetToContext setTo : setToStatement.setTo()) { + if (setTo.identifier() != null) { + addDataReference(paragraph, setTo.identifier()); + } + } + for (Cobol85Parser.SetToValueContext value : setToStatement.setToValue()) { + for (Cobol85Parser.IdentifierContext identifier : value.getRuleContexts(Cobol85Parser.IdentifierContext.class)) { + addDataReference(paragraph, identifier); + } + } + } + + if (ctx.setUpDownByStatement() != null) { + Cobol85Parser.SetUpDownByStatementContext upDown = ctx.setUpDownByStatement(); + for (Cobol85Parser.SetToContext setTo : upDown.setTo()) { + if (setTo.identifier() != null) { + addDataReference(paragraph, setTo.identifier()); + } + } + if (upDown.setByValue().identifier() != null) { + addDataReference(paragraph, upDown.setByValue().identifier()); + } + } + } + return super.visitSetStatement(ctx); + } + + // Extract control-flow statements (GOBACK, STOP RUN, EXIT PROGRAM, RETURN). + @Override + public Void visitGobackStatement(Cobol85Parser.GobackStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + addControlFlowStatement(paragraph, "GOBACK", null); + return super.visitGobackStatement(ctx); + } + + @Override + public Void visitStopStatement(Cobol85Parser.StopStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + String type = "STOP"; + String target = null; + if (ctx.RUN() != null) { + type = "STOP_RUN"; + } else if (ctx.literal() != null) { + type = "STOP_LITERAL"; + target = normalizeName(ctx.literal().getText()); + } + addControlFlowStatement(paragraph, type, target); + } + return super.visitStopStatement(ctx); + } + + @Override + public Void visitExitStatement(Cobol85Parser.ExitStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null && ctx.PROGRAM() != null) { + // Only capture EXIT PROGRAM, not bare EXIT (which is a no-op) + addControlFlowStatement(paragraph, "EXIT_PROGRAM", null); + } + return super.visitExitStatement(ctx); + } + + @Override + public Void visitReturnStatement(Cobol85Parser.ReturnStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + String target = null; + // RETURN works with fileName, not identifier + if (ctx.fileName() != null) { + target = normalizeName(ctx.fileName().getText()); + } + addControlFlowStatement(paragraph, "RETURN", target); + } + return super.visitReturnStatement(ctx); + } + + private void addControlFlowStatement(COBOLParagraph paragraph, String type, String target) { + if (paragraph == null) { + return; + } + COBOLControlFlowStatement controlFlow = new COBOLControlFlowStatement(); + controlFlow.type = type; + controlFlow.target = target; + paragraph.controlFlowStatements.add(controlFlow); + } + + private void addSimpleFileOperation(Cobol85Parser.FileNameContext fileName, String verb) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null && fileName != null) { + addFileOperation(paragraph, verb, fileName.getText()); + } + } + + private void addSimpleFileOperation(Cobol85Parser.RecordNameContext recordName, String verb) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null && recordName != null) { + addFileOperation(paragraph, verb, recordName.getText()); + } + } + + private void addDataReference(COBOLParagraph paragraph, Cobol85Parser.IdentifierContext identifier) { + if (paragraph == null || identifier == null) { + return; + } + paragraph.dataReferences.add(normalizeDataReference(getOriginalText(identifier))); + } + + // Get original text from token stream, preserving whitespace + private String getOriginalText(ParserRuleContext ctx) { + if (ctx == null || tokens == null) { + return ""; + } + int start = ctx.start.getStartIndex(); + int stop = ctx.stop.getStopIndex(); + if (start >= 0 && stop >= 0 && stop >= start) { + CharStream charStream = tokens.getTokenSource().getInputStream(); + return charStream.getText(Interval.of(start, stop)); + } + return ctx.getText(); // fallback to regular getText() + } + + private void addQualifiedNameReference(COBOLParagraph paragraph, Cobol85Parser.QualifiedDataNameContext qualifiedDataName) { + if (paragraph == null || qualifiedDataName == null) { + return; + } + paragraph.dataReferences.add(normalizeDataReference(qualifiedDataName.getText())); + } + + // Extract data references from STRING statements (simplified). + @Override + public Void visitStringStatement(Cobol85Parser.StringStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph == null) { + return super.visitStringStatement(ctx); + } + // Extract from stringSendingPhrase (source operands) + for (Cobol85Parser.StringSendingPhraseContext sendingPhrase : ctx.stringSendingPhrase()) { + for (Cobol85Parser.StringSendingContext sending : sendingPhrase.stringSending()) { + if (sending.identifier() != null) { + addDataReference(paragraph, sending.identifier()); + } + } + } + // Extract from stringIntoPhrase (target operand) + if (ctx.stringIntoPhrase() != null && ctx.stringIntoPhrase().identifier() != null) { + addDataReference(paragraph, ctx.stringIntoPhrase().identifier()); + } + return super.visitStringStatement(ctx); + } + + // Extract data references from UNSTRING statements (simplified). + @Override + public Void visitUnstringStatement(Cobol85Parser.UnstringStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph == null) { + return super.visitUnstringStatement(ctx); + } + // Extract from unstringSendingPhrase (source identifier) + if (ctx.unstringSendingPhrase() != null && ctx.unstringSendingPhrase().identifier() != null) { + addDataReference(paragraph, ctx.unstringSendingPhrase().identifier()); + } + // Extract from unstringIntoPhrase (target identifiers) + if (ctx.unstringIntoPhrase() != null) { + for (Cobol85Parser.UnstringIntoContext unstringInto : ctx.unstringIntoPhrase().unstringInto()) { + if (unstringInto.identifier() != null) { + addDataReference(paragraph, unstringInto.identifier()); + } + } + } + // Extract from unstringDelimitedByPhrase (delimiter identifier) + if (ctx.unstringSendingPhrase() != null && ctx.unstringSendingPhrase().unstringDelimitedByPhrase() != null) { + Cobol85Parser.UnstringDelimitedByPhraseContext delimitedBy = ctx.unstringSendingPhrase().unstringDelimitedByPhrase(); + if (delimitedBy.identifier() != null) { + addDataReference(paragraph, delimitedBy.identifier()); + } + } + return super.visitUnstringStatement(ctx); + } + + // Extract data references from EVALUATE statements (simplified). + @Override + public Void visitEvaluateStatement(Cobol85Parser.EvaluateStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + // Extract from evaluateSelect (subject identifier) + if (ctx.evaluateSelect().identifier() != null) { + addDataReference(paragraph, ctx.evaluateSelect().identifier()); + } + // Extract from evaluateAlsoSelect (additional subjects) + for (Cobol85Parser.EvaluateAlsoSelectContext alsoSelect : ctx.evaluateAlsoSelect()) { + if (alsoSelect.evaluateSelect().identifier() != null) { + addDataReference(paragraph, alsoSelect.evaluateSelect().identifier()); + } + } + } + return super.visitEvaluateStatement(ctx); + } + + // Extract data references from INITIALIZE statements (simplified). + @Override + public Void visitInitializeStatement(Cobol85Parser.InitializeStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + // Extract target identifiers + for (Cobol85Parser.IdentifierContext identifier : ctx.identifier()) { + addDataReference(paragraph, identifier); + } + } + return super.visitInitializeStatement(ctx); + } + + // Extract data references from DISPLAY statements (simplified). + @Override + public Void visitDisplayStatement(Cobol85Parser.DisplayStatementContext ctx) { + COBOLParagraph paragraph = targetParagraph(); + if (paragraph != null) { + // Extract from displayOperand (identifier operands) + for (Cobol85Parser.DisplayOperandContext operand : ctx.displayOperand()) { + if (operand.identifier() != null) { + addDataReference(paragraph, operand.identifier()); + } + } + // Extract from displayAt (identifier for AT clause) + if (ctx.displayAt() != null && ctx.displayAt().identifier() != null) { + addDataReference(paragraph, ctx.displayAt().identifier()); + } + } + return super.visitDisplayStatement(ctx); + } + + private String normalizeDataReference(String raw) { + String normalized = normalizeName(raw); + if (normalized == null) { + return null; + } + + String prefix = "ADDRESSOF"; + if (normalized.regionMatches(true, 0, prefix, 0, prefix.length()) && normalized.length() > prefix.length()) { + return normalized.substring(prefix.length()); + } + return normalized; + } + + // Count CALL USING parameters across BY REFERENCE/VALUE/CONTENT phrases. + private int countCallUsingParameters(Cobol85Parser.CallUsingPhraseContext usingPhrase) { + int total = 0; + for (Cobol85Parser.CallUsingParameterContext parameter : usingPhrase.callUsingParameter()) { + if (parameter.callByReferencePhrase() != null) { + total += parameter.callByReferencePhrase().callByReference().size(); + } + if (parameter.callByValuePhrase() != null) { + total += parameter.callByValuePhrase().callByValue().size(); + } + if (parameter.callByContentPhrase() != null) { + total += parameter.callByContentPhrase().callByContent().size(); + } + } + return total; + } + + // Extract identifier names from CALL USING phrase for dataReferences. + private List extractCallUsingIdentifiers(Cobol85Parser.CallUsingPhraseContext usingPhrase) { + List identifiers = new ArrayList<>(); + for (Cobol85Parser.CallUsingParameterContext parameter : usingPhrase.callUsingParameter()) { + if (parameter.callByReferencePhrase() != null) { + collectIdentifiers(parameter.callByReferencePhrase().callByReference(), identifiers); + } + if (parameter.callByValuePhrase() != null) { + collectIdentifiers(parameter.callByValuePhrase().callByValue(), identifiers); + } + if (parameter.callByContentPhrase() != null) { + collectIdentifiers(parameter.callByContentPhrase().callByContent(), identifiers); + } + } + return identifiers; + } + + private void collectIdentifiers(List contexts, List identifiers) { + for (T ctx : contexts) { + Cobol85Parser.IdentifierContext id = ctx.getRuleContext(Cobol85Parser.IdentifierContext.class, 0); + if (id != null) { + identifiers.add(normalizeName(id.getText())); + } + } + } + + private boolean shouldSkipDataDescription() { + return currentDataSection == null || (hasFdEntries && currentDataSection == DataSection.FILE); + } + + // Extract data items with hierarchy and section context (format 1 entries). + @Override + public Void visitDataDescriptionEntryFormat1(Cobol85Parser.DataDescriptionEntryFormat1Context ctx) { + if (shouldSkipDataDescription()) { + return null; + } + + COBOLDataItem dataItem = toDataItem(ctx); + if (dataItem == null) { + return null; + } + + while (!hierarchy.isEmpty() && dataItem.level <= hierarchy.peek().level) { + hierarchy.pop(); + } + + assignSectionAndAdd(dataItem); + + if (dataItem.level != 77) { + hierarchy.push(dataItem); + } + + return null; + } + + // Extract 88-level condition names as children in dataItems hierarchy. + @Override + public Void visitDataDescriptionEntryFormat3(Cobol85Parser.DataDescriptionEntryFormat3Context ctx) { + if (shouldSkipDataDescription()) { + return null; + } + + COBOLDataItem dataItem = toDataItemFromFormat3(ctx); + if (dataItem == null) { + return null; + } + + assignSectionAndAdd(dataItem); + + // Note: 88-level items are not pushed to hierarchy (they can't have children) + + return null; + } + + private List targetListFor(DataSection section) { + switch (section) { + case WORKING_STORAGE: return workingStorageDataItems; + case LINKAGE: return linkageDataItems; + case LOCAL_STORAGE: return localStorageDataItems; + case FILE: return fileSectionDataItems; + default: return null; + } + } + + private void assignSectionAndAdd(COBOLDataItem dataItem) { + dataItem.section = currentDataSection.label; + List targetList = targetListFor(currentDataSection); + if (targetList != null) { + if (hierarchy.isEmpty()) { + targetList.add(dataItem); + } else { + hierarchy.peek().children.add(dataItem); + } + } + } + + // Convert DataDescriptionEntryFormat1Context to COBOLDataItem with level, name, and picture. + private COBOLDataItem toDataItem(Cobol85Parser.DataDescriptionEntryFormat1Context ctx) { + Integer level = parseInteger(ctx.getStart().getText()); + if (level == null) { + return null; + } + + COBOLDataItem item = new COBOLDataItem(); + item.level = level; + + if (ctx.dataName() != null) { + item.name = ctx.dataName().getText(); + } else if (ctx.FILLER() != null) { + item.name = "FILLER"; + } + + List pictureClauses = + ctx.getRuleContexts(Cobol85Parser.DataPictureClauseContext.class); + if (!pictureClauses.isEmpty() && pictureClauses.get(0).pictureString() != null) { + item.picture = pictureClauses.get(0).pictureString().getText(); + } + + List usageClauses = + ctx.getRuleContexts(Cobol85Parser.DataUsageClauseContext.class); + if (!usageClauses.isEmpty()) { + item.usage = normalizeUsage(usageClauses.get(0).getText()); + } + + List redefineClauses = + ctx.getRuleContexts(Cobol85Parser.DataRedefinesClauseContext.class); + if (!redefineClauses.isEmpty() && redefineClauses.get(0).dataName() != null) { + item.redefines = redefineClauses.get(0).dataName().getText(); + } + + List occursClauses = + ctx.getRuleContexts(Cobol85Parser.DataOccursClauseContext.class); + if (!occursClauses.isEmpty()) { + List integerLiterals = + occursClauses.get(0).getRuleContexts(Cobol85Parser.IntegerLiteralContext.class); + if (!integerLiterals.isEmpty()) { + item.occurs = parseInteger(integerLiterals.get(0).getText()); + } + } + + return item; + } + + // Convert DataDescriptionEntryFormat3Context (88-level) to COBOLDataItem. + private COBOLDataItem toDataItemFromFormat3(Cobol85Parser.DataDescriptionEntryFormat3Context ctx) { + COBOLDataItem item = new COBOLDataItem(); + item.level = 88; // 88-level entries are always level 88 + + if (ctx.conditionName() != null) { + item.name = ctx.conditionName().getText(); + } + + // Note: VALUE clause is intentionally excluded per Decision #12 in research doc + + return item; + } + + // Normalize USAGE clause (COMP, COMP-3, COMP-5, DISPLAY, etc.). + private static String normalizeUsage(String raw) { + if (raw == null || raw.isEmpty()) { + return null; + } + + String value = raw; + if (value.startsWith("USAGE")) { + value = value.substring("USAGE".length()); + } + if (value.startsWith("IS")) { + value = value.substring("IS".length()); + } + + value = value.trim(); + return value.isEmpty() ? null : value; + } + + private static Integer parseInteger(String raw) { + try { + return Integer.parseInt(raw); + } catch (Exception e) { + return null; + } + } + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/CobolCopybookRepository.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/CobolCopybookRepository.java new file mode 100644 index 0000000..715041c --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/CobolCopybookRepository.java @@ -0,0 +1,135 @@ +package org.dxworks.codeframe.analyzer.cobol; + +import java.io.File; +import java.util.*; +import java.util.stream.Collectors; + +/** + * Run-scoped repository of COBOL copybooks. + * + * - Built from the filtered list of copybook files. + * - Detects duplicate copybook names across multiple paths and prints them. + * - Provides the deduplicated list of copybook files for the preprocessor. + */ +public final class CobolCopybookRepository { + + private final Map byNormalizedName; + + public CobolCopybookRepository(List copybookFiles) { + Objects.requireNonNull(copybookFiles, "copybookFiles"); + + // Track candidates by key so we can both (a) warn about duplicates and (b) choose a winner deterministically. + Map> candidatesByKey = new HashMap<>(); + + for (File f : copybookFiles) { + if (f == null) continue; + if (!f.isFile()) continue; + + String fileName = f.getName(); + + // Index under base-name (strip extension) and full filename + String keyBase = normalizeCopybookToken(stripExtension(fileName)); + String keyFull = normalizeCopybookToken(fileName); + + candidatesByKey.computeIfAbsent(keyBase, k -> new ArrayList<>()).add(f); + candidatesByKey.computeIfAbsent(keyFull, k -> new ArrayList<>()).add(f); + } + + printDuplicates(candidatesByKey); + + Map index = new HashMap<>(); + for (Map.Entry> e : candidatesByKey.entrySet()) { + index.put(e.getKey(), pickWinner(e.getValue())); + } + + this.byNormalizedName = Collections.unmodifiableMap(index); + } + + /** + * Returns the resolved copybook files (deduplicated, one per normalized key). + */ + public Collection copyFiles() { + return byNormalizedName.values(); + } + + private static void printDuplicates(Map> candidatesByKey) { + Map> dupes = new TreeMap<>(); + + for (Map.Entry> e : candidatesByKey.entrySet()) { + String key = e.getKey(); + + // Unique by absolute path + LinkedHashMap unique = new LinkedHashMap<>(); + for (File f : e.getValue()) { + unique.put(f.getAbsolutePath(), f); + } + + if (unique.size() > 1) { + dupes.put(key, new ArrayList<>(unique.values())); + } + } + + if (dupes.isEmpty()) { + return; + } + + synchronized (System.out) { + System.out.println("Warning: duplicate COBOL copybook names detected (multiple paths for same key):"); + for (Map.Entry> e : dupes.entrySet()) { + System.out.println(" - " + e.getKey()); + for (File f : e.getValue()) { + System.out.println(" " + f.getAbsolutePath()); + } + } + } + } + + private static File pickWinner(List candidates) { + // De-dupe by absolute path, then pick deterministically: + // 1) shortest absolute path length + // 2) lexicographically smallest absolute path + Collection unique = candidates.stream() + .filter(Objects::nonNull) + .collect(Collectors.toMap( + f -> f.getAbsolutePath(), + f -> f, + (a, b) -> a, + LinkedHashMap::new + )) + .values(); + + return unique.stream() + .min(Comparator + .comparingInt((File f) -> f.getAbsolutePath().length()) + .thenComparing(File::getAbsolutePath)) + .orElseThrow(() -> new IllegalArgumentException("No copybook candidates")); + } + + private static String normalizeCopybookToken(String token) { + String t = token.trim().toLowerCase(Locale.ROOT); + + if ((t.startsWith("\"") && t.endsWith("\"")) || (t.startsWith("'") && t.endsWith("'"))) { + t = t.substring(1, t.length() - 1).trim(); + } + + // Remove trailing punctuation (common with naive tokenization) + t = t.replaceAll("[.;,]+$", ""); + + // Normalize separators + t = t.replace('\\', '/'); + + // Keep only last segment + int slash = t.lastIndexOf('/'); + if (slash >= 0 && slash + 1 < t.length()) { + t = t.substring(slash + 1); + } + + return t; + } + + private static String stripExtension(String fileName) { + int lastDot = fileName.lastIndexOf('.'); + if (lastDot <= 0) return fileName; + return fileName.substring(0, lastDot); + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/CobolPreprocessor.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/CobolPreprocessor.java new file mode 100644 index 0000000..e763cf3 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/CobolPreprocessor.java @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.regex.Pattern; + +public interface CobolPreprocessor { + + public enum CobolDialect { + ANSI85, MF, OSVS + } + + public enum CobolSourceFormatEnum { + + /** + * Fixed format, standard ANSI / IBM reference. Each line 80 + * chars.
+ *
+ * 1-6: sequence area
+ * 7: indicator field
+ * 8-12: area A
+ * 13-72: area B
+ * 73-80: comments
+ */ + FIXED("(.{6})" + INDICATOR_FIELD + "(.{0,4})(.{0,61})(.*)", true), + + /** + * HP Tandem format.
+ *
+ * 1: indicator field
+ * 2-5: optional area A
+ * 6-132: optional area B
+ */ + TANDEM("()" + INDICATOR_FIELD + "(.{0,4})(.*)()", false), + + /** + * Variable format.
+ *
+ * 1-6: sequence area
+ * 7: indicator field
+ * 8-12: optional area A
+ * 13-*: optional area B
+ */ + VARIABLE("(.{6})(?:" + INDICATOR_FIELD + "(.{0,4})(.*)())?", true); + + private final boolean commentEntryMultiLine; + + private final Pattern pattern; + + private final String regex; + + CobolSourceFormatEnum(final String regex, final boolean commentEntryMultiLine) { + this.regex = regex; + pattern = Pattern.compile(regex); + this.commentEntryMultiLine = commentEntryMultiLine; + } + + public Pattern getPattern() { + return pattern; + } + + public String getRegex() { + return regex; + } + + public boolean isCommentEntryMultiLine() { + return commentEntryMultiLine; + } + } + + final static String CHAR_ASTERISK = "*"; + + final static String CHAR_D = "D"; + + final static String CHAR_D_ = "d"; + + final static String CHAR_MINUS = "-"; + + final static String CHAR_SLASH = "/"; + + final static String COMMENT_ENTRY_TAG = "*>CE"; + + final static String COMMENT_TAG = "*>"; + + final static String EXEC_CICS_TAG = "*>EXECCICS"; + + final static String EXEC_SQL_TAG = "*>EXECSQL"; + + final static String EXEC_SQLIMS_TAG = "*>EXECSQLIMS"; + + final static String INDICATOR_FIELD = "([ABCdD\\t\\-/*# ])"; + + final static String NEWLINE = "\n"; + + final static String WS = " "; + + String process(File cobolFile, List copyFiles, CobolSourceFormatEnum format) throws IOException; + + String process(File cobolFile, List copyFiles, CobolSourceFormatEnum format, CobolDialect dialect) + throws IOException; + + String process(String cobolCode, List copyFiles, CobolSourceFormatEnum format); + + String process(String cobolCode, List copyFiles, CobolSourceFormatEnum format, CobolDialect dialect); + +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/impl/CobolPreprocessorImpl.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/impl/CobolPreprocessorImpl.java new file mode 100644 index 0000000..17d6e0d --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/impl/CobolPreprocessorImpl.java @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.impl; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Collections; +import java.util.List; +import java.util.logging.Logger; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.impl.CobolDocumentParserImpl; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.reader.impl.CobolLineReaderImpl; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter.impl.CobolCommentEntriesMarkerImpl; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter.impl.CobolLineIndicatorProcessorImpl; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.writer.CobolLineWriter; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.writer.impl.CobolLineWriterImpl; + +public class CobolPreprocessorImpl implements CobolPreprocessor { + + private final static Logger LOG = Logger.getLogger(CobolPreprocessorImpl.class.getSimpleName()); + + private List copyStatements = Collections.emptyList(); + + protected CobolCommentEntriesMarkerImpl createCommentEntriesMarker() { + return new CobolCommentEntriesMarkerImpl(); + } + + protected CobolDocumentParserImpl createDocumentParser(final List copyFiles) { + return new CobolDocumentParserImpl(copyFiles); + } + + protected CobolLineIndicatorProcessorImpl createLineIndicatorProcessor() { + return new CobolLineIndicatorProcessorImpl(); + } + + protected CobolLineReaderImpl createLineReader() { + return new CobolLineReaderImpl(); + } + + protected CobolLineWriter createLineWriter() { + return new CobolLineWriterImpl(); + } + + protected String parseDocument(final List lines, final List copyFiles, + final CobolSourceFormatEnum format, final CobolDialect dialect) { + final String code = createLineWriter().serialize(lines); + final CobolDocumentParserImpl parser = createDocumentParser(copyFiles); + final String result = parser.processLines(code, format, dialect); + copyStatements = parser.copyStatements(); + return result; + } + + public List copyStatements() { + return copyStatements; + } + + @Override + public String process(final File cobolFile, final List copyFiles, final CobolSourceFormatEnum format) + throws IOException { + return process(cobolFile, copyFiles, format, null); + } + + @Override + public String process(final File cobolFile, final List copyFiles, final CobolSourceFormatEnum format, + final CobolDialect dialect) throws IOException { + LOG.info(String.format("Preprocessing file %s.", cobolFile.getName())); + + final InputStream inputStream = new FileInputStream(cobolFile); + final InputStreamReader inputStreamReader = new InputStreamReader(inputStream); + final BufferedReader bufferedInputStreamReader = new BufferedReader(inputStreamReader); + final StringBuffer outputBuffer = new StringBuffer(); + + String line = null; + + while ((line = bufferedInputStreamReader.readLine()) != null) { + outputBuffer.append(line + NEWLINE); + } + + bufferedInputStreamReader.close(); + + final String result = process(outputBuffer.toString(), copyFiles, format, dialect); + return result; + } + + @Override + public String process(final String cobolSourceCode, final List copyFiles, + final CobolSourceFormatEnum format) { + return process(cobolSourceCode, copyFiles, format, null); + } + + @Override + public String process(final String cobolCode, final List copyFiles, final CobolSourceFormatEnum format, + final CobolDialect dialect) { + final List lines = readLines(cobolCode, format, dialect); + final List rewrittenLines = rewriteLines(lines); + final String result = parseDocument(rewrittenLines, copyFiles, format, dialect); + + LOG.fine(String.format("Processed input:\n\n%s\n\n", result)); + + return result; + } + + protected List readLines(final String cobolCode, final CobolSourceFormatEnum format, + final CobolDialect dialect) { + final List lines = createLineReader().processLines(cobolCode, format, dialect); + return lines; + } + + /** + * Normalizes lines of given COBOL source code, so that comment entries can + * be parsed and lines have a unified line format. + */ + protected List rewriteLines(final List lines) { + final List lineIndicatorProcessedLines = createLineIndicatorProcessor().processLines(lines); + final List result = createCommentEntriesMarker().processLines(lineIndicatorProcessedLines); + return result; + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/CobolLine.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/CobolLine.java new file mode 100644 index 0000000..ff585e3 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/CobolLine.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolDialect; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum; + +/** + * Representation of a Cobol line. + */ +public class CobolLine { + + public static String blankSequenceArea(final CobolSourceFormatEnum format) { + return CobolSourceFormatEnum.TANDEM.equals(format) ? "" : CobolPreprocessor.WS.repeat(6); + } + + private static String contentAreaA(final String contentArea) { + return contentArea.length() > 4 ? contentArea.substring(0, 4) : contentArea; + } + + private static String contentAreaB(final String contentArea) { + return contentArea.length() > 4 ? contentArea.substring(4) : ""; + } + + public static CobolLine with(final CobolLine line, final String indicatorArea, final String contentArea) { + return new CobolLine(line.sequenceArea, indicatorArea, contentAreaA(contentArea), contentAreaB(contentArea), + line.comment, line.format, line.dialect, line.number, line.type); + } + + public static CobolLine withContentArea(final CobolLine line, final String contentArea) { + return new CobolLine(line.sequenceArea, line.indicatorArea, contentAreaA(contentArea), + contentAreaB(contentArea), line.comment, line.format, line.dialect, line.number, line.type); + } + + public String comment; + + public String contentAreaA; + + public String contentAreaB; + + public CobolDialect dialect; + + public CobolSourceFormatEnum format; + + public String indicatorArea; + + public int number; + + public String sequenceArea; + + public CobolLineTypeEnum type; + + public CobolLine(final String sequenceArea, final String indicatorArea, final String contentAreaA, + final String contentAreaB, final String comment, final CobolSourceFormatEnum format, + final CobolDialect dialect, final int number, final CobolLineTypeEnum type) { + this.sequenceArea = sequenceArea; + this.indicatorArea = indicatorArea; + this.contentAreaA = contentAreaA; + this.contentAreaB = contentAreaB; + this.comment = comment; + + this.format = format; + this.dialect = dialect; + this.number = number; + this.type = type; + } + + public String blankSequenceArea() { + return blankSequenceArea(format); + } + + public String getContentArea() { + return contentAreaA + contentAreaB; + } + + public String serialize() { + return sequenceArea + indicatorArea + contentAreaA + contentAreaB + comment; + } + + @Override + public String toString() { + return serialize(); + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/CobolLineTypeEnum.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/CobolLineTypeEnum.java new file mode 100644 index 0000000..f5241d3 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/CobolLineTypeEnum.java @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub; + +public enum CobolLineTypeEnum { + + BLANK, COMMENT, CONTINUATION, DEBUG, NORMAL +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/CobolDocumentParser.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/CobolDocumentParser.java new file mode 100644 index 0000000..f739c1d --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/CobolDocumentParser.java @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolDialect; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum; + +public interface CobolDocumentParser { + + String processLines(String code, CobolSourceFormatEnum format, CobolDialect dialect); +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentContext.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentContext.java new file mode 100644 index 0000000..3df8018 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentContext.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.impl; + +import java.util.Arrays; +import java.util.List; + +import org.antlr.v4.runtime.BufferedTokenStream; + +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser.ReplaceClauseContext; + +/** + * A replacement context that defines, which replaceables should be replaced by + * which replacements. + */ +public class CobolDocumentContext { + + private CobolReplacementMapping[] currentReplaceableReplacements; + + private StringBuffer outputBuffer = new StringBuffer(); + + public String read() { + return outputBuffer.toString(); + } + + /** + * Replaces replaceables with replacements. + */ + public void replaceReplaceablesByReplacements(final BufferedTokenStream tokens) { + if (currentReplaceableReplacements != null) { + Arrays.sort(currentReplaceableReplacements); + + for (final CobolReplacementMapping replaceableReplacement : currentReplaceableReplacements) { + final String currentOutput = outputBuffer.toString(); + final String replacedOutput = replaceableReplacement.replace(currentOutput, tokens); + + outputBuffer = new StringBuffer(); + outputBuffer.append(replacedOutput); + } + } + } + + public void storeReplaceablesAndReplacements(final List replaceClauses) { + if (replaceClauses == null) { + currentReplaceableReplacements = null; + } else { + final int length = replaceClauses.size(); + currentReplaceableReplacements = new CobolReplacementMapping[length]; + + int i = 0; + + for (final ReplaceClauseContext replaceClause : replaceClauses) { + final CobolReplacementMapping replaceableReplacement = new CobolReplacementMapping(); + + replaceableReplacement.replaceable = replaceClause.replaceable(); + replaceableReplacement.replacement = replaceClause.replacement(); + + currentReplaceableReplacements[i] = replaceableReplacement; + i++; + } + } + } + + public void write(final String text) { + outputBuffer.append(text); + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentParserImpl.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentParserImpl.java new file mode 100644 index 0000000..89dd9e6 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentParserImpl.java @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.impl; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.tree.ParseTreeWalker; + +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorLexer; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser.StartRuleContext; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolDialect; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.CobolDocumentParser; + +/** + * Preprocessor, which parses and processes COPY REPLACE and EXEC SQL + * statements. + */ +public class CobolDocumentParserImpl implements CobolDocumentParser { + + protected final List copyFiles; + + private List copyStatements = Collections.emptyList(); + + protected final String[] triggers = new String[] { "copy", "exec sql", "exec sqlims", "exec cics", "replace" }; + + public CobolDocumentParserImpl(final List copyFiles) { + this.copyFiles = copyFiles; + } + + private void debugLog(String message) { + // Intentionally no-op. + } + + protected boolean containsTrigger(final String code, final String[] triggers) { + debugLog("DEBUG: containsTrigger called with code length: " + code.length()); + debugLog("DEBUG: First 200 chars: " + (code.length() > 200 ? code.substring(0, 200) + "..." : code)); + final String[] lines = code.split("\\r?\\n"); + debugLog("DEBUG: Total lines to check: " + lines.length); + + for (int i = 0; i < lines.length; i++) { + final String line = lines[i]; + final String trimmedLine = line.trim(); + + // Skip comment lines - any line starting with comment tags + if (trimmedLine.length() > 0) { + if (trimmedLine.startsWith(CobolPreprocessor.COMMENT_TAG) || + trimmedLine.startsWith(CobolPreprocessor.COMMENT_ENTRY_TAG)) { + debugLog("DEBUG: Skipping comment line " + (i+1) + ": '" + trimmedLine + "'"); + continue; + } + } + + // Skip empty lines + if (trimmedLine.isEmpty()) { + debugLog("DEBUG: Skipping empty line " + (i+1)); + continue; + } + + // Debug: print the line being checked + debugLog("DEBUG: Checking line " + (i+1) + ": '" + trimmedLine + "'"); + + final String lineLowerCase = trimmedLine.toLowerCase(); + for (final String trigger : triggers) { + if (lineLowerCase.contains(trigger)) { + debugLog("DEBUG: Found trigger '" + trigger + "' in line " + (i+1) + ": '" + trimmedLine + "'"); + return true; + } + } + } + + debugLog("DEBUG: No triggers found in any lines"); + return false; + } + + @Override + public String processLines(final String code, final CobolSourceFormatEnum format, final CobolDialect dialect) { + debugLog("DEBUG: processLines called"); + final boolean requiresProcessorExecution = containsTrigger(code, triggers); + debugLog("DEBUG: requiresProcessorExecution = " + requiresProcessorExecution); + final String result; + + if (requiresProcessorExecution) { + debugLog("DEBUG: Going to processWithParser - this is where the error occurs"); + result = processWithParser(code, copyFiles, format, dialect); + } else { + debugLog("DEBUG: No processing needed, returning original code"); + copyStatements = Collections.emptyList(); + result = code; + } + + return result; + } + + protected String processWithParser(final String code, final List copyFiles, + final CobolSourceFormatEnum format, final CobolDialect dialect) { + debugLog("DEBUG: processWithParser called with code length: " + code.length()); + // Show first 500 chars of code being sent to parser + debugLog("DEBUG: Code to parser (first 500 chars): " + (code.length() > 500 ? code.substring(0, 500) + "..." : code)); + + // run the lexer + final Cobol85PreprocessorLexer lexer = new Cobol85PreprocessorLexer(CharStreams.fromString(code)); + + // get a list of matched tokens + final CommonTokenStream tokens = new CommonTokenStream(lexer); + + // pass the tokens to the parser + final Cobol85PreprocessorParser parser = new Cobol85PreprocessorParser(tokens); + + // register an error listener, so that preprocessing stops on errors + parser.removeErrorListeners(); + parser.addErrorListener(new ThrowingErrorListener()); + + // specify our entry point + final StartRuleContext startRule = parser.startRule(); + + // analyze contained copy books + final CobolDocumentParserListenerImpl listener = new CobolDocumentParserListenerImpl(copyFiles, format, dialect, + tokens); + final ParseTreeWalker walker = new ParseTreeWalker(); + + walker.walk(listener, startRule); + copyStatements = listener.copyStatements(); + + final String result = listener.context().read(); + return result; + } + + public List copyStatements() { + return copyStatements; + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentParserListenerImpl.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentParserListenerImpl.java new file mode 100644 index 0000000..cebf336 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolDocumentParserListenerImpl.java @@ -0,0 +1,374 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.impl; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; +import java.util.List; +import java.util.Scanner; +import java.util.logging.Logger; + +import org.antlr.v4.runtime.BufferedTokenStream; +import org.antlr.v4.runtime.tree.TerminalNode; + +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorBaseListener; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser.ReplaceClauseContext; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser.ReplacingPhraseContext; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolDialect; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.impl.CobolPreprocessorImpl; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.util.TokenUtils; + +/** + * ANTLR visitor, which preprocesses a given COBOL program by executing COPY and + * REPLACE statements. + */ +public class CobolDocumentParserListenerImpl extends Cobol85PreprocessorBaseListener { + + private final static Logger LOG = Logger.getLogger(CobolDocumentParserListenerImpl.class.getSimpleName()); + + private final Deque contexts = new ArrayDeque<>(); + + private final List copyFiles; + + private final CobolDialect dialect; + + private final CobolSourceFormatEnum format; + + private final BufferedTokenStream tokens; + + private final List copyStatements = new ArrayList<>(); + + public CobolDocumentParserListenerImpl(final List copyFiles, final CobolSourceFormatEnum format, + final CobolDialect dialect, final BufferedTokenStream tokens) { + this.copyFiles = copyFiles; + this.dialect = dialect; + this.tokens = tokens; + this.format = format; + + contexts.push(new CobolDocumentContext()); + } + + protected String buildLines(final String text, final String linePrefix) { + final StringBuffer sb = new StringBuffer(text.length()); + final Scanner scanner = new Scanner(text); + boolean firstLine = true; + + while (scanner.hasNextLine()) { + final String line = scanner.nextLine(); + + if (!firstLine) { + sb.append(CobolPreprocessor.NEWLINE); + } + + sb.append(linePrefix + CobolPreprocessor.WS + line.trim()); + firstLine = false; + } + + scanner.close(); + return sb.toString(); + } + + public CobolDocumentContext context() { + return contexts.peek(); + } + + public List copyStatements() { + return Collections.unmodifiableList(copyStatements); + } + + @Override + public void enterCopyStatement(final Cobol85PreprocessorParser.CopyStatementContext ctx) { + // push a new context for COPY terminals + push(); + } + + @Override + public void enterExecCicsStatement(final Cobol85PreprocessorParser.ExecCicsStatementContext ctx) { + // push a new context for SQL terminals + push(); + } + + @Override + public void enterExecSqlImsStatement(final Cobol85PreprocessorParser.ExecSqlImsStatementContext ctx) { + // push a new context for SQL IMS terminals + push(); + } + + @Override + public void enterExecSqlStatement(final Cobol85PreprocessorParser.ExecSqlStatementContext ctx) { + // push a new context for SQL terminals + push(); + } + + @Override + public void enterReplaceArea(final Cobol85PreprocessorParser.ReplaceAreaContext ctx) { + push(); + } + + @Override + public void enterReplaceByStatement(final Cobol85PreprocessorParser.ReplaceByStatementContext ctx) { + push(); + } + + @Override + public void enterReplaceOffStatement(final Cobol85PreprocessorParser.ReplaceOffStatementContext ctx) { + push(); + } + + @Override + public void exitCopyStatement(final Cobol85PreprocessorParser.CopyStatementContext ctx) { + final String copySourceName = extractCopySourceName(ctx.copySource()); + if (copySourceName != null && !copySourceName.isEmpty()) { + copyStatements.add(copySourceName); + } + + // throw away COPY terminals + pop(); + + // a new context for the copy file content + push(); + + /* + * replacement phrase + */ + final List replacingPhrases = ctx.replacingPhrase(); + + if (!replacingPhrases.isEmpty()) { + context().storeReplaceablesAndReplacements(replacingPhrases.get(0).replaceClause()); + } + + /* + * copy the copy file + */ + final String copyFileIdentifier = ctx.copySource().getText(); + + if (copyFiles == null || copyFiles.isEmpty()) { + LOG.warning(String.format("Could not identify copy file %s due to missing copy files.", copyFileIdentifier)); + } else { + final String fileContent = getCopyFileContent(copyFileIdentifier, copyFiles, dialect, format); + + if (fileContent != null) { + context().write(fileContent + CobolPreprocessor.NEWLINE); + context().replaceReplaceablesByReplacements(tokens); + } + } + + final String content = context().read(); + pop(); + + context().write(content); + } + + private String extractCopySourceName(final Cobol85PreprocessorParser.CopySourceContext copySource) { + if (copySource == null) { + return null; + } + + if (copySource.literal() != null) { + return normalizeName(copySource.literal().getText()); + } + + if (copySource.cobolWord() != null) { + return normalizeName(copySource.cobolWord().getText()); + } + + if (copySource.filename() != null) { + return normalizeName(copySource.filename().getText()); + } + + return null; + } + + private String normalizeName(final String raw) { + if (raw == null) { + return null; + } + + String text = raw.trim(); + if (text.isEmpty()) { + return null; + } + + if ((text.startsWith("\"") && text.endsWith("\"")) || (text.startsWith("'") && text.endsWith("'"))) { + text = text.substring(1, text.length() - 1).trim(); + } + + return text; + } + + @Override + public void exitExecCicsStatement(final Cobol85PreprocessorParser.ExecCicsStatementContext ctx) { + // throw away EXEC CICS terminals + pop(); + + // a new context for the CICS statement + push(); + + /* + * text + */ + final String text = TokenUtils.getTextIncludingHiddenTokens(ctx, tokens); + final String linePrefix = CobolLine.blankSequenceArea(format) + CobolPreprocessor.EXEC_CICS_TAG; + final String lines = buildLines(text, linePrefix); + + context().write(lines); + + final String content = context().read(); + pop(); + + context().write(content); + } + + @Override + public void exitExecSqlImsStatement(final Cobol85PreprocessorParser.ExecSqlImsStatementContext ctx) { + // throw away EXEC SQLIMS terminals + pop(); + + // a new context for the SQLIMS statement + push(); + + /* + * text + */ + final String text = TokenUtils.getTextIncludingHiddenTokens(ctx, tokens); + final String linePrefix = CobolLine.blankSequenceArea(format) + CobolPreprocessor.EXEC_SQLIMS_TAG; + final String lines = buildLines(text, linePrefix); + + context().write(lines); + + final String content = context().read(); + pop(); + + context().write(content); + } + + @Override + public void exitExecSqlStatement(final Cobol85PreprocessorParser.ExecSqlStatementContext ctx) { + // throw away EXEC SQL terminals + pop(); + + // a new context for the SQL statement + push(); + + /* + * text + */ + final String text = TokenUtils.getTextIncludingHiddenTokens(ctx, tokens); + final String linePrefix = CobolLine.blankSequenceArea(format) + CobolPreprocessor.EXEC_SQL_TAG; + final String lines = buildLines(text, linePrefix); + + context().write(lines); + + final String content = context().read(); + pop(); + + context().write(content); + } + + @Override + public void exitReplaceArea(final Cobol85PreprocessorParser.ReplaceAreaContext ctx) { + /* + * replacement phrase + */ + final List replaceClauses = ctx.replaceByStatement().replaceClause(); + context().storeReplaceablesAndReplacements(replaceClauses); + + context().replaceReplaceablesByReplacements(tokens); + final String content = context().read(); + + pop(); + context().write(content); + } + + @Override + public void exitReplaceByStatement(final Cobol85PreprocessorParser.ReplaceByStatementContext ctx) { + // throw away REPLACE BY terminals + pop(); + } + + @Override + public void exitReplaceOffStatement(final Cobol85PreprocessorParser.ReplaceOffStatementContext ctx) { + // throw away REPLACE OFF terminals + pop(); + }; + + protected String getCopyFileContent(final String filename, final List copyFiles, final CobolDialect dialect, + final CobolSourceFormatEnum format) { + final File copyFile = identifyCopyFile(filename, copyFiles); + String result; + + if (copyFile == null) { + LOG.warning(String.format("Copy file %s not found in copy files %s.", filename, copyFiles)); + result = null; + } else { + try { + result = new CobolPreprocessorImpl().process(copyFile, copyFiles, format, dialect); + } catch (final IOException e) { + result = null; + LOG.warning(e.getMessage()); + } + } + + return result; + } + + /** + * Identifies a copy file by its name and directory. + */ + protected File identifyCopyFile(final String filename, final List copyFiles) { + File copyFile = null; + + for (final File file : copyFiles) { + final String baseName = file.getName().substring(0, file.getName().lastIndexOf('.')); + final boolean matchingBaseName = filename.toLowerCase().equals(baseName.toLowerCase()); + + if (matchingBaseName) { + copyFile = file; + break; + } + } + + return copyFile; + } + + /** + * Pops the current preprocessing context from the stack. + */ + protected CobolDocumentContext pop() { + return contexts.pop(); + } + + /** + * Pushes a new preprocessing context onto the stack. + */ + protected CobolDocumentContext push() { + CobolDocumentContext ctx = new CobolDocumentContext(); + contexts.push(ctx); + return ctx; + } + + @Override + public void visitTerminal(final TerminalNode node) { + final int tokPos = node.getSourceInterval().a; + context().write(TokenUtils.getHiddenTokensToLeft(tokPos, tokens)); + + if (!TokenUtils.isEOF(node)) { + final String text = node.getText(); + context().write(text); + } + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolHiddenTokenCollectorListenerImpl.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolHiddenTokenCollectorListenerImpl.java new file mode 100644 index 0000000..6ade9d2 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolHiddenTokenCollectorListenerImpl.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.impl; + +import org.antlr.v4.runtime.BufferedTokenStream; +import org.antlr.v4.runtime.tree.TerminalNode; + +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorBaseListener; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.util.TokenUtils; + +/** + * ANTLR listener, which collects visible as well as hidden tokens for a given + * parse tree in a string buffer. + */ +public class CobolHiddenTokenCollectorListenerImpl extends Cobol85PreprocessorBaseListener { + + boolean firstTerminal = true; + + private final StringBuffer outputBuffer = new StringBuffer(); + + private final BufferedTokenStream tokens; + + public CobolHiddenTokenCollectorListenerImpl(final BufferedTokenStream tokens) { + this.tokens = tokens; + } + + public String read() { + return outputBuffer.toString(); + } + + @Override + public void visitTerminal(final TerminalNode node) { + if (!firstTerminal) { + final int tokPos = node.getSourceInterval().a; + outputBuffer.append(TokenUtils.getHiddenTokensToLeft(tokPos, tokens)); + } + + if (!TokenUtils.isEOF(node)) { + final String text = node.getText(); + outputBuffer.append(text); + } + + firstTerminal = false; + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolReplacementMapping.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolReplacementMapping.java new file mode 100644 index 0000000..9e3fea4 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/CobolReplacementMapping.java @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.impl; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.antlr.v4.runtime.BufferedTokenStream; + +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser.PseudoTextContext; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser.ReplaceableContext; +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorParser.ReplacementContext; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.util.TokenUtils; + +/** + * A mapping from a replaceable to a replacement. + */ +public class CobolReplacementMapping implements Comparable { + + public ReplaceableContext replaceable; + + public ReplacementContext replacement; + + @Override + public int compareTo(final CobolReplacementMapping o) { + return o.replaceable.getText().length() - replaceable.getText().length(); + } + + private String extractPseudoText(final PseudoTextContext pseudoTextCtx, final BufferedTokenStream tokens) { + final String pseudoText = TokenUtils.getTextIncludingHiddenTokens(pseudoTextCtx, tokens).trim(); + final String content = pseudoText.replaceAll("^==", "").replaceAll("==$", "").trim(); + return content; + } + + /** + * Whitespace in Cobol replaceables matches line breaks. Hence, the + * replaceable search string has to be enhanced to a regex, which is + * returned by this function. + */ + private String getRegexFromReplaceable(final String replaceable) { + final String result; + + if (replaceable == null) { + result = null; + } else { + final String[] parts = replaceable.split("[ \t\n\r\f]"); + final String[] regexParts = new String[parts.length]; + final String regexSeparator = "[\\r\\n\\s]+"; + + for (int i = 0; i < parts.length; i++) { + final String part = parts[i]; + regexParts[i] = Pattern.quote(part); + } + + result = String.join(regexSeparator, regexParts); + } + + return result; + } + + private String getText(final ReplaceableContext ctx, final BufferedTokenStream tokens) { + final String result; + + if (ctx.pseudoText() != null) { + result = extractPseudoText(ctx.pseudoText(), tokens); + } else if (ctx.charDataLine() != null) { + result = TokenUtils.getTextIncludingHiddenTokens(ctx, tokens); + } else if (ctx.cobolWord() != null) { + result = ctx.getText(); + } else if (ctx.literal() != null) { + result = ctx.literal().getText(); + } else { + result = null; + } + + return result; + } + + private String getText(final ReplacementContext ctx, final BufferedTokenStream tokens) { + final String result; + + if (ctx.pseudoText() != null) { + result = extractPseudoText(ctx.pseudoText(), tokens); + } else if (ctx.charDataLine() != null) { + result = TokenUtils.getTextIncludingHiddenTokens(ctx, tokens); + } else if (ctx.cobolWord() != null) { + result = ctx.getText(); + } else if (ctx.literal() != null) { + result = ctx.literal().getText(); + } else { + result = null; + } + + return result; + } + + protected String replace(final String string, final BufferedTokenStream tokens) { + final String replaceableString = getText(replaceable, tokens); + final String replacementString = getText(replacement, tokens); + + final String result; + + if (replaceableString != null && replacementString != null) { + // regex for the replaceable + final String replaceableRegex = getRegexFromReplaceable(replaceableString); + + // regex for the replacement + final String quotedReplacementRegex = Matcher.quoteReplacement(replacementString); + + result = Pattern.compile(replaceableRegex).matcher(string).replaceAll(quotedReplacementRegex); + } else { + result = string; + } + + return result; + } + + @Override + public String toString() { + return replaceable.getText() + " -> " + replacement.getText(); + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/ThrowingErrorListener.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/ThrowingErrorListener.java new file mode 100644 index 0000000..654f19c --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/document/impl/ThrowingErrorListener.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.impl; + +import org.antlr.v4.runtime.BaseErrorListener; +import org.antlr.v4.runtime.RecognitionException; +import org.antlr.v4.runtime.Recognizer; + +public class ThrowingErrorListener extends BaseErrorListener { + + @Override + public void syntaxError(final Recognizer recognizer, final Object offendingSymbol, final int line, + final int charPositionInLine, final String msg, final RecognitionException e) { + throw new RuntimeException("syntax error in line " + line + ":" + charPositionInLine + " " + msg); + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/reader/CobolLineReader.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/reader/CobolLineReader.java new file mode 100644 index 0000000..7c9c8cb --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/reader/CobolLineReader.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.reader; + +import java.util.List; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolDialect; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; + +/** + * Preprocessor, which analyzes and processes line indicators. + */ +public interface CobolLineReader { + + CobolLine parseLine(String line, int lineNumber, CobolSourceFormatEnum format, CobolDialect dialect); + + List processLines(String lines, CobolSourceFormatEnum format, CobolDialect dialect); + +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/reader/impl/CobolLineReaderImpl.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/reader/impl/CobolLineReaderImpl.java new file mode 100644 index 0000000..7196711 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/reader/impl/CobolLineReaderImpl.java @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.reader.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolDialect; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolSourceFormatEnum; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLineTypeEnum; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.reader.CobolLineReader; + +public class CobolLineReaderImpl implements CobolLineReader { + + protected CobolLineTypeEnum determineType(final String indicatorArea) { + final CobolLineTypeEnum result; + + switch (indicatorArea) { + case CobolPreprocessor.CHAR_D: + case CobolPreprocessor.CHAR_D_: + result = CobolLineTypeEnum.DEBUG; + break; + case CobolPreprocessor.CHAR_MINUS: + result = CobolLineTypeEnum.CONTINUATION; + break; + case CobolPreprocessor.CHAR_ASTERISK: + case CobolPreprocessor.CHAR_SLASH: + result = CobolLineTypeEnum.COMMENT; + break; + case CobolPreprocessor.WS: + default: + result = CobolLineTypeEnum.NORMAL; + break; + } + + return result; + } + + @Override + public CobolLine parseLine(final String line, final int lineNumber, final CobolSourceFormatEnum format, + final CobolDialect dialect) { + final Pattern pattern = format.getPattern(); + final Matcher matcher = pattern.matcher(line); + + final CobolLine result; + + if (line.chars().allMatch(Character::isWhitespace)) { + result = new CobolLine(CobolLine.blankSequenceArea(format), CobolPreprocessor.WS, "", "", "", format, + dialect, lineNumber, CobolLineTypeEnum.BLANK); + } else if (!matcher.matches()) { + throw new RuntimeException("Is " + format + " the correct line format? Could not parse line " + + (lineNumber + 1) + ": " + line); + } else { + final String sequenceAreaGroup = matcher.group(1); + final String indicatorAreaGroup = matcher.group(2); + final String contentAreaAGroup = matcher.group(3); + final String contentAreaBGroup = matcher.group(4); + final String commentAreaGroup = matcher.group(5); + + final String sequenceArea = sequenceAreaGroup != null ? sequenceAreaGroup : ""; + final String indicatorArea = indicatorAreaGroup != null ? indicatorAreaGroup : " "; + final String contentAreaA = contentAreaAGroup != null ? contentAreaAGroup : ""; + final String contentAreaB = contentAreaBGroup != null ? contentAreaBGroup : ""; + final String commentArea = commentAreaGroup != null ? commentAreaGroup : ""; + + final CobolLineTypeEnum type = determineType(indicatorArea); + + result = new CobolLine(sequenceArea, indicatorArea, contentAreaA, contentAreaB, commentArea, format, + dialect, lineNumber, type); + } + + return result; + } + + @Override + public List processLines(final String lines, final CobolSourceFormatEnum format, + final CobolDialect dialect) { + final Scanner scanner = new Scanner(lines); + final List result = new ArrayList(); + + String currentLine = null; + int lineNumber = 0; + + while (scanner.hasNextLine()) { + currentLine = scanner.nextLine(); + + final CobolLine parsedLine = parseLine(currentLine, lineNumber, format, dialect); + result.add(parsedLine); + + lineNumber++; + } + + scanner.close(); + return result; + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolCommentEntriesMarker.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolCommentEntriesMarker.java new file mode 100644 index 0000000..f6d3fd8 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolCommentEntriesMarker.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; + +/** + * Preprocessor, which identifies and marks comment entries depending on the + * COBOL dialect. + */ +public interface CobolCommentEntriesMarker extends CobolLineRewriter { + + CobolLine processLine(CobolLine line); +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolLineIndicatorProcessor.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolLineIndicatorProcessor.java new file mode 100644 index 0000000..8b3f982 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolLineIndicatorProcessor.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; + +/** + * Preprocessor, which analyzes and processes line indicators. + */ +public interface CobolLineIndicatorProcessor extends CobolLineRewriter { + + CobolLine processLine(CobolLine line); + +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolLineRewriter.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolLineRewriter.java new file mode 100644 index 0000000..538482e --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/CobolLineRewriter.java @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter; + +import java.util.List; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; + +public interface CobolLineRewriter { + + List processLines(List lines); + +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/impl/CobolCommentEntriesMarkerImpl.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/impl/CobolCommentEntriesMarkerImpl.java new file mode 100644 index 0000000..90dfa5a --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/impl/CobolCommentEntriesMarkerImpl.java @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor.CobolDialect; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLineTypeEnum; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter.CobolCommentEntriesMarker; + +public class CobolCommentEntriesMarkerImpl implements CobolCommentEntriesMarker { + + protected final Pattern commentEntryTriggerLinePattern; + + protected boolean foundCommentEntryTriggerInPreviousLine = false; + + protected boolean isInCommentEntry = false; + + protected final String[] triggersEnd = new String[] { "PROGRAM-ID.", "AUTHOR.", "INSTALLATION.", "DATE-WRITTEN.", + "DATE-COMPILED.", "SECURITY.", "ENVIRONMENT", "DATA.", "PROCEDURE." }; + + protected final String[] triggersStart = new String[] { "AUTHOR.", "INSTALLATION.", "DATE-WRITTEN.", + "DATE-COMPILED.", "SECURITY.", "REMARKS." }; + + public CobolCommentEntriesMarkerImpl() { + final String commentEntryTriggerLineFormat = new String("(" + String.join("|", triggersStart) + ")(.+)"); + commentEntryTriggerLinePattern = Pattern.compile(commentEntryTriggerLineFormat, Pattern.CASE_INSENSITIVE); + } + + protected CobolLine buildMultiLineCommentEntryLine(final CobolLine line) { + return new CobolLine(line.sequenceArea, CobolPreprocessor.COMMENT_ENTRY_TAG + CobolPreprocessor.WS, + line.contentAreaA, line.contentAreaB, line.comment, line.format, line.dialect, line.number, line.type); + } + + /** + * Escapes in a given line a potential comment entry. + */ + protected CobolLine escapeCommentEntry(final CobolLine line) { + final CobolLine result; + + final Matcher matcher = commentEntryTriggerLinePattern.matcher(line.getContentArea()); + + if (matcher.matches()) { + final String trigger = matcher.group(1); + final String commentEntry = matcher.group(2); + final String newContentArea = trigger + CobolPreprocessor.WS + CobolPreprocessor.COMMENT_ENTRY_TAG + + commentEntry; + + result = CobolLine.withContentArea(line, newContentArea); + } else { + result = line; + } + + return result; + } + + protected boolean isInCommentEntry(final CobolLine line, final boolean isContentAreaAEmpty, + final boolean isInOsvsCommentEntry) { + final boolean result = CobolLineTypeEnum.COMMENT.equals(line.type) || isContentAreaAEmpty + || isInOsvsCommentEntry; + return result; + } + + /** + * OSVS: The comment-entry can be contained in either area A or area B of + * the comment-entry lines. However, the next occurrence in area A of any + * one of the following COBOL words or phrases terminates the comment-entry + * and begin the next paragraph or division. + */ + protected boolean isInOsvsCommentEntry(final CobolLine line) { + final boolean result = CobolDialect.OSVS.equals(line.dialect) && !startsWithTrigger(line, triggersEnd); + return result; + } + + @Override + public CobolLine processLine(final CobolLine line) { + final CobolLine result; + + if (line.format.isCommentEntryMultiLine()) { + result = processMultiLineCommentEntry(line); + } else { + result = processSingleLineCommentEntry(line); + } + + return result; + } + + @Override + public List processLines(final List lines) { + final List result = new ArrayList(); + + for (final CobolLine line : lines) { + final CobolLine processedLine = processLine(line); + result.add(processedLine); + } + + return result; + } + + /** + * If the Compiler directive SOURCEFORMAT is specified as or defaulted to + * FIXED, the comment-entry can be contained on one or more lines but is + * restricted to area B of those lines; the next line commencing in area A + * begins the next non-comment entry. + */ + protected CobolLine processMultiLineCommentEntry(final CobolLine line) { + final boolean foundCommentEntryTriggerInCurrentLine = startsWithTrigger(line, triggersStart); + final CobolLine result; + + if (foundCommentEntryTriggerInCurrentLine) { + result = escapeCommentEntry(line); + } else if (foundCommentEntryTriggerInPreviousLine || isInCommentEntry) { + final boolean isContentAreaAEmpty = line.contentAreaA.trim().isEmpty(); + final boolean isInOsvsCommentEntry = isInOsvsCommentEntry(line); + + isInCommentEntry = isInCommentEntry(line, isContentAreaAEmpty, isInOsvsCommentEntry); + + if (isInCommentEntry) { + result = buildMultiLineCommentEntryLine(line); + } else { + result = line; + } + } else { + result = line; + } + + foundCommentEntryTriggerInPreviousLine = foundCommentEntryTriggerInCurrentLine; + + return result; + } + + protected CobolLine processSingleLineCommentEntry(final CobolLine line) { + final boolean foundCommentEntryTriggerInCurrentLine = startsWithTrigger(line, triggersStart); + final CobolLine result; + + if (foundCommentEntryTriggerInCurrentLine) { + result = escapeCommentEntry(line); + } else { + result = line; + } + + return result; + } + + /** + * Checks, whether given line starts with a trigger keyword indicating a + * comment entry. + */ + protected boolean startsWithTrigger(final CobolLine line, final String[] triggers) { + final String contentAreaUpperCase = new String(line.getContentArea()).toUpperCase(); + + boolean result = false; + + for (final String trigger : triggers) { + final boolean containsTrigger = contentAreaUpperCase.startsWith(trigger); + + if (containsTrigger) { + result = true; + break; + } + } + + return result; + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/impl/CobolLineIndicatorProcessorImpl.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/impl/CobolLineIndicatorProcessorImpl.java new file mode 100644 index 0000000..6b33a97 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/rewriter/impl/CobolLineIndicatorProcessorImpl.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.rewriter.CobolLineIndicatorProcessor; + +public class CobolLineIndicatorProcessorImpl implements CobolLineIndicatorProcessor { + + protected String handleTrailingComma(final String contentArea) { + final String result; + + /* + * repair trimmed whitespace after comma separator + */ + if (contentArea.isEmpty()) { + result = contentArea; + } else { + final char lastCharAtTrimmedLineArea = contentArea.charAt(contentArea.length() - 1); + + if (lastCharAtTrimmedLineArea == ',' || lastCharAtTrimmedLineArea == ';') { + result = contentArea + CobolPreprocessor.WS; + } else { + result = contentArea; + } + } + + return result; + } + + /** + * Normalizes a line by stripping the sequence number and line indicator, + * and interpreting the line indicator. + */ + @Override + public CobolLine processLine(final CobolLine line) { + // trim trailing whitespace + final String trimmedTrailWsContentArea = line.getContentArea().replaceAll("\\s+$", ""); + + // handle trailing comma + final String handledContentArea = handleTrailingComma(trimmedTrailWsContentArea); + + final CobolLine result; + + switch (line.type) { + case DEBUG: + result = CobolLine.with(line, CobolPreprocessor.WS, handledContentArea); + break; + case CONTINUATION: + final String trimmedContentArea = handledContentArea.trim(); + final char firstCharOfContentArea = trimmedContentArea.charAt(0); + + switch (firstCharOfContentArea) { + case '\"': + case '\'': + result = CobolLine.with(line, CobolPreprocessor.WS, trimmedContentArea.substring(1)); + break; + default: + result = CobolLine.with(line, CobolPreprocessor.WS, trimmedContentArea); + break; + } + break; + case COMMENT: + result = CobolLine.with(line, CobolPreprocessor.COMMENT_TAG + CobolPreprocessor.WS, handledContentArea); + break; + case NORMAL: + default: + result = CobolLine.with(line, CobolPreprocessor.WS, handledContentArea); + break; + } + + return result; + } + + @Override + public List processLines(final List lines) { + final List result = new ArrayList(); + + for (final CobolLine line : lines) { + final CobolLine processedLine = processLine(line); + result.add(processedLine); + } + + return result; + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/writer/CobolLineWriter.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/writer/CobolLineWriter.java new file mode 100644 index 0000000..92e709b --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/writer/CobolLineWriter.java @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.writer; + +import java.util.List; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; + +public interface CobolLineWriter { + + String serialize(List lines); +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/writer/impl/CobolLineWriterImpl.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/writer/impl/CobolLineWriterImpl.java new file mode 100644 index 0000000..d561239 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/line/writer/impl/CobolLineWriterImpl.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.writer.impl; + +import java.util.List; + +import org.dxworks.codeframe.analyzer.cobol.preprocessor.CobolPreprocessor; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLine; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.CobolLineTypeEnum; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.line.writer.CobolLineWriter; + +public class CobolLineWriterImpl implements CobolLineWriter { + + @Override + public String serialize(final List lines) { + final StringBuffer sb = new StringBuffer(); + + for (final CobolLine line : lines) { + final boolean notContinuationLine = !CobolLineTypeEnum.CONTINUATION.equals(line.type); + + if (notContinuationLine) { + if (line.number > 0) { + sb.append(CobolPreprocessor.NEWLINE); + } + + sb.append(line.blankSequenceArea()); + sb.append(line.indicatorArea); + } + + sb.append(line.getContentArea()); + } + + return sb.toString(); + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/util/TokenUtils.java b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/util/TokenUtils.java new file mode 100644 index 0000000..dabdfc4 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/cobol/preprocessor/sub/util/TokenUtils.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2017, Ulrich Wolffgang + * All rights reserved. + * + * This software may be modified and distributed under the terms + * of the BSD 3-clause license. See the LICENSE file for details. + */ + +package org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.util; + +import java.util.List; + +import org.antlr.v4.runtime.BufferedTokenStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.ParseTree; +import org.antlr.v4.runtime.tree.ParseTreeWalker; +import org.antlr.v4.runtime.tree.TerminalNode; + +import org.dxworks.codeframe.analyzer.cobol.generated.Cobol85PreprocessorLexer; +import org.dxworks.codeframe.analyzer.cobol.preprocessor.sub.document.impl.CobolHiddenTokenCollectorListenerImpl; + +public class TokenUtils { + + public static String getHiddenTokensToLeft(final int tokPos, final BufferedTokenStream tokens) { + final List refChannel = tokens.getHiddenTokensToLeft(tokPos, Cobol85PreprocessorLexer.HIDDEN); + final StringBuffer sb = new StringBuffer(); + + if (refChannel != null) { + for (final Token refToken : refChannel) { + final String text = refToken.getText(); + sb.append(text); + } + } + + return sb.toString(); + } + + public static String getTextIncludingHiddenTokens(final ParseTree ctx, final BufferedTokenStream tokens) { + final CobolHiddenTokenCollectorListenerImpl listener = new CobolHiddenTokenCollectorListenerImpl(tokens); + final ParseTreeWalker walker = new ParseTreeWalker(); + walker.walk(listener, ctx); + + return listener.read(); + } + + public static boolean isEOF(final TerminalNode node) { + return Token.EOF == node.getSymbol().getType(); + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/AntlrRoutineBodyAnalyzer.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/AntlrRoutineBodyAnalyzer.java new file mode 100644 index 0000000..8fc5054 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/AntlrRoutineBodyAnalyzer.java @@ -0,0 +1,66 @@ +package org.dxworks.codeframe.analyzer.sql; + +import org.antlr.v4.runtime.tree.ParseTree; + +/** + * ANTLR-based routine body analyzer, parameterized by dialect. + * Replaces the structurally identical TSqlRoutineBodyAnalyzer and PlSqlRoutineBodyAnalyzer. + */ +final class AntlrRoutineBodyAnalyzer implements RoutineBodyAnalyzer { + + @FunctionalInterface + interface ParseAndExtract { + void execute(String body, ReferenceCollector target); + } + + private final ParseAndExtract strategy; + + private AntlrRoutineBodyAnalyzer(ParseAndExtract strategy) { + this.strategy = strategy; + } + + @Override + public Result analyze(String body, String dialectHint) { + Result result = new Result(); + + if (body == null || body.trim().isEmpty()) { + return result; + } + + try { + ReferenceCollector collector = new ReferenceCollector(); + strategy.execute(body, collector); + + result.relations.addAll(collector.getTableReferences()); + result.procedureCalls.addAll(collector.getProcedureCalls()); + result.functionCalls.addAll(collector.getFunctionCalls()); + + } catch (Exception e) { + // On parse error, return empty result (graceful degradation) + } + + return result; + } + + static AntlrRoutineBodyAnalyzer forTSql() { + return new AntlrRoutineBodyAnalyzer((body, collector) -> { + ParseTree tree = AntlrParserFactory.createTSqlParser(body).tsql_file(); + TSqlReferenceExtractor extractor = new TSqlReferenceExtractor(); + extractor.visit(tree); + collector.getTableReferences().addAll(extractor.getTableReferences()); + collector.getProcedureCalls().addAll(extractor.getProcedureCalls()); + collector.getFunctionCalls().addAll(extractor.getFunctionCalls()); + }); + } + + static AntlrRoutineBodyAnalyzer forPlSql() { + return new AntlrRoutineBodyAnalyzer((body, collector) -> { + ParseTree tree = AntlrParserFactory.createPlSqlParser(body).body(); + PlSqlReferenceExtractor extractor = new PlSqlReferenceExtractor(); + extractor.visit(tree); + collector.getTableReferences().addAll(extractor.getTableReferences()); + collector.getProcedureCalls().addAll(extractor.getProcedureCalls()); + collector.getFunctionCalls().addAll(extractor.getFunctionCalls()); + }); + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/DdlStatementHandler.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/DdlStatementHandler.java new file mode 100644 index 0000000..2b2e624 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/DdlStatementHandler.java @@ -0,0 +1,380 @@ +package org.dxworks.codeframe.analyzer.sql; + +import net.sf.jsqlparser.schema.Table; +import net.sf.jsqlparser.statement.Statement; +import net.sf.jsqlparser.statement.create.index.CreateIndex; +import net.sf.jsqlparser.statement.create.table.ColDataType; +import net.sf.jsqlparser.statement.create.table.ColumnDefinition; +import net.sf.jsqlparser.statement.create.table.CreateTable; +import net.sf.jsqlparser.statement.create.table.ForeignKeyIndex; +import net.sf.jsqlparser.statement.create.table.Index; +import net.sf.jsqlparser.statement.create.table.Index.ColumnParams; +import net.sf.jsqlparser.statement.create.view.AlterView; +import net.sf.jsqlparser.statement.create.view.CreateView; +import net.sf.jsqlparser.statement.alter.Alter; +import net.sf.jsqlparser.statement.alter.AlterExpression; +import net.sf.jsqlparser.statement.drop.Drop; +import org.dxworks.codeframe.model.sql.*; + +import java.util.ArrayList; +import java.util.List; + +/** + * Handles DDL statements parsed by JSqlParser: + * CREATE TABLE, CREATE VIEW, CREATE INDEX, ALTER TABLE, ALTER VIEW, DROP. + */ +final class DdlStatementHandler { + + DdlStatementHandler() { + } + + void handleCreateTable(CreateTable ct, SQLFileAnalysis out) { + CreateTableOperation op = new CreateTableOperation(); + Table t = ct.getTable(); + if (t != null) { + op.tableName = t.getName(); + op.schema = t.getSchemaName(); + } + // IF NOT EXISTS + op.ifNotExists = ct.isIfNotExists(); + + List cols = ct.getColumnDefinitions(); + if (cols != null) { + for (ColumnDefinition cd : cols) { + org.dxworks.codeframe.model.sql.ColumnDefinition m = new org.dxworks.codeframe.model.sql.ColumnDefinition(); + m.name = cd.getColumnName(); + m.type = toTypeString(cd.getColDataType()); + // constraints in columnSpecStrings + List specs = cd.getColumnSpecs(); + if (specs != null) { + List norm = normalize(specs); + if (containsSequence(norm, "not", "null")) { + m.nullable = false; + m.constraints.add("NOT NULL"); + } + if (norm.contains("unique")) { + m.constraints.add("UNIQUE"); + } + if (containsSequence(norm, "primary", "key")) { + m.constraints.add("PRIMARY KEY"); + if (!op.primaryKeys.contains(m.name)) op.primaryKeys.add(m.name); + } + } + op.columns.add(m); + } + } + + // Table-level indexes/constraints + List indexes = ct.getIndexes(); + if (indexes != null) { + for (Index idx : indexes) { + String type = idx.getType(); + if (type != null && type.equalsIgnoreCase("primary key")) { + for (String col : RoutineSqlUtils.safeList(idx.getColumnsNames())) { + if (!op.primaryKeys.contains(col)) op.primaryKeys.add(col); + } + } + if (idx instanceof ForeignKeyIndex) { + ForeignKeyIndex fkIdx = (ForeignKeyIndex) idx; + ForeignKeyDefinition fk = new ForeignKeyDefinition(); + fk.name = fkIdx.getName(); + fk.columns.addAll(RoutineSqlUtils.safeList(fkIdx.getColumnsNames())); + Table ref = fkIdx.getTable(); + if (ref != null) { + fk.referencedTable = RoutineSqlUtils.qualifyName(ref.getSchemaName(), ref.getName()); + } + fk.referencedColumns.addAll(RoutineSqlUtils.safeList(fkIdx.getReferencedColumnNames())); + // onDelete/onUpdate not extracted; leave null intentionally + op.foreignKeys.add(fk); + } + } + } + + out.createTables.add(op); + } + + void handleCreateView(CreateView cv, SQLFileAnalysis out) { + boolean isAlter = cv.isOrReplace(); + + if (isAlter) { + AlterViewOperation op = new AlterViewOperation(); + extractViewData(cv.getView(), cv.getSelect(), + (name) -> op.viewName = name, + (schema) -> op.schema = schema, + op.references.relations); + out.alterViews.add(op); + } else { + CreateViewOperation op = new CreateViewOperation(); + extractViewData(cv.getView(), cv.getSelect(), + (name) -> op.viewName = name, + (schema) -> op.schema = schema, + op.references.relations); + out.createViews.add(op); + } + } + + void handleAlterViewAst(AlterView av, SQLFileAnalysis out) { + AlterViewOperation op = new AlterViewOperation(); + extractViewData(av.getView(), av.getSelect(), + (name) -> op.viewName = name, + (schema) -> op.schema = schema, + op.references.relations); + out.alterViews.add(op); + } + + void handleCreateIndex(CreateIndex ci, SQLFileAnalysis out) { + CreateIndexOperation op = new CreateIndexOperation(); + if (ci.getIndex() != null) { + op.indexName = ci.getIndex().getName(); + + // Extract columns using the inner Index API (compatible with older versions) + List params = ci.getIndex().getColumns(); + if (params != null) { + for (ColumnParams cp : params) { + String name = cp.getColumnName(); + if (name != null && !name.isEmpty()) op.columns.add(name); + } + } + + // Uniqueness might be encoded in the type string + String t = ci.getIndex().getType(); + if (t != null && t.toUpperCase().contains("UNIQUE")) { + op.unique = true; + } + } + if (ci.getTable() != null) { + Table t = ci.getTable(); + op.tableName = t.getName(); + op.schema = t.getSchemaName(); + } + out.createIndexes.add(op); + } + + void handleAlter(Alter alter, SQLFileAnalysis out, String sourceCode) { + // Check if this is ALTER VIEW by examining the source text + // JSqlParser 5.3 uses Alter for both ALTER TABLE and ALTER VIEW + if (isAlterView(alter, sourceCode)) { + handleAlterView(alter, out); + return; + } + handleAlterTable(alter, out); + } + + void handleDrop(Drop drop, SQLFileAnalysis out) { + DropOperation op = new DropOperation(); + // Type + String t = drop.getType(); + op.objectType = t != null ? t.toUpperCase() : null; + // IF EXISTS + op.ifExists = drop.isIfExists(); + // Name and schema (JSqlParser models names as Table-like in most cases) + if (drop.getName() instanceof Table) { + Table tbl = (Table) drop.getName(); + op.objectName = tbl.getName(); + op.schema = tbl.getSchemaName(); + } else if (drop.getName() != null) { + // Fallback: use toString for name when not table-like + op.objectName = drop.getName().toString(); + } + if (op.objectName != null || op.objectType != null) out.dropOperations.add(op); + } + + // ---- View Extraction Helpers ---- + + private void extractViewData(Table view, Object select, + java.util.function.Consumer nameConsumer, + java.util.function.Consumer schemaConsumer, + java.util.Collection references) { + if (view != null) { + nameConsumer.accept(view.getName()); + schemaConsumer.accept(view.getSchemaName()); + } + + if (select != null) { + TableReferenceExtractor.extractTableReferences((Statement) select, references); + } + } + + // ---- ALTER helpers ---- + + private boolean isAlterView(Alter alter, String sourceCode) { + // If there's no table but the statement is ALTER, it might be ALTER VIEW + // Check the source text around the statement + if (alter.getTable() == null) { + return false; // Could be ALTER VIEW, but we need more context + } + // For now, check if the toString contains VIEW keyword + String alterStr = alter.toString().toUpperCase(); + boolean isView = alterStr.startsWith("ALTER VIEW") || alterStr.contains("ALTER VIEW"); + return isView; + } + + private void handleAlterView(Alter alter, SQLFileAnalysis out) { + // Legacy path: JSqlParser once modeled ALTER VIEW as Alter; keep minimal support + AlterViewOperation op = new AlterViewOperation(); + extractViewData(alter.getTable(), null, + (name) -> op.viewName = name, + (schema) -> op.schema = schema, + op.references.relations); + out.alterViews.add(op); + } + + private void handleAlterTable(Alter alter, SQLFileAnalysis out) { + AlterTableOperation op = new AlterTableOperation(); + if (alter.getTable() != null) { + Table t = alter.getTable(); + op.tableName = t.getName(); + op.schema = t.getSchemaName(); + } + + List exprs = alter.getAlterExpressions(); + if (exprs != null) { + for (AlterExpression ae : exprs) { + processAlterExpression(ae, op); + } + } + + if (op.operationType != null || !op.addedColumns.isEmpty() || !op.droppedColumns.isEmpty() || !op.addedConstraints.isEmpty() || !op.droppedConstraints.isEmpty()) { + out.alterTables.add(op); + } + } + + // ---- ALTER TABLE Expression Processing ---- + + private void processAlterExpression(AlterExpression ae, AlterTableOperation op) { + Object opObj = ae.getOperation(); + String opStr = opObj == null ? "" : opObj.toString(); + + if (opStr.equals("ADD") || opStr.equals("ADD_COLUMN") || opStr.equals("ADD_COLUMN_IF_NOT_EXISTS")) { + handleAddOperation(ae, op); + } else if (opStr.equals("DROP") || opStr.equals("DROP_COLUMN") || opStr.equals("DROP_COLUMN_IF_EXISTS")) { + handleDropColumnOperation(ae, op); + } else if (opStr.equals("ADD_CONSTRAINT")) { + handleAddConstraintOperation(ae, op); + } else if (opStr.equals("DROP_CONSTRAINT")) { + handleDropConstraintOperation(ae, op); + } + // Ignore other operations + } + + private void handleAddOperation(AlterExpression ae, AlterTableOperation op) { + // Check if this ADD is a constraint + if (tryAddConstraint(ae, op)) { + return; + } + + // Otherwise, handle ADD COLUMN + List cds = ae.getColDataTypeList(); + if (cds != null) { + for (AlterExpression.ColumnDataType cdt : cds) { + org.dxworks.codeframe.model.sql.ColumnDefinition cd = + new org.dxworks.codeframe.model.sql.ColumnDefinition(); + cd.name = cdt.getColumnName(); + cd.type = toTypeString(cdt.getColDataType()); + op.addedColumns.add(cd); + } + if (op.operationType == null) { + op.operationType = "ADD_COLUMN"; + } + } + } + + private boolean tryAddConstraint(AlterExpression ae, AlterTableOperation op) { + try { + Object idxObj = ae.getIndex(); + if (idxObj instanceof ForeignKeyIndex) { + String constraint = ConstraintBuilder.buildForeignKeyConstraint((ForeignKeyIndex) idxObj); + if (constraint != null) { + op.addedConstraints.add(constraint); + if (op.operationType == null) { + op.operationType = "ADD_CONSTRAINT"; + } + return true; + } + } else if (idxObj instanceof Index) { + Index idx = (Index) idxObj; + if (ConstraintBuilder.isPrimaryKey(idx)) { + String constraint = ConstraintBuilder.buildPrimaryKeyConstraint(idx); + if (constraint != null) { + op.addedConstraints.add(constraint); + if (op.operationType == null) { + op.operationType = "ADD_CONSTRAINT"; + } + return true; + } + } + } + } catch (Exception ignore) { + // Silently ignore parsing errors + } + return false; + } + + private void handleAddConstraintOperation(AlterExpression ae, AlterTableOperation op) { + tryAddConstraint(ae, op); + } + + private void handleDropColumnOperation(AlterExpression ae, AlterTableOperation op) { + String colName = extractColumnName(ae); + if (colName != null && !colName.isEmpty()) { + op.droppedColumns.add(RoutineSqlUtils.stripQuotes(colName)); + if (op.operationType == null) { + op.operationType = "DROP_COLUMN"; + } + } + } + + private void handleDropConstraintOperation(AlterExpression ae, AlterTableOperation op) { + String cname = ae.getConstraintName(); + if (cname != null && !cname.isEmpty()) { + op.droppedConstraints.add(RoutineSqlUtils.stripQuotes(cname)); + if (op.operationType == null) { + op.operationType = "DROP_CONSTRAINT"; + } + } + } + + private String extractColumnName(AlterExpression ae) { + try { + String colName = ae.getColumnName(); + if (colName != null) return colName; + } catch (Exception ignored) { + // Method might not exist or throw + } + + try { + return ae.getColOldName(); + } catch (Exception ignored) { + return null; + } + } + + // ---- Type/constraint helpers ---- + + static String toTypeString(ColDataType dt) { + if (dt == null) return null; + String base = dt.getDataType(); + List args = dt.getArgumentsStringList(); + String result; + if (args != null && !args.isEmpty()) { + result = base + "(" + String.join(",", args) + ")"; + } else { + result = base; + } + // Normalize to remove any extra spaces from JSqlParser output + return RoutineSqlUtils.normalizeTypeFormat(result); + } + + private static List normalize(List specs) { + List out = new ArrayList<>(); + for (String s : specs) out.add(s.toLowerCase()); + return out; + } + + private static boolean containsSequence(List items, String a, String b) { + for (int i = 0; i < items.size() - 1; i++) { + if (items.get(i).equals(a) && items.get(i + 1).equals(b)) return true; + } + return false; + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/DialectHeuristics.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/DialectHeuristics.java index ce3ff11..f728b0b 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/DialectHeuristics.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/DialectHeuristics.java @@ -3,6 +3,30 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * Heuristic detection of SQL dialects from source text. + * + *

Dialect detection priority ({@link #detectDialectFromSource}):

+ *
    + *
  1. tsql — {@code CREATE OR ALTER PROCEDURE/FUNCTION} (T-SQL specific syntax)
  2. + *
  3. tsql — standalone {@code GO} batch separator on its own line
  4. + *
  5. mysql — {@code DELIMITER $$} or {@code ENGINE=InnoDB}
  6. + *
  7. plsql — {@code CREATE OR REPLACE} without PL/pgSQL or MySQL markers
  8. + *
  9. plsql — {@code BEGIN} with trailing {@code /} line (Oracle convention)
  10. + *
  11. plpgsql — {@code LANGUAGE plpgsql} or non-MySQL {@code $$} quoting
  12. + *
  13. unknown — fallback
  14. + *
+ * + *

Body dialect hint priority ({@link #detectDialectHint}):

+ *
    + *
  1. plpgsql — {@code LANGUAGE plpgsql}
  2. + *
  3. mysql — MySQL keywords ({@code DETERMINISTIC}, {@code READS SQL DATA}, etc.)
  4. + *
  5. plpgsql — {@code $$} quoting
  6. + *
  7. tsql — {@code AS BEGIN}, {@code EXEC}, {@code EXECUTE}, {@code GO}
  8. + *
  9. mysql — {@code BEGIN} without T-SQL markers
  10. + *
  11. unknown — fallback
  12. + *
+ */ public final class DialectHeuristics { private DialectHeuristics() { diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlDefinitionExtractor.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlDefinitionExtractor.java index 60d0f8a..deb8c13 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlDefinitionExtractor.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlDefinitionExtractor.java @@ -44,7 +44,7 @@ public Void visitCreate_procedure_body(PlSqlParser.Create_procedure_bodyContext if (pd != null) op.parameters.add(pd); } } - analyzeBody(ctx.body(), op.references, op.calls); + analyzeBody(ctx.body(), op); procedures.add(op); return super.visitCreate_procedure_body(ctx); } @@ -63,7 +63,7 @@ public Void visitCreate_function_body(PlSqlParser.Create_function_bodyContext ct } } if (ctx.type_spec() != null) op.returnType = ctx.type_spec().getText(); - analyzeBody(ctx.body(), op.references, op.calls); + analyzeBody(ctx.body(), op); functions.add(op); return super.visitCreate_function_body(ctx); } @@ -116,7 +116,7 @@ public Void visitProcedure_body(PlSqlParser.Procedure_bodyContext ctx) { } } - analyzeBody(ctx.body(), op.references, op.calls); + analyzeBody(ctx.body(), op); procedures.add(op); return super.visitProcedure_body(ctx); @@ -146,20 +146,19 @@ public Void visitFunction_body(PlSqlParser.Function_bodyContext ctx) { if (ctx.type_spec() != null) op.returnType = ctx.type_spec().getText(); - analyzeBody(ctx.body(), op.references, op.calls); + analyzeBody(ctx.body(), op); functions.add(op); return super.visitFunction_body(ctx); } - private void analyzeBody(org.antlr.v4.runtime.tree.ParseTree ctx, SqlReferences references, - SqlInvocations calls) { - if (ctx == null || references == null || calls == null) return; + private void analyzeBody(org.antlr.v4.runtime.tree.ParseTree ctx, HasReferencesAndCalls op) { + if (ctx == null || op == null) return; PlSqlReferenceExtractor extractor = new PlSqlReferenceExtractor(); extractor.visit(ctx); - references.relations.addAll(extractor.getTableReferences()); - calls.functions.addAll(extractor.getFunctionCalls()); - calls.procedures.addAll(extractor.getProcedureCalls()); + op.getReferences().relations.addAll(extractor.getTableReferences()); + op.getCalls().functions.addAll(extractor.getFunctionCalls()); + op.getCalls().procedures.addAll(extractor.getProcedureCalls()); } private ParameterDefinition extractParameter(PlSqlParser.ParameterContext ctx) { @@ -256,7 +255,7 @@ else if (ctx.non_dml_trigger() != null) { } // Analyze trigger body for references/calls - analyzeBody(ctx.trigger_body(), op.references, op.calls); + analyzeBody(ctx.trigger_body(), op); triggers.add(op); return super.visitCreate_trigger(ctx); diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlReferenceExtractor.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlReferenceExtractor.java index c584528..5e4d7e7 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlReferenceExtractor.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlReferenceExtractor.java @@ -14,7 +14,7 @@ */ public class PlSqlReferenceExtractor extends PlSqlParserBaseVisitor { - private final BaseReferenceExtractor state = new BaseReferenceExtractor() {}; + private final ReferenceCollector state = new ReferenceCollector(); public Set getTableReferences() { return state.getTableReferences(); diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlRoutineBodyAnalyzer.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlRoutineBodyAnalyzer.java deleted file mode 100644 index 5bcfc30..0000000 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlRoutineBodyAnalyzer.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.dxworks.codeframe.analyzer.sql; - -import org.antlr.v4.runtime.tree.ParseTree; -import org.dxworks.codeframe.analyzer.sql.generated.PlSqlParser; - -public class PlSqlRoutineBodyAnalyzer implements RoutineBodyAnalyzer { - - @Override - public Result analyze(String body, String dialectHint) { - Result result = new Result(); - - if (body == null || body.trim().isEmpty()) { - return result; - } - - try { - PlSqlParser parser = AntlrParserFactory.createPlSqlParser(body); - // The body text passed from PlSqlDefinitionExtractor is a BEGIN...END block, - // which matches the 'body' rule in the grammar. - ParseTree tree = parser.body(); - - PlSqlReferenceExtractor extractor = new PlSqlReferenceExtractor(); - extractor.visit(tree); - - result.relations.addAll(extractor.getTableReferences()); - result.procedureCalls.addAll(extractor.getProcedureCalls()); - result.functionCalls.addAll(extractor.getFunctionCalls()); - - } catch (Exception e) { - // graceful degradation: return whatever we managed to collect so far - } - - return result; - } -} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlTopLevelCollector.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlTopLevelCollector.java index 33fe4aa..3285c42 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlTopLevelCollector.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/PlSqlTopLevelCollector.java @@ -11,7 +11,7 @@ */ public class PlSqlTopLevelCollector extends PlSqlParserBaseVisitor { - private final BaseReferenceExtractor state = new BaseReferenceExtractor() {}; + private final ReferenceCollector state = new ReferenceCollector(); public Set getTableReferences() { return state.getTableReferences(); diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/BaseReferenceExtractor.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/ReferenceCollector.java similarity index 87% rename from src/main/java/org/dxworks/codeframe/analyzer/sql/BaseReferenceExtractor.java rename to src/main/java/org/dxworks/codeframe/analyzer/sql/ReferenceCollector.java index 9f013f7..19167d1 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/BaseReferenceExtractor.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/ReferenceCollector.java @@ -4,10 +4,9 @@ import java.util.Set; /** - * Base class for ANTLR-based reference extractors. - * Provides shared state for collecting table references and routine calls. + * Collects table references and routine calls extracted by ANTLR-based visitors. */ -public abstract class BaseReferenceExtractor { +public class ReferenceCollector { protected final Set tableReferences = new HashSet<>(); protected final Set procedureCalls = new HashSet<>(); diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/RoutineAnalysisService.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/RoutineAnalysisService.java index c991c78..1c4c00a 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/RoutineAnalysisService.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/RoutineAnalysisService.java @@ -6,12 +6,9 @@ import org.dxworks.codeframe.model.sql.AlterProcedureOperation; import org.dxworks.codeframe.model.sql.CreateFunctionOperation; import org.dxworks.codeframe.model.sql.CreateProcedureOperation; -import org.dxworks.codeframe.model.sql.ParameterDefinition; import org.dxworks.codeframe.model.sql.SQLFileAnalysis; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; public class RoutineAnalysisService { @@ -31,7 +28,7 @@ public void handleCreateFunction(CreateFunction cf, SQLFileAnalysis out, String CreateFunctionOperation op = new CreateFunctionOperation(); String decl = cf.toString(); - RoutineSignature sig = parseRoutineSignature(decl, true); + RoutineSignatureParser.RoutineSignature sig = RoutineSignatureParser.parse(decl, true); if (sig != null) { op.functionName = sig.name; op.schema = sig.schema; @@ -68,7 +65,7 @@ public void handleCreateProcedure(CreateProcedure cp, SQLFileAnalysis out, Strin CreateProcedureOperation op = new CreateProcedureOperation(); String decl = cp.toString(); - RoutineSignature sig = parseRoutineSignature(decl, false); + RoutineSignatureParser.RoutineSignature sig = RoutineSignatureParser.parse(decl, false); if (sig != null) { op.procedureName = sig.name; op.schema = sig.schema; @@ -131,68 +128,4 @@ private RoutineBodyAnalyzer selectAnalyzer(String dialectHint) { return noopAnalyzer; } - private RoutineSignature parseRoutineSignature(String decl, boolean isFunction) { - if (decl == null) return null; - String s = decl.trim(); - - Pattern headPat = Pattern.compile("(?is)\\bcreate\\b\\s+(?:or\\s+replace\\s+)?" - + (isFunction ? "function" : "procedure") - + "\\s+([\\[\\]`\"\\w\\.]+)"); - Matcher m = headPat.matcher(s); - if (!m.find()) return null; - - RoutineSignature sig = new RoutineSignature(); - - String ident = m.group(1); - String[] sn = RoutineSqlUtils.splitSchemaAndName(ident); - sig.schema = sn[0]; - sig.name = sn[1]; - - int startParams = s.indexOf('(', m.end()); - if (startParams >= 0) { - int endParams = SqlRoutineTextUtils.findMatchingParen(s, startParams); - if (endParams > startParams) { - String paramsText = s.substring(startParams + 1, endParams).trim(); - if (!paramsText.isEmpty()) { - for (String p : SqlRoutineTextUtils.splitTopLevel(paramsText, ',')) { - String pt = p.trim(); - if (pt.isEmpty()) continue; - ParameterDefinition pd = new ParameterDefinition(); - - String lower = pt.toLowerCase(); - if (lower.startsWith("out ")) { pd.direction = "OUT"; pt = pt.substring(4).trim(); } - else if (lower.startsWith("inout ")) { pd.direction = "INOUT"; pt = pt.substring(6).trim(); } - else if (lower.startsWith("in out ")) { pd.direction = "INOUT"; pt = pt.substring(6).trim(); } - else if (lower.startsWith("in ")) { pd.direction = "IN"; pt = pt.substring(3).trim(); } - - String[] toks = pt.split("\\s+", 2); - if (toks.length >= 1) pd.name = RoutineSqlUtils.stripQuotes(toks[0]); - if (toks.length >= 2) pd.type = RoutineSqlUtils.normalizeTypeFormat(toks[1].trim()); - sig.parameters.add(pd); - } - } - } - } - - if (isFunction) { - Pattern retPat = Pattern.compile("(?is)\\breturns\\b\\s+([^\\s]+(?:\\s*\\([^\\)]*\\))?)"); - Matcher rm = retPat.matcher(s); - if (rm.find()) { - sig.returnType = RoutineSqlUtils.normalizeTypeFormat(rm.group(1).trim()); - } else { - Pattern ret2 = Pattern.compile("(?is)\\breturn\\b\\s+([^\\s]+(?:\\s*\\([^\\)]*\\))?)"); - Matcher rm2 = ret2.matcher(s); - if (rm2.find()) sig.returnType = RoutineSqlUtils.normalizeTypeFormat(rm2.group(1).trim()); - } - } - - return sig; - } - - private static class RoutineSignature { - String schema; - String name; - java.util.List parameters = new java.util.ArrayList<>(); - String returnType; - } } diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/RoutineSignatureParser.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/RoutineSignatureParser.java new file mode 100644 index 0000000..2dfacb7 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/RoutineSignatureParser.java @@ -0,0 +1,93 @@ +package org.dxworks.codeframe.analyzer.sql; + +import org.dxworks.codeframe.model.sql.ParameterDefinition; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Parses routine (function/procedure) signatures from SQL declaration text. + * Extracts name, schema, parameters, and return type. + */ +final class RoutineSignatureParser { + + private RoutineSignatureParser() { + // utility class + } + + static RoutineSignature parse(String decl, boolean isFunction) { + if (decl == null) return null; + String s = decl.trim(); + + Pattern headPat = Pattern.compile("(?is)\\bcreate\\b\\s+(?:or\\s+replace\\s+)?" + + (isFunction ? "function" : "procedure") + + "\\s+([\\[\\]`\"\\w\\.]+)"); + Matcher m = headPat.matcher(s); + if (!m.find()) return null; + + RoutineSignature sig = new RoutineSignature(); + + String ident = m.group(1); + String[] sn = RoutineSqlUtils.splitSchemaAndName(ident); + sig.schema = sn[0]; + sig.name = sn[1]; + + int startParams = s.indexOf('(', m.end()); + if (startParams >= 0) { + int endParams = SqlRoutineTextUtils.findMatchingParen(s, startParams); + if (endParams > startParams) { + String paramsText = s.substring(startParams + 1, endParams).trim(); + if (!paramsText.isEmpty()) { + for (String p : SqlRoutineTextUtils.splitTopLevel(paramsText, ',')) { + sig.parameters.add(parseParameter(p)); + } + } + } + } + + if (isFunction) { + sig.returnType = extractReturnType(s); + } + + return sig; + } + + private static ParameterDefinition parseParameter(String raw) { + String pt = raw.trim(); + ParameterDefinition pd = new ParameterDefinition(); + + String lower = pt.toLowerCase(); + if (lower.startsWith("out ")) { pd.direction = "OUT"; pt = pt.substring(4).trim(); } + else if (lower.startsWith("inout ")) { pd.direction = "INOUT"; pt = pt.substring(6).trim(); } + else if (lower.startsWith("in out ")) { pd.direction = "INOUT"; pt = pt.substring(6).trim(); } + else if (lower.startsWith("in ")) { pd.direction = "IN"; pt = pt.substring(3).trim(); } + + String[] toks = pt.split("\\s+", 2); + if (toks.length >= 1) pd.name = RoutineSqlUtils.stripQuotes(toks[0]); + if (toks.length >= 2) pd.type = RoutineSqlUtils.normalizeTypeFormat(toks[1].trim()); + return pd; + } + + private static String extractReturnType(String s) { + Pattern retPat = Pattern.compile("(?is)\\breturns\\b\\s+([^\\s]+(?:\\s*\\([^\\)]*\\))?)"); + Matcher rm = retPat.matcher(s); + if (rm.find()) { + return RoutineSqlUtils.normalizeTypeFormat(rm.group(1).trim()); + } + Pattern ret2 = Pattern.compile("(?is)\\breturn\\b\\s+([^\\s]+(?:\\s*\\([^\\)]*\\))?)"); + Matcher rm2 = ret2.matcher(s); + if (rm2.find()) { + return RoutineSqlUtils.normalizeTypeFormat(rm2.group(1).trim()); + } + return null; + } + + static class RoutineSignature { + String schema; + String name; + List parameters = new ArrayList<>(); + String returnType; + } +} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzer.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzer.java index be46111..8d41ac6 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzer.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzer.java @@ -1,22 +1,15 @@ package org.dxworks.codeframe.analyzer.sql; import net.sf.jsqlparser.parser.CCJSqlParserUtil; -import net.sf.jsqlparser.schema.Table; import net.sf.jsqlparser.statement.Statement; import net.sf.jsqlparser.statement.Statements; import net.sf.jsqlparser.statement.create.index.CreateIndex; import net.sf.jsqlparser.statement.create.function.CreateFunction; import net.sf.jsqlparser.statement.create.procedure.CreateProcedure; -import net.sf.jsqlparser.statement.create.table.ColDataType; -import net.sf.jsqlparser.statement.create.table.ColumnDefinition; import net.sf.jsqlparser.statement.create.table.CreateTable; -import net.sf.jsqlparser.statement.create.table.ForeignKeyIndex; -import net.sf.jsqlparser.statement.create.table.Index; -import net.sf.jsqlparser.statement.create.table.Index.ColumnParams; import net.sf.jsqlparser.statement.create.view.CreateView; import net.sf.jsqlparser.statement.create.view.AlterView; import net.sf.jsqlparser.statement.alter.Alter; -import net.sf.jsqlparser.statement.alter.AlterExpression; import net.sf.jsqlparser.statement.drop.Drop; import net.sf.jsqlparser.statement.execute.Execute; import org.dxworks.codeframe.analyzer.LanguageAnalyzer; @@ -25,20 +18,15 @@ import org.treesitter.TSNode; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class SQLAnalyzer implements LanguageAnalyzer { private final RoutineBodyAnalyzer noopAnalyzer = new NoopRoutineBodyAnalyzer(); - private final RoutineBodyAnalyzer tsqlAnalyzer = new TSqlRoutineBodyAnalyzer(); + private final RoutineBodyAnalyzer tsqlAnalyzer = AntlrRoutineBodyAnalyzer.forTSql(); private final RoutineBodyAnalyzer sqlRoutineAnalyzer = new SqlRoutineBodyAnalyzer(); private final RoutineAnalysisService routineAnalysisService = new RoutineAnalysisService(noopAnalyzer, tsqlAnalyzer, sqlRoutineAnalyzer); + private final DdlStatementHandler ddlHandler = new DdlStatementHandler(); + private final TriggerRegexExtractor triggerExtractor = new TriggerRegexExtractor(sqlRoutineAnalyzer); @Override public Analysis analyze(String filePath, String sourceCode, TSNode rootNode) { @@ -72,7 +60,7 @@ public Analysis analyze(String filePath, String sourceCode, TSNode rootNode) { return parseWithAntlr(filePath, sourceCode, dialect); } // For other dialects (PostgreSQL, MySQL), try regex-based trigger extraction - extractTriggersFromSource(sourceCode, out); + triggerExtractor.extractTriggersFromSource(sourceCode, out); return out; } @@ -80,17 +68,17 @@ public Analysis analyze(String filePath, String sourceCode, TSNode rootNode) { if (st == null) continue; if (st instanceof CreateTable) { - handleCreateTable((CreateTable) st, out); + ddlHandler.handleCreateTable((CreateTable) st, out); } else if (st instanceof CreateView) { - handleCreateView((CreateView) st, out); + ddlHandler.handleCreateView((CreateView) st, out); } else if (st instanceof AlterView) { - handleAlterViewAst((AlterView) st, out); + ddlHandler.handleAlterViewAst((AlterView) st, out); } else if (st instanceof CreateIndex) { - handleCreateIndex((CreateIndex) st, out); + ddlHandler.handleCreateIndex((CreateIndex) st, out); } else if (st instanceof Alter) { - handleAlter((Alter) st, out, sourceCode); + ddlHandler.handleAlter((Alter) st, out, sourceCode); } else if (st instanceof Drop) { - handleDrop((Drop) st, out); + ddlHandler.handleDrop((Drop) st, out); } else if (st instanceof CreateFunction) { routineAnalysisService.handleCreateFunction((CreateFunction) st, out, sourceCode); } else if (st instanceof CreateProcedure) { @@ -101,7 +89,7 @@ public Analysis analyze(String filePath, String sourceCode, TSNode rootNode) { } // Fallback: Extract triggers using regex (JSqlParser doesn't support CREATE TRIGGER) - extractTriggersFromSource(sourceCode, out); + triggerExtractor.extractTriggersFromSource(sourceCode, out); return out; } @@ -121,204 +109,7 @@ private void handleTopLevelStatement(Statement st, SQLFileAnalysis out) { } // Function calls: traverse expressions - collectFunctionsTopLevel(st, out.topLevelCalls.functions); - } - - private void collectFunctionsTopLevel(Statement st, java.util.Collection sink) { - ExpressionAnalyzer.collectFunctions(st, sink); - } - - private void handleDrop(Drop drop, SQLFileAnalysis out) { - DropOperation op = new DropOperation(); - // Type - String t = drop.getType(); - op.objectType = t != null ? t.toUpperCase() : null; - // IF EXISTS - op.ifExists = drop.isIfExists(); - // Name and schema (JSqlParser models names as Table-like in most cases) - if (drop.getName() instanceof Table) { - Table tbl = (Table) drop.getName(); - op.objectName = tbl.getName(); - op.schema = tbl.getSchemaName(); - } else if (drop.getName() != null) { - // Fallback: use toString for name when not table-like - op.objectName = drop.getName().toString(); - } - if (op.objectName != null || op.objectType != null) out.dropOperations.add(op); - } - - private void handleAlter(Alter alter, SQLFileAnalysis out, String sourceCode) { - // Check if this is ALTER VIEW by examining the source text - // JSqlParser 5.3 uses Alter for both ALTER TABLE and ALTER VIEW - if (isAlterView(alter, sourceCode)) { - handleAlterView(alter, out); - return; - } - handleAlterTable(alter, out); - } - - private boolean isAlterView(Alter alter, String sourceCode) { - // If there's no table but the statement is ALTER, it might be ALTER VIEW - // Check the source text around the statement - if (alter.getTable() == null) { - return false; // Could be ALTER VIEW, but we need more context - } - // For now, check if the toString contains VIEW keyword - String alterStr = alter.toString().toUpperCase(); - boolean isView = alterStr.startsWith("ALTER VIEW") || alterStr.contains("ALTER VIEW"); - return isView; - } - - private void handleAlterView(Alter alter, SQLFileAnalysis out) { - // Legacy path: JSqlParser once modeled ALTER VIEW as Alter; keep minimal support - AlterViewOperation op = new AlterViewOperation(); - extractViewData(alter.getTable(), null, - (name) -> op.viewName = name, - (schema) -> op.schema = schema, - op.references.relations); - out.alterViews.add(op); - } - - private void handleAlterViewAst(AlterView av, SQLFileAnalysis out) { - AlterViewOperation op = new AlterViewOperation(); - extractViewData(av.getView(), av.getSelect(), - (name) -> op.viewName = name, - (schema) -> op.schema = schema, - op.references.relations); - out.alterViews.add(op); - } - - private void handleAlterTable(Alter alter, SQLFileAnalysis out) { - AlterTableOperation op = new AlterTableOperation(); - if (alter.getTable() != null) { - Table t = alter.getTable(); - op.tableName = t.getName(); - op.schema = t.getSchemaName(); - } - - List exprs = alter.getAlterExpressions(); - if (exprs != null) { - for (AlterExpression ae : exprs) { - processAlterExpression(ae, op); - } - } - - if (op.operationType != null || !op.addedColumns.isEmpty() || !op.droppedColumns.isEmpty() || !op.addedConstraints.isEmpty() || !op.droppedConstraints.isEmpty()) { - out.alterTables.add(op); - } - } - - private void handleCreateTable(CreateTable ct, SQLFileAnalysis out) { - CreateTableOperation op = new CreateTableOperation(); - Table t = ct.getTable(); - if (t != null) { - op.tableName = t.getName(); - op.schema = t.getSchemaName(); - } - // IF NOT EXISTS - op.ifNotExists = ct.isIfNotExists(); - - List cols = ct.getColumnDefinitions(); - if (cols != null) { - for (ColumnDefinition cd : cols) { - org.dxworks.codeframe.model.sql.ColumnDefinition m = new org.dxworks.codeframe.model.sql.ColumnDefinition(); - m.name = cd.getColumnName(); - m.type = toTypeString(cd.getColDataType()); - // constraints in columnSpecStrings - List specs = cd.getColumnSpecs(); - if (specs != null) { - List norm = normalize(specs); - if (containsSequence(norm, "not", "null")) { - m.nullable = false; - m.constraints.add("NOT NULL"); - } - if (norm.contains("unique")) { - m.constraints.add("UNIQUE"); - } - if (containsSequence(norm, "primary", "key")) { - m.constraints.add("PRIMARY KEY"); - if (!op.primaryKeys.contains(m.name)) op.primaryKeys.add(m.name); - } - } - op.columns.add(m); - } - } - - // Table-level indexes/constraints - List indexes = ct.getIndexes(); - if (indexes != null) { - for (Index idx : indexes) { - String type = idx.getType(); - if (type != null && type.equalsIgnoreCase("primary key")) { - for (String col : RoutineSqlUtils.safeList(idx.getColumnsNames())) { - if (!op.primaryKeys.contains(col)) op.primaryKeys.add(col); - } - } - if (idx instanceof ForeignKeyIndex) { - ForeignKeyIndex fkIdx = (ForeignKeyIndex) idx; - ForeignKeyDefinition fk = new ForeignKeyDefinition(); - fk.name = fkIdx.getName(); - fk.columns.addAll(RoutineSqlUtils.safeList(fkIdx.getColumnsNames())); - Table ref = fkIdx.getTable(); - if (ref != null) { - fk.referencedTable = RoutineSqlUtils.qualifyName(ref.getSchemaName(), ref.getName()); - } - fk.referencedColumns.addAll(RoutineSqlUtils.safeList(fkIdx.getReferencedColumnNames())); - // onDelete/onUpdate not extracted; leave null intentionally - op.foreignKeys.add(fk); - } - } - } - - out.createTables.add(op); - } - - private void handleCreateView(CreateView cv, SQLFileAnalysis out) { - boolean isAlter = cv.isOrReplace(); - - if (isAlter) { - AlterViewOperation op = new AlterViewOperation(); - extractViewData(cv.getView(), cv.getSelect(), - (name) -> op.viewName = name, - (schema) -> op.schema = schema, - op.references.relations); - out.alterViews.add(op); - } else { - CreateViewOperation op = new CreateViewOperation(); - extractViewData(cv.getView(), cv.getSelect(), - (name) -> op.viewName = name, - (schema) -> op.schema = schema, - op.references.relations); - out.createViews.add(op); - } - } - - private void handleCreateIndex(CreateIndex ci, SQLFileAnalysis out) { - CreateIndexOperation op = new CreateIndexOperation(); - if (ci.getIndex() != null) { - op.indexName = ci.getIndex().getName(); - - // Extract columns using the inner Index API (compatible with older versions) - List params = ci.getIndex().getColumns(); - if (params != null) { - for (ColumnParams cp : params) { - String name = cp.getColumnName(); - if (name != null && !name.isEmpty()) op.columns.add(name); - } - } - - // Uniqueness might be encoded in the type string - String t = ci.getIndex().getType(); - if (t != null && t.toUpperCase().contains("UNIQUE")) { - op.unique = true; - } - } - if (ci.getTable() != null) { - Table t = ci.getTable(); - op.tableName = t.getName(); - op.schema = t.getSchemaName(); - } - out.createIndexes.add(op); + ExpressionAnalyzer.collectFunctions(st, out.topLevelCalls.functions); } // ---------- Helpers ---------- @@ -375,312 +166,4 @@ private Analysis parseWithAntlr(String filePath, String sourceCode, String diale return out; } - - private static String toTypeString(ColDataType dt) { - if (dt == null) return null; - String base = dt.getDataType(); - List args = dt.getArgumentsStringList(); - String result; - if (args != null && !args.isEmpty()) { - result = base + "(" + String.join(",", args) + ")"; - } else { - result = base; - } - // Normalize to remove any extra spaces from JSqlParser output - return RoutineSqlUtils.normalizeTypeFormat(result); - } - - private static List normalize(List specs) { - List out = new ArrayList<>(); - for (String s : specs) out.add(s.toLowerCase()); - return out; - } - - private static boolean containsSequence(List items, String a, String b) { - for (int i = 0; i < items.size() - 1; i++) { - if (items.get(i).equals(a) && items.get(i + 1).equals(b)) return true; - } - return false; - } - - - // ---- View Extraction Helpers ---- - - private void extractViewData(Table view, Object select, - java.util.function.Consumer nameConsumer, - java.util.function.Consumer schemaConsumer, - java.util.Collection references) { - if (view != null) { - nameConsumer.accept(view.getName()); - schemaConsumer.accept(view.getSchemaName()); - } - - if (select != null) { - TableReferenceExtractor.extractTableReferences((Statement) select, references); - } - } - - // ---- ALTER TABLE Expression Processing ---- - - private void processAlterExpression(AlterExpression ae, AlterTableOperation op) { - Object opObj = ae.getOperation(); - String opStr = opObj == null ? "" : opObj.toString(); - - if (opStr.equals("ADD") || opStr.equals("ADD_COLUMN") || opStr.equals("ADD_COLUMN_IF_NOT_EXISTS")) { - handleAddOperation(ae, op); - } else if (opStr.equals("DROP") || opStr.equals("DROP_COLUMN") || opStr.equals("DROP_COLUMN_IF_EXISTS")) { - handleDropColumnOperation(ae, op); - } else if (opStr.equals("ADD_CONSTRAINT")) { - handleAddConstraintOperation(ae, op); - } else if (opStr.equals("DROP_CONSTRAINT")) { - handleDropConstraintOperation(ae, op); - } - // Ignore other operations - } - - private void handleAddOperation(AlterExpression ae, AlterTableOperation op) { - // Check if this ADD is a constraint - if (tryAddConstraint(ae, op)) { - return; - } - - // Otherwise, handle ADD COLUMN - List cds = ae.getColDataTypeList(); - if (cds != null) { - for (AlterExpression.ColumnDataType cdt : cds) { - org.dxworks.codeframe.model.sql.ColumnDefinition cd = - new org.dxworks.codeframe.model.sql.ColumnDefinition(); - cd.name = cdt.getColumnName(); - cd.type = toTypeString(cdt.getColDataType()); - op.addedColumns.add(cd); - } - if (op.operationType == null) { - op.operationType = "ADD_COLUMN"; - } - } - } - - private boolean tryAddConstraint(AlterExpression ae, AlterTableOperation op) { - try { - Object idxObj = ae.getIndex(); - if (idxObj instanceof ForeignKeyIndex) { - String constraint = ConstraintBuilder.buildForeignKeyConstraint((ForeignKeyIndex) idxObj); - if (constraint != null) { - op.addedConstraints.add(constraint); - if (op.operationType == null) { - op.operationType = "ADD_CONSTRAINT"; - } - return true; - } - } else if (idxObj instanceof Index) { - Index idx = (Index) idxObj; - if (ConstraintBuilder.isPrimaryKey(idx)) { - String constraint = ConstraintBuilder.buildPrimaryKeyConstraint(idx); - if (constraint != null) { - op.addedConstraints.add(constraint); - if (op.operationType == null) { - op.operationType = "ADD_CONSTRAINT"; - } - return true; - } - } - } - } catch (Exception ignore) { - // Silently ignore parsing errors - } - return false; - } - - private void handleAddConstraintOperation(AlterExpression ae, AlterTableOperation op) { - tryAddConstraint(ae, op); - } - - private void handleDropColumnOperation(AlterExpression ae, AlterTableOperation op) { - String colName = extractColumnName(ae); - if (colName != null && !colName.isEmpty()) { - op.droppedColumns.add(RoutineSqlUtils.stripQuotes(colName)); - if (op.operationType == null) { - op.operationType = "DROP_COLUMN"; - } - } - } - - private void handleDropConstraintOperation(AlterExpression ae, AlterTableOperation op) { - String cname = ae.getConstraintName(); - if (cname != null && !cname.isEmpty()) { - op.droppedConstraints.add(RoutineSqlUtils.stripQuotes(cname)); - if (op.operationType == null) { - op.operationType = "DROP_CONSTRAINT"; - } - } - } - - private String extractColumnName(AlterExpression ae) { - try { - String colName = ae.getColumnName(); - if (colName != null) return colName; - } catch (Exception ignored) { - // Method might not exist or throw - } - - try { - return ae.getColOldName(); - } catch (Exception ignored) { - return null; - } - } - - // ---- Trigger extraction (regex fallback for PostgreSQL/MySQL) ---- - // JSqlParser doesn't support CREATE TRIGGER, so we use regex-based extraction - - private static final String SQL_IDENTIFIER = "[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*)?"; - private static final String DML_EVENTS = "INSERT|UPDATE|DELETE"; - - // PostgreSQL: CREATE [OR REPLACE] TRIGGER name timing events ON table ... EXECUTE FUNCTION/PROCEDURE - // Requires EXECUTE FUNCTION/PROCEDURE to distinguish from MySQL - private static final Pattern POSTGRES_TRIGGER_PATTERN = Pattern.compile( - "CREATE\\s+(OR\\s+REPLACE\\s+)?TRIGGER\\s+(" + SQL_IDENTIFIER + ")\\s+" + - "(BEFORE|AFTER|INSTEAD\\s+OF)\\s+" + - "((?:" + DML_EVENTS + ")(?:\\s+OR\\s+(?:" + DML_EVENTS + "))*)\\s+" + - "ON\\s+(" + SQL_IDENTIFIER + ")\\s+" + - "(?:FOR\\s+EACH\\s+(?:ROW|STATEMENT)\\s+)?EXECUTE\\s+(?:FUNCTION|PROCEDURE)", - Pattern.CASE_INSENSITIVE | Pattern.DOTALL - ); - - // MySQL: CREATE TRIGGER name timing event ON table (single event, no OR REPLACE) - private static final Pattern MYSQL_TRIGGER_PATTERN = Pattern.compile( - "CREATE\\s+TRIGGER\\s+(" + SQL_IDENTIFIER + ")\\s+" + - "(BEFORE|AFTER)\\s+(" + DML_EVENTS + ")\\s+" + - "ON\\s+(" + SQL_IDENTIFIER + ")", - Pattern.CASE_INSENSITIVE - ); - - // PostgreSQL EXECUTE FUNCTION/PROCEDURE clause - private static final Pattern EXECUTE_PATTERN = Pattern.compile( - "EXECUTE\\s+(FUNCTION|PROCEDURE)\\s+(" + SQL_IDENTIFIER + ")\\s*\\([^)]*\\)", - Pattern.CASE_INSENSITIVE - ); - - // MySQL body patterns - private static final Pattern MYSQL_END_DOLLAR_PATTERN = Pattern.compile( - "\\bEND\\s*\\$\\$", Pattern.CASE_INSENSITIVE); - private static final Pattern MYSQL_BEGIN_END_SEMI_PATTERN = Pattern.compile( - "BEGIN\\s+(.+?)\\bEND\\s*;\\s*(?=\\n|$)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); - private static final Pattern MYSQL_SINGLE_STMT_PATTERN = Pattern.compile( - "FOR\\s+EACH\\s+ROW\\s+(?!BEGIN)(.+?)(?:;|\\$\\$|$)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); - - private void extractTriggersFromSource(String sourceCode, SQLFileAnalysis out) { - if (sourceCode == null || sourceCode.isEmpty()) return; - - Set matchedPositions = new HashSet<>(); - extractPostgresTriggers(sourceCode, out, matchedPositions); - extractMySqlTriggers(sourceCode, out, matchedPositions); - } - - private void extractPostgresTriggers(String sourceCode, SQLFileAnalysis out, Set matchedPositions) { - Matcher matcher = POSTGRES_TRIGGER_PATTERN.matcher(sourceCode); - while (matcher.find()) { - matchedPositions.add(matcher.start()); - - CreateTriggerOperation op = new CreateTriggerOperation(); - op.orReplace = matcher.group(1) != null; - setSchemaAndName(op, matcher.group(2)); - op.timing = normalizeTiming(matcher.group(3)); - extractEvents(matcher.group(4), op.events); - op.tableName = matcher.group(5); - - extractPostgresExecuteCall(sourceCode.substring(matcher.start()), op); - out.createTriggers.add(op); - } - } - - private void extractMySqlTriggers(String sourceCode, SQLFileAnalysis out, Set matchedPositions) { - Matcher matcher = MYSQL_TRIGGER_PATTERN.matcher(sourceCode); - while (matcher.find()) { - if (matchedPositions.contains(matcher.start())) continue; - - CreateTriggerOperation op = new CreateTriggerOperation(); - op.orReplace = false; - setSchemaAndName(op, matcher.group(1)); - op.timing = matcher.group(2).toUpperCase(); - op.events.add(matcher.group(3).toUpperCase()); - op.tableName = matcher.group(4); - - analyzeMySqlTriggerBody(sourceCode.substring(matcher.start()), op); - out.createTriggers.add(op); - } - } - - private void setSchemaAndName(CreateTriggerOperation op, String fullName) { - String[] parts = RoutineSqlUtils.splitSchemaAndName(fullName); - op.schema = parts[0]; - op.triggerName = parts[1]; - } - - private String normalizeTiming(String timing) { - if (timing == null) return null; - String normalized = timing.toUpperCase().replaceAll("\\s+", " ").trim(); - return normalized.contains("INSTEAD") ? "INSTEAD OF" : normalized; - } - - private void extractEvents(String eventsClause, List events) { - if (eventsClause == null) return; - Matcher matcher = Pattern.compile(DML_EVENTS, Pattern.CASE_INSENSITIVE).matcher(eventsClause); - while (matcher.find()) { - events.add(matcher.group().toUpperCase()); - } - } - - private void extractPostgresExecuteCall(String triggerText, CreateTriggerOperation op) { - Matcher matcher = EXECUTE_PATTERN.matcher(triggerText); - if (matcher.find()) { - String keyword = matcher.group(1).toUpperCase(); - String name = matcher.group(2); - if ("FUNCTION".equals(keyword)) { - op.calls.functions.add(name); - } else { - op.calls.procedures.add(name); - } - } - } - - private void analyzeMySqlTriggerBody(String triggerText, CreateTriggerOperation op) { - String body = extractMySqlTriggerBody(triggerText); - if (body == null || body.isEmpty()) return; - - RoutineBodyAnalyzer.Result result = sqlRoutineAnalyzer.analyze(body, "mysql"); - if (result != null) { - if (result.relations != null) op.references.relations.addAll(result.relations); - if (result.functionCalls != null) op.calls.functions.addAll(result.functionCalls); - if (result.procedureCalls != null) op.calls.procedures.addAll(result.procedureCalls); - } - } - - private String extractMySqlTriggerBody(String triggerText) { - // Try BEGIN...END$$ (custom delimiter) - String body = extractBeginEndDollarBody(triggerText); - if (body != null) return body; - - // Try BEGIN...END; (standard delimiter) - Matcher semiMatcher = MYSQL_BEGIN_END_SEMI_PATTERN.matcher(triggerText); - if (semiMatcher.find()) return semiMatcher.group(1); - - // Try single statement (no BEGIN...END) - Matcher singleMatcher = MYSQL_SINGLE_STMT_PATTERN.matcher(triggerText); - if (singleMatcher.find()) return singleMatcher.group(1); - - return null; - } - - private String extractBeginEndDollarBody(String text) { - int beginIdx = text.toUpperCase().indexOf("BEGIN"); - if (beginIdx < 0) return null; - - Matcher endMatcher = MYSQL_END_DOLLAR_PATTERN.matcher(text); - if (!endMatcher.find(beginIdx)) return null; - - int bodyStart = beginIdx + "BEGIN".length(); - int bodyEnd = endMatcher.start(); - return bodyEnd > bodyStart ? text.substring(bodyStart, bodyEnd).trim() : null; - } } diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/SqlRoutineBodyAnalyzer.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/SqlRoutineBodyAnalyzer.java index 030f234..6465c6d 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/SqlRoutineBodyAnalyzer.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/SqlRoutineBodyAnalyzer.java @@ -60,7 +60,7 @@ private static String extractCallName(Statement st) { * Aggressive simplification for PostgreSQL routine bodies. * Goal: Strip all procedural logic, keep only data access statements (SELECT/INSERT/UPDATE/DELETE/CALL). * This allows JSqlParser to extract table references and function/procedure calls. - * Package-private for use by UnifiedTSqlRoutineBodyAnalyzer. + * Package-private for use by AntlrRoutineBodyAnalyzer. */ static String preprocessPostgreSQL(String body) { if (body == null) return null; @@ -144,7 +144,7 @@ static String preprocessPostgreSQL(String body) { /** * Aggressive simplification for MySQL routine bodies. * Goal: Strip all procedural logic, keep only data access statements. - * Package-private for use by UnifiedTSqlRoutineBodyAnalyzer. + * Package-private for use by AntlrRoutineBodyAnalyzer. */ static String preprocessMySql(String body) { if (body == null) return null; @@ -270,33 +270,15 @@ private static String extractSelectFromExists(String trimmed, String upper) { if (existsIdx < 0) return null; // Find closing paren of EXISTS clause (start searching after "EXISTS") - int endIdx = findMatchingParen(trimmed, existsIdx + "EXISTS".length()); + int openParen = trimmed.indexOf('(', existsIdx + "EXISTS".length()); + if (openParen < 0) return null; + int endIdx = SqlRoutineTextUtils.findMatchingParen(trimmed, openParen); if (endIdx <= selectIdx) return null; String innerSelect = trimmed.substring(selectIdx, endIdx).trim(); return innerSelect.endsWith(";") ? innerSelect : innerSelect + ";"; } - /** - * Finds the position of the closing parenthesis matching the opening paren after startIdx. - * Returns -1 if not found. - */ - private static int findMatchingParen(String s, int startIdx) { - if (startIdx < 0 || startIdx >= s.length()) return -1; - int openIdx = s.indexOf('(', startIdx); - if (openIdx < 0) return -1; - - int depth = 1; - for (int i = openIdx + 1; i < s.length(); i++) { - char c = s.charAt(i); - if (c == '(') depth++; - else if (c == ')') { - depth--; - if (depth == 0) return i; - } - } - return -1; - } private static String stripBeginEnd(String s) { String t = s.trim(); diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlDefinitionExtractor.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlDefinitionExtractor.java index 1c326a2..74b16dd 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlDefinitionExtractor.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlDefinitionExtractor.java @@ -17,7 +17,7 @@ public class TSqlDefinitionExtractor extends TSqlParserBaseVisitor { private final List procedures = new ArrayList<>(); private final List functions = new ArrayList<>(); private final List triggers = new ArrayList<>(); - private final TSqlRoutineBodyAnalyzer bodyAnalyzer = new TSqlRoutineBodyAnalyzer(); + private final RoutineBodyAnalyzer bodyAnalyzer = AntlrRoutineBodyAnalyzer.forTSql(); public TSqlDefinitionExtractor(String sourceCode, org.antlr.v4.runtime.CommonTokenStream tokens) { this.sourceCode = sourceCode; @@ -149,31 +149,13 @@ private ParameterDefinition extractParameter(TSqlParser.Procedure_paramContext c return pd; } - private void analyzeBody(String body, CreateProcedureOperation op) { + private void analyzeBody(String body, HasReferencesAndCalls op) { if (body == null || body.isEmpty()) return; RoutineBodyAnalyzer.Result result = bodyAnalyzer.analyze(body, "tsql"); if (result == null) return; - if (result.relations != null) op.references.relations.addAll(result.relations); - if (result.functionCalls != null) op.calls.functions.addAll(result.functionCalls); - if (result.procedureCalls != null) op.calls.procedures.addAll(result.procedureCalls); - } - - private void analyzeBody(String body, CreateFunctionOperation op) { - if (body == null || body.isEmpty()) return; - RoutineBodyAnalyzer.Result result = bodyAnalyzer.analyze(body, "tsql"); - if (result == null) return; - if (result.relations != null) op.references.relations.addAll(result.relations); - if (result.functionCalls != null) op.calls.functions.addAll(result.functionCalls); - if (result.procedureCalls != null) op.calls.procedures.addAll(result.procedureCalls); - } - - private void analyzeBody(String body, CreateTriggerOperation op) { - if (body == null || body.isEmpty()) return; - RoutineBodyAnalyzer.Result result = bodyAnalyzer.analyze(body, "tsql"); - if (result == null) return; - if (result.relations != null) op.references.relations.addAll(result.relations); - if (result.functionCalls != null) op.calls.functions.addAll(result.functionCalls); - if (result.procedureCalls != null) op.calls.procedures.addAll(result.procedureCalls); + if (result.relations != null) op.getReferences().relations.addAll(result.relations); + if (result.functionCalls != null) op.getCalls().functions.addAll(result.functionCalls); + if (result.procedureCalls != null) op.getCalls().procedures.addAll(result.procedureCalls); } private String extractProcedureBody(TSqlParser.Create_or_alter_procedureContext ctx) { diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlReferenceExtractor.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlReferenceExtractor.java index ce90f00..32cdf37 100644 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlReferenceExtractor.java +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlReferenceExtractor.java @@ -8,7 +8,7 @@ */ public class TSqlReferenceExtractor extends TSqlParserBaseVisitor { - private final BaseReferenceExtractor state = new BaseReferenceExtractor() {}; + private final ReferenceCollector state = new ReferenceCollector(); public java.util.Set getTableReferences() { return state.getTableReferences(); diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlRoutineBodyAnalyzer.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlRoutineBodyAnalyzer.java deleted file mode 100644 index 1fc57a4..0000000 --- a/src/main/java/org/dxworks/codeframe/analyzer/sql/TSqlRoutineBodyAnalyzer.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.dxworks.codeframe.analyzer.sql; - -import org.antlr.v4.runtime.tree.ParseTree; -import org.dxworks.codeframe.analyzer.sql.generated.TSqlParser; - -public class TSqlRoutineBodyAnalyzer implements RoutineBodyAnalyzer { - - @Override - public Result analyze(String body, String dialectHint) { - Result result = new Result(); - - if (body == null || body.trim().isEmpty()) { - return result; - } - - try { - TSqlParser parser = AntlrParserFactory.createTSqlParser(body); - ParseTree tree = parser.tsql_file(); - - // Walk the tree to extract references and calls - TSqlReferenceExtractor extractor = new TSqlReferenceExtractor(); - extractor.visit(tree); - - result.relations.addAll(extractor.getTableReferences()); - result.procedureCalls.addAll(extractor.getProcedureCalls()); - result.functionCalls.addAll(extractor.getFunctionCalls()); - - } catch (Exception e) { - // On parse error, return empty result (graceful degradation) - } - - return result; - } -} diff --git a/src/main/java/org/dxworks/codeframe/analyzer/sql/TriggerRegexExtractor.java b/src/main/java/org/dxworks/codeframe/analyzer/sql/TriggerRegexExtractor.java new file mode 100644 index 0000000..8fbc13e --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/analyzer/sql/TriggerRegexExtractor.java @@ -0,0 +1,174 @@ +package org.dxworks.codeframe.analyzer.sql; + +import org.dxworks.codeframe.model.sql.CreateTriggerOperation; +import org.dxworks.codeframe.model.sql.SQLFileAnalysis; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Regex-based trigger extraction for PostgreSQL and MySQL. + * JSqlParser doesn't support CREATE TRIGGER, so we use regex as a fallback. + */ +final class TriggerRegexExtractor { + + private static final String SQL_IDENTIFIER = "[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*)?"; + private static final String DML_EVENTS = "INSERT|UPDATE|DELETE"; + + // PostgreSQL: CREATE [OR REPLACE] TRIGGER name timing events ON table ... EXECUTE FUNCTION/PROCEDURE + // Requires EXECUTE FUNCTION/PROCEDURE to distinguish from MySQL + private static final Pattern POSTGRES_TRIGGER_PATTERN = Pattern.compile( + "CREATE\\s+(OR\\s+REPLACE\\s+)?TRIGGER\\s+(" + SQL_IDENTIFIER + ")\\s+" + + "(BEFORE|AFTER|INSTEAD\\s+OF)\\s+" + + "((?:" + DML_EVENTS + ")(?:\\s+OR\\s+(?:" + DML_EVENTS + "))*)\\s+" + + "ON\\s+(" + SQL_IDENTIFIER + ")\\s+" + + "(?:FOR\\s+EACH\\s+(?:ROW|STATEMENT)\\s+)?EXECUTE\\s+(?:FUNCTION|PROCEDURE)", + Pattern.CASE_INSENSITIVE | Pattern.DOTALL + ); + + // MySQL: CREATE TRIGGER name timing event ON table (single event, no OR REPLACE) + private static final Pattern MYSQL_TRIGGER_PATTERN = Pattern.compile( + "CREATE\\s+TRIGGER\\s+(" + SQL_IDENTIFIER + ")\\s+" + + "(BEFORE|AFTER)\\s+(" + DML_EVENTS + ")\\s+" + + "ON\\s+(" + SQL_IDENTIFIER + ")", + Pattern.CASE_INSENSITIVE + ); + + // PostgreSQL EXECUTE FUNCTION/PROCEDURE clause + private static final Pattern EXECUTE_PATTERN = Pattern.compile( + "EXECUTE\\s+(FUNCTION|PROCEDURE)\\s+(" + SQL_IDENTIFIER + ")\\s*\\([^)]*\\)", + Pattern.CASE_INSENSITIVE + ); + + // MySQL body patterns + private static final Pattern MYSQL_END_DOLLAR_PATTERN = Pattern.compile( + "\\bEND\\s*\\$\\$", Pattern.CASE_INSENSITIVE); + private static final Pattern MYSQL_BEGIN_END_SEMI_PATTERN = Pattern.compile( + "BEGIN\\s+(.+?)\\bEND\\s*;\\s*(?=\\n|$)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); + private static final Pattern MYSQL_SINGLE_STMT_PATTERN = Pattern.compile( + "FOR\\s+EACH\\s+ROW\\s+(?!BEGIN)(.+?)(?:;|\\$\\$|$)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); + + private final RoutineBodyAnalyzer bodyAnalyzer; + + TriggerRegexExtractor(RoutineBodyAnalyzer bodyAnalyzer) { + this.bodyAnalyzer = bodyAnalyzer; + } + + void extractTriggersFromSource(String sourceCode, SQLFileAnalysis out) { + if (sourceCode == null || sourceCode.isEmpty()) return; + + Set matchedPositions = new HashSet<>(); + extractPostgresTriggers(sourceCode, out, matchedPositions); + extractMySqlTriggers(sourceCode, out, matchedPositions); + } + + private void extractPostgresTriggers(String sourceCode, SQLFileAnalysis out, Set matchedPositions) { + Matcher matcher = POSTGRES_TRIGGER_PATTERN.matcher(sourceCode); + while (matcher.find()) { + matchedPositions.add(matcher.start()); + + CreateTriggerOperation op = new CreateTriggerOperation(); + op.orReplace = matcher.group(1) != null; + setSchemaAndName(op, matcher.group(2)); + op.timing = normalizeTiming(matcher.group(3)); + extractEvents(matcher.group(4), op.events); + op.tableName = matcher.group(5); + + extractPostgresExecuteCall(sourceCode.substring(matcher.start()), op); + out.createTriggers.add(op); + } + } + + private void extractMySqlTriggers(String sourceCode, SQLFileAnalysis out, Set matchedPositions) { + Matcher matcher = MYSQL_TRIGGER_PATTERN.matcher(sourceCode); + while (matcher.find()) { + if (matchedPositions.contains(matcher.start())) continue; + + CreateTriggerOperation op = new CreateTriggerOperation(); + op.orReplace = false; + setSchemaAndName(op, matcher.group(1)); + op.timing = matcher.group(2).toUpperCase(); + op.events.add(matcher.group(3).toUpperCase()); + op.tableName = matcher.group(4); + + analyzeMySqlTriggerBody(sourceCode.substring(matcher.start()), op); + out.createTriggers.add(op); + } + } + + private void setSchemaAndName(CreateTriggerOperation op, String fullName) { + String[] parts = RoutineSqlUtils.splitSchemaAndName(fullName); + op.schema = parts[0]; + op.triggerName = parts[1]; + } + + private String normalizeTiming(String timing) { + if (timing == null) return null; + String normalized = timing.toUpperCase().replaceAll("\\s+", " ").trim(); + return normalized.contains("INSTEAD") ? "INSTEAD OF" : normalized; + } + + private void extractEvents(String eventsClause, List events) { + if (eventsClause == null) return; + Matcher matcher = Pattern.compile(DML_EVENTS, Pattern.CASE_INSENSITIVE).matcher(eventsClause); + while (matcher.find()) { + events.add(matcher.group().toUpperCase()); + } + } + + private void extractPostgresExecuteCall(String triggerText, CreateTriggerOperation op) { + Matcher matcher = EXECUTE_PATTERN.matcher(triggerText); + if (matcher.find()) { + String keyword = matcher.group(1).toUpperCase(); + String name = matcher.group(2); + if ("FUNCTION".equals(keyword)) { + op.calls.functions.add(name); + } else { + op.calls.procedures.add(name); + } + } + } + + private void analyzeMySqlTriggerBody(String triggerText, CreateTriggerOperation op) { + String body = extractMySqlTriggerBody(triggerText); + if (body == null || body.isEmpty()) return; + + RoutineBodyAnalyzer.Result result = bodyAnalyzer.analyze(body, "mysql"); + if (result != null) { + if (result.relations != null) op.references.relations.addAll(result.relations); + if (result.functionCalls != null) op.calls.functions.addAll(result.functionCalls); + if (result.procedureCalls != null) op.calls.procedures.addAll(result.procedureCalls); + } + } + + private String extractMySqlTriggerBody(String triggerText) { + // Try BEGIN...END$$ (custom delimiter) + String body = extractBeginEndDollarBody(triggerText); + if (body != null) return body; + + // Try BEGIN...END; (standard delimiter) + Matcher semiMatcher = MYSQL_BEGIN_END_SEMI_PATTERN.matcher(triggerText); + if (semiMatcher.find()) return semiMatcher.group(1); + + // Try single statement (no BEGIN...END) + Matcher singleMatcher = MYSQL_SINGLE_STMT_PATTERN.matcher(triggerText); + if (singleMatcher.find()) return singleMatcher.group(1); + + return null; + } + + private String extractBeginEndDollarBody(String text) { + int beginIdx = text.toUpperCase().indexOf("BEGIN"); + if (beginIdx < 0) return null; + + Matcher endMatcher = MYSQL_END_DOLLAR_PATTERN.matcher(text); + if (!endMatcher.find(beginIdx)) return null; + + int bodyStart = beginIdx + "BEGIN".length(); + int bodyEnd = endMatcher.start(); + return bodyEnd > bodyStart ? text.substring(bodyStart, bodyEnd).trim() : null; + } +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLControlFlowStatement.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLControlFlowStatement.java new file mode 100644 index 0000000..93befa2 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLControlFlowStatement.java @@ -0,0 +1,6 @@ +package org.dxworks.codeframe.model.cobol; + +public class COBOLControlFlowStatement { + public String type; // "GOBACK", "STOP_RUN", "EXIT_PROGRAM", "RETURN" + public String target; // nullable string for statements that carry a target +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLDataItem.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLDataItem.java new file mode 100644 index 0000000..c928136 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLDataItem.java @@ -0,0 +1,15 @@ +package org.dxworks.codeframe.model.cobol; + +import java.util.ArrayList; +import java.util.List; + +public class COBOLDataItem { + public String name; + public int level; + public String picture; + public String section; + public String usage; + public String redefines; + public Integer occurs; + public List children = new ArrayList<>(); +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLExternalCall.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLExternalCall.java new file mode 100644 index 0000000..b813ce5 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLExternalCall.java @@ -0,0 +1,7 @@ +package org.dxworks.codeframe.model.cobol; + +public class COBOLExternalCall { + public String programName; + public boolean isDynamic; + public Integer parameterCount; +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileAnalysis.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileAnalysis.java new file mode 100644 index 0000000..90ae6cb --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileAnalysis.java @@ -0,0 +1,35 @@ +package org.dxworks.codeframe.model.cobol; + +import org.dxworks.codeframe.model.Analysis; + +import java.util.ArrayList; +import java.util.List; + +public class COBOLFileAnalysis implements Analysis { + public String filePath; + public String language = "cobol"; + public String programId; + + public List fileControls = new ArrayList<>(); + public List dataItems = new ArrayList<>(); + public List fileDefinitions = new ArrayList<>(); + public List copyStatements = new ArrayList<>(); + public List procedureParameters = new ArrayList<>(); + + public List sections = new ArrayList<>(); + public List paragraphs = new ArrayList<>(); + + public boolean hasExecSql; + public boolean hasExecCics; + public boolean hasExecSqlIms; + + @Override + public String getFilePath() { + return filePath; + } + + @Override + public String getLanguage() { + return language; + } +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileControl.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileControl.java new file mode 100644 index 0000000..5c84ebe --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileControl.java @@ -0,0 +1,8 @@ +package org.dxworks.codeframe.model.cobol; + +public class COBOLFileControl { + public String name; + public String organization; + public String accessMode; + public boolean hasKey; +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileDefinition.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileDefinition.java new file mode 100644 index 0000000..7ed5280 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileDefinition.java @@ -0,0 +1,9 @@ +package org.dxworks.codeframe.model.cobol; + +import java.util.ArrayList; +import java.util.List; + +public class COBOLFileDefinition { + public String name; + public List records = new ArrayList<>(); +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileOperation.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileOperation.java new file mode 100644 index 0000000..8591f34 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLFileOperation.java @@ -0,0 +1,6 @@ +package org.dxworks.codeframe.model.cobol; + +public class COBOLFileOperation { + public String verb; + public String target; +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLParagraph.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLParagraph.java new file mode 100644 index 0000000..3a81585 --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLParagraph.java @@ -0,0 +1,15 @@ +package org.dxworks.codeframe.model.cobol; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +public class COBOLParagraph { + public String name; + public List performCalls = new ArrayList<>(); + public List externalCalls = new ArrayList<>(); + public List fileOperations = new ArrayList<>(); + public List controlFlowStatements = new ArrayList<>(); + public Set dataReferences = new LinkedHashSet<>(); +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLPerformCall.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLPerformCall.java new file mode 100644 index 0000000..de18dac --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLPerformCall.java @@ -0,0 +1,6 @@ +package org.dxworks.codeframe.model.cobol; + +public class COBOLPerformCall { + public String targetParagraph; + public String thruParagraph; +} diff --git a/src/main/java/org/dxworks/codeframe/model/cobol/COBOLSection.java b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLSection.java new file mode 100644 index 0000000..bd1578a --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/cobol/COBOLSection.java @@ -0,0 +1,9 @@ +package org.dxworks.codeframe.model.cobol; + +import java.util.ArrayList; +import java.util.List; + +public class COBOLSection { + public String name; + public List paragraphs = new ArrayList<>(); +} diff --git a/src/main/java/org/dxworks/codeframe/model/sql/CreateFunctionOperation.java b/src/main/java/org/dxworks/codeframe/model/sql/CreateFunctionOperation.java index 7ea6b4c..aa6f383 100644 --- a/src/main/java/org/dxworks/codeframe/model/sql/CreateFunctionOperation.java +++ b/src/main/java/org/dxworks/codeframe/model/sql/CreateFunctionOperation.java @@ -1,6 +1,6 @@ package org.dxworks.codeframe.model.sql; -public class CreateFunctionOperation { +public class CreateFunctionOperation implements HasReferencesAndCalls { public String functionName; public String schema; // optional public boolean orReplace; // CREATE OR REPLACE FUNCTION @@ -8,4 +8,7 @@ public class CreateFunctionOperation { public String returnType; public SqlReferences references = new SqlReferences(); public SqlInvocations calls = new SqlInvocations(); + + @Override public SqlReferences getReferences() { return references; } + @Override public SqlInvocations getCalls() { return calls; } } diff --git a/src/main/java/org/dxworks/codeframe/model/sql/CreateProcedureOperation.java b/src/main/java/org/dxworks/codeframe/model/sql/CreateProcedureOperation.java index cfe8564..c9d21d9 100644 --- a/src/main/java/org/dxworks/codeframe/model/sql/CreateProcedureOperation.java +++ b/src/main/java/org/dxworks/codeframe/model/sql/CreateProcedureOperation.java @@ -1,10 +1,13 @@ package org.dxworks.codeframe.model.sql; -public class CreateProcedureOperation { +public class CreateProcedureOperation implements HasReferencesAndCalls { public String procedureName; public String schema; // optional public boolean orReplace; // CREATE OR REPLACE PROCEDURE public java.util.List parameters = new java.util.ArrayList<>(); public SqlReferences references = new SqlReferences(); public SqlInvocations calls = new SqlInvocations(); + + @Override public SqlReferences getReferences() { return references; } + @Override public SqlInvocations getCalls() { return calls; } } diff --git a/src/main/java/org/dxworks/codeframe/model/sql/CreateTriggerOperation.java b/src/main/java/org/dxworks/codeframe/model/sql/CreateTriggerOperation.java index bcf70ca..ddacd71 100644 --- a/src/main/java/org/dxworks/codeframe/model/sql/CreateTriggerOperation.java +++ b/src/main/java/org/dxworks/codeframe/model/sql/CreateTriggerOperation.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -public class CreateTriggerOperation { +public class CreateTriggerOperation implements HasReferencesAndCalls { public String triggerName; public String tableName; public String schema; // optional @@ -12,4 +12,7 @@ public class CreateTriggerOperation { public List events = new ArrayList<>(); // INSERT, UPDATE, DELETE (can be multiple) public SqlReferences references = new SqlReferences(); // tables/views accessed in body public SqlInvocations calls = new SqlInvocations(); // functions/procedures called in body + + @Override public SqlReferences getReferences() { return references; } + @Override public SqlInvocations getCalls() { return calls; } } diff --git a/src/main/java/org/dxworks/codeframe/model/sql/HasReferencesAndCalls.java b/src/main/java/org/dxworks/codeframe/model/sql/HasReferencesAndCalls.java new file mode 100644 index 0000000..7d0500e --- /dev/null +++ b/src/main/java/org/dxworks/codeframe/model/sql/HasReferencesAndCalls.java @@ -0,0 +1,10 @@ +package org.dxworks.codeframe.model.sql; + +/** + * Shared contract for SQL operations that carry references (table/view names) + * and calls (function/procedure invocations) extracted from their body. + */ +public interface HasReferencesAndCalls { + SqlReferences getReferences(); + SqlInvocations getCalls(); +} diff --git a/src/test/java/org/dxworks/codeframe/TestUtils.java b/src/test/java/org/dxworks/codeframe/TestUtils.java new file mode 100644 index 0000000..5cfb0c2 --- /dev/null +++ b/src/test/java/org/dxworks/codeframe/TestUtils.java @@ -0,0 +1,12 @@ +package org.dxworks.codeframe; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.annotation.JsonInclude; + +public class TestUtils { + public static final ObjectMapper APPROVAL_MAPPER = new ObjectMapper() + .enable(SerializationFeature.INDENT_OUTPUT) + .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS) + .setSerializationInclusion(JsonInclude.Include.NON_EMPTY); +} diff --git a/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_BasicProgram.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_BasicProgram.approved.txt new file mode 100644 index 0000000..3bdec9c --- /dev/null +++ b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_BasicProgram.approved.txt @@ -0,0 +1,149 @@ +{ + "filePath" : "src/test/resources/samples/cobol/basic-program.cbl", + "language" : "cobol", + "programId" : "HELLO-WORLD", + "dataItems" : [ { + "name" : "WS-NAME", + "level" : 1, + "picture" : "X(20)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-TABLE", + "level" : 1, + "section" : "WORKING-STORAGE", + "children" : [ { + "name" : "WS-ROW", + "level" : 5, + "section" : "WORKING-STORAGE", + "occurs" : 10, + "children" : [ { + "name" : "WS-COL", + "level" : 10, + "picture" : "9(3)", + "section" : "WORKING-STORAGE", + "occurs" : 5 + } ] + } ] + }, { + "name" : "WS-INDEX1", + "level" : 1, + "picture" : "9(2)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-INDEX2", + "level" : 1, + "picture" : "9(2)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-FIRST-NAME", + "level" : 1, + "picture" : "X(15)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-MIDDLE-NAME", + "level" : 1, + "picture" : "X(15)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-LAST-NAME", + "level" : 1, + "picture" : "X(20)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-FULL-NAME", + "level" : 1, + "picture" : "X(50)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-STATUS-CODE", + "level" : 1, + "picture" : "9", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-UNSTRING-FIRST", + "level" : 1, + "picture" : "X(15)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-UNSTRING-MIDDLE", + "level" : 1, + "picture" : "X(15)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-UNSTRING-LAST", + "level" : 1, + "picture" : "X(20)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-UNSTRING-SOURCE", + "level" : 1, + "picture" : "X(50)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-CORR-RECORD-1", + "level" : 1, + "section" : "WORKING-STORAGE", + "children" : [ { + "name" : "WS-CORR-FIELD-1-1", + "level" : 5, + "picture" : "9(5)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-CORR-FIELD-1-2", + "level" : 5, + "picture" : "X(10)", + "section" : "WORKING-STORAGE" + } ] + }, { + "name" : "WS-CORR-RECORD-2", + "level" : 1, + "section" : "WORKING-STORAGE", + "children" : [ { + "name" : "WS-CORR-FIELD-2-1", + "level" : 5, + "picture" : "9(5)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-CORR-FIELD-2-2", + "level" : 5, + "picture" : "X(10)", + "section" : "WORKING-STORAGE" + } ] + }, { + "name" : "WS-TRANSACTION-TABLE", + "level" : 1, + "section" : "WORKING-STORAGE", + "children" : [ { + "name" : "WS-TRAN-REC", + "level" : 5, + "section" : "WORKING-STORAGE", + "occurs" : 100, + "children" : [ { + "name" : "WS-TRAN-ID", + "level" : 10, + "picture" : "9(5)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-TRAN-AMT", + "level" : 10, + "picture" : "9(8)V99", + "section" : "WORKING-STORAGE" + } ] + } ] + }, { + "name" : "WS-TRAN-COUNTER", + "level" : 1, + "picture" : "9(3)", + "section" : "WORKING-STORAGE" + } ], + "paragraphs" : [ { + "name" : "1000-MAIN", + "controlFlowStatements" : [ { + "type" : "STOP_RUN" + } ], + "dataReferences" : [ "WS-NAME", "WS-INDEX1", "WS-INDEX2", "WS-COL(WS-INDEX1, WS-INDEX2)", "WS-FULL-NAME", "WS-FIRST-NAME", "WS-MIDDLE-NAME", "WS-LAST-NAME", "WS-UNSTRING-SOURCE", "WS-UNSTRING-FIRST", "WS-UNSTRING-MIDDLE", "WS-UNSTRING-LAS", "WS-CORR-RECORD-1", "WS-CORR-RECORD-2", "WS-STATUS-CODE", "WS-TRANSACTION-TABLE", "WS-TRAN-COUNTER" ] + } ], + "hasExecSql" : false, + "hasExecCics" : false, + "hasExecSqlIms" : false +} \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_CopybookExpansion.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_CopybookExpansion.approved.txt new file mode 100644 index 0000000..b7a34da --- /dev/null +++ b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_CopybookExpansion.approved.txt @@ -0,0 +1,73 @@ +{ + "filePath" : "src/test/resources/samples/cobol/copybook-test.cbl", + "language" : "cobol", + "programId" : "COPYBOOK-TEST", + "dataItems" : [ { + "name" : "SIMPLE-RECORD", + "level" : 1, + "section" : "WORKING-STORAGE", + "children" : [ { + "name" : "FIELD-1", + "level" : 5, + "picture" : "9(5)", + "section" : "WORKING-STORAGE" + }, { + "name" : "FIELD-2", + "level" : 5, + "picture" : "X(10)", + "section" : "WORKING-STORAGE" + } ] + }, { + "name" : "FUNCTION-PARAMETERS", + "level" : 1, + "section" : "WORKING-STORAGE", + "children" : [ { + "name" : "FUNC-INPUT", + "level" : 5, + "picture" : "X(20)", + "section" : "WORKING-STORAGE" + }, { + "name" : "FUNC-OUTPUT", + "level" : 5, + "picture" : "X(20)", + "section" : "WORKING-STORAGE" + }, { + "name" : "FUNC-RESULT", + "level" : 5, + "picture" : "9(3)", + "section" : "WORKING-STORAGE" + } ] + }, { + "name" : "FUNCTION-ERRORS", + "level" : 1, + "section" : "WORKING-STORAGE", + "children" : [ { + "name" : "ERROR-CODE", + "level" : 5, + "picture" : "9(2)", + "section" : "WORKING-STORAGE" + } ] + }, { + "name" : "WS-RESULT", + "level" : 1, + "picture" : "9(5)", + "section" : "WORKING-STORAGE" + } ], + "copyStatements" : [ "SIMPLE", "PROCEDURES" ], + "sections" : [ { + "name" : "PROCESS-STRING", + "paragraphs" : [ { + "name" : "PROCESS-STRING-PARAGRAPH", + "dataReferences" : [ "FUNC-OUTPUT", "ERROR-CODE" ] + } ] + }, { + "name" : "CALCULATE-SUM", + "paragraphs" : [ { + "name" : "CALCULATE-SUM-PARAGRAPH", + "dataReferences" : [ "FUNC-RESULT", "ERROR-CODE" ] + } ] + } ], + "hasExecSql" : false, + "hasExecCics" : false, + "hasExecSqlIms" : false +} \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_FileOperations.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_FileOperations.approved.txt new file mode 100644 index 0000000..66f55be --- /dev/null +++ b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_FileOperations.approved.txt @@ -0,0 +1,272 @@ +{ + "filePath" : "src/test/resources/samples/cobol/file-operations.cbl", + "language" : "cobol", + "programId" : "FILEOPS-DEMO", + "fileControls" : [ { + "name" : "CUSTOMER-FILE", + "organization" : "SEQUENTIAL", + "accessMode" : "SEQUENTIAL", + "hasKey" : false + }, { + "name" : "TRANSACTION-FILE", + "organization" : "INDEXED", + "accessMode" : "DYNAMIC", + "hasKey" : true + }, { + "name" : "REPORT-FILE", + "organization" : "SEQUENTIAL", + "accessMode" : "SEQUENTIAL", + "hasKey" : false + } ], + "dataItems" : [ { + "name" : "WS-EOF-FLAG", + "level" : 1, + "picture" : "X", + "section" : "WORKING-STORAGE", + "children" : [ { + "name" : "END-OF-FILE", + "level" : 88, + "section" : "WORKING-STORAGE" + } ] + }, { + "name" : "WS-RECORD-COUNT", + "level" : 1, + "picture" : "9(5)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-COUNT", + "level" : 1, + "picture" : "9(5)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-INPUT", + "level" : 1, + "picture" : "X(10)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-OUTPUT", + "level" : 1, + "picture" : "X(10)", + "section" : "WORKING-STORAGE" + } ], + "fileDefinitions" : [ { + "name" : "CUSTOMER-FILE", + "records" : [ { + "name" : "CUSTOMER-HEADER-RECORD", + "level" : 1, + "section" : "FILE SECTION", + "children" : [ { + "name" : "RECORD-TYPE", + "level" : 5, + "picture" : "X(1)" + }, { + "name" : "HEADER-DATE", + "level" : 5, + "picture" : "X(8)" + }, { + "name" : "RECORD-COUNT", + "level" : 5, + "picture" : "9(5)" + } ] + }, { + "name" : "CUSTOMER-DETAIL-RECORD", + "level" : 1, + "section" : "FILE SECTION", + "children" : [ { + "name" : "RECORD-TYPE", + "level" : 5, + "picture" : "X(1)" + }, { + "name" : "CUST-ID", + "level" : 5, + "picture" : "X(10)" + }, { + "name" : "CUST-NAME", + "level" : 5, + "picture" : "X(50)" + }, { + "name" : "CUST-ADDRESS", + "level" : 5, + "picture" : "X(100)" + } ] + }, { + "name" : "CUSTOMER-TRAILER-RECORD", + "level" : 1, + "section" : "FILE SECTION", + "children" : [ { + "name" : "RECORD-TYPE", + "level" : 5, + "picture" : "X(1)" + }, { + "name" : "TRAILER-COUNT", + "level" : 5, + "picture" : "9(5)" + } ] + } ] + }, { + "name" : "TRANSACTION-FILE", + "records" : [ { + "name" : "TRANSACTION-RECORD", + "level" : 1, + "section" : "FILE SECTION", + "children" : [ { + "name" : "TRNX-ID", + "level" : 5, + "picture" : "X(15)" + }, { + "name" : "TRNX-AMOUNT", + "level" : 5, + "picture" : "9(9)V99" + }, { + "name" : "TRNX-DATE", + "level" : 5, + "picture" : "X(8)" + } ] + }, { + "name" : "TRANSACTION-HEADER-RECORD", + "level" : 1, + "section" : "FILE SECTION", + "children" : [ { + "name" : "RECORD-TYPE", + "level" : 5, + "picture" : "X(1)" + }, { + "name" : "BATCH-NUMBER", + "level" : 5, + "picture" : "9(5)" + }, { + "name" : "BATCH-DATE", + "level" : 5, + "picture" : "X(8)" + } ] + } ] + }, { + "name" : "REPORT-FILE", + "records" : [ { + "name" : "REPORT-HEADER-RECORD", + "level" : 1, + "section" : "FILE SECTION", + "children" : [ { + "name" : "REPORT-TITLE", + "level" : 5, + "picture" : "X(50)" + }, { + "name" : "REPORT-DATE", + "level" : 5, + "picture" : "X(8)" + }, { + "name" : "PAGE-NUMBER", + "level" : 5, + "picture" : "9(5)" + } ] + }, { + "name" : "REPORT-DETAIL-RECORD", + "level" : 1, + "section" : "FILE SECTION", + "children" : [ { + "name" : "LINE-TYPE", + "level" : 5, + "picture" : "X(1)" + }, { + "name" : "LINE-TEXT", + "level" : 5, + "picture" : "X(132)" + } ] + } ] + } ], + "paragraphs" : [ { + "name" : "1000-MAINLINE", + "performCalls" : [ { + "targetParagraph" : "2000-OPEN-FILES" + }, { + "targetParagraph" : "3000-PROCESS-FILES" + }, { + "targetParagraph" : "9000-CLOSE-FILES" + } ], + "controlFlowStatements" : [ { + "type" : "STOP_RUN" + } ] + }, { + "name" : "2000-OPEN-FILES", + "fileOperations" : [ { + "verb" : "OPEN", + "target" : "CUSTOMER-FILE" + }, { + "verb" : "OPEN", + "target" : "TRANSACTION-FILE" + }, { + "verb" : "OPEN", + "target" : "REPORT-FILE" + } ] + }, { + "name" : "3000-PROCESS-FILES", + "performCalls" : [ { + "targetParagraph" : "3100-READ-CUSTOMER" + }, { + "targetParagraph" : "3200-UPDATE-TRANSACTIONS" + }, { + "targetParagraph" : "3300-DELETE-OLD-RECORDS" + }, { + "targetParagraph" : "3400-START-AT-KEY" + }, { + "targetParagraph" : "3500-WRITE-REPORTS" + }, { + "targetParagraph" : "3600-DATA-REFERENCES" + } ] + }, { + "name" : "3100-READ-CUSTOMER", + "fileOperations" : [ { + "verb" : "READ", + "target" : "CUSTOMER-FILE" + } ], + "dataReferences" : [ "WS-EOF-FLAG" ] + }, { + "name" : "3200-UPDATE-TRANSACTIONS", + "fileOperations" : [ { + "verb" : "REWRITE", + "target" : "TRANSACTION-RECORD" + } ] + }, { + "name" : "3300-DELETE-OLD-RECORDS", + "fileOperations" : [ { + "verb" : "DELETE", + "target" : "TRANSACTION-FILE" + } ] + }, { + "name" : "3400-START-AT-KEY", + "fileOperations" : [ { + "verb" : "START", + "target" : "TRANSACTION-FILE" + } ] + }, { + "name" : "3500-WRITE-REPORTS", + "fileOperations" : [ { + "verb" : "WRITE", + "target" : "REPORT-RECORD" + } ], + "dataReferences" : [ "WS-RECORD-COUNT" ] + }, { + "name" : "3600-DATA-REFERENCES", + "externalCalls" : [ { + "programName" : "SUBPROGRAM", + "isDynamic" : false, + "parameterCount" : 2 + } ], + "dataReferences" : [ "WS-RECORD-COUNT", "END-OF-FILE", "WS-COUNT", "WS-RECORD-COUNT-ADD", "WS-RECORD-COUNT-SUB", "WS-RECORD-COUNT-MUL", "WS-RECORD-COUNT-DIV", "WS-INPUT", "WS-OUTPUT" ] + }, { + "name" : "9000-CLOSE-FILES", + "fileOperations" : [ { + "verb" : "CLOSE", + "target" : "CUSTOMER-FILE" + }, { + "verb" : "CLOSE", + "target" : "TRANSACTION-FILE" + }, { + "verb" : "CLOSE", + "target" : "REPORT-FILE" + } ] + } ], + "hasExecSql" : false, + "hasExecCics" : false, + "hasExecSqlIms" : false +} \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_ProcedurePrologue.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_ProcedurePrologue.approved.txt new file mode 100644 index 0000000..3326fb2 --- /dev/null +++ b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_ProcedurePrologue.approved.txt @@ -0,0 +1,28 @@ +{ + "filePath" : "src/test/resources/samples/cobol/procedure-prologue.cbl", + "language" : "cobol", + "programId" : "PROLOGUE-DEMO", + "dataItems" : [ { + "name" : "WS-NAME", + "level" : 1, + "picture" : "X(8)", + "section" : "WORKING-STORAGE" + } ], + "paragraphs" : [ { + "name" : "__PROCEDURE_DIVISION_PROLOGUE__", + "externalCalls" : [ { + "programName" : "SUBPROG", + "isDynamic" : false, + "parameterCount" : 1 + } ], + "dataReferences" : [ "WS-NAME" ] + }, { + "name" : "MAIN-PARA", + "controlFlowStatements" : [ { + "type" : "GOBACK" + } ] + } ], + "hasExecSql" : false, + "hasExecCics" : false, + "hasExecSqlIms" : false +} \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_Sections.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_Sections.approved.txt new file mode 100644 index 0000000..02f7af6 --- /dev/null +++ b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.analyze_COBOL_Sections.approved.txt @@ -0,0 +1,107 @@ +{ + "filePath" : "src/test/resources/samples/cobol/sections.cbl", + "language" : "cobol", + "programId" : "LINKAGE-TEST", + "dataItems" : [ { + "name" : "WS-INPUT", + "level" : 1, + "picture" : "X(10)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-PROGRAM-NAME", + "level" : 1, + "picture" : "X(8)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-COUNT", + "level" : 1, + "picture" : "9(5)", + "section" : "WORKING-STORAGE" + }, { + "name" : "WS-IMS-STATUS", + "level" : 1, + "picture" : "S9(4)", + "section" : "WORKING-STORAGE", + "usage" : "COMP" + }, { + "name" : "LS-PARAMETERS", + "level" : 1, + "section" : "LINKAGE", + "children" : [ { + "name" : "LS-INPUT-REC", + "level" : 5, + "picture" : "X(10)", + "section" : "LINKAGE" + }, { + "name" : "LS-OUTPUT-REC", + "level" : 5, + "picture" : "X(10)", + "section" : "LINKAGE" + } ] + }, { + "name" : "LS-COUNTER", + "level" : 1, + "picture" : "99", + "section" : "LOCAL-STORAGE" + } ], + "fileDefinitions" : [ { + "name" : "INPUT-FILE", + "records" : [ { + "name" : "INPUT-RECORD", + "level" : 1, + "picture" : "X(80)", + "section" : "FILE SECTION" + } ] + } ], + "copyStatements" : [ "CUSTCOPY", "ACCTLAY" ], + "procedureParameters" : [ "LS-PARAMETERS" ], + "paragraphs" : [ { + "name" : "MAIN-LOGIC", + "performCalls" : [ { + "targetParagraph" : "INITIALIZATION" + }, { + "targetParagraph" : "PROCESS-DATA" + }, { + "targetParagraph" : "CLEANUP" + } ], + "controlFlowStatements" : [ { + "type" : "GOBACK" + } ] + }, { + "name" : "INITIALIZATION", + "dataReferences" : [ "WS-INPUT", "WS-PROGRAM-NAME", "WS-COUNT" ] + }, { + "name" : "PROCESS-DATA", + "dataReferences" : [ "WS-COUNT", "LS-INPUT-REC", "WS-INPUT" ] + }, { + "name" : "CLEANUP", + "externalCalls" : [ { + "programName" : "SUBPROG", + "isDynamic" : false, + "parameterCount" : 2 + }, { + "programName" : "WS-PROGRAM-NAME", + "isDynamic" : true, + "parameterCount" : 1 + } ], + "fileOperations" : [ { + "verb" : "READ", + "target" : "INPUT-FILE" + }, { + "verb" : "WRITE", + "target" : "INPUT-RECORD" + } ], + "controlFlowStatements" : [ { + "type" : "STOP_RUN" + }, { + "type" : "EXIT_PROGRAM" + }, { + "type" : "RETURN", + "target" : "INPUT-FILE" + } ], + "dataReferences" : [ "WS-COUNT", "WS-INPUT", "LS-PARAMETERS", "WS-IMS-STATUS" ] + } ], + "hasExecSql" : true, + "hasExecCics" : true, + "hasExecSqlIms" : true +} \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.java new file mode 100644 index 0000000..e1168a3 --- /dev/null +++ b/src/test/java/org/dxworks/codeframe/analyzer/cobol/COBOLAnalyzeApprovalTest.java @@ -0,0 +1,60 @@ +package org.dxworks.codeframe.analyzer.cobol; + +import org.approvaltests.Approvals; +import org.dxworks.codeframe.App; +import org.dxworks.codeframe.Language; +import org.dxworks.codeframe.model.Analysis; +import org.dxworks.codeframe.TestUtils; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +public class COBOLAnalyzeApprovalTest { + + @Test + void analyze_COBOL_BasicProgram() throws Exception { + verifyWithEmptyCopybooks("src/test/resources/samples/cobol/basic-program.cbl"); + } + + @Test + void analyze_COBOL_Sections() throws Exception { + verifyWithEmptyCopybooks("src/test/resources/samples/cobol/sections.cbl"); + } + + @Test + void analyze_COBOL_ProcedurePrologue() throws Exception { + verifyWithEmptyCopybooks("src/test/resources/samples/cobol/procedure-prologue.cbl"); + } + + @Test + void analyze_COBOL_FileOperations() throws Exception { + verifyWithEmptyCopybooks("src/test/resources/samples/cobol/file-operations.cbl"); + } + + @Test + void analyze_COBOL_CopybookExpansion() throws Exception { + // Initialize analyzers with copybooks using the new convenience method + List copybookPaths = List.of( + Paths.get("src/test/resources/samples/cobol/SIMPLE.cpy"), + Paths.get("src/test/resources/samples/cobol/PROCEDURES.cpy") + ); + App.initAnalyzersForTestsFromPaths(copybookPaths); + + // Now use the standard verify method since analyzers are initialized + verify("src/test/resources/samples/cobol/copybook-test.cbl"); + } + + private static void verify(String filePath) throws Exception { + Analysis analysis = App.analyzeFile(Paths.get(filePath), Language.COBOL); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); + } + + private static void verifyWithEmptyCopybooks(String filePath) throws Exception { + // Initialize analyzers for COBOL tests (no copybooks needed for basic tests) + App.initAnalyzersForTestsFromPaths(List.of()); + Analysis analysis = App.analyzeFile(Paths.get(filePath), Language.COBOL); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); + } +} diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DataClass.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DataClass.approved.txt index f23a71f..8650eda 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DataClass.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DataClass.approved.txt @@ -7,24 +7,18 @@ "name" : "DataContainer", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "IDetectTypeCodeIssue" ], - "mixins" : [ ], "fields" : [ { "name" : "Few", "type" : "int", "visibility" : "private", - "modifiers" : [ "private", "const" ], - "annotations" : [ ] + "modifiers" : [ "private", "const" ] } ], - "properties" : [ ], "methods" : [ { "name" : "Detect", "returnType" : "Maybe", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "t", "type" : "ClassModel" @@ -38,38 +32,27 @@ "parameterCount" : 0 }, { "methodName" : "CalculateSeverity", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 }, { "methodName" : "Debug", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "For", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "From", "objectType" : "Maybe", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "Output", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "PrintoTo", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { @@ -80,65 +63,51 @@ "parameterCount" : 0 }, { "methodName" : "Query", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "ToList", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 0 }, { "methodName" : "get_Count", "objectType" : "IList", "objectName" : "publicAttributes", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Count", "objectType" : "IList", "objectName" : "accessors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_FilePath", "objectType" : "ClassModel", "objectName" : "t", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_None", "objectType" : "Maybe", - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_OneThird", - "objectType" : null, "objectName" : "CommonFractionThreshold", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_WeightOfAClass", "objectType" : "var", "objectName" : "metrics", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_WeightedMethodCount", "objectType" : "var", "objectName" : "metrics", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "CalculateBigNumber", "returnType" : "Task", "visibility" : "public", "modifiers" : [ "public", "async" ], - "annotations" : [ ], "parameters" : [ { "name" : "bigNumber", "type" : "int" @@ -149,13 +118,10 @@ "localVariables" : [ "period" ], "methodCalls" : [ { "methodName" : "AddSeconds", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "GetLongValue", - "objectType" : null, "objectName" : "service", "callCount" : 1, "parameterCount" : 2 @@ -165,7 +131,6 @@ "returnType" : "double", "visibility" : "private", "modifiers" : [ "private", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "publicAttributes", "type" : "IList" @@ -179,14 +144,10 @@ "localVariables" : [ "severityExploit", "severityExposure" ], "methodCalls" : [ { "methodName" : "SeverityExploit", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 }, { "methodName" : "SeverityExposure", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -195,7 +156,6 @@ "returnType" : "double", "visibility" : "private", "modifiers" : [ "private", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "publicAttributes", "type" : "IList" @@ -203,16 +163,12 @@ "name" : "accessors", "type" : "IList" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueFor", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "WithMeasurementRange", - "objectType" : null, "objectName" : "LinearNormalization", "callCount" : 1, "parameterCount" : 2 @@ -220,21 +176,18 @@ "methodName" : "get_Count", "objectType" : "IList", "objectName" : "publicAttributes", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Count", "objectType" : "IList", "objectName" : "accessors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "SeverityExploit", "returnType" : "double", "visibility" : "private", "modifiers" : [ "private", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "publicAttributes", "type" : "IList" @@ -284,54 +237,39 @@ "parameterCount" : 1 }, { "methodName" : "ToHashSet", - "objectType" : null, - "objectName" : null, "callCount" : 3, "parameterCount" : 0 }, { "methodName" : "ValueFor", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "WithMeasurementRange", - "objectType" : null, "objectName" : "LinearNormalization", "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "get_Accesses", - "objectType" : null, "objectName" : "pa", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Count", "objectType" : "var", "objectName" : "classesUsingPublicData", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ScatteredDependencies", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "IDetectMethodCodeIssue" ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "DetectScattered", "returnType" : "Maybe", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "m", "type" : "MethodModel" @@ -339,65 +277,49 @@ "localVariables" : [ "shortMemoryCap", "metrics", "cint", "cdisp" ], "methodCalls" : [ { "methodName" : "CalculateSeverityScattered", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "For", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "From", "objectType" : "Maybe", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "get_CouplingDispersion", "objectType" : "var", "objectName" : "metrics", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_CouplingIntensity", "objectType" : "var", "objectName" : "metrics", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Entity", "objectType" : "MethodModel", "objectName" : "m", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_FilePath", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Half", - "objectType" : null, "objectName" : "CommonFractionThreshold", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_None", "objectType" : "Maybe", - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "CalculateSeverityScattered", "returnType" : "double", "visibility" : "private", "modifiers" : [ "private", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "method", "type" : "MethodModel" @@ -417,52 +339,35 @@ "parameterCount" : 1 }, { "methodName" : "ToList", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "ValueFor", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 }, { "methodName" : "Where", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "WithMeasurementRange", - "objectType" : null, "objectName" : "LinearNormalization", "callCount" : 2, "parameterCount" : 2 }, { "methodName" : "get_Count", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Count", "objectType" : "List>>", "objectName" : "relevantCouplingIntensityPerProvider", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Item2", - "objectType" : null, "objectName" : "g", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using CSharpFunctionalExtensions;", "using CodeAnalysis.Metrics;", "using Analysis.Plugins.Models;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DataClassNS.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DataClassNS.approved.txt index d50e177..4d7e2bd 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DataClassNS.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DataClassNS.approved.txt @@ -7,24 +7,18 @@ "name" : "DataContainer", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "IDetectTypeCodeIssue" ], - "mixins" : [ ], "fields" : [ { "name" : "Few", "type" : "int", "visibility" : "private", - "modifiers" : [ "private", "const" ], - "annotations" : [ ] + "modifiers" : [ "private", "const" ] } ], - "properties" : [ ], "methods" : [ { "name" : "Detect", "returnType" : "Maybe", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "t", "type" : "ClassModel" @@ -38,20 +32,15 @@ "parameterCount" : 0 }, { "methodName" : "CalculateSeverity", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 }, { "methodName" : "For", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "From", "objectType" : "Maybe", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { @@ -62,59 +51,47 @@ "parameterCount" : 0 }, { "methodName" : "ToList", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 0 }, { "methodName" : "get_Count", "objectType" : "IList", "objectName" : "publicAttributes", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Count", "objectType" : "IList", "objectName" : "accessors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_FilePath", "objectType" : "ClassModel", "objectName" : "t", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_None", "objectType" : "Maybe", - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_OneThird", - "objectType" : null, "objectName" : "CommonFractionThreshold", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_WeightOfAClass", "objectType" : "var", "objectName" : "metrics", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_WeightedMethodCount", "objectType" : "var", "objectName" : "metrics", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "CalculateSeverity", "returnType" : "double", "visibility" : "private", "modifiers" : [ "private", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "publicAttributes", "type" : "IList" @@ -128,14 +105,10 @@ "localVariables" : [ "severityExploit", "severityExposure" ], "methodCalls" : [ { "methodName" : "SeverityExploit", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 }, { "methodName" : "SeverityExposure", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -144,7 +117,6 @@ "returnType" : "double", "visibility" : "private", "modifiers" : [ "private", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "publicAttributes", "type" : "IList" @@ -152,16 +124,12 @@ "name" : "accessors", "type" : "IList" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueFor", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "WithMeasurementRange", - "objectType" : null, "objectName" : "LinearNormalization", "callCount" : 1, "parameterCount" : 2 @@ -169,21 +137,18 @@ "methodName" : "get_Count", "objectType" : "IList", "objectName" : "publicAttributes", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Count", "objectType" : "IList", "objectName" : "accessors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "SeverityExploit", "returnType" : "double", "visibility" : "private", "modifiers" : [ "private", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "publicAttributes", "type" : "IList" @@ -233,40 +198,28 @@ "parameterCount" : 1 }, { "methodName" : "ToHashSet", - "objectType" : null, - "objectName" : null, "callCount" : 3, "parameterCount" : 0 }, { "methodName" : "ValueFor", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "WithMeasurementRange", - "objectType" : null, "objectName" : "LinearNormalization", "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "get_Accesses", - "objectType" : null, "objectName" : "pa", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Count", "objectType" : "var", "objectName" : "classesUsingPublicData", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using CSharpFunctionalExtensions;", "using CodeAnalysis.Metrics;", "using Analysis.Plugins.Models;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DelegatesEventsLambdasSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DelegatesEventsLambdasSample.approved.txt index 3254843..aa309c0 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DelegatesEventsLambdasSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_DelegatesEventsLambdasSample.approved.txt @@ -7,80 +7,52 @@ "name" : "ValueChangedEventArgs", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "extendsType" : "EventArgs", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "OldValue", "type" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] }, { "name" : "NewValue", "type" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] } ], "methods" : [ { "name" : "ValueChangedEventArgs", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "oldValue", "type" : "int" }, { "name" : "newValue", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Counter", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "_value", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "Increment", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "step", "type" : "Func" @@ -88,31 +60,20 @@ "localVariables" : [ "oldV" ], "methodCalls" : [ { "methodName" : "step", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Demo", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "WireUp", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "c", "onChanged" ], "methodCalls" : [ { "methodName" : "Increment", @@ -122,28 +83,19 @@ "parameterCount" : 1 }, { "methodName" : "WriteLine", - "objectType" : null, "objectName" : "Console", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "get_NewValue", - "objectType" : null, "objectName" : "e", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "onChanged", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_EnumUsageSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_EnumUsageSample.approved.txt index 13ab78b..9590557 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_EnumUsageSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_EnumUsageSample.approved.txt @@ -7,105 +7,65 @@ "name" : "EnumUsageSample", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "GetStatusMessage", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "status", "type" : "Status" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get_Active", - "objectType" : null, "objectName" : "Status", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Closed", - "objectType" : null, "objectName" : "Status", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_Pending", - "objectType" : null, "objectName" : "Status", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "PrintAll", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "GetValues", - "objectType" : null, "objectName" : "Enum", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "ToString", - "objectType" : null, "objectName" : "s", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "WriteLine", - "objectType" : null, "objectName" : "Console", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "enum", "name" : "Status", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "Pending", - "type" : "Status", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Status" }, { "name" : "Active", - "type" : "Status", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Status" }, { "name" : "Closed", - "type" : "Status", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "Status" + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_ExceptionsAndUsingSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_ExceptionsAndUsingSample.approved.txt index d3fd57d..93f8331 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_ExceptionsAndUsingSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_ExceptionsAndUsingSample.approved.txt @@ -7,43 +7,26 @@ "name" : "InvalidInputException", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "extendsType" : "Exception", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "InvalidInputException", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Runner", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "ParsePositive", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "string" @@ -52,22 +35,18 @@ "methodCalls" : [ { "methodName" : "Parse", "objectType" : "int", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "get_Message", - "objectType" : null, "objectName" : "ex", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "ReadFirstByteLength", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "path", "type" : "string" @@ -75,7 +54,6 @@ "localVariables" : [ "stream" ], "methodCalls" : [ { "methodName" : "OpenRead", - "objectType" : null, "objectName" : "File", "callCount" : 1, "parameterCount" : 1 @@ -86,11 +64,7 @@ "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;", "using System.IO;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_ExtensionMethodsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_ExtensionMethodsSample.approved.txt index 4c7d465..4134890 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_ExtensionMethodsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_ExtensionMethodsSample.approved.txt @@ -7,27 +7,18 @@ "name" : "StringExtensions", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "IsBlank", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "string?" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "IsNullOrWhiteSpace", "objectType" : "string", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -36,43 +27,30 @@ "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "string?" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "IsBlank", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Demo", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "Check", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "string?" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "IsBlank", "objectType" : "string?", @@ -80,11 +58,7 @@ "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InheritanceSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InheritanceSample.approved.txt index d7c4634..9de34f6 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InheritanceSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InheritanceSample.approved.txt @@ -7,111 +7,64 @@ "name" : "Animal", "visibility" : "public", "modifiers" : [ "public", "abstract" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "Name", "type" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] } ], "methods" : [ { "name" : "Speak", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public", "virtual" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public", "virtual" ] }, { "name" : "Animal", - "returnType" : null, "visibility" : "protected", "modifiers" : [ "protected" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Dog", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "extendsType" : "Animal", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "Speak", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public", "sealed", "override" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public", "sealed", "override" ] }, { "name" : "Dog", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "LoudDog", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "extendsType" : "Dog", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "LoudDog", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InnerOutter.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InnerOutter.approved.txt index 2e003d7..b482c5e 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InnerOutter.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InnerOutter.approved.txt @@ -7,31 +7,15 @@ "name" : "OuterClass", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "Name", "type" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" }, { - "kind" : "set", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "set" } ] } ], "methods" : [ { @@ -39,12 +23,8 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "WriteLine", - "objectType" : null, "objectName" : "Console", "callCount" : 1, "parameterCount" : 1 @@ -54,8 +34,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "helper" ], "methodCalls" : [ { "methodName" : "DoWork", @@ -66,47 +44,27 @@ } ] }, { "name" : "OuterClass", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] } ], "types" : [ { "kind" : "class", "name" : "InnerClassA", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "Value", "type" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" }, { - "kind" : "set", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "set" } ] } ], "methods" : [ { @@ -114,90 +72,56 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "WriteLine", - "objectType" : null, "objectName" : "Console", "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "InnerClassA", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] } ], "types" : [ { "kind" : "class", "name" : "InnerClassB", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "Display", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "WriteLine", - "objectType" : null, "objectName" : "Console", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ] }, { "kind" : "class", "name" : "InnerHelper", "visibility" : "private", "modifiers" : [ "private" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "DoWork", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "WriteLine", - "objectType" : null, "objectName" : "Console", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InterfaceAndGenericsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InterfaceAndGenericsSample.approved.txt index 4cec8a8..037f2b1 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InterfaceAndGenericsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_InterfaceAndGenericsSample.approved.txt @@ -7,18 +7,11 @@ "name" : "Demo", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "greet", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "T" @@ -35,7 +28,6 @@ "parameterCount" : 0 }, { "methodName" : "WriteLine", - "objectType" : null, "objectName" : "Console", "callCount" : 1, "parameterCount" : 1 @@ -45,7 +37,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "T" @@ -65,75 +56,41 @@ "parameterCount" : 0 }, { "methodName" : "WriteLine", - "objectType" : null, "objectName" : "Console", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "interface", "name" : "IRepository", "visibility" : "public", "modifiers" : [ "public" ], "annotations" : [ "[Obsolete]" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "FindById", "returnType" : "T", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "ID" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "Save", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "entity", "type" : "T" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "interface", "name" : "INamed", "visibility" : "public", "modifiers" : [ "public" ], "annotations" : [ "[Obsolete]" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "GetName", - "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "returnType" : "string" + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_IteratorsAndIndexersSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_IteratorsAndIndexersSample.approved.txt index 546cd13..7a6f638 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_IteratorsAndIndexersSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_IteratorsAndIndexersSample.approved.txt @@ -7,54 +7,35 @@ "name" : "Seq", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "UpTo", "returnType" : "IEnumerable", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "SimpleMap", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "IEnumerable>" ], - "mixins" : [ ], "fields" : [ { "name" : "_inner", "type" : "Dictionary", "visibility" : "private", - "modifiers" : [ "private", "readonly" ], - "annotations" : [ ] + "modifiers" : [ "private", "readonly" ] } ], - "properties" : [ ], "methods" : [ { "name" : "GetEnumerator", "returnType" : "IEnumerator>", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "GetEnumerator", - "objectType" : null, "objectName" : "_inner", "callCount" : 1, "parameterCount" : 0 @@ -62,23 +43,12 @@ }, { "name" : "GetEnumerator", "returnType" : "IEnumerator", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "GetEnumerator", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System.Collections;", "using System.Collections.Generic;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_LoopLocalsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_LoopLocalsSample.approved.txt index ed2e4ff..88091c7 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_LoopLocalsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_LoopLocalsSample.approved.txt @@ -7,42 +7,31 @@ "name" : "LoopLocals", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "SumUpTo", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" } ], - "localVariables" : [ "sum" ], - "methodCalls" : [ ] + "localVariables" : [ "sum" ] }, { "name" : "SumList", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "xs", "type" : "List" } ], - "localVariables" : [ "sum" ], - "methodCalls" : [ ] + "localVariables" : [ "sum" ] }, { "name" : "Process", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" @@ -52,14 +41,8 @@ }, { "name" : "values", "type" : "int[]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;", "using System.Collections.Generic;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_NullabilitySample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_NullabilitySample.approved.txt index 74c3ea6..fb063f0 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_NullabilitySample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_NullabilitySample.approved.txt @@ -7,39 +7,27 @@ "name" : "N", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "LengthOrDefault", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "string?" } ], - "localVariables" : [ "len" ], - "methodCalls" : [ ] + "localVariables" : [ "len" ] }, { "name" : "NotNull", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "string?" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "nameof", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -48,18 +36,11 @@ "returnType" : "string", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "string?" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_PropertiesUsageSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_PropertiesUsageSample.approved.txt index ea00805..6bd40f8 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_PropertiesUsageSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_PropertiesUsageSample.approved.txt @@ -7,61 +7,39 @@ "name" : "Person", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "_age", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], "properties" : [ { "name" : "FirstName", "type" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] }, { "name" : "LastName", "type" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] }, { "name" : "DisplayName", "type" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "localVariables" : [ "space", "name" ], "methodCalls" : [ { "methodName" : "Concat", "objectType" : "string", - "objectName" : null, "callCount" : 1, "parameterCount" : 3 }, { @@ -77,49 +55,32 @@ "type" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" }, { "kind" : "set", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ "v" ], - "methodCalls" : [ ] + "localVariables" : [ "v" ] } ] }, { "name" : "NameLength", "type" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "accessors" : [ { "kind" : "get", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get_Length", - "objectType" : null, "objectName" : "DisplayName", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ] } ], "methods" : [ { "name" : "Person", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "firstName", "type" : "string" @@ -129,58 +90,43 @@ }, { "name" : "age", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "PersonService", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "Promote", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "p", "type" : "Person" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get_Age", "objectType" : "Person", "objectName" : "p", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "get_NameLength", "objectType" : "Person", "objectName" : "p", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "set_Age", "objectType" : "Person", "objectName" : "p", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "Describe", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "p", "type" : "Person" @@ -190,26 +136,19 @@ "methodName" : "get_Age", "objectType" : "Person", "objectName" : "p", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_DisplayName", "objectType" : "Person", "objectName" : "p", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get_NameLength", "objectType" : "Person", "objectName" : "p", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_RecordsAndPatternsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_RecordsAndPatternsSample.approved.txt index 54ef3d2..691553a 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_RecordsAndPatternsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_RecordsAndPatternsSample.approved.txt @@ -7,72 +7,43 @@ "name" : "Classifier", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "Describe", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "p", "type" : "Person" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "Birthday", "returnType" : "Person", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "p", "type" : "Person" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get_Age", "objectType" : "Person", "objectName" : "p", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "record", "name" : "Person", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "Name", - "type" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "string" }, { "name" : "Age", - "type" : "int", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "int" + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_RecursionSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_RecursionSample.approved.txt index 61a007a..b756b5a 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_RecursionSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_RecursionSample.approved.txt @@ -7,27 +7,17 @@ "name" : "RecursionSample", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "Factorial", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Factorial", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -36,7 +26,6 @@ "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "int" @@ -44,17 +33,12 @@ "name" : "b", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "DoStuff", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "DoStuff", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -63,16 +47,12 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "WriteLine", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -81,7 +61,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "int" @@ -89,17 +68,12 @@ "name" : "b", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "DoStuff", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "WriteLine", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -108,16 +82,12 @@ "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Odd", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -126,16 +96,12 @@ "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Even", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -144,12 +110,10 @@ "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Sum", "objectType" : "RecursionSample", @@ -162,7 +126,6 @@ "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "input", "type" : "string" @@ -170,8 +133,6 @@ "localVariables" : [ "transformed" ], "methodCalls" : [ { "methodName" : "Process", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { @@ -192,12 +153,10 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "RecursionSample" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "DoStuff", "objectType" : "RecursionSample", @@ -210,24 +169,16 @@ "returnType" : "int", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "StaticFactorial", - "objectType" : null, "objectName" : "RecursionSample", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_TuplesRangesAndTargetTypedNewSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_TuplesRangesAndTargetTypedNewSample.approved.txt index 742c0ec..b2d5742 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_TuplesRangesAndTargetTypedNewSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.analyze_CSharp_TuplesRangesAndTargetTypedNewSample.approved.txt @@ -7,18 +7,11 @@ "name" : "Utils", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "SumAndCount", "returnType" : "(int sum, int count)", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "ReadOnlySpan" @@ -28,41 +21,30 @@ "methodName" : "get_Length", "objectType" : "ReadOnlySpan", "objectName" : "data", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 } ] }, { "name" : "Tail", "returnType" : "int[]", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "xs", "type" : "int[]" } ], - "localVariables" : [ "tail" ], - "methodCalls" : [ ] + "localVariables" : [ "tail" ] }, { "name" : "Demo", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "dict", "list", "arr", "last" ], "methodCalls" : [ { "methodName" : "SumAndCount", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "using System;", "using System.Collections.Generic;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.java index 345224e..fd2c1aa 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/csharp/CSharpAnalyzeApprovalTest.java @@ -1,10 +1,9 @@ package org.dxworks.codeframe.analyzer.csharp; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.approvaltests.Approvals; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; +import org.dxworks.codeframe.TestUtils; import org.dxworks.codeframe.model.FileAnalysis; import org.junit.jupiter.api.Test; @@ -14,10 +13,6 @@ public class CSharpAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_CSharp_DataClass() throws IOException { verify(Paths.get("src/test/resources/samples/csharp/DataClass.cs"), Language.CSHARP); @@ -100,6 +95,6 @@ void analyze_CSharp_RecursionSample() throws IOException { private static void verify(Path file, Language language) throws IOException { FileAnalysis analysis = (FileAnalysis) App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_AnonymousInnerClassesSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_AnonymousInnerClassesSample.approved.txt index df0cb65..ae81616 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_AnonymousInnerClassesSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_AnonymousInnerClassesSample.approved.txt @@ -7,29 +7,21 @@ "name" : "AnonymousInnerClassesSample", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "logger", "type" : "Logger", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] } ], - "properties" : [ ], "methods" : [ { "name" : "createTask", "returnType" : "Runnable", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "String" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "info", "objectType" : "Logger", @@ -38,8 +30,6 @@ "parameterCount" : 1 }, { "methodName" : "process", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] @@ -48,12 +38,10 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "callback", "type" : "Callback" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "onComplete", "objectType" : "Callback", @@ -66,8 +54,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "processor" ], "methodCalls" : [ { "methodName" : "info", @@ -88,111 +74,59 @@ "name" : "InnerHelper", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "assist", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "info", - "objectType" : null, "objectName" : "logger", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "StaticHelper", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "help", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println", - "objectType" : null, "objectName" : "System.out", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ] }, { "kind" : "class", "name" : "Logger", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "info", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "interface", "name" : "Callback", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "onComplete", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "result", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_ConstructorSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_ConstructorSample.approved.txt index b7147a4..bdb571c 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_ConstructorSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_ConstructorSample.approved.txt @@ -7,39 +7,26 @@ "name" : "ConstructorSample", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "dep", "type" : "Dependency", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] }, { "name" : "count", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "getCount", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "ConstructorSample", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "dep", "type" : "Dependency" @@ -47,7 +34,6 @@ "name" : "initial", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "init", "objectType" : "Dependency", @@ -55,33 +41,15 @@ "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Dependency", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "init", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "modifiers" : [ "public" ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_EnumSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_EnumSample.approved.txt index 4c46fb4..962bb13 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_EnumSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_EnumSample.approved.txt @@ -7,23 +7,15 @@ "name" : "EnumSample", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "getStatusMessage", "returnType" : "String", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "status", "type" : "Status" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getCode", "objectType" : "Status", @@ -36,100 +28,61 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getCode", - "objectType" : null, "objectName" : "s", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "println", - "objectType" : null, "objectName" : "System.out", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "values", - "objectType" : null, "objectName" : "Status", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "enum", "name" : "Status", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "code", "type" : "String", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] }, { "name" : "priority", "type" : "int", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] } ], - "properties" : [ ], "methods" : [ { "name" : "getCode", "returnType" : "String", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getPriority", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isActive", "returnType" : "boolean", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "Status", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "code", "type" : "String" }, { "name" : "priority", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_ExceptionHandlingSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_ExceptionHandlingSample.approved.txt index add7bdf..e1d8a92 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_ExceptionHandlingSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_ExceptionHandlingSample.approved.txt @@ -7,24 +7,17 @@ "name" : "ExceptionHandlingSample", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "logger", "type" : "Logger", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] } ], - "properties" : [ ], "methods" : [ { "name" : "processFile", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "path", "type" : "String" @@ -32,8 +25,6 @@ "localVariables" : [ "data" ], "methodCalls" : [ { "methodName" : "cleanup", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { @@ -44,7 +35,6 @@ "parameterCount" : 1 }, { "methodName" : "getMessage", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 @@ -56,7 +46,6 @@ "parameterCount" : 1 }, { "methodName" : "read", - "objectType" : null, "objectName" : "reader", "callCount" : 1, "parameterCount" : 0 @@ -66,12 +55,10 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "input", "type" : "String" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "info", "objectType" : "Logger", @@ -90,9 +77,6 @@ "returnType" : "void", "visibility" : "private", "modifiers" : [ "private" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "info", "objectType" : "Logger", @@ -100,73 +84,42 @@ "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ValidationException", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Exception", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "ValidationException", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Logger", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "info", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "error", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "import java.io.FileReader;", "import java.io.IOException;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_GenericsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_GenericsSample.approved.txt index d015e22..5a26906 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_GenericsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_GenericsSample.approved.txt @@ -7,33 +7,21 @@ "name" : "GenericsSample", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "findMax", "returnType" : "T", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "List" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "max", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "orElse", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { @@ -48,15 +36,12 @@ "returnType" : "Optional", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "List" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "empty", - "objectType" : null, "objectName" : "Optional", "callCount" : 1, "parameterCount" : 0 @@ -74,7 +59,6 @@ "parameterCount" : 0 }, { "methodName" : "of", - "objectType" : null, "objectName" : "Optional", "callCount" : 1, "parameterCount" : 1 @@ -84,21 +68,17 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "numbers", "type" : "List" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "doubleValue", - "objectType" : null, "objectName" : "n", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "println", - "objectType" : null, "objectName" : "System.out", "callCount" : 1, "parameterCount" : 1 @@ -108,7 +88,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "container", "type" : "GenericContainer" @@ -119,7 +98,6 @@ "name" : "value", "type" : "V" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "put", "objectType" : "GenericContainer", @@ -127,57 +105,42 @@ "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "GenericContainer", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "key", "type" : "K", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "value", "type" : "V", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "put", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "K" }, { "name" : "value", "type" : "V" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "get", "returnType" : "V", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "K" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "equals", "objectType" : "K", @@ -185,11 +148,7 @@ "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "import java.util.List;", "import java.util.Optional;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_LambdaSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_LambdaSample.approved.txt index 76d585f..af79e25 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_LambdaSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_LambdaSample.approved.txt @@ -7,24 +7,17 @@ "name" : "LambdaSample", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "logger", "type" : "Logger", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] } ], - "properties" : [ ], "methods" : [ { "name" : "namesLongerThan3", "returnType" : "List", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "users", "type" : "List" @@ -32,14 +25,10 @@ "localVariables" : [ "names" ], "methodCalls" : [ { "methodName" : "collect", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "filter", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { @@ -50,7 +39,6 @@ "parameterCount" : 1 }, { "methodName" : "getName", - "objectType" : null, "objectName" : "u", "callCount" : 1, "parameterCount" : 0 @@ -62,14 +50,11 @@ "parameterCount" : 1 }, { "methodName" : "length", - "objectType" : null, "objectName" : "n", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "map", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { @@ -80,7 +65,6 @@ "parameterCount" : 0 }, { "methodName" : "toList", - "objectType" : null, "objectName" : "Collectors", "callCount" : 1, "parameterCount" : 0 @@ -90,12 +74,10 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "counters", "type" : "List" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "forEach", "objectType" : "List", @@ -104,91 +86,48 @@ "parameterCount" : 1 }, { "methodName" : "increment", - "objectType" : null, "objectName" : "c", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "User", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "name", "type" : "String", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "getName", "returnType" : "String", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] }, { "kind" : "class", "name" : "Logger", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "info", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "s", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Counter", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "increment", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "import java.util.ArrayList;", "import java.util.List;", "import java.util.stream.Collectors;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_MultipleClasses.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_MultipleClasses.approved.txt index 357020d..97a7551 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_MultipleClasses.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_MultipleClasses.approved.txt @@ -7,26 +7,17 @@ "name" : "MultipleClasses", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "greet", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "String" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println", - "objectType" : null, "objectName" : "System.out", "callCount" : 1, "parameterCount" : 1 @@ -36,7 +27,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "String" @@ -53,7 +43,6 @@ "parameterCount" : 0 }, { "methodName" : "println", - "objectType" : null, "objectName" : "System.out", "callCount" : 1, "parameterCount" : 1 @@ -64,61 +53,33 @@ "name" : "InnerHelper", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "assist", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println", - "objectType" : null, "objectName" : "System.out", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ] }, { "kind" : "class", "name" : "ExtraClass", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "doWork", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println", - "objectType" : null, "objectName" : "System.out", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_RecordsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_RecordsSample.approved.txt index 1b4f2d4..358ce15 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_RecordsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_RecordsSample.approved.txt @@ -7,23 +7,13 @@ "name" : "Point", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "distanceFromOrigin", "returnType" : "double", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "sqrt", - "objectType" : null, "objectName" : "Math", "callCount" : 1, "parameterCount" : 1 @@ -32,60 +22,32 @@ "name" : "origin", "returnType" : "Point", "visibility" : "public", - "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public", "static" ] }, { "name" : "Point", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "Point", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] }, { "kind" : "record", "name" : "Person", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "isAdult", "returnType" : "boolean", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "Person", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "String" @@ -93,7 +55,6 @@ "name" : "age", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isEmpty", "objectType" : "String", @@ -101,11 +62,6 @@ "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_RepositorySample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_RepositorySample.approved.txt index 32ab5b8..bb735ac 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_RepositorySample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_RepositorySample.approved.txt @@ -8,49 +8,29 @@ "visibility" : "public", "modifiers" : [ "public" ], "annotations" : [ "@Deprecated" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "findById", "returnType" : "T", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "ID" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "save", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "entity", "type" : "T" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "countAll", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public", "default" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "modifiers" : [ "public", "default" ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_Sample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_Sample.approved.txt index 7a791f8..7996ff6 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_Sample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_Sample.approved.txt @@ -8,44 +8,33 @@ "visibility" : "public", "modifiers" : [ "public" ], "annotations" : [ "@Resource(name = RestConstants.VERSION_1 + \"/user\", supportedClass = Sample.class, supportedVersions = { \"1.0.* - 2.0.*\" })" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "db", "type" : "DatabaseConnection", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] }, { "name" : "logger", "type" : "Logger", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] }, { "name" : "users", "type" : "List", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "findById", "returnType" : "User", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "String" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "debug", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { @@ -56,14 +45,10 @@ "parameterCount" : 1 }, { "methodName" : "output", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "printoTo", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { @@ -84,9 +69,6 @@ "returnType" : "List", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "queryList", "objectType" : "DatabaseConnection", @@ -99,12 +81,10 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "String" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "info", "objectType" : "Logger", @@ -117,24 +97,19 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "users", "type" : "List" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "save", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "user", "type" : "User" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getId", "objectType" : "User", @@ -143,14 +118,10 @@ "parameterCount" : 0 }, { "methodName" : "insert", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "update", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -159,12 +130,10 @@ "returnType" : "void", "visibility" : "private", "modifiers" : [ "private" ], - "annotations" : [ ], "parameters" : [ { "name" : "user", "type" : "User" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "execute", "objectType" : "DatabaseConnection", @@ -189,12 +158,10 @@ "returnType" : "void", "visibility" : "private", "modifiers" : [ "private" ], - "annotations" : [ ], "parameters" : [ { "name" : "user", "type" : "User" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "execute", "objectType" : "DatabaseConnection", @@ -222,118 +189,78 @@ } ] }, { "name" : "Sample", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "db", "type" : "DatabaseConnection" }, { "name" : "logger", "type" : "Logger" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "User", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "id", "type" : "String", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "name", "type" : "String", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "email", "type" : "String", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "getId", "returnType" : "String", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setId", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getName", "returnType" : "String", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setName", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getEmail", "returnType" : "String", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setEmail", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "email", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "import java.util.List;", "import java.util.stream.Collectors;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_SealedClassesSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_SealedClassesSample.approved.txt index bdec955..8905943 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_SealedClassesSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.analyze_Java_SealedClassesSample.approved.txt @@ -5,218 +5,139 @@ "types" : [ { "kind" : "class", "name" : "Circle", - "visibility" : null, "modifiers" : [ "final" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Shape" ], - "mixins" : [ ], "fields" : [ { "name" : "radius", "type" : "double", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] } ], - "properties" : [ ], "methods" : [ { "name" : "area", "returnType" : "double", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ "@Override" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@Override" ] }, { "name" : "getRadius", "returnType" : "double", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "Circle", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "radius", "type" : "double" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Rectangle", - "visibility" : null, "modifiers" : [ "final" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Shape" ], - "mixins" : [ ], "fields" : [ { "name" : "width", "type" : "double", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] }, { "name" : "height", "type" : "double", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] } ], - "properties" : [ ], "methods" : [ { "name" : "area", "returnType" : "double", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ "@Override" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@Override" ] }, { "name" : "Rectangle", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "width", "type" : "double" }, { "name" : "height", "type" : "double" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Triangle", - "visibility" : null, "modifiers" : [ "non-sealed" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Shape" ], - "mixins" : [ ], "fields" : [ { "name" : "base", "type" : "double", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] }, { "name" : "height", "type" : "double", "visibility" : "private", - "modifiers" : [ "private", "final" ], - "annotations" : [ ] + "modifiers" : [ "private", "final" ] } ], - "properties" : [ ], "methods" : [ { "name" : "area", "returnType" : "double", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ "@Override" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@Override" ] }, { "name" : "Triangle", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "base", "type" : "double" }, { "name" : "height", "type" : "double" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "ShapeProcessor", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "describe", "returnType" : "String", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "shape", "type" : "Shape" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "area", - "objectType" : null, "objectName" : "r", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "area", - "objectType" : null, "objectName" : "t", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "getRadius", - "objectType" : null, "objectName" : "c", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "interface", "name" : "Shape", "visibility" : "public", "modifiers" : [ "public", "sealed" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "area", - "returnType" : "double", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "returnType" : "double" + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.java index c486e75..27479e2 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/java/JavaAnalyzeApprovalTest.java @@ -1,11 +1,10 @@ package org.dxworks.codeframe.analyzer.java; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.approvaltests.Approvals; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; import org.dxworks.codeframe.model.FileAnalysis; +import org.dxworks.codeframe.TestUtils; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -14,10 +13,6 @@ public class JavaAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_Java_Sample() throws IOException { verify(Paths.get("src/test/resources/samples/java/Sample.java"), Language.JAVA); @@ -73,8 +68,8 @@ void analyze_Java_SealedClassesSample() throws IOException { verify(Paths.get("src/test/resources/samples/java/SealedClassesSample.java"), Language.JAVA); } - private static void verify(Path file, Language language) throws IOException { - FileAnalysis analysis = (FileAnalysis) App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + private static void verify(Path filePath, Language language) throws IOException { + FileAnalysis analysis = (FileAnalysis) App.analyzeFile(filePath, language); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ClassicPatterns.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ClassicPatterns.approved.txt index 79489a4..84c4beb 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ClassicPatterns.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ClassicPatterns.approved.txt @@ -1,487 +1,251 @@ { "filePath" : "src/test/resources/samples/javascript/ClassicPatterns.js", "language" : "javascript", - "packageName" : null, - "types" : [ ], "methods" : [ { "name" : "formatMessage", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "level", - "type" : null + "name" : "level" }, { - "name" : "message", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "message" + } ] }, { "name" : "Person", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "age", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "age" + } ] }, { "name" : "Employee", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "age", - "type" : null + "name" : "age" }, { - "name" : "department", - "type" : null + "name" : "department" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "call", - "objectType" : null, "objectName" : "Person", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "DataStore", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "initialData", - "type" : null + "name" : "initialData" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "initObservable", - "objectType" : null, "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "on", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "event", - "type" : null + "name" : "event" }, { - "name" : "callback", - "type" : null + "name" : "callback" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "push", - "objectType" : null, "objectName" : "events[event]", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "off", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "event", - "type" : null + "name" : "event" }, { - "name" : "callback", - "type" : null + "name" : "callback" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "filter", - "objectType" : null, "objectName" : "events[event]", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "emit", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "event", - "type" : null + "name" : "event" }, { - "name" : "...args", - "type" : null + "name" : "...args" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "callback", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "forEach", - "objectType" : null, "objectName" : "events[event]", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "once", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "event", - "type" : null + "name" : "event" }, { - "name" : "callback", - "type" : null + "name" : "callback" } ], "localVariables" : [ "wrapper" ], "methodCalls" : [ { "methodName" : "callback", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "off", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "on", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "createValidator", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "rules", - "type" : null + "name" : "rules" } ], "localVariables" : [ "validators", "errors", "validator" ], "methodCalls" : [ { "methodName" : "String", - "objectType" : null, - "objectName" : null, - "callCount" : 3, - "parameterCount" : null + "callCount" : 3 }, { "methodName" : "entries", - "objectType" : null, "objectName" : "Object", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "push", "objectType" : "Array", "objectName" : "errors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "test", - "objectType" : null, "objectName" : "regex", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "validator", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "add", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "value", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "value" + } ] }, { "name" : "subtract", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "value", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "value" + } ] }, { "name" : "multiply", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "value", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "value" + } ] }, { "name" : "divide", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "value", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - }, { - "name" : "getResult", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - }, { - "name" : "reset", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "value" + } ] + }, { + "name" : "getResult" + }, { + "name" : "reset" }, { "name" : "factorial", - "returnType" : null, - "visibility" : null, "modifiers" : [ "const" ], - "annotations" : [ ], "parameters" : [ { - "name" : "n", - "type" : null + "name" : "n" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "calculateFactorial", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fibonacci", - "returnType" : null, - "visibility" : null, "modifiers" : [ "const" ], - "annotations" : [ ], "parameters" : [ { - "name" : "n", - "type" : null + "name" : "n" }, { - "name" : "memo", - "type" : null + "name" : "memo" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "fib", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 } ] }, { - "name" : "Person.prototype.greet", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - }, { - "name" : "Person.prototype.haveBirthday", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "Person.prototype.greet" + }, { + "name" : "Person.prototype.haveBirthday" }, { "name" : "Person.create", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "age", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - }, { - "name" : "Employee.prototype.getDetails", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "age" + } ] + }, { + "name" : "Employee.prototype.getDetails" }, { "name" : "Employee.prototype.greet", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "call", - "objectType" : null, "objectName" : "Person.prototype.greet", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "DataStore.prototype.set", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "key", - "type" : null + "name" : "key" }, { - "name" : "value", - "type" : null + "name" : "value" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "notify", - "objectType" : null, "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "DataStore.prototype.get", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "key", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "key" + } ] } ], "fields" : [ { "name" : "Counter", - "type" : null, - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "Logger", - "type" : null, - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "Serializable", "type" : "Object", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "Comparable", "type" : "Object", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "Observable", "type" : "Object", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "EventBus", - "type" : null, - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "Calculator", - "type" : null, - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], "methodCalls" : [ { "methodName" : "assign", - "objectType" : null, "objectName" : "Object", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "call", - "objectType" : null, "objectName" : "Person.prototype.greet", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "create", - "objectType" : null, "objectName" : "Object", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "notify", - "objectType" : null, "objectName" : "this", - "callCount" : 1, - "parameterCount" : null - } ], - "imports" : [ ] + "callCount" : 1 + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_DestructuringAndSpread.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_DestructuringAndSpread.approved.txt index 3d7214d..c9a785c 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_DestructuringAndSpread.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_DestructuringAndSpread.approved.txt @@ -1,286 +1,167 @@ { "filePath" : "src/test/resources/samples/javascript/DestructuringAndSpread.js", "language" : "javascript", - "packageName" : null, - "types" : [ ], "methods" : [ { "name" : "createUser", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "email", - "type" : null + "name" : "email" }, { - "name" : "age", - "type" : null + "name" : "age" }, { - "name" : "role", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "role" + } ] }, { "name" : "getFirstAndLast", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "items", - "type" : null + "name" : "items" } ], - "localVariables" : [ "items", "last" ], - "methodCalls" : [ ] + "localVariables" : [ "items", "last" ] }, { "name" : "processApiResponse", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "user", - "type" : null + "name" : "user" }, { - "name" : "settings", - "type" : null + "name" : "settings" }, { - "name" : "timestamp", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "timestamp" + } ] }, { "name" : "mergeUserData", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "baseUser", - "type" : null + "name" : "baseUser" }, { - "name" : "updates", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "updates" + } ] }, { "name" : "combineArrays", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "arr1", - "type" : null + "name" : "arr1" }, { - "name" : "arr2", - "type" : null + "name" : "arr2" }, { - "name" : "arr3", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "arr3" + } ] }, { "name" : "sum", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "...numbers", - "type" : null + "name" : "...numbers" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "reduce", - "objectType" : null, "objectName" : "numbers", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "logWithPrefix", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "prefix", - "type" : null + "name" : "prefix" }, { - "name" : "...messages", - "type" : null + "name" : "...messages" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "forEach", - "objectType" : null, "objectName" : "messages", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "log", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "extractUserInfo", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "userName", - "type" : null + "name" : "userName" }, { - "name" : "userEmail", - "type" : null + "name" : "userEmail" }, { - "name" : "avatarUrl", - "type" : null + "name" : "avatarUrl" }, { - "name" : "bio", - "type" : null + "name" : "bio" }, { - "name" : "theme", - "type" : null + "name" : "theme" }, { - "name" : "language", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "language" + } ] }, { "name" : "processUsers", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "users", - "type" : null + "name" : "users" } ], "localVariables" : [ "results" ], "methodCalls" : [ { "methodName" : "push", "objectType" : "Array", "objectName" : "results", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "createConfig", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "env", - "type" : null + "name" : "env" }, { - "name" : "port", - "type" : null + "name" : "port" }, { - "name" : "debug", - "type" : null + "name" : "debug" } ], "localVariables" : [ "timestamp" ], "methodCalls" : [ { "methodName" : "now", - "objectType" : null, "objectName" : "Date", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "parseOptions", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "otherOptions", - "type" : null + "name" : "otherOptions" }, { - "name" : "timeout", - "type" : null + "name" : "timeout" }, { - "name" : "retries", - "type" : null + "name" : "retries" }, { - "name" : "headers", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "headers" + } ] }, { "name" : "getOddIndexed", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "items", - "type" : null + "name" : "items" } ], "localVariables" : [ "items" ], "methodCalls" : [ { "methodName" : "filter", - "objectType" : null, "objectName" : "", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "swapValues", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "a", - "type" : null + "name" : "a" }, { - "name" : "b", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "b" + } ] }, { "name" : "getDimensions", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "export" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "export" ] }, { "name" : "useDimensions", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getDimensions", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_DynamicImportsAndModules.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_DynamicImportsAndModules.approved.txt index 0986152..ad4f79a 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_DynamicImportsAndModules.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_DynamicImportsAndModules.approved.txt @@ -1,561 +1,317 @@ { "filePath" : "src/test/resources/samples/javascript/DynamicImportsAndModules.js", "language" : "javascript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "ModuleLoader", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { - "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "constructor" }, { "name" : "load", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "moduleName", - "type" : null + "name" : "moduleName" } ], "localVariables" : [ "module" ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "this.cache", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "has", - "objectType" : null, "objectName" : "this.cache", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "set", - "objectType" : null, "objectName" : "this.cache", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "loadMultiple", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "moduleNames", - "type" : null + "name" : "moduleNames" } ], "localVariables" : [ "promises" ], "methodCalls" : [ { "methodName" : "all", - "objectType" : null, "objectName" : "Promise", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "load", "objectType" : "ModuleLoader", "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "map", - "objectType" : null, "objectName" : "moduleNames", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "clearCache", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "clear", - "objectType" : null, "objectName" : "this.cache", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "has", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "moduleName", - "type" : null + "name" : "moduleName" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "has", - "objectType" : null, "objectName" : "this.cache", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "PluginManager", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { - "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "constructor" }, { "name" : "register", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "pluginName", - "type" : null + "name" : "pluginName" }, { - "name" : "pluginPath", - "type" : null + "name" : "pluginPath" } ], "localVariables" : [ "pluginModule", "plugin" ], "methodCalls" : [ { "methodName" : "error", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "init", - "objectType" : null, "objectName" : "plugin", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "set", - "objectType" : null, "objectName" : "this.plugins", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "execute", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "pluginName", - "type" : null + "name" : "pluginName" }, { - "name" : "method", - "type" : null + "name" : "method" }, { - "name" : "...args", - "type" : null + "name" : "...args" } ], "localVariables" : [ "plugin" ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "this.plugins", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "getPlugin", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "pluginName", - "type" : null + "name" : "pluginName" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "this.plugins", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "listPlugins", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "from", - "objectType" : null, "objectName" : "Array", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "keys", - "objectType" : null, "objectName" : "this.plugins", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "FeatureFlags", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { - "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "constructor" }, { "name" : "enableFeature", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "featureName", - "type" : null + "name" : "featureName" } ], "localVariables" : [ "featureModule", "feature" ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "this.features", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "has", - "objectType" : null, "objectName" : "this.features", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "onEnable", - "objectType" : null, "objectName" : "feature", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "set", - "objectType" : null, "objectName" : "this.features", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "isEnabled", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "featureName", - "type" : null + "name" : "featureName" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "has", - "objectType" : null, "objectName" : "this.features", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "disableFeature", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "featureName", - "type" : null + "name" : "featureName" } ], "localVariables" : [ "feature" ], "methodCalls" : [ { "methodName" : "delete", - "objectType" : null, "objectName" : "this.features", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get", - "objectType" : null, "objectName" : "this.features", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "onDisable", - "objectType" : null, "objectName" : "feature", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Router", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { - "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "constructor" }, { "name" : "register", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "path", - "type" : null + "name" : "path" }, { - "name" : "importFn", - "type" : null + "name" : "importFn" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "set", - "objectType" : null, "objectName" : "this.routes", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "navigate", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "path", - "type" : null + "name" : "path" } ], "localVariables" : [ "importFn", "module" ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "this.routes", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "importFn", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "PreloadManager", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { - "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "constructor" }, { "name" : "preload", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "modulePaths", - "type" : null + "name" : "modulePaths" } ], "localVariables" : [ "promises" ], "methodCalls" : [ { "methodName" : "add", - "objectType" : null, "objectName" : "this.preloaded", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "all", - "objectType" : null, "objectName" : "Promise", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "filter", - "objectType" : null, "objectName" : "modulePaths", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "has", - "objectType" : null, "objectName" : "this.preloaded", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "map", - "objectType" : null, "objectName" : "modulePaths.filter()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "warn", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "isPreloaded", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "modulePath", - "type" : null + "name" : "modulePath" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "has", - "objectType" : null, "objectName" : "this.preloaded", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "loadUserModule", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async", "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "userId", - "type" : null + "name" : "userId" } ], - "localVariables" : [ "userModule" ], - "methodCalls" : [ ] + "localVariables" : [ "userModule" ] }, { "name" : "loadAnalytics", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async", "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "environment", - "type" : null + "name" : "environment" } ], - "localVariables" : [ "analytics" ], - "methodCalls" : [ ] + "localVariables" : [ "analytics" ] }, { "name" : "safeImport", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async", "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "modulePath", - "type" : null + "name" : "modulePath" } ], "localVariables" : [ "module" ], "methodCalls" : [ { "methodName" : "error", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "setupRouter", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "router" ], "methodCalls" : [ { "methodName" : "register", "objectType" : "Router", "objectName" : "router", - "callCount" : 3, - "parameterCount" : null + "callCount" : 3 } ] - } ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_EnumsAndConstants.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_EnumsAndConstants.approved.txt index 2def433..8354a40 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_EnumsAndConstants.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_EnumsAndConstants.approved.txt @@ -1,264 +1,141 @@ { "filePath" : "src/test/resources/samples/javascript/EnumsAndConstants.js", "language" : "javascript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "OrderStatus", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "PENDING", "type" : "OrderStatus", - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ] + "modifiers" : [ "static" ] }, { "name" : "PROCESSING", "type" : "OrderStatus", - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ] + "modifiers" : [ "static" ] }, { "name" : "SHIPPED", "type" : "OrderStatus", - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ] + "modifiers" : [ "static" ] }, { "name" : "DELIVERED", "type" : "OrderStatus", - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ] + "modifiers" : [ "static" ] }, { "name" : "CANCELLED", "type" : "OrderStatus", - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ] + "modifiers" : [ "static" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "key", - "type" : null + "name" : "key" }, { - "name" : "label", - "type" : null + "name" : "label" }, { - "name" : "order", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "order" + } ] }, { "name" : "values", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "static" ] }, { "name" : "fromKey", - "returnType" : null, - "visibility" : null, "modifiers" : [ "static" ], - "annotations" : [ ], "parameters" : [ { - "name" : "key", - "type" : null + "name" : "key" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "find", - "objectType" : null, "objectName" : "OrderStatus.values()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "values", - "objectType" : null, "objectName" : "OrderStatus", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { - "name" : "isTerminal", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "isTerminal" }, { "name" : "canTransitionTo", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "nextStatus", - "type" : null + "name" : "nextStatus" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isTerminal", "objectType" : "OrderStatus", "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { - "name" : "toString", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "toString" + } ] }, { "kind" : "class", "name" : "Order", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "id", - "type" : null + "name" : "id" }, { - "name" : "items", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "items" + } ] }, { "name" : "updateStatus", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "newStatus", - "type" : null + "name" : "newStatus" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "canTransitionTo", - "objectType" : null, "objectName" : "this.status", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "push", - "objectType" : null, "objectName" : "this.statusHistory", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "getStatusLabel", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "toString", - "objectType" : null, "objectName" : "this.status", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "isComplete", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isTerminal", - "objectType" : null, "objectName" : "this.status", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "getRolePermissions", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "role", - "type" : null + "name" : "role" } ], - "localVariables" : [ "permissions" ], - "methodCalls" : [ ] + "localVariables" : [ "permissions" ] }, { "name" : "getHttpStatusMessage", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "status", - "type" : null + "name" : "status" } ], "localVariables" : [ "messages" ], "methodCalls" : [ { "methodName" : "get", "objectType" : "Map", "objectName" : "messages", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ], "fields" : [ { "name" : "UserRole", - "type" : null, - "visibility" : null, - "modifiers" : [ "const", "export" ], - "annotations" : [ ] + "modifiers" : [ "const", "export" ] }, { "name" : "HttpStatus", - "type" : null, - "visibility" : null, - "modifiers" : [ "const", "export" ], - "annotations" : [ ] - } ], - "methodCalls" : [ ], - "imports" : [ ] + "modifiers" : [ "const", "export" ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_GeneratorsAndIterators.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_GeneratorsAndIterators.approved.txt index fabd512..d8860f4 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_GeneratorsAndIterators.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_GeneratorsAndIterators.approved.txt @@ -1,355 +1,197 @@ { "filePath" : "src/test/resources/samples/javascript/GeneratorsAndIterators.js", "language" : "javascript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Range", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "start", - "type" : null + "name" : "start" }, { - "name" : "end", - "type" : null + "name" : "end" }, { - "name" : "step", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "step" + } ] }, { "name" : "reverse", - "returnType" : null, - "visibility" : null, "modifiers" : [ "*" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ "i" ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "localVariables" : [ "i" ] + } ] }, { "kind" : "class", "name" : "PaginatedData", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "items", - "type" : null + "name" : "items" }, { - "name" : "pageSize", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "pageSize" + } ] }, { "name" : "pages", - "returnType" : null, - "visibility" : null, "modifiers" : [ "*" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "i" ], "methodCalls" : [ { "methodName" : "slice", - "objectType" : null, "objectName" : "this.items", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "TreeNode", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "value", - "type" : null + "name" : "value" }, { - "name" : "children", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "children" + } ] }, { "name" : "preOrder", - "returnType" : null, - "visibility" : null, "modifiers" : [ "*" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "preOrder", - "objectType" : null, "objectName" : "child", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "postOrder", - "returnType" : null, - "visibility" : null, "modifiers" : [ "*" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "postOrder", - "objectType" : null, "objectName" : "child", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "breadthFirst", - "returnType" : null, - "visibility" : null, "modifiers" : [ "*" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "queue", "node" ], "methodCalls" : [ { "methodName" : "push", "objectType" : "Array", "objectName" : "queue", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "shift", "objectType" : "Array", "objectName" : "queue", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "processAsyncStream", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async", "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "asyncIterable", - "type" : null + "name" : "asyncIterable" } ], "localVariables" : [ "results" ], "methodCalls" : [ { "methodName" : "push", "objectType" : "Array", "objectName" : "results", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "numberGenerator", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export", "function*" ], - "annotations" : [ ], "parameters" : [ { - "name" : "start", - "type" : null + "name" : "start" }, { - "name" : "end", - "type" : null + "name" : "end" } ], - "localVariables" : [ "i" ], - "methodCalls" : [ ] + "localVariables" : [ "i" ] }, { "name" : "flattenArray", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export", "function*" ], - "annotations" : [ ], "parameters" : [ { - "name" : "arr", - "type" : null + "name" : "arr" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "flattenArray", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "isArray", - "objectType" : null, "objectName" : "Array", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fibonacci", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "export", "function*" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "export", "function*" ] }, { "name" : "dataProcessor", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export", "function*" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ "value" ], - "methodCalls" : [ ] + "localVariables" : [ "value" ] }, { "name" : "fetchPages", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async", "export", "function*" ], - "annotations" : [ ], "parameters" : [ { - "name" : "baseUrl", - "type" : null + "name" : "baseUrl" }, { - "name" : "maxPages", - "type" : null + "name" : "maxPages" } ], "localVariables" : [ "page", "response", "data" ], "methodCalls" : [ { "methodName" : "fetch", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "json", - "objectType" : null, "objectName" : "response", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "streamData", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async", "export", "function*" ], - "annotations" : [ ], "parameters" : [ { - "name" : "source", - "type" : null + "name" : "source" } ], "localVariables" : [ "hasMore", "offset", "batch" ], "methodCalls" : [ { "methodName" : "error", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "fetch", - "objectType" : null, "objectName" : "source", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "map", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export", "function*" ], - "annotations" : [ ], "parameters" : [ { - "name" : "iterable", - "type" : null + "name" : "iterable" }, { - "name" : "fn", - "type" : null + "name" : "fn" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "fn", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "filter", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export", "function*" ], - "annotations" : [ ], "parameters" : [ { - "name" : "iterable", - "type" : null + "name" : "iterable" }, { - "name" : "predicate", - "type" : null + "name" : "predicate" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "predicate", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "take", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export", "function*" ], - "annotations" : [ ], "parameters" : [ { - "name" : "iterable", - "type" : null + "name" : "iterable" }, { - "name" : "n", - "type" : null + "name" : "n" } ], - "localVariables" : [ "count" ], - "methodCalls" : [ ] - } ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "localVariables" : [ "count" ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ModernClassFeatures.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ModernClassFeatures.approved.txt index 28ba3de..bea92a1 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ModernClassFeatures.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ModernClassFeatures.approved.txt @@ -1,382 +1,192 @@ { "filePath" : "src/test/resources/samples/javascript/ModernClassFeatures.js", "language" : "javascript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "BaseEntity", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "#id", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "#createdAt", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "id", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "id" + } ] }, { "name" : "id", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "get" ] }, { "name" : "createdAt", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "get" ] }, { "name" : "toJSON", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "toISOString", - "objectType" : null, "objectName" : "this.#createdAt", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "User", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "extendsType" : "BaseEntity", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "#instanceCount", "type" : "Number", "visibility" : "private", - "modifiers" : [ "static" ], - "annotations" : [ ] + "modifiers" : [ "static" ] }, { "name" : "MAX_NAME_LENGTH", "type" : "Number", - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ] + "modifiers" : [ "static" ] }, { "name" : "#name", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "#email", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "#role", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "id", - "type" : null + "name" : "id" }, { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "email", - "type" : null + "name" : "email" }, { - "name" : "role", - "type" : null + "name" : "role" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "name", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "get" ] }, { "name" : "name", - "returnType" : null, - "visibility" : null, "modifiers" : [ "set" ], - "annotations" : [ ], "parameters" : [ { - "name" : "value", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "value" + } ] }, { "name" : "email", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "get" ] }, { "name" : "email", - "returnType" : null, - "visibility" : null, "modifiers" : [ "set" ], - "annotations" : [ ], "parameters" : [ { - "name" : "value", - "type" : null + "name" : "value" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "includes", - "objectType" : null, "objectName" : "value", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "role", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "get" ] }, { "name" : "getInstanceCount", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "static" ] }, { "name" : "resetCount", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "static" ] }, { "name" : "#validatePermission", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "action", - "type" : null + "name" : "action" } ], "localVariables" : [ "permissions" ], "methodCalls" : [ { "methodName" : "includes", - "objectType" : null, "objectName" : "permissions[this.#role]", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "canPerform", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "action", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "action" + } ] }, { "name" : "toJSON", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "toJSON", - "objectType" : null, "objectName" : "super", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "AdminUser", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "extendsType" : "User", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "#permissions", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "id", - "type" : null + "name" : "id" }, { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "email", - "type" : null + "name" : "email" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "permissions", - "returnType" : null, - "visibility" : null, "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "from", - "objectType" : null, "objectName" : "Array", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "addPermission", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "permission", - "type" : null + "name" : "permission" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "add", - "objectType" : null, "objectName" : "this.#permissions", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "removePermission", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "permission", - "type" : null + "name" : "permission" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "delete", - "objectType" : null, "objectName" : "this.#permissions", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "hasPermission", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "permission", - "type" : null + "name" : "permission" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "has", - "objectType" : null, "objectName" : "this.#permissions", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ModernSyntax.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ModernSyntax.approved.txt index 2d47d46..7db2ef7 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ModernSyntax.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ModernSyntax.approved.txt @@ -1,728 +1,407 @@ { "filePath" : "src/test/resources/samples/javascript/ModernSyntax.js", "language" : "javascript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Point", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "x", - "type" : null + "name" : "x" }, { - "name" : "y", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "y" + } ] }, { "name" : "distanceTo", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "other", - "type" : null + "name" : "other" } ], "localVariables" : [ "dx", "dy" ], "methodCalls" : [ { "methodName" : "sqrt", - "objectType" : null, "objectName" : "Math", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { - "name" : "toString", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "toString" + } ] }, { "kind" : "class", "name" : "Rectangle", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "width", - "type" : null + "name" : "width" }, { - "name" : "height", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "height" + } ] }, { "name" : "area", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "get" ] }, { "name" : "perimeter", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "get" ] }, { "name" : "scale", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "factor", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "factor" + } ] + } ] }, { "kind" : "class", "name" : "Shape", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "name", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - }, { - "name" : "describe", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "name" + } ] + }, { + "name" : "describe" + } ] }, { "kind" : "class", "name" : "Circle", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "extendsType" : "Shape", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "radius", - "type" : null + "name" : "radius" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "area", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "get" ] }, { "name" : "circumference", - "returnType" : null, - "visibility" : null, - "modifiers" : [ "get" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "get" ] + } ] } ], "methods" : [ { "name" : "getUserCity", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "user", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "user" + } ] }, { "name" : "getFirstItemName", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "order", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "order" + } ] }, { "name" : "safelyCallMethod", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "obj", - "type" : null + "name" : "obj" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "process", - "objectType" : null, "objectName" : "obj", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "getNestedValue", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "data", - "type" : null + "name" : "data" } ], "localVariables" : [ "street", "zipCode", "callback" ], "methodCalls" : [ { "methodName" : "callback", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "getConfigValue", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "config", - "type" : null + "name" : "config" }, { - "name" : "key", - "type" : null + "name" : "key" }, { - "name" : "defaultValue", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "defaultValue" + } ] }, { "name" : "mergeSettings", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "userSettings", - "type" : null + "name" : "userSettings" }, { - "name" : "defaults", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "defaults" + } ] }, { "name" : "getSafeValue", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "obj", - "type" : null + "name" : "obj" }, { - "name" : "path", - "type" : null + "name" : "path" }, { - "name" : "defaultValue", - "type" : null + "name" : "defaultValue" } ], "localVariables" : [ "parts", "current" ], "methodCalls" : [ { "methodName" : "split", - "objectType" : null, "objectName" : "path", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "html", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "strings", - "type" : null + "name" : "strings" }, { - "name" : "...values", - "type" : null + "name" : "...values" } ], "localVariables" : [ "escaped" ], "methodCalls" : [ { "methodName" : "String", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "map", - "objectType" : null, "objectName" : "values", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "reduce", - "objectType" : null, "objectName" : "strings", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "replace", - "objectType" : null, "objectName" : "String()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "replace", - "objectType" : null, "objectName" : "String().replace()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "replace", - "objectType" : null, "objectName" : "String().replace().replace()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "replace", - "objectType" : null, "objectName" : "String().replace().replace().replace()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "sql", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "strings", - "type" : null + "name" : "strings" }, { - "name" : "...values", - "type" : null + "name" : "...values" } ], "localVariables" : [ "sanitized" ], "methodCalls" : [ { "methodName" : "String", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "map", - "objectType" : null, "objectName" : "values", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "reduce", - "objectType" : null, "objectName" : "strings", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "replace", - "objectType" : null, "objectName" : "val", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "trim", - "objectType" : null, "objectName" : "strings.reduce()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "css", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "strings", - "type" : null + "name" : "strings" }, { - "name" : "...values", - "type" : null + "name" : "...values" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "reduce", - "objectType" : null, "objectName" : "strings", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "renderUserCard", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "user", - "type" : null + "name" : "user" } ], "localVariables" : [ "cardHtml" ], "methodCalls" : [ { "methodName" : "html", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "buildQuery", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "tableName", - "type" : null + "name" : "tableName" }, { - "name" : "conditions", - "type" : null + "name" : "conditions" } ], "localVariables" : [ "conditions" ], "methodCalls" : [ { "methodName" : "sql", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "parseJSON", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "jsonString", - "type" : null + "name" : "jsonString" } ], "localVariables" : [ "result", "error", "parsed", "validated", "errorMessage", "errorStack", "timestamp" ], "methodCalls" : [ { "methodName" : "log", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "now", - "objectType" : null, "objectName" : "Date", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "parse", - "objectType" : null, "objectName" : "JSON", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "validateStructure", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "validateStructure", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "obj", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "obj" + } ] }, { "name" : "fetchWithRetry", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async", "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "url", - "type" : null + "name" : "url" }, { - "name" : "maxRetries", - "type" : null + "name" : "maxRetries" } ], "localVariables" : [ "lastError", "attempts", "response", "data", "retryCount", "delay", "attemptNumber" ], "methodCalls" : [ { "methodName" : "fetch", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "json", - "objectType" : null, "objectName" : "response", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "log", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "pow", - "objectType" : null, "objectName" : "Math", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "setTimeout", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "processFile", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "fileContent", - "type" : null + "name" : "fileContent" } ], "localVariables" : [ "resources", "lines", "header", "body", "resource", "errorLine", "errorMessage", "resourceCount" ], "methodCalls" : [ { "methodName" : "log", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "parseLine", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "push", "objectType" : "Array", "objectName" : "resources", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "slice", - "objectType" : null, "objectName" : "lines", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "split", - "objectType" : null, "objectName" : "fileContent", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "parseLine", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "line", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "line" + } ] }, { "name" : "createPerson", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "initialName", - "type" : null + "name" : "initialName" }, { - "name" : "initialAge", - "type" : null + "name" : "initialAge" } ], - "localVariables" : [ "_name", "_age" ], - "methodCalls" : [ ] + "localVariables" : [ "_name", "_age" ] }, { "name" : "createDynamicObject", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "keyPrefix", - "type" : null + "name" : "keyPrefix" }, { - "name" : "values", - "type" : null + "name" : "values" } ], "localVariables" : [ "result", "key" ], "methodCalls" : [ { "methodName" : "forEach", - "objectType" : null, "objectName" : "values", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "createAccessors", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "propertyName", - "type" : null + "name" : "propertyName" } ], "localVariables" : [ "privateKey" ], "methodCalls" : [ { "methodName" : "charAt", - "objectType" : null, "objectName" : "propertyName", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "slice", - "objectType" : null, "objectName" : "propertyName", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "toUpperCase", - "objectType" : null, "objectName" : "propertyName.charAt()", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 } ] }, { "name" : "updateConfig", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "config", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "config" + } ] }, { "name" : "initializeDefaults", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "options", - "type" : null + "name" : "options" } ], - "localVariables" : [ "result" ], - "methodCalls" : [ ] + "localVariables" : [ "result" ] } ], "fields" : [ { "name" : "mathUtils", "type" : "Object", - "visibility" : null, - "modifiers" : [ "const", "export" ], - "annotations" : [ ] - } ], - "methodCalls" : [ ], - "imports" : [ ] + "modifiers" : [ "const", "export" ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ResourceWrapper.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ResourceWrapper.approved.txt index 04d738e..1aca815 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ResourceWrapper.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_ResourceWrapper.approved.txt @@ -1,317 +1,197 @@ { "filePath" : "src/test/resources/samples/javascript/resourceLocationWrapper.js", "language" : "javascript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "ResourceLocationWrapper", - "visibility" : null, "modifiers" : [ "export", "default" ], - "annotations" : [ ], "extendsType" : "React.Component", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "resourceLocationFunctions", - "type" : "Object", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Object" }, { "name" : "style", - "type" : "Object", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Object" } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "props", - "type" : null + "name" : "props" }, { - "name" : "context", - "type" : null + "name" : "context" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "bind", - "objectType" : null, "objectName" : "this.fetchAllResourceLocations", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "bind", - "objectType" : null, "objectName" : "this.fetchAllVisitLocations", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "bind", - "objectType" : null, "objectName" : "this.fetchItemTypes", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "bind", - "objectType" : null, "objectName" : "this.getBody", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "fetchAllResourceLocations", "objectType" : "ResourceLocationWrapper", "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "fetchAllVisitLocations", "objectType" : "ResourceLocationWrapper", "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "fetchItemTypes", "objectType" : "ResourceLocationWrapper", "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fetchAllResourceLocations", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], "localVariables" : [ "resourceLocationUuidList", "resourceLocations", "error" ], "methodCalls" : [ { "methodName" : "apiBaseUrl", - "objectType" : null, "objectName" : "this.urlHelper", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "catch", - "objectType" : null, "objectName" : "axios.get().then()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get", - "objectType" : null, "objectName" : "axios", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "includes", - "objectType" : null, "objectName" : "_", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "map", - "objectType" : null, "objectName" : "_", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "notify", - "objectType" : null, "objectName" : "self.resourceLocationFunctions", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "reduce", - "objectType" : null, "objectName" : "_", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "replace", - "objectType" : null, "objectName" : "error.message", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "setState", - "objectType" : null, "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "then", - "objectType" : null, "objectName" : "axios.get()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fetchAllVisitLocations", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], "localVariables" : [ "visitLocationUuidList", "visitLocations", "error" ], "methodCalls" : [ { "methodName" : "apiBaseUrl", - "objectType" : null, "objectName" : "this.urlHelper", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "catch", - "objectType" : null, "objectName" : "axios.get().then()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get", - "objectType" : null, "objectName" : "axios", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "includes", - "objectType" : null, "objectName" : "_", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "map", - "objectType" : null, "objectName" : "_", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "notify", - "objectType" : null, "objectName" : "self.resourceLocationFunctions", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "reduce", - "objectType" : null, "objectName" : "_", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "replace", - "objectType" : null, "objectName" : "error.message", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "setState", - "objectType" : null, "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "then", - "objectType" : null, "objectName" : "axios.get()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fetchItemTypes", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "self", "error" ], "methodCalls" : [ { "methodName" : "apiBaseUrl", - "objectType" : null, "objectName" : "this.urlHelper", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "catch", - "objectType" : null, "objectName" : "axios.get().then()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get", - "objectType" : null, "objectName" : "axios", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "notify", - "objectType" : null, "objectName" : "self.resourceLocationFunctions", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "replace", - "objectType" : null, "objectName" : "error.message", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "setState", - "objectType" : null, "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "then", - "objectType" : null, "objectName" : "axios.get()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { - "name" : "getBody", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "getBody" }, { "name" : "render", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getBody", "objectType" : "ResourceLocationWrapper", "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "import React from 'react';", "import PropTypes from 'prop-types';", "import axios from 'axios';", "import _ from 'lodash';", "import Header from 'components/header';", "import ItemHierarchy from 'components/resourceLocation/leftPanel/itemHierarchy';", "import ResourceLocationList from 'components/resourceLocation/rightPanel/resourceLocationList';", "import AddEditResourceLocation\n from 'components/resourceLocation/rightPanel/resourceLocationForm/addEditResourceLocation';", "import SetItemLayout from 'components/resourceLocation/rightPanel/resourceLocationForm/setItemLayout';", "import AddEditItem from 'components/resourceLocation/rightPanel/resourceLocationForm/addEditItem';", "import ResourceLocationHelper from 'utilities/resourceLocationHelper';", "import UrlHelper from 'utilities/urlHelper';", "import ReactNotify from 'react-notify';" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_Sample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_Sample.approved.txt index 580b609..e9ff29c 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_Sample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_Sample.approved.txt @@ -1,173 +1,108 @@ { "filePath" : "src/test/resources/samples/javascript/sample.js", "language" : "javascript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "DataManager", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "apiUrl", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "apiUrl" + } ] }, { "name" : "getData", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "key", - "type" : null + "name" : "key" } ], "localVariables" : [ "data" ], "methodCalls" : [ { "methodName" : "fetchData", "objectType" : "DataManager", "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "get", - "objectType" : null, "objectName" : "this.cache", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "has", - "objectType" : null, "objectName" : "this.cache", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "set", - "objectType" : null, "objectName" : "this.cache", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fetchData", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { - "name" : "key", - "type" : null + "name" : "key" } ], "localVariables" : [ "response" ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "axios", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "processData", - "returnType" : null, - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "data", - "type" : null + "name" : "data" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "expect", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "map", - "objectType" : null, "objectName" : "data", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "parseFloat", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "toBeGreaterThan", - "objectType" : null, "objectName" : "expect()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fetchUser", - "returnType" : null, - "visibility" : null, "modifiers" : [ "async", "const", "export" ], - "annotations" : [ ], "parameters" : [ { - "name" : "userId", - "type" : null + "name" : "userId" } ], "localVariables" : [ "response" ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "axios", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ], "fields" : [ { "name" : "API_VERSION", "type" : "String", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "MAX_RETRIES", "type" : "Number", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "currentUser", - "type" : null, - "visibility" : null, - "modifiers" : [ "let" ], - "annotations" : [ ] + "modifiers" : [ "let" ] }, { "name" : "DEFAULT_TIMEOUT", "type" : "Number", - "visibility" : null, - "modifiers" : [ "const", "export" ], - "annotations" : [ ] + "modifiers" : [ "const", "export" ] } ], "methodCalls" : [ { "methodName" : "log", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ], "imports" : [ "import axios from 'axios';", "import { formatDate } from './utils';" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_TestFile.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_TestFile.approved.txt index 0fd3c5f..928788f 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_TestFile.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.analyze_JavaScript_TestFile.approved.txt @@ -1,124 +1,73 @@ { "filePath" : "src/test/resources/samples/javascript/example.test.js", "language" : "javascript", - "packageName" : null, - "types" : [ ], - "methods" : [ ], - "fields" : [ ], "methodCalls" : [ { "methodName" : "afterEach", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "beforeEach", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "describe", - "objectType" : null, - "objectName" : null, - "callCount" : 7, - "parameterCount" : null + "callCount" : 7 }, { "methodName" : "expect", - "objectType" : null, - "objectName" : null, - "callCount" : 11, - "parameterCount" : null + "callCount" : 11 }, { "methodName" : "failingFetch", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "fetchData", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "filter", - "objectType" : null, "objectName" : "numbers", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "map", - "objectType" : null, "objectName" : "items", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "parseFloat", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "reject", - "objectType" : null, "objectName" : "Promise", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "resolve", - "objectType" : null, "objectName" : "Promise", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "test", - "objectType" : null, - "objectName" : null, - "callCount" : 11, - "parameterCount" : null + "callCount" : 11 }, { "methodName" : "toBe", - "objectType" : null, "objectName" : "expect()", - "callCount" : 4, - "parameterCount" : null + "callCount" : 4 }, { "methodName" : "toBeDefined", - "objectType" : null, "objectName" : "expect()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "toBeGreaterThan", - "objectType" : null, "objectName" : "expect()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "toBeUndefined", - "objectType" : null, "objectName" : "expect()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "toContain", - "objectType" : null, "objectName" : "expect()", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "toEqual", - "objectType" : null, "objectName" : "expect()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "toThrow", - "objectType" : null, "objectName" : "expect().rejects", - "callCount" : 1, - "parameterCount" : null - } ], - "imports" : [ ] + "callCount" : 1 + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.java index 266942f..9494358 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/javascript/JavaScriptAnalyzeApprovalTest.java @@ -1,11 +1,10 @@ package org.dxworks.codeframe.analyzer.javascript; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.approvaltests.Approvals; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; import org.dxworks.codeframe.model.FileAnalysis; +import org.dxworks.codeframe.TestUtils; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -14,10 +13,6 @@ public class JavaScriptAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_JavaScript_Sample() throws IOException { verify(Paths.get("src/test/resources/samples/javascript/sample.js"), Language.JAVASCRIPT); @@ -68,8 +63,8 @@ void analyze_JavaScript_TestFile() throws IOException { verify(Paths.get("src/test/resources/samples/javascript/example.test.js"), Language.JAVASCRIPT); } - private static void verify(Path file, Language language) throws IOException { - FileAnalysis analysis = (FileAnalysis) App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + private static void verify(Path filePath, Language language) throws IOException { + FileAnalysis analysis = (FileAnalysis) App.analyzeFile(filePath, language); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ClosuresAndArrowFunctionsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ClosuresAndArrowFunctionsSample.approved.txt index 1948fe3..ae14f73 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ClosuresAndArrowFunctionsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ClosuresAndArrowFunctionsSample.approved.txt @@ -1,44 +1,31 @@ { "filePath" : "src/test/resources/samples/php/ClosuresAndArrowFunctionsSample.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Calculator", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "operations", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "logger", "type" : "?callable", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "logger", "type" : "?callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "initializeOperations", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -47,32 +34,24 @@ "name" : "initializeOperations", "returnType" : "void", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "private" ] }, { "name" : "registerOperation", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" }, { "name" : "operation", "type" : "callable" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "execute", "returnType" : "float", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "operation", "type" : "string" @@ -86,8 +65,6 @@ "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -96,65 +73,44 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "logger", "type" : "callable" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getOperationNames", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_keys", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Collection", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "items", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "map", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "callback", "type" : "callable" @@ -162,8 +118,6 @@ "localVariables" : [ "mapped" ], "methodCalls" : [ { "methodName" : "array_map", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -172,7 +126,6 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "predicate", "type" : "callable" @@ -180,14 +133,10 @@ "localVariables" : [ "filtered" ], "methodCalls" : [ { "methodName" : "array_filter", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "array_values", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -196,7 +145,6 @@ "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "callback", "type" : "callable" @@ -204,11 +152,8 @@ "name" : "initial", "type" : "mixed" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_reduce", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] @@ -217,31 +162,24 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "callback", "type" : "callable" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "find", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "predicate", "type" : "callable" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "sort", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "comparator", "type" : "callable" @@ -249,8 +187,6 @@ "localVariables" : [ "sorted" ], "methodCalls" : [ { "methodName" : "usort", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -258,51 +194,33 @@ "name" : "toArray", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "count", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "count", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "EventEmitter", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "listeners", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "on", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "event", "type" : "string" @@ -310,11 +228,8 @@ "name" : "listener", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -323,7 +238,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "event", "type" : "string" @@ -331,11 +245,8 @@ "name" : "...args", "type" : "mixed" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -344,7 +255,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "event", "type" : "string" @@ -355,13 +265,11 @@ "localVariables" : [ "wrapper" ], "methodCalls" : [ { "methodName" : "off", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "on", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 2 @@ -371,7 +279,6 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "event", "type" : "string" @@ -379,17 +286,12 @@ "name" : "listener", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_filter", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -398,47 +300,30 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "event", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "FunctionUtils", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "compose", "returnType" : "callable", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "...functions", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_reduce", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 }, { "methodName" : "array_reverse", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -447,16 +332,12 @@ "returnType" : "callable", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "...functions", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_reduce", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] @@ -465,7 +346,6 @@ "returnType" : "callable", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "fn", "type" : "callable" @@ -473,17 +353,13 @@ "name" : "arity", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "count", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 }, { "methodName" : "curry", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -492,7 +368,6 @@ "returnType" : "callable", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "fn", "type" : "callable" @@ -500,14 +375,10 @@ "localVariables" : [ "cache", "key" ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "serialize", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -516,7 +387,6 @@ "returnType" : "callable", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "fn", "type" : "callable" @@ -527,47 +397,32 @@ "localVariables" : [ "lastCall", "now" ], "methodCalls" : [ { "methodName" : "microtime", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "createCounter", "returnType" : "callable", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "start", "type" : "int" } ], - "localVariables" : [ "count" ], - "methodCalls" : [ ] + "localVariables" : [ "count" ] }, { "name" : "createFormatter", "returnType" : "callable", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "prefix", "type" : "string" }, { "name" : "suffix", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "applyToAll", "returnType" : "array", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "array" @@ -575,20 +430,14 @@ "name" : "fn", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_map", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] }, { "name" : "filterBy", "returnType" : "array", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "array" @@ -596,17 +445,12 @@ "name" : "predicate", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_filter", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "array_values", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -614,26 +458,18 @@ "fields" : [ { "name" : "MULTIPLIER", "type" : "int", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "DEFAULT_PREFIX", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], "methodCalls" : [ { "methodName" : "error_log", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "set_error_handler", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ], diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_EnumsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_EnumsSample.approved.txt index 8b7674b..d71bb70 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_EnumsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_EnumsSample.approved.txt @@ -1,48 +1,35 @@ { "filePath" : "src/test/resources/samples/php/EnumsSample.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Task", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "id", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "title", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "status", "type" : "Status", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "priority", "type" : "Priority", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -55,152 +42,92 @@ }, { "name" : "priority", "type" : "Priority" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getTitle", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getStatus", "returnType" : "Status", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setStatus", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "status", "type" : "Status" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getPriority", "returnType" : "Priority", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setPriority", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "priority", "type" : "Priority" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "isHighPriority", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "toArray", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getColor", - "objectType" : null, "objectName" : "priority", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "label", - "objectType" : null, "objectName" : "status", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "interface", "name" : "Describable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "describe", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "abstract" ] + } ] }, { "kind" : "trait", "name" : "EnumHelpers", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "names", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_column", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "cases", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] @@ -209,19 +136,13 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_column", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "cases", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] @@ -230,174 +151,105 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "cases" ], "methodCalls" : [ { "methodName" : "array_rand", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "cases", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "enum", "name" : "Status", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "Pending", - "type" : null, - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Active", - "type" : null, - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Inactive", - "type" : null, - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Deleted", - "type" : null, - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] } ], - "properties" : [ ], "methods" : [ { "name" : "label", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isActive", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "default", "returnType" : "self", "visibility" : "public", - "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public", "static" ] + } ] }, { "kind" : "enum", "name" : "Color", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "string", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "Red", "type" : "string", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Green", "type" : "string", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Blue", "type" : "string", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Yellow", "type" : "string", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Black", "type" : "string", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "White", "type" : "string", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] } ], - "properties" : [ ], "methods" : [ { "name" : "hex", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "rgb", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "hex" ], "methodCalls" : [ { "methodName" : "hex", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "hexdec", - "objectType" : null, - "objectName" : null, "callCount" : 3, "parameterCount" : 1 }, { "methodName" : "ltrim", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "substr", - "objectType" : null, - "objectName" : null, "callCount" : 3, "parameterCount" : 3 } ] @@ -406,300 +258,192 @@ "returnType" : "?self", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "hex", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "cases", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "hex", - "objectType" : null, "objectName" : "case", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "strtoupper", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "enum", "name" : "HttpStatus", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "int", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "OK", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Created", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "NoContent", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "BadRequest", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Unauthorized", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Forbidden", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "NotFound", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "InternalServerError", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "ServiceUnavailable", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] } ], - "properties" : [ ], "methods" : [ { "name" : "message", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isSuccess", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isClientError", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isServerError", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "fromCode", "returnType" : "?self", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "code", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "tryFrom", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "enum", "name" : "Priority", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "int", "implementsInterfaces" : [ "Describable" ], - "mixins" : [ ], "fields" : [ { "name" : "Low", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Medium", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "High", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Critical", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] } ], - "properties" : [ ], "methods" : [ { "name" : "describe", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getColor", "returnType" : "Color", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "highest", "returnType" : "self", "visibility" : "public", - "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public", "static" ] }, { "name" : "lowest", "returnType" : "self", "visibility" : "public", - "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public", "static" ] + } ] }, { "kind" : "enum", "name" : "DayOfWeek", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "int", - "implementsInterfaces" : [ ], "mixins" : [ "EnumHelpers" ], "fields" : [ { "name" : "Monday", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Tuesday", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Wednesday", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Thursday", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Friday", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Saturday", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] }, { "name" : "Sunday", "type" : "int", - "visibility" : null, - "modifiers" : [ "case" ], - "annotations" : [ ] + "modifiers" : [ "case" ] } ], - "properties" : [ ], "methods" : [ { "name" : "isWeekend", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isWeekday", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isWeekend", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -709,13 +453,10 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "nextValue" ], "methodCalls" : [ { "methodName" : "from", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -724,33 +465,24 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "prevValue" ], "methodCalls" : [ { "methodName" : "from", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "getStatusLabel", "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "status", "type" : "Status" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "label", - "objectType" : null, "objectName" : "status", "callCount" : 1, "parameterCount" : 0 @@ -758,9 +490,6 @@ }, { "name" : "createTask", "returnType" : "Task", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "title", "type" : "string" @@ -768,16 +497,12 @@ "name" : "priority", "type" : "Priority" } ], - "localVariables" : [ "task" ], - "methodCalls" : [ ] + "localVariables" : [ "task" ] } ], "fields" : [ { "name" : "ENUM_VERSION", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], - "methodCalls" : [ ], "imports" : [ "namespace App\\Enums;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ExceptionHandlingSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ExceptionHandlingSample.approved.txt index 1deb854..6d8e4a5 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ExceptionHandlingSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ExceptionHandlingSample.approved.txt @@ -1,36 +1,25 @@ { "filePath" : "src/test/resources/samples/php/ExceptionHandlingSample.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "ApplicationException", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "errorCode", "type" : "string", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] }, { "name" : "context", "type" : "array", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" @@ -47,11 +36,9 @@ "name" : "previous", "type" : "?\\Throwable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] @@ -59,72 +46,49 @@ "name" : "getErrorCode", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getContext", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "toArray", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getFile", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "getLine", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "getMessage", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ValidationException", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationException", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "errors", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "errors", "type" : "array" @@ -132,11 +96,9 @@ "name" : "message", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] @@ -144,26 +106,18 @@ "name" : "getErrors", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "hasError", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "field", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -172,44 +126,31 @@ "returnType" : "?string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "field", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "NotFoundException", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationException", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "resourceType", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "resourceId", "type" : "mixed", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "resourceType", "type" : "string" @@ -221,7 +162,6 @@ "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 4 } ] @@ -229,45 +169,28 @@ "name" : "getResourceType", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getResourceId", "returnType" : "mixed", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] }, { "kind" : "class", "name" : "DatabaseException", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationException", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "query", "type" : "?string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" @@ -278,11 +201,9 @@ "name" : "previous", "type" : "?\\Throwable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 5 } ] @@ -290,67 +211,43 @@ "name" : "getQuery", "returnType" : "?string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] }, { "kind" : "class", "name" : "AuthenticationException", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationException", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 4 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "AuthorizationException", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationException", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "requiredPermission", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "requiredPermission", "type" : "string" @@ -359,7 +256,6 @@ "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 4 } ] @@ -367,54 +263,33 @@ "name" : "getRequiredPermission", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] }, { "kind" : "class", "name" : "UserService", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "users", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "findById", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -423,7 +298,6 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array" @@ -431,25 +305,18 @@ "localVariables" : [ "errors", "id", "user" ], "methodCalls" : [ { "methodName" : "array_keys", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "empty", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "max", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "validate", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 @@ -459,7 +326,6 @@ "returnType" : "array", "visibility" : "private", "modifiers" : [ "private" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array" @@ -467,14 +333,10 @@ "localVariables" : [ "errors" ], "methodCalls" : [ { "methodName" : "empty", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 }, { "methodName" : "filter_var", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -483,156 +345,103 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "DatabaseConnection", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "connected", "type" : "bool", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "inTransaction", "type" : "bool", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "connect", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "disconnect", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isConnected", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "beginTransaction", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "commit", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "rollback", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "query", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "sql", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "str_contains", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ExceptionHandler", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "handlers", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "register", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "exceptionClass", "type" : "string" }, { "name" : "handler", "type" : "callable" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "handle", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "e", "type" : "\\Throwable" @@ -640,20 +449,15 @@ "localVariables" : [ "class" ], "methodCalls" : [ { "methodName" : "defaultHandler", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "get_class", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -662,71 +466,53 @@ "returnType" : "array", "visibility" : "private", "modifiers" : [ "private" ], - "annotations" : [ ], "parameters" : [ { "name" : "e", "type" : "\\Throwable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getCode", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "getMessage", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "RetryableOperation", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "maxAttempts", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "delayMs", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "maxAttempts", "type" : "int" }, { "name" : "delayMs", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "execute", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "operation", "type" : "callable" @@ -734,57 +520,41 @@ "localVariables" : [ "lastException", "attempt" ], "methodCalls" : [ { "methodName" : "usleep", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "OrderProcessor", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "userService", "type" : "UserService", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "db", "type" : "DatabaseConnection", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "userService", "type" : "UserService" }, { "name" : "db", "type" : "DatabaseConnection" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "processOrder", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "userId", "type" : "int" @@ -795,43 +565,36 @@ "localVariables" : [ "user", "order" ], "methodCalls" : [ { "methodName" : "beginTransaction", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "commit", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "connect", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "createOrder", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "disconnect", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "findById", - "objectType" : null, "objectName" : "userService", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "rollback", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 0 @@ -841,7 +604,6 @@ "returnType" : "array", "visibility" : "private", "modifiers" : [ "private" ], - "annotations" : [ ], "parameters" : [ { "name" : "user", "type" : "array" @@ -849,11 +611,8 @@ "name" : "items", "type" : "array" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "rand", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -862,7 +621,6 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "userId", "type" : "int" @@ -870,31 +628,26 @@ "localVariables" : [ "user", "result" ], "methodCalls" : [ { "methodName" : "findById", - "objectType" : null, "objectName" : "userService", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "getCode", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "getMessage", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "getQuery", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "query", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 1 @@ -904,27 +657,21 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "userId", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "error_log", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "getMessage", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "processWithMultipleCatch", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 @@ -934,48 +681,36 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "userId", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "connect", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "query", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "safeExecute", "returnType" : "mixed", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "fn", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "error_log", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "getMessage", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 @@ -983,9 +718,6 @@ }, { "name" : "validateOrThrow", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array" @@ -996,8 +728,6 @@ "localVariables" : [ "errors" ], "methodCalls" : [ { "methodName" : "empty", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 } ] @@ -1005,26 +735,19 @@ "fields" : [ { "name" : "MAX_RETRY_ATTEMPTS", "type" : "int", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], "methodCalls" : [ { "methodName" : "error_log", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "getMessage", - "objectType" : null, "objectName" : "e", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "set_exception_handler", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ], diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_InheritanceSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_InheritanceSample.approved.txt index ad89522..640c39e 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_InheritanceSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_InheritanceSample.approved.txt @@ -1,44 +1,34 @@ { "filePath" : "src/test/resources/samples/php/InheritanceSample.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "BaseEntity", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Entity", "Comparable" ], "mixins" : [ "HasTimestamps", "HasUuid" ], "fields" : [ { "name" : "id", "type" : "int", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "generateUuid", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "initializeTimestamps", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -47,28 +37,18 @@ "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "serialize", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "json_encode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "toArray", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -78,57 +58,40 @@ "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "equals", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getType", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "abstract", "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "abstract", "public" ] }, { "name" : "toArray", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_merge", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "getBaseData", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "getSpecificData", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -138,18 +101,13 @@ "returnType" : "array", "visibility" : "protected", "modifiers" : [ "protected" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "format", - "objectType" : null, "objectName" : "createdAt", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "getType", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -158,48 +116,33 @@ "name" : "getSpecificData", "returnType" : "array", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "protected" ] + } ] }, { "kind" : "class", "name" : "User", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "BaseEntity", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "username", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "email", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "active", "type" : "bool", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -210,11 +153,9 @@ "name" : "email", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -222,49 +163,29 @@ "name" : "getType", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getUsername", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getEmail", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isActive", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "activate", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "touch", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -274,12 +195,8 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "touch", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -288,17 +205,12 @@ "name" : "getSpecificData", "returnType" : "array", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "protected" ] }, { "name" : "deserialize", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "string" @@ -306,48 +218,35 @@ "localVariables" : [ "arr" ], "methodCalls" : [ { "methodName" : "json_decode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Product", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "BaseEntity", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "name", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "price", "type" : "float", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "stock", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -361,11 +260,9 @@ "name" : "stock", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -373,52 +270,33 @@ "name" : "getType", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getName", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getPrice", "returnType" : "float", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getStock", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setPrice", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "price", "type" : "float" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "touch", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -428,15 +306,12 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "quantity", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "touch", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -446,15 +321,12 @@ "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "quantity", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "touch", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -463,22 +335,14 @@ "name" : "isInStock", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getSpecificData", "returnType" : "array", "visibility" : "protected", "modifiers" : [ "protected" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isInStock", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -488,7 +352,6 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "string" @@ -496,42 +359,30 @@ "localVariables" : [ "arr" ], "methodCalls" : [ { "methodName" : "json_decode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "AdminUser", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "User", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "permissions", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "role", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -545,11 +396,9 @@ "name" : "role", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__construct", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] @@ -557,49 +406,32 @@ "name" : "getType", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getRole", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getPermissions", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "addPermission", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "permission", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "in_array", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 }, { "methodName" : "touch", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -609,21 +441,16 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "permission", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_filter", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "touch", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -633,16 +460,12 @@ "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "permission", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "in_array", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] @@ -651,19 +474,13 @@ "returnType" : "array", "visibility" : "protected", "modifiers" : [ "protected" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_merge", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "getSpecificData", "objectType" : "parent", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] @@ -672,7 +489,6 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "string" @@ -680,72 +496,53 @@ "localVariables" : [ "arr" ], "methodCalls" : [ { "methodName" : "json_decode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ImmutableConfig", "visibility" : "public", "modifiers" : [ "final" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Serializable" ], - "mixins" : [ ], "fields" : [ { "name" : "settings", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "settings", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "get", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "string" }, { "name" : "default", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "has", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -753,23 +550,14 @@ "name" : "all", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "serialize", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "json_encode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -778,68 +566,49 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "json_decode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ServiceContainer", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "services", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "register", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" }, { "name" : "factory", "type" : "callable" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "get", "returnType" : "object", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -848,311 +617,177 @@ "returnType" : "object", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "instance" ], "methodCalls" : [ { "methodName" : "date", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "json_decode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "json_encode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "interface", "name" : "Identifiable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "abstract" ] }, { "name" : "getUuid", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "abstract" ] + } ] }, { "kind" : "interface", "name" : "Timestampable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "getCreatedAt", "returnType" : "\\DateTimeInterface", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "abstract" ] }, { "name" : "getUpdatedAt", "returnType" : "?\\DateTimeInterface", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "abstract" ] }, { "name" : "touch", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "abstract" ] + } ] }, { "kind" : "interface", "name" : "Serializable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "serialize", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "abstract" ] }, { "name" : "deserialize", "returnType" : "self", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "interface", "name" : "Comparable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "compareTo", "returnType" : "int", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "equals", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "interface", "name" : "Entity", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Identifiable", "Timestampable", "Serializable" ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "toArray", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "abstract" ] + } ] }, { "kind" : "trait", "name" : "HasTimestamps", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "createdAt", "type" : "\\DateTimeInterface", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] }, { "name" : "updatedAt", "type" : "?\\DateTimeInterface", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] } ], - "properties" : [ ], "methods" : [ { "name" : "getCreatedAt", "returnType" : "\\DateTimeInterface", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getUpdatedAt", "returnType" : "?\\DateTimeInterface", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "touch", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "initializeTimestamps", "returnType" : "void", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "protected" ] + } ] }, { "kind" : "trait", "name" : "HasUuid", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "uuid", "type" : "string", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] } ], - "properties" : [ ], "methods" : [ { "name" : "getUuid", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "generateUuid", "returnType" : "void", "visibility" : "protected", "modifiers" : [ "protected" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "mt_rand", - "objectType" : null, - "objectName" : null, "callCount" : 8, "parameterCount" : 2 }, { "methodName" : "sprintf", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 9 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "createUser", "returnType" : "User", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -1162,15 +797,10 @@ }, { "name" : "email", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "compareEntities", "returnType" : "int", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "BaseEntity" @@ -1178,10 +808,8 @@ "name" : "b", "type" : "BaseEntity" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "compareTo", - "objectType" : null, "objectName" : "a", "callCount" : 1, "parameterCount" : 1 @@ -1190,10 +818,7 @@ "fields" : [ { "name" : "INHERITANCE_VERSION", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], - "methodCalls" : [ ], "imports" : [ "namespace App\\Inheritance;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_InterfaceSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_InterfaceSample.approved.txt index 4b6e892..d594480 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_InterfaceSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_InterfaceSample.approved.txt @@ -1,69 +1,35 @@ { "filePath" : "src/test/resources/samples/php/InterfaceSample.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "interface", "name" : "IRepository", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "findById", - "returnType" : null, "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], "parameters" : [ { - "name" : "id", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "id" + } ] }, { "name" : "save", "returnType" : "void", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], "parameters" : [ { - "name" : "entity", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "entity" + } ] + } ] }, { "kind" : "interface", "name" : "INamed", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "getName", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "modifiers" : [ "abstract" ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_MagicMethodsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_MagicMethodsSample.approved.txt index ed8bae4..a0e0ca1 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_MagicMethodsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_MagicMethodsSample.approved.txt @@ -1,66 +1,44 @@ { "filePath" : "src/test/resources/samples/php/MagicMethodsSample.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Entity", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "data", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "modified", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__destruct", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "__get", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_key_exists", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -69,31 +47,24 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" }, { "name" : "value", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__isset", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -102,25 +73,17 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__toString", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "json_encode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -129,13 +92,8 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_keys", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -143,59 +101,38 @@ "name" : "getData", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "isModified", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "MethodOverloader", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "methods", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "registerDefaultMethods", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -204,17 +141,12 @@ "name" : "registerDefaultMethods", "returnType" : "void", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "private" ] }, { "name" : "__call", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" @@ -222,17 +154,12 @@ "name" : "arguments", "type" : "array" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "call_user_func_array", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -241,86 +168,63 @@ "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" }, { "name" : "arguments", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "registerMethod", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" }, { "name" : "callback", "type" : "callable" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "hasMethod", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Validator", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "rules", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "rules", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__invoke", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array" @@ -328,14 +232,10 @@ "localVariables" : [ "errors" ], "methodCalls" : [ { "methodName" : "empty", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "filter_var", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -343,96 +243,67 @@ "name" : "getRules", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "addRule", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "field", "type" : "string" }, { "name" : "rule", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "DeepCopyable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "id", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "name", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "items", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "createdAt", "type" : "?\\DateTime", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" }, { "name" : "name", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__clone", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_map", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "is_object", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -440,117 +311,75 @@ "name" : "__serialize", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "__unserialize", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__sleep", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "__wakeup", "returnType" : "void", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getName", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "addItem", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "item", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getItems", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] }, { "kind" : "class", "name" : "Exportable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "id", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "name", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "attributes", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -560,109 +389,74 @@ }, { "name" : "attributes", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__set_state", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "properties", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getName", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getAttributes", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setAttribute", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "string" }, { "name" : "value", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Collection", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "ArrayAccess", "Countable", "IteratorAggregate" ], - "mixins" : [ ], "fields" : [ { "name" : "items", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "offsetExists", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "offset", "type" : "mixed" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isset", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -671,52 +465,38 @@ "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "offset", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "offsetSet", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "offset", "type" : "mixed" }, { "name" : "value", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "offsetUnset", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "offset", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "count", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "count", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -724,35 +504,23 @@ "name" : "getIterator", "returnType" : "\\Traversable", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "toArray", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "map", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "callback", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_map", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -761,68 +529,51 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "predicate", "type" : "callable" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_filter", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "QueryBuilder", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "table", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "selects", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "wheres", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "orders", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "limitValue", "type" : "?int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__call", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" @@ -833,38 +584,26 @@ "localVariables" : [ "field", "direction" ], "methodCalls" : [ { "methodName" : "lcfirst", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 }, { "methodName" : "ltrim", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 2 }, { "methodName" : "preg_replace", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 3 }, { "methodName" : "str_starts_with", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 2 }, { "methodName" : "strtolower", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 }, { "methodName" : "substr", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 2 } ] @@ -873,31 +612,24 @@ "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "table", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "select", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "...columns", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "where", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "field", "type" : "string" @@ -907,60 +639,44 @@ }, { "name" : "value", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "orderBy", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "field", "type" : "string" }, { "name" : "direction", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "limit", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "limit", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "toSql", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "sql", "conditions", "orderClauses" ], "methodCalls" : [ { "methodName" : "array_map", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 2 }, { "methodName" : "empty", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 }, { "methodName" : "implode", - "objectType" : null, - "objectName" : null, "callCount" : 3, "parameterCount" : 2 } ] @@ -969,37 +685,23 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_column", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "createEntity", "returnType" : "Entity", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "validateData", "returnType" : "array", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array" @@ -1007,16 +709,12 @@ "name" : "rules", "type" : "array" } ], - "localVariables" : [ "validator" ], - "methodCalls" : [ ] + "localVariables" : [ "validator" ] } ], "fields" : [ { "name" : "MAGIC_VERSION", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], - "methodCalls" : [ ], "imports" : [ "namespace App\\Magic;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ModernPhpSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ModernPhpSample.approved.txt index c55c9c8..7e56ce2 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ModernPhpSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_ModernPhpSample.approved.txt @@ -1,200 +1,133 @@ { "filePath" : "src/test/resources/samples/php/ModernPhpSample.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "UnionTypeExample", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "number", "type" : "int|float", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "name", "type" : "string|null", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "data", "type" : "array|object", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "number", "type" : "int|float" }, { "name" : "name", "type" : "string|null" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getNumber", "returnType" : "int|float", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setNumber", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "int|float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getName", "returnType" : "string|null", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setData", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "array|object" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getData", "returnType" : "array|object", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "process", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "input", "type" : "mixed" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_values", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "is_array", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "is_string", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "strtoupper", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "IntersectionTypeExample", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "processCollection", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { - "name" : "collection", - "type" : null + "name" : "collection" } ], - "localVariables" : [ "result" ], - "methodCalls" : [ ] + "localVariables" : [ "result" ] }, { "name" : "formatCountable", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { - "name" : "item", - "type" : null + "name" : "item" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "count", - "objectType" : null, "objectName" : "item", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ImmutableUser", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -207,55 +140,36 @@ }, { "name" : "createdAt", "type" : "\\DateTimeImmutable" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "withEmail", "returnType" : "self", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "email", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "toArray", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "format", - "objectType" : null, "objectName" : "createdAt", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ImmutableConfig", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "appName", "type" : "string" @@ -268,119 +182,78 @@ }, { "name" : "settings", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "get", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "string" }, { "name" : "default", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "isProduction", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] }, { "kind" : "class", "name" : "MatchExpressionExample", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "getStatusLabel", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "status", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getHttpMessage", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "code", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "processValue", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "mixed" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "count", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "get_class", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "gettype", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Address", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "street", "type" : "?string" @@ -390,128 +263,78 @@ }, { "name" : "country", "type" : "?string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getFullAddress", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "array_filter", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "implode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Profile", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "address", "type" : "?Address" }, { "name" : "bio", "type" : "?string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "NullsafeExample", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "profile", "type" : "?Profile", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "profile", "type" : "?Profile" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getCity", "returnType" : "?string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getCountry", "returnType" : "?string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getFullAddress", "returnType" : "?string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getBioLength", "returnType" : "?int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "strlen", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -520,32 +343,20 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "profile", "type" : "?Profile" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "NamedArgumentsExample", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "createUser", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "username", "type" : "string" @@ -567,20 +378,14 @@ }, { "name" : "age", "type" : "?int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "demonstrateNamedArgs", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "createUser", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 4 @@ -590,7 +395,6 @@ "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "year", "type" : "int" @@ -610,33 +414,20 @@ "name" : "second", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "sprintf", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 7 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "PromotedPropertiesExample", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -652,83 +443,48 @@ }, { "name" : "immutable", "type" : "bool" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getSecret", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getDescription", "returnType" : "?string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "setDescription", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "description", "type" : "?string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Entity", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "table", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Column", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" @@ -738,99 +494,61 @@ }, { "name" : "nullable", "type" : "bool" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Route", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "path", "type" : "string" }, { "name" : "method", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Validated", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "rule", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Product", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "id", "type" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ] + "modifiers" : [ "public" ] }, { "name" : "name", "type" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ] + "modifiers" : [ "public" ] }, { "name" : "price", "type" : "?float", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ] + "modifiers" : [ "public" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -840,9 +558,7 @@ }, { "name" : "price", "type" : "?float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "show", "returnType" : "array", @@ -852,9 +568,7 @@ "parameters" : [ { "name" : "id", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "store", "returnType" : "array", @@ -868,81 +582,58 @@ "name" : "price", "type" : "float" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "show", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "FirstClassCallableExample", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "add", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "int" }, { "name" : "b", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "multiply", "returnType" : "int", "visibility" : "public", "modifiers" : [ "public", "static" ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "int" }, { "name" : "b", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getCallables", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "add", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "multiply", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "strlen", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -951,7 +642,6 @@ "returnType" : "int", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "operation", "type" : "callable" @@ -961,159 +651,95 @@ }, { "name" : "b", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "demonstrateFirstClassCallable", "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "callables" ], "methodCalls" : [ { "methodName" : "applyOperation", - "objectType" : null, "objectName" : "this", "callCount" : 2, "parameterCount" : 3 }, { "methodName" : "getCallables", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "NewInInitializersExample", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "createdAt", "type" : "\\DateTimeImmutable" }, { "name" : "config", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getCreatedAt", "returnType" : "\\DateTimeImmutable", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getConfig", "returnType" : "array", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "public" ] + } ] }, { "kind" : "interface", "name" : "Countable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "count", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "abstract" ] + } ] }, { "kind" : "interface", "name" : "Stringable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__toString", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "abstract" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "abstract" ] + } ] } ], "methods" : [ { "name" : "processInput", "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "input", "type" : "int|float|string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "is_float", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "is_int", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "is_string", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "createImmutableUser", "returnType" : "ImmutableUser", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -1123,33 +749,22 @@ }, { "name" : "email", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getNullsafeValue", "returnType" : "?string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "obj", "type" : "?object" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] } ], "fields" : [ { "name" : "PHP_VERSION_MIN", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], "methodCalls" : [ { "methodName" : "ini_set", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ], diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_OrderParams.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_OrderParams.approved.txt index a54fe6a..87f5c98 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_OrderParams.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_OrderParams.approved.txt @@ -1,24 +1,14 @@ { "filePath" : "src/test/resources/samples/php/OrderParams.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Svc", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -28,15 +18,11 @@ }, { "name" : "logger", "type" : "Logger" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "m", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "string" @@ -44,20 +30,12 @@ "name" : "b", "type" : "int" }, { - "name" : "c", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "c" + } ] + } ] } ], "methods" : [ { "name" : "f", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "x", "type" : "int" @@ -67,11 +45,6 @@ }, { "name" : "z", "type" : "bool" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_TraitsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_TraitsSample.approved.txt index bf7c9e1..138ff09 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_TraitsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_TraitsSample.approved.txt @@ -1,100 +1,71 @@ { "filePath" : "src/test/resources/samples/php/TraitsSample.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "SimpleLogger", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], "mixins" : [ "Loggable" ], "fields" : [ { "name" : "name", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getName", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "logWithName", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "log", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "User", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], "mixins" : [ "Loggable", "Identifiable", "Countable" ], "fields" : [ { "name" : "id", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "username", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "email", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -105,16 +76,13 @@ "name" : "email", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "incrementCount", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "log", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 @@ -123,116 +91,76 @@ "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getUsername", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getEmail", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "__destruct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "decrementCount", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "DataExporter", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], "mixins" : [ "Serializable", "JsonExportable" ], "fields" : [ { "name" : "name", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "items", "type" : "array", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" }, { "name" : "items", "type" : "array" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getName", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "addItem", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "item", "type" : "mixed" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "exportAsJson", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "jsonSerialize", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -242,111 +170,78 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "toArray", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "SecureEntity", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], "mixins" : [ "Loggable" ], "fields" : [ { "name" : "id", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "logSecure", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "privateLog", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Product", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], "mixins" : [ "FullyFeatured", "Countable" ], "fields" : [ { "name" : "id", "type" : "int", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "name", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "price", "type" : "float", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -357,11 +252,9 @@ "name" : "price", "type" : "float" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "incrementCount", "objectType" : "self", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] @@ -369,69 +262,42 @@ "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getName", "returnType" : "string", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getPrice", "returnType" : "float", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public" ] }, { "name" : "getFormattedPrice", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "number_format", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "trait", "name" : "Loggable", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "logPrefix", "type" : "string", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] } ], - "properties" : [ ], "methods" : [ { "name" : "log", "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" @@ -439,8 +305,6 @@ "localVariables" : [ "timestamp" ], "methodCalls" : [ { "methodName" : "date", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -449,15 +313,12 @@ "returnType" : "void", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "log", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 @@ -467,52 +328,31 @@ "returnType" : "string", "visibility" : "protected", "modifiers" : [ "protected" ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "trim", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "trait", "name" : "Identifiable", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "getId", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "abstract", "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "abstract", "public" ] }, { "name" : "getIdentifier", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getId", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -522,107 +362,65 @@ "returnType" : "bool", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getId", - "objectType" : null, "objectName" : "other", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "getId", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "method_exists", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "trait", "name" : "Countable", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "instanceCount", "type" : "int", "visibility" : "private", - "modifiers" : [ "private", "static" ], - "annotations" : [ ] + "modifiers" : [ "private", "static" ] } ], - "properties" : [ ], "methods" : [ { "name" : "getInstanceCount", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public", "static" ] }, { "name" : "incrementCount", "returnType" : "void", "visibility" : "protected", - "modifiers" : [ "protected", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "protected", "static" ] }, { "name" : "decrementCount", "returnType" : "void", "visibility" : "protected", - "modifiers" : [ "protected", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "protected", "static" ] + } ] }, { "kind" : "trait", "name" : "Serializable", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "serialize", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "json_encode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "toArray", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 @@ -632,47 +430,27 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get_object_vars", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "trait", "name" : "JsonExportable", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "serialize", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "getData", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "json_encode", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -681,59 +459,38 @@ "returnType" : "array", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get_object_vars", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "trait", "name" : "FullyFeatured", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], "mixins" : [ "Loggable", "Identifiable" ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "describe", "returnType" : "string", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "id" ], "methodCalls" : [ { "methodName" : "getIdentifier", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "log", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "createUser", "returnType" : "User", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -744,20 +501,15 @@ "name" : "email", "type" : "string" } ], - "localVariables" : [ "user" ], - "methodCalls" : [ ] + "localVariables" : [ "user" ] } ], "fields" : [ { "name" : "TRAIT_VERSION", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], "methodCalls" : [ { "methodName" : "error_reporting", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ], diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_UserService.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_UserService.approved.txt index 0294727..86a31c1 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_UserService.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.analyze_Php_UserService.approved.txt @@ -1,42 +1,30 @@ { "filePath" : "src/test/resources/samples/php/UserService.php", "language" : "php", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "UserService", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "repository", "type" : "UserRepository", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ] + "modifiers" : [ "public" ] }, { "name" : "apiKey", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "instanceCount", "type" : "int", "visibility" : "protected", - "modifiers" : [ "protected", "static" ], - "annotations" : [ ] + "modifiers" : [ "protected", "static" ] } ], - "properties" : [ ], "methods" : [ { "name" : "__construct", - "returnType" : null, "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "logger", "type" : "LoggerInterface" @@ -44,29 +32,20 @@ "name" : "cache", "type" : "CacheInterface" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "env", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "expect", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "parseFloat", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "toBeGreaterThan", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -75,7 +54,6 @@ "returnType" : "?User", "visibility" : "public", "modifiers" : [ "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -83,25 +61,21 @@ "localVariables" : [ "cacheKey", "user" ], "methodCalls" : [ { "methodName" : "find", - "objectType" : null, "objectName" : "repository", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "get", - "objectType" : null, "objectName" : "cache", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "info", - "objectType" : null, "objectName" : "logger", "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "set", - "objectType" : null, "objectName" : "cache", "callCount" : 1, "parameterCount" : 2 @@ -111,7 +85,6 @@ "returnType" : "bool", "visibility" : "protected", "modifiers" : [ "protected" ], - "annotations" : [ ], "parameters" : [ { "name" : "user", "type" : "User" @@ -119,20 +92,17 @@ "localVariables" : [ "isValid" ], "methodCalls" : [ { "methodName" : "hasValidEmail", - "objectType" : null, "objectName" : "user", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "isActive", - "objectType" : null, "objectName" : "user", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "warning", "objectType" : "Log", - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -141,7 +111,6 @@ "returnType" : "void", "visibility" : "private", "modifiers" : [ "private" ], - "annotations" : [ ], "parameters" : [ { "name" : "user", "type" : "User" @@ -152,13 +121,11 @@ "localVariables" : [ "notifier" ], "methodCalls" : [ { "methodName" : "debug", - "objectType" : null, "objectName" : "logger", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "send", - "objectType" : null, "objectName" : "notifier", "callCount" : 1, "parameterCount" : 2 @@ -167,17 +134,12 @@ "name" : "getInstanceCount", "returnType" : "int", "visibility" : "public", - "modifiers" : [ "public", "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "public", "static" ] }, { "name" : "deleteUser", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "final", "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -185,25 +147,21 @@ "localVariables" : [ "user", "result" ], "methodCalls" : [ { "methodName" : "delete", - "objectType" : null, "objectName" : "cache", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "delete", - "objectType" : null, "objectName" : "repository", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "findUser", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "validateUser", - "objectType" : null, "objectName" : "this", "callCount" : 1, "parameterCount" : 1 @@ -215,85 +173,56 @@ "modifiers" : [ "public" ], "annotations" : [ "#[Deprecated]" ], "parameters" : [ { - "name" : "id", - "type" : null + "name" : "id" }, { "name" : "...tags", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "BaseRepository", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "connection", "type" : "PDO", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] } ], - "properties" : [ ], "methods" : [ { "name" : "find", "returnType" : "?object", "visibility" : "public", "modifiers" : [ "abstract", "public" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getTableName", "returnType" : "string", "visibility" : "protected", - "modifiers" : [ "abstract", "protected" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "abstract", "protected" ] + } ] }, { "kind" : "interface", "name" : "CacheInterface", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "get", "returnType" : "mixed", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "set", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "string" @@ -303,30 +232,21 @@ }, { "name" : "ttl", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "delete", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "abstract" ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] } ], "methods" : [ { "name" : "formatUserName", "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "firstName", "type" : "string" @@ -337,14 +257,10 @@ "localVariables" : [ "fullName" ], "methodCalls" : [ { "methodName" : "trim", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "ucwords", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -352,32 +268,22 @@ "fields" : [ { "name" : "APP_VERSION", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "MAX_RETRIES", "type" : "int", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "DEBUG_MODE", "type" : "bool", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], "methodCalls" : [ { "methodName" : "date_default_timezone_set", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "error_reporting", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ], diff --git a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.java index d74ec85..490de56 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/php/PhpAnalyzeApprovalTest.java @@ -1,10 +1,9 @@ package org.dxworks.codeframe.analyzer.php; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.approvaltests.Approvals; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; +import org.dxworks.codeframe.TestUtils; import org.dxworks.codeframe.model.FileAnalysis; import org.junit.jupiter.api.Test; @@ -14,10 +13,6 @@ public class PhpAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_Php_UserService() throws IOException { verify(Paths.get("src/test/resources/samples/php/UserService.php"), Language.PHP); @@ -70,6 +65,6 @@ void analyze_Php_ModernPhpSample() throws IOException { private static void verify(Path file, Language language) throws IOException { FileAnalysis analysis = (FileAnalysis) App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_ComplexExample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_ComplexExample.approved.txt index ce319db..5c0b334 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_ComplexExample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_ComplexExample.approved.txt @@ -1,79 +1,50 @@ { "filePath" : "src/test/resources/samples/python/complex_example.py", "language" : "python", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Config", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@dataclass(frozen=True)" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "name", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "version", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "debug", "type" : "bool", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "metadata", "type" : "Dict[str, Any]", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "Repository", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "abc.ABC", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "config", "type" : "Config" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "utcnow", - "objectType" : null, "objectName" : "datetime", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "put", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" @@ -86,27 +57,22 @@ "methodName" : "_normalize_key", "objectType" : "Repository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "_put_impl", "objectType" : "Repository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "_validate", "objectType" : "Repository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "get", "returnType" : "Optional[Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" @@ -116,21 +82,17 @@ "methodName" : "_get_impl", "objectType" : "Repository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "_normalize_key", "objectType" : "Repository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "delete", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" @@ -140,84 +102,55 @@ "methodName" : "_delete_impl", "objectType" : "Repository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "_normalize_key", "objectType" : "Repository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "keys", "returnType" : "List[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "_keys_impl", "objectType" : "Repository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "expect", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "list", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "parse_float", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "to_be_greater_than", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "_normalize_key", "returnType" : "str", "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "lower", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "strip", - "objectType" : null, "objectName" : "key", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "_validate", "returnType" : "None", "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" @@ -225,19 +158,14 @@ "name" : "value", "type" : "Any" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueError", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 } ] }, { "name" : "_put_impl", "returnType" : "None", "visibility" : "protected", - "modifiers" : [ ], "annotations" : [ "@abc.abstractmethod" ], "parameters" : [ { "name" : "key", @@ -245,85 +173,55 @@ }, { "name" : "value", "type" : "Any" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "_get_impl", "returnType" : "Optional[Any]", "visibility" : "protected", - "modifiers" : [ ], "annotations" : [ "@abc.abstractmethod" ], "parameters" : [ { "name" : "key", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "_delete_impl", "returnType" : "bool", "visibility" : "protected", - "modifiers" : [ ], "annotations" : [ "@abc.abstractmethod" ], "parameters" : [ { "name" : "key", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "_keys_impl", "returnType" : "Iterable[str]", "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ "@abc.abstractmethod" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@abc.abstractmethod" ] + } ] }, { "kind" : "class", "name" : "InMemoryRepository", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Repository", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "config", "type" : "Config" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "upsert", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" @@ -331,20 +229,16 @@ "name" : "value", "type" : "Any" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "put", "objectType" : "InMemoryRepository", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "_put_impl", "returnType" : "None", "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" @@ -352,38 +246,27 @@ "name" : "value", "type" : "Any" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "print", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "_get_impl", "returnType" : "Optional[Any]", "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "self.__store", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "_delete_impl", "returnType" : "bool", "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" @@ -391,123 +274,71 @@ "localVariables" : [ "existed" ], "methodCalls" : [ { "methodName" : "pop", - "objectType" : null, "objectName" : "self.__store", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "print", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "_keys_impl", "returnType" : "Iterable[str]", "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "keys", - "objectType" : null, "objectName" : "self.__store", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ResourceManager", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "label", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__enter__", "returnType" : "\"ResourceManager\"", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "print", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "__exit__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "exc_type", - "type" : null + "name" : "exc_type" }, { - "name" : "exc", - "type" : null + "name" : "exc" }, { - "name" : "tb", - "type" : null + "name" : "tb" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "print", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "is_active", "returnType" : "bool", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "_tag", "returnType" : "str", - "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "protected" + } ] } ], "methods" : [ { "name" : "batched", "returnType" : "Generator[List[Any], None, None]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "iterable", "type" : "Iterable[Any]" @@ -518,29 +349,19 @@ "localVariables" : [ "batch" ], "methodCalls" : [ { "methodName" : "ValueError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "append", - "objectType" : null, "objectName" : "batch", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "len", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "slugify", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "text", "type" : "str" @@ -548,50 +369,35 @@ "localVariables" : [ "text" ], "methodCalls" : [ { "methodName" : "lower", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "strip", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "strip", - "objectType" : null, "objectName" : "text", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "sub", - "objectType" : null, "objectName" : "re", - "callCount" : 3, - "parameterCount" : null + "callCount" : 3 } ] }, { "name" : "safe_divide", "returnType" : "float", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "float" }, { "name" : "b", "type" : "float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "fetch_data_async", "returnType" : "List[int]", "visibility" : "public", "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { "name" : "n", "type" : "int" @@ -599,91 +405,57 @@ "name" : "delay", "type" : "float" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "list", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "range", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "sleep", - "objectType" : null, "objectName" : "asyncio", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "_demo", - "returnType" : null, "visibility" : "protected", "modifiers" : [ "async" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "fetch_data_async", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "print", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ], "fields" : [ { "name" : "MAX_RETRIES", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "DEFAULT_TIMEOUT", "type" : "float", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "APP_NAME", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "VERSION", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "logger", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], "methodCalls" : [ { "methodName" : "basicConfig", - "objectType" : null, "objectName" : "logging", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "getLogger", - "objectType" : null, "objectName" : "logging", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ], "imports" : [ "from __future__ import annotations", "import abc", "import asyncio", "import contextlib", "import logging", "import math", "import re", "from dataclasses import dataclass, field", "from datetime import datetime", "from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_DecoratorsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_DecoratorsSample.approved.txt index 91a4366..996f085 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_DecoratorsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_DecoratorsSample.approved.txt @@ -1,92 +1,61 @@ { "filePath" : "src/test/resources/samples/python/decorators_sample.py", "language" : "python", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Calculator", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "_instances", "type" : "int", - "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "protected" }, { "name" : "_precision", "type" : "int", - "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "protected" } ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "name", "returnType" : "str", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "name", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@name.setter" ], "parameters" : [ { "name" : "value", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "name", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ "@name.deleter" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@name.deleter" ] }, { "name" : "history", "returnType" : "list[str]", "visibility" : "public", "modifiers" : [ "property" ], "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "copy", - "objectType" : null, "objectName" : "self._history", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "add", @@ -100,9 +69,7 @@ }, { "name" : "b", "type" : "float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "subtract", "returnType" : "float", @@ -115,18 +82,13 @@ }, { "name" : "b", "type" : "float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "get_instance_count", "returnType" : "int", "visibility" : "public", "modifiers" : [ "classmethod" ], - "annotations" : [ "@classmethod" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@classmethod" ] }, { "name" : "set_precision", "returnType" : "None", @@ -137,13 +99,9 @@ "name" : "precision", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "from_string", @@ -158,22 +116,16 @@ "localVariables" : [ "name" ], "methodCalls" : [ { "methodName" : "cls", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "split", - "objectType" : null, "objectName" : "config", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "multiply", "returnType" : "float", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@log_calls" ], "parameters" : [ { "name" : "a", @@ -185,22 +137,16 @@ "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "append", - "objectType" : null, "objectName" : "self._history", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "round", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "divide", "returnType" : "float", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@retry(times=2)" ], "parameters" : [ { "name" : "a", @@ -212,36 +158,20 @@ "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "ZeroDivisionError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "append", - "objectType" : null, "objectName" : "self._history", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "round", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "MathUtils", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "power", "returnType" : "float", @@ -254,9 +184,7 @@ }, { "name" : "exp", "type" : "float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "parse_and_add", "returnType" : "float", @@ -270,23 +198,16 @@ "name" : "b_str", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "float", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "log_calls", "returnType" : "Callable[..., T]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "func", "type" : "Callable[..., T]" @@ -294,29 +215,17 @@ "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "func", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "print", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "wraps", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "retry", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "times", "type" : "int" @@ -324,118 +233,72 @@ "localVariables" : [ "last_error" ], "methodCalls" : [ { "methodName" : "RuntimeError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "func", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "print", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "range", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "wraps", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "validate_args", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "*validators", "type" : "Callable[[Any], bool]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "enumerate", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "func", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "validator", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "wraps", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "zip", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "greet", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@log_calls" ], "parameters" : [ { "name" : "name", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "fetch_data", "returnType" : "dict[str, Any]", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@retry(times=5)" ], "parameters" : [ { "name" : "url", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ConnectionError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "safe_divide", "returnType" : "float", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@validate_args(lambda x: x > 0, lambda x: x > 0)" ], "parameters" : [ { "name" : "a", @@ -443,41 +306,27 @@ }, { "name" : "b", "type" : "float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] } ], "fields" : [ { "name" : "MAX_RETRIES", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "DEFAULT_TIMEOUT", "type" : "float", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "APP_NAME", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "T", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], "methodCalls" : [ { "methodName" : "TypeVar", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ], "imports" : [ "from functools import wraps", "from typing import Any, Callable, TypeVar" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_EnumSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_EnumSample.approved.txt index 7b802ae..cc4ef91 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_EnumSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_EnumSample.approved.txt @@ -1,91 +1,56 @@ { "filePath" : "src/test/resources/samples/python/enum_sample.py", "language" : "python", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Color", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Enum", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "RED", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "GREEN", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "BLUE", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "describe", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "Status", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "str", "implementsInterfaces" : [ "Enum" ], - "mixins" : [ ], "fields" : [ { "name" : "PENDING", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "ACTIVE", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "COMPLETED", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "CANCELLED", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "is_terminal", "returnType" : "bool", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "from_string", "returnType" : "\"Status\"", @@ -96,334 +61,199 @@ "name" : "value", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "lower", - "objectType" : null, "objectName" : "value", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Priority", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "IntEnum", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "LOW", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "MEDIUM", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "HIGH", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "CRITICAL", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "__str__", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "is_urgent", "returnType" : "bool", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "ErrorCode", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@unique" ], "extendsType" : "IntEnum", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "SUCCESS", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "NOT_FOUND", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "SERVER_ERROR", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "UNAUTHORIZED", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "FORBIDDEN", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "is_error", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "Permission", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Flag", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "NONE", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "READ", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "WRITE", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "EXECUTE", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "DELETE", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "READ_WRITE", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "ALL", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "can_read", "returnType" : "bool", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "can_write", "returnType" : "bool", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "Direction", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Enum", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "NORTH", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "SOUTH", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "EAST", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "WEST", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "opposite", "returnType" : "\"Direction\"", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ "opposites" ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "localVariables" : [ "opposites" ] + } ] }, { "kind" : "class", "name" : "Planet", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Enum", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "MERCURY", "type" : "tuple", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "VENUS", "type" : "tuple", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "EARTH", "type" : "tuple", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "MARS", "type" : "tuple", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "mass", "type" : "float" }, { "name" : "radius", "type" : "float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "mass", "returnType" : "float", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "radius", "returnType" : "float", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "surface_gravity", "returnType" : "float", "visibility" : "public", "modifiers" : [ "property" ], "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ "G" ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "localVariables" : [ "G" ] + } ] } ], "methods" : [ { "name" : "get_status_label", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "status", "type" : "Status" @@ -433,35 +263,25 @@ "methodName" : "get", "objectType" : "dict", "objectName" : "labels", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "combine_permissions", "returnType" : "Permission", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "perms", "type" : "list[Permission]" } ], - "localVariables" : [ "result" ], - "methodCalls" : [ ] + "localVariables" : [ "result" ] }, { "name" : "find_planet_by_mass", "returnType" : "Optional[Planet]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "min_mass", "type" : "float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] } ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "from enum import Enum, IntEnum, Flag, auto, unique", "from typing import Optional" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_ExceptionHandlingSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_ExceptionHandlingSample.approved.txt index 0226c12..4b4fbb9 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_ExceptionHandlingSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_ExceptionHandlingSample.approved.txt @@ -1,24 +1,15 @@ { "filePath" : "src/test/resources/samples/python/exception_handling_sample.py", "language" : "python", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "ApplicationError", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Exception", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "str" @@ -26,48 +17,27 @@ "name" : "code", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "__str__", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "ValidationError", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationError", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "field", "type" : "str" @@ -75,39 +45,23 @@ "name" : "message", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "NotFoundError", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationError", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "resource", "type" : "str" @@ -115,76 +69,44 @@ "name" : "identifier", "type" : "Any" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "AuthenticationError", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationError", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "reason", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "RetryableError", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ApplicationError", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "str" @@ -192,111 +114,68 @@ "name" : "retry_after", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "DataProcessor", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "strict", "type" : "bool" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "parse_int", "returnType" : "Optional[int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "int", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "parse_number", "returnType" : "float", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValidationError", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "error", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "float", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "str", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "warning", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "safe_divide", "returnType" : "Optional[float]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "float" @@ -307,23 +186,17 @@ "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "info", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "warning", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "process_file", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "path", "type" : "str" @@ -331,47 +204,32 @@ "localVariables" : [ "handle", "lines" ], "methodCalls" : [ { "methodName" : "ApplicationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "NotFoundError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "close", "objectType" : "None", "objectName" : "handle", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "debug", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "open", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "readlines", "objectType" : "None", "objectName" : "handle", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fetch_data", "returnType" : "dict[str, Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" @@ -379,149 +237,92 @@ "localVariables" : [ "data", "acquired" ], "methodCalls" : [ { "methodName" : "ApplicationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "ValidationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "debug", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "exception", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "hash", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "info", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "validate_and_process", "returnType" : "dict[str, Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "dict[str, Any]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ApplicationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "ValidationError", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "load_config", "returnType" : "dict[str, Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "path", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "NotFoundError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "ValidationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "load", - "objectType" : null, "objectName" : "json", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "open", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "convert_value", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "Any" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "decode", - "objectType" : null, "objectName" : "value", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "str", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "type", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "risky_operation", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "Any" @@ -529,17 +330,13 @@ "localVariables" : [ "_" ], "methodCalls" : [ { "methodName" : "some_method", - "objectType" : null, "objectName" : "value", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "process_batch", "returnType" : "list[Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "list[Any]" @@ -549,44 +346,31 @@ "methodName" : "_process_single", "objectType" : "DataProcessor", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "append", - "objectType" : null, "objectName" : "results", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "append", - "objectType" : null, "objectName" : "self._errors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "clear", - "objectType" : null, "objectName" : "self._errors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "_process_single", "returnType" : "Any", "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "item", "type" : "Any" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValidationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "errors", @@ -594,118 +378,75 @@ "visibility" : "public", "modifiers" : [ "property" ], "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "copy", - "objectType" : null, "objectName" : "self._errors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "TransactionContext", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__enter__", "returnType" : "\"TransactionContext\"", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "info", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "__exit__", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "exc_type", - "type" : null + "name" : "exc_type" }, { - "name" : "exc_val", - "type" : null + "name" : "exc_val" }, { - "name" : "exc_tb", - "type" : null + "name" : "exc_tb" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "error", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "info", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "execute", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "operation", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ApplicationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "info", - "objectType" : null, "objectName" : "logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "assert_not_none", "returnType" : "Any", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "Any" @@ -713,52 +454,32 @@ "name" : "name", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValidationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "wrap_exception", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "func", - "type" : null + "name" : "func" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ApplicationError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "func", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ], "fields" : [ { "name" : "logger", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], "methodCalls" : [ { "methodName" : "getLogger", - "objectType" : null, "objectName" : "logging", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ], "imports" : [ "from typing import Any, Optional", "import logging", "import json" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_InheritanceSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_InheritanceSample.approved.txt index 86750ed..1ba5a6f 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_InheritanceSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_InheritanceSample.approved.txt @@ -1,103 +1,62 @@ { "filePath" : "src/test/resources/samples/python/inheritance_sample.py", "language" : "python", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Animal", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "ABC", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "str" }, { "name" : "age", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "describe", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "type", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "name", "returnType" : "str", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "age", "returnType" : "int", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "speak", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ "@abstractmethod" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@abstractmethod" ] }, { "name" : "move", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ "@abstractmethod" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@abstractmethod" ] + } ] }, { "kind" : "class", "name" : "Dog", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Animal", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "str" @@ -108,78 +67,45 @@ "name" : "breed", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "speak", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "move", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "fetch", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "item", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "breed", "returnType" : "str", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "Cat", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Animal", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "str" @@ -190,101 +116,56 @@ "name" : "indoor", "type" : "bool" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "speak", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "move", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "purr", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "indoor", "returnType" : "bool", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "SerializableMixin", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "to_dict", "returnType" : "dict[str, Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "result", "clean_key" ], "methodCalls" : [ { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "isoformat", - "objectType" : null, "objectName" : "value", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "items", - "objectType" : null, "objectName" : "self.__dict__", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "lstrip", - "objectType" : null, "objectName" : "key", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "from_dict", @@ -296,142 +177,87 @@ "name" : "data", "type" : "dict[str, Any]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "cls", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ComparableMixin", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__eq__", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "__lt__", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "str", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 } ] }, { "name" : "__le__", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__gt__", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "str", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 } ] }, { "name" : "__ge__", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "object" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "LoggableMixin", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "_log", "type" : "list[str]", - "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "protected" } ], - "properties" : [ ], "methods" : [ { "name" : "log", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "str" @@ -439,133 +265,80 @@ "localVariables" : [ "timestamp", "entry" ], "methodCalls" : [ { "methodName" : "append", - "objectType" : null, "objectName" : "self._log", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "isoformat", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "now", - "objectType" : null, "objectName" : "datetime", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "type", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "get_logs", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "copy", - "objectType" : null, "objectName" : "self._log", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "clear_logs", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "clear", - "objectType" : null, "objectName" : "self._log", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "ValidatableMixin", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "validate", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "errors" ], "methodCalls" : [ { "methodName" : "append", - "objectType" : null, "objectName" : "errors", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "items", - "objectType" : null, "objectName" : "self.__dict__", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "is_valid", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "len", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "validate", "objectType" : "ValidatableMixin", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Entity", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "SerializableMixin", "implementsInterfaces" : [ "ComparableMixin", "ValidatableMixin" ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -573,66 +346,42 @@ "name" : "created_at", "type" : "Optional[datetime]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "now", - "objectType" : null, "objectName" : "datetime", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "__str__", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "type", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "id", "returnType" : "int", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "created_at", "returnType" : "datetime", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "User", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Entity", "implementsInterfaces" : [ "LoggableMixin" ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -646,26 +395,17 @@ "name" : "created_at", "type" : "Optional[datetime]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "change_email", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "new_email", "type" : "str" @@ -675,79 +415,49 @@ "methodName" : "log", "objectType" : "User", "objectName" : "self", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "validate", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "errors" ], "methodCalls" : [ { "methodName" : "append", - "objectType" : null, "objectName" : "errors", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "len", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "validate", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "username", "returnType" : "str", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "email", "returnType" : "str", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "Product", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Entity", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "int" @@ -761,308 +471,170 @@ "name" : "created_at", "type" : "Optional[datetime]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "validate", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "errors" ], "methodCalls" : [ { "methodName" : "append", - "objectType" : null, "objectName" : "errors", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "validate", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "name", "returnType" : "str", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "price", "returnType" : "float", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "A", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "method", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "greet", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "B", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "A", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "method", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "method", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "greet", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "C", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "A", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "method", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "method", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "greet", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "D", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "B", "implementsInterfaces" : [ "C" ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "method", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "method", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "show_mro", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "type", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "SlottedBase", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "__slots__", "type" : "tuple", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "x", "type" : "int" }, { "name" : "y", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "x", "returnType" : "int", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "y", "returnType" : "int", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "SlottedChild", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "SlottedBase", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "__slots__", "type" : "tuple", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "x", "type" : "int" @@ -1073,43 +645,24 @@ "name" : "z", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "__init__", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "super", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "coordinates", "returnType" : "tuple[int, int, int]", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "z", "returnType" : "int", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "from abc import ABC, abstractmethod", "from datetime import datetime", "from typing import Any, Optional" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_NestedStructuresSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_NestedStructuresSample.approved.txt index 7f1f43d..43f1237 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_NestedStructuresSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_NestedStructuresSample.approved.txt @@ -1,184 +1,102 @@ { "filePath" : "src/test/resources/samples/python/nested_structures_sample.py", "language" : "python", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Outer", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "label", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "create_inner", "returnType" : "\"Outer.Inner\"", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "int" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Inner", - "objectType" : null, "objectName" : "Outer", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "get_label", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" } ], "types" : [ { "kind" : "class", "name" : "Inner", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "get_value", "returnType" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" } ], "types" : [ { "kind" : "class", "name" : "DeepNested", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "process", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "upper", - "objectType" : null, "objectName" : "self._data", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ] }, { "kind" : "class", "name" : "AnotherInner", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "greet", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] } ] }, { "kind" : "class", "name" : "Node", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "Any" @@ -188,29 +106,21 @@ }, { "name" : "metadata", "type" : "dict[str, Any] | None" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "traverse", "returnType" : "list[Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "extend", "objectType" : "list", "objectName" : "result", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "traverse", - "objectType" : null, "objectName" : "child", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "builder", @@ -218,236 +128,138 @@ "visibility" : "public", "modifiers" : [ "static" ], "annotations" : [ "@staticmethod" ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Builder", - "objectType" : null, "objectName" : "Node", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ], "types" : [ { "kind" : "class", "name" : "Builder", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "value", "returnType" : "\"Node.Builder\"", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "val", "type" : "Any" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "add_child", "returnType" : "\"Node.Builder\"", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "child", "type" : "\"Node\"" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "append", - "objectType" : null, "objectName" : "self._children", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "metadata", "returnType" : "\"Node.Builder\"", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" }, { "name" : "val", "type" : "Any" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "build", "returnType" : "\"Node\"", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Node", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ] }, { "kind" : "class", "name" : "ListProcessor", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "list[Any]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "filter_positive", "returnType" : "list[int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "filter", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "list", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "double_values", "returnType" : "list[int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "list", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "map", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "sort_by_length", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "len", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "sorted", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "str", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "sort_by_key", "returnType" : "list[dict]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "key", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "get", - "objectType" : null, "objectName" : "d", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "sorted", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "reduce_sum", "returnType" : "int", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "reduce", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "find_first", "returnType" : "Any | None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "predicate", "type" : "Callable[[Any], bool]" @@ -455,198 +267,112 @@ "localVariables" : [ "matches" ], "methodCalls" : [ { "methodName" : "filter", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "next", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "DataTransformer", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "list[Any]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "list_comprehension", "returnType" : "list[int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "dict_comprehension", "returnType" : "dict[str, int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "str", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "set_comprehension", "returnType" : "set[int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "abs", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "nested_comprehension", "returnType" : "list[tuple[int, int]]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "range", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 } ] }, { "name" : "generator_expression", "returnType" : "int", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "sum", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "conditional_expression", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "make_counter", "returnType" : "Callable[[], int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "start", "type" : "int" } ], - "localVariables" : [ "count" ], - "methodCalls" : [ ] + "localVariables" : [ "count" ] }, { "name" : "make_multiplier", "returnType" : "Callable[[int], int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "factor", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "create_operations", "returnType" : "dict[str, Callable[[int, int], int]]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "memoize", "returnType" : "Callable[..., T]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "func", "type" : "Callable[..., T]" @@ -654,17 +380,12 @@ "localVariables" : [ "cache", "key" ], "methodCalls" : [ { "methodName" : "func", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "process_with_transform", "returnType" : "list[int]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "list[int]" @@ -675,26 +396,17 @@ "name" : "filter_func", "type" : "Callable[[int], bool]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "filter_func", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "transform", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "sort_with_key", "returnType" : "list[Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "list[Any]" @@ -705,49 +417,29 @@ "name" : "reverse", "type" : "bool" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "sorted", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "create_calculator", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "do_add", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "do_subtract", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ], "fields" : [ { "name" : "T", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], "methodCalls" : [ { "methodName" : "TypeVar", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ], "imports" : [ "from typing import Any, Callable, TypeVar", "from functools import reduce" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_TypingSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_TypingSample.approved.txt index f3589d0..00fd5ae 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_TypingSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.analyze_Python_TypingSample.approved.txt @@ -1,45 +1,28 @@ { "filePath" : "src/test/resources/samples/python/typing_sample.py", "language" : "python", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Point", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "NamedTuple", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "x", "type" : "float", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "y", "type" : "float", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "distance_from_origin", "returnType" : "float", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "translate", "returnType" : "Point", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "dx", "type" : "float" @@ -47,108 +30,65 @@ "name" : "dy", "type" : "float" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Point", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Person", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "NamedTuple", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "name", "type" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "age", "type" : "int", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "email", "type" : "str | None", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "active", "type" : "bool", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "greet", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "Rectangle", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "NamedTuple", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "top_left", "type" : "Point", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "bottom_right", "type" : "Point", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "area", "returnType" : "float", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "width", "returnType" : "float", "visibility" : "public", "modifiers" : [ "property" ], "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "abs", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "height", @@ -156,377 +96,210 @@ "visibility" : "public", "modifiers" : [ "property" ], "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "abs", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Drawable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Protocol", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "draw", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "Sizeable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Protocol", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "size", "returnType" : "int", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "Closeable", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@runtime_checkable" ], "extendsType" : "Protocol", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "close", "returnType" : "None", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "Comparable", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__lt__", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "T_contra" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "__le__", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "T_contra" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "SupportsAdd", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__add__", "returnType" : "T_co", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "Any" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Stack", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "push", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "item", "type" : "T" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "append", - "objectType" : null, "objectName" : "self._items", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "pop", "returnType" : "T", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "IndexError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "pop", - "objectType" : null, "objectName" : "self._items", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "peek", "returnType" : "T | None", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "is_empty", "returnType" : "bool", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "len", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Pair", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "first", "type" : "K" }, { "name" : "second", "type" : "V" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "swap", "returnType" : "Pair[V, K]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Pair", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "map_first", "returnType" : "Pair[T, V]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "func", "type" : "Callable[[K], T]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Pair", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "func", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "first", "returnType" : "K", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "annotations" : [ "@property" ] }, { "name" : "second", "returnType" : "V", "visibility" : "public", "modifiers" : [ "property" ], - "annotations" : [ "@property" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@property" ] + } ] }, { "kind" : "class", "name" : "Result", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "T | None" }, { "name" : "error", "type" : "str | None" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "is_ok", "returnType" : "bool", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "unwrap", "returnType" : "T", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "ValueError", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "unwrap_or", "returnType" : "T", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "default", "type" : "T" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "ok", "returnType" : "Result[T]", @@ -537,13 +310,9 @@ "name" : "value", "type" : "T" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "cls", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "err", @@ -555,121 +324,74 @@ "name" : "error", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "cls", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Configuration", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "VERSION", "type" : "Final[str]", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "_instance_count", "type" : "ClassVar[int]", - "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "protected" }, { "name" : "DEFAULT_TIMEOUT", "type" : "ClassVar[int]", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], - "properties" : [ ], "methods" : [ { "name" : "__init__", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "get_name", "returnType" : "str", - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "get_instance_count", "returnType" : "int", "visibility" : "public", "modifiers" : [ "classmethod" ], - "annotations" : [ "@classmethod" ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "annotations" : [ "@classmethod" ] + } ] }, { "kind" : "class", "name" : "Router", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "navigate", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "direction", "type" : "Direction" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "request", "returnType" : "dict[str, Any]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "method", "type" : "HttpMethod" }, { "name" : "url", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "log", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "level", "type" : "LogLevel" @@ -677,63 +399,37 @@ "name" : "message", "type" : "str" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "print", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Converter", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "convert", "returnType" : "int | str", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "int | str | float" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "int", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "isinstance", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "str", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "parse", "returnType" : "str | list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "data", "type" : "str" @@ -741,61 +437,46 @@ "name" : "as_list", "type" : "bool" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "split", - "objectType" : null, "objectName" : "data", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "strip", - "objectType" : null, "objectName" : "data", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "convert", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@overload" ], "parameters" : [ { "name" : "value", "type" : "int" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "convert", "returnType" : "int", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@overload" ], "parameters" : [ { "name" : "value", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "convert", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@overload" ], "parameters" : [ { "name" : "value", "type" : "float" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "parse", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@overload" ], "parameters" : [ { "name" : "data", @@ -803,14 +484,11 @@ }, { "name" : "as_list", "type" : "Literal[True]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "parse", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@overload" ], "parameters" : [ { "name" : "data", @@ -818,254 +496,155 @@ }, { "name" : "as_list", "type" : "Literal[False]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "parse", "returnType" : "str", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@overload" ], "parameters" : [ { "name" : "data", "type" : "str" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "type_alias", "name" : "JsonValue", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : "Union[str, int, float, bool, None, list[\"JsonValue\"], dict[str, \"JsonValue\"]]", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "extendsType" : "Union[str, int, float, bool, None, list[\"JsonValue\"], dict[str, \"JsonValue\"]]" }, { "kind" : "type_alias", "name" : "Callback", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : "Callable[[str, int], bool]", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "extendsType" : "Callable[[str, int], bool]" }, { "kind" : "type_alias", "name" : "Matrix", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : "list[list[float]]", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "extendsType" : "list[list[float]]" } ], "methods" : [ { "name" : "first", "returnType" : "T | None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "Sequence[T]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "last", "returnType" : "T | None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "Sequence[T]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "identity", "returnType" : "T", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "value", "type" : "T" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "swap", "returnType" : "tuple[V, K]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "pair", "type" : "tuple[K, V]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "merge_dicts", "returnType" : "dict[K, V]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "d1", "type" : "dict[K, V]" }, { "name" : "d2", "type" : "dict[K, V]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "find_max", "returnType" : "Numeric | None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "Iterable[Numeric]" } ], - "localVariables" : [ "result" ], - "methodCalls" : [ ] + "localVariables" : [ "result" ] }, { "name" : "draw_all", "returnType" : "list[str]", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "drawables", "type" : "list[Drawable]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "draw", - "objectType" : null, "objectName" : "d", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "total_size", "returnType" : "int", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "list[Sizeable]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "sum", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "close_all", "returnType" : "None", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "resources", "type" : "list[Closeable]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "close", - "objectType" : null, "objectName" : "resource", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ], "fields" : [ { "name" : "T", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "K", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "V", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "T_co", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "T_contra", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "Numeric", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "Direction", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "HttpMethod", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" }, { "name" : "LogLevel", - "type" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "public" } ], "methodCalls" : [ { "methodName" : "TypeVar", - "objectType" : null, - "objectName" : null, - "callCount" : 6, - "parameterCount" : null + "callCount" : 6 } ], "imports" : [ "from __future__ import annotations", "from abc import abstractmethod", "from collections.abc import Iterable, Iterator, Mapping, Sequence", "from dataclasses import dataclass", "from typing import (\n Any,\n Callable,\n ClassVar,\n Final,\n Generic,\n Literal,\n NamedTuple,\n Optional,\n Protocol,\n TypeAlias,\n TypeVar,\n Union,\n overload,\n runtime_checkable,\n)" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.java index 10773a4..03f7327 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/python/PythonAnalyzeApprovalTest.java @@ -1,10 +1,9 @@ package org.dxworks.codeframe.analyzer.python; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.approvaltests.Approvals; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; +import org.dxworks.codeframe.TestUtils; import org.dxworks.codeframe.model.FileAnalysis; import org.junit.jupiter.api.Test; @@ -14,10 +13,6 @@ public class PythonAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_Python_ComplexExample() throws IOException { verify(Paths.get("src/test/resources/samples/python/complex_example.py"), Language.PYTHON); @@ -55,6 +50,6 @@ void analyze_Python_TypingSample() throws IOException { private static void verify(Path file, Language language) throws IOException { FileAnalysis analysis = (FileAnalysis) App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ActiveRecordSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ActiveRecordSample.approved.txt index 63ac48e..d18e6b4 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ActiveRecordSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ActiveRecordSample.approved.txt @@ -1,126 +1,70 @@ { "filePath" : "src/test/resources/samples/ruby/ActiveRecordSample.rb", "language" : "ruby", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "User", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@has_many(posts)", "@has_many(comments)", "@belongs_to(organization)", "@has_one(profile)", "@validates(email)", "@validates(name)", "@validates(age)", "@before_save(normalize_email)", "@after_create(send_welcome_email)", "@before_destroy(cleanup_data)", "@scope(active)", "@scope(recent)" ], "extendsType" : "ActiveRecord::Base", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@name", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@email", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "email", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "email" + } ] }, { "name" : "full_info", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "normalize_email", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "downcase", - "objectType" : null, "objectName" : "@email", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "strip", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] }, { "name" : "send_welcome_email", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "puts", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "cleanup_data", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "destroy_all", - "objectType" : null, "objectName" : "posts", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Post", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@belongs_to(user)", "@has_many(comments)", "@validates(title)", "@validates(content)", "@before_validation(set_default_title)", "@scope(published)" ], "extendsType" : "ActiveRecord::Base", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "set_default_title", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "title", "objectType" : "Post", @@ -128,24 +72,13 @@ "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Organization", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@has_many(users)", "@validates(name)" ], - "extendsType" : "ActiveRecord::Base", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "extendsType" : "ActiveRecord::Base" } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "require 'active_record'" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_BlocksAndLambdasSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_BlocksAndLambdasSample.approved.txt index df06c30..6ae14cf 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_BlocksAndLambdasSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_BlocksAndLambdasSample.approved.txt @@ -1,337 +1,201 @@ { "filePath" : "src/test/resources/samples/ruby/BlocksAndLambdasSample.rb", "language" : "ruby", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Calculator", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@operations", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "MULTIPLY", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "DIVIDE", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "SQUARE", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "LOGGER", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], - "properties" : [ ], "methods" : [ { "name" : "initialize", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "process_with_block", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "&block", - "type" : null + "name" : "&block" } ], "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "block_given?", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] }, { "name" : "apply_operation", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "x", - "type" : null + "name" : "x" }, { - "name" : "y", - "type" : null + "name" : "y" }, { - "name" : "operation", - "type" : null + "name" : "operation" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "call", - "objectType" : null, "objectName" : "operation", "callCount" : 1, "parameterCount" : 2 } ] }, { "name" : "create_adder", - "returnType" : null, "visibility" : "public", "modifiers" : [ "static" ], - "annotations" : [ ], "parameters" : [ { - "name" : "increment", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "increment" + } ] }, { "name" : "map_values", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "values", - "type" : null + "name" : "values" }, { - "name" : "&transformer", - "type" : null + "name" : "&transformer" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "map", - "objectType" : null, "objectName" : "values", "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "demo_splat", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "values", - "type" : null + "name" : "values" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "log", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "demo_keywords", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "call", "objectType" : "LOGGER", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "demo_hash_literal", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "call", "objectType" : "LOGGER", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "demo_mixed_splat_and_keywords", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "items", - "type" : null + "name" : "items" }, { - "name" : "opts", - "type" : null + "name" : "opts" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "call", "objectType" : "LOGGER", - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] }, { "name" : "log", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "message", - "type" : null + "name" : "message" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "call", "objectType" : "LOGGER", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "DataProcessor", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@data", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "FILTER_POSITIVE", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "FILTER_EVEN", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], - "properties" : [ ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "data", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "data" + } ] }, { "name" : "filter", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "&predicate", - "type" : null + "name" : "&predicate" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "select", - "objectType" : null, "objectName" : "@data", "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "transform", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "&block", - "type" : null + "name" : "&block" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "map", - "objectType" : null, "objectName" : "@data", "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "default_filter", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "static" ] + } ] }, { "kind" : "module", "name" : "Helpers", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "FORMATTER", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "VALIDATOR", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "modifiers" : [ "const" ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ConstantsAndRequiresSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ConstantsAndRequiresSample.approved.txt index 1c54a23..9462262 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ConstantsAndRequiresSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ConstantsAndRequiresSample.approved.txt @@ -1,265 +1,146 @@ { "filePath" : "src/test/resources/samples/ruby/ConstantsAndRequiresSample.rb", "language" : "ruby", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Configuration", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@retries", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@timeout", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "MAX_RETRIES", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "DEFAULT_TIMEOUT", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "API_VERSION", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "ALLOWED_FORMATS", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "Database", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], - "properties" : [ ], "methods" : [ { "name" : "initialize", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "api_endpoint", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "static" ] }, { "name" : "get_timeout", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "max_retries", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "ApiClient", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@timeout", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@max_retries", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "BASE_URL", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "MAX_CONNECTIONS", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "RETRY_DELAY", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], "properties" : [ { "name" : "timeout", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] } ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "timeout", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "timeout" + } ] }, { "name" : "default_headers", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "static" ] }, { "name" : "fetch_data", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "endpoint", - "type" : null + "name" : "endpoint" } ], - "localVariables" : [ "url" ], - "methodCalls" : [ ] + "localVariables" : [ "url" ] }, { "name" : "retry_request", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "sleep", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "module", "name" : "HttpHelpers", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "TIMEOUT", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "MAX_REDIRECTS", - "type" : null, "visibility" : "public", - "modifiers" : [ "const" ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "modifiers" : [ "const" ] + } ] } ], - "methods" : [ ], "fields" : [ { "name" : "APP_VERSION", "type" : "String", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "MAX_CONNECTIONS", "type" : "Integer", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "DEBUG_MODE", "type" : "Boolean", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], "methodCalls" : [ { "methodName" : "info", - "objectType" : null, "objectName" : "Rails.logger", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "logger", - "objectType" : null, "objectName" : "Rails", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "puts", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ], diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_InheritanceSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_InheritanceSample.approved.txt index 3b39336..b1a6418 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_InheritanceSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_InheritanceSample.approved.txt @@ -1,159 +1,78 @@ { "filePath" : "src/test/resources/samples/ruby/InheritanceSample.rb", "language" : "ruby", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Animal", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@name", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], "properties" : [ { "name" : "name", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" }, { - "kind" : "set", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "set" } ] } ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "name", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "name" + } ] }, { "name" : "speak", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "Dog", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "extendsType" : "Animal", - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@breed", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], "properties" : [ { "name" : "breed", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" }, { - "kind" : "set", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "set" } ] } ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "breed", - "type" : null + "name" : "breed" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "super", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "speak", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "fetch", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "item", - "type" : null + "name" : "item" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "puts", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ModuleSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ModuleSample.approved.txt index 9af31b5..c615cf8 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ModuleSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_ModuleSample.approved.txt @@ -1,108 +1,64 @@ { "filePath" : "src/test/resources/samples/ruby/ModuleSample.rb", "language" : "ruby", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "TextProcessor", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], "mixins" : [ "StringHelpers" ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "process", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "text", - "type" : null + "name" : "text" } ], "localVariables" : [ "result" ], "methodCalls" : [ { "methodName" : "capitalize_words", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "reverse_string", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "module", "name" : "StringHelpers", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "capitalize_words", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "text", - "type" : null + "name" : "text" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "join", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "map", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "split", - "objectType" : null, "objectName" : "text", "callCount" : 1, "parameterCount" : 0 } ] }, { "name" : "reverse_string", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "text", - "type" : null + "name" : "text" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "reverse", - "objectType" : null, "objectName" : "text", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_NestedTypesSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_NestedTypesSample.approved.txt index d85b415..0757173 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_NestedTypesSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_NestedTypesSample.approved.txt @@ -1,139 +1,73 @@ { "filePath" : "src/test/resources/samples/ruby/NestedTypesSample.rb", "language" : "ruby", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Car::Engine", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@cylinders", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@type", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], "properties" : [ { "name" : "cylinders", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] }, { "name" : "type", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] } ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "cylinders", - "type" : null + "name" : "cylinders" }, { - "name" : "type", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "type" + } ] }, { "name" : "start", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "puts", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Motorcycle", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@engine", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "new", "objectType" : "Engine", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "start", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "puts", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "start", - "objectType" : null, "objectName" : "@engine", "callCount" : 1, "parameterCount" : 0 @@ -143,396 +77,188 @@ "kind" : "class", "name" : "Engine", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@cylinders", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@type", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], "properties" : [ { "name" : "cylinders", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] }, { "name" : "type", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] } ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "cylinders", - "type" : null + "name" : "cylinders" }, { - "name" : "type", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "type" + } ] }, { "name" : "start", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "puts", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "module", "name" : "SafetyFeatures", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], "types" : [ { "kind" : "class", "name" : "ABS", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "engage", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "static" ] + } ] }, { "kind" : "class", "name" : "TractionControl", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "engage", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "static" ] + } ] } ] } ] }, { "kind" : "module", "name" : "Vehicle", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], "types" : [ { "kind" : "class", "name" : "Hybrid", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], "mixins" : [ "Electric", "Combustion" ], "fields" : [ { "name" : "@battery", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@engine", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "new", - "objectType" : null, "objectName" : "Combustion::Engine", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "new", - "objectType" : null, "objectName" : "Electric::Battery", "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "status", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "start", - "objectType" : null, "objectName" : "@engine", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "status", - "objectType" : null, "objectName" : "@battery", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "module", "name" : "Electric", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "charge", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" } ], "types" : [ { "kind" : "class", "name" : "Battery", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@capacity", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], "properties" : [ { "name" : "capacity", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] } ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "capacity", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "capacity" + } ] }, { "name" : "status", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "rand", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ] }, { "kind" : "module", "name" : "Combustion", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], "types" : [ { "kind" : "class", "name" : "Engine", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@cylinders", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "cylinders", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "cylinders" + } ] }, { "name" : "start", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "module", "name" : "FuelSystem", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], "types" : [ { "kind" : "class", "name" : "Injector", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "clean", - "returnType" : null, "visibility" : "public", - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "modifiers" : [ "static" ] + } ] } ] } ] } ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_Sample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_Sample.approved.txt index 1c0f62c..be8a1c3 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_Sample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_Sample.approved.txt @@ -1,355 +1,205 @@ { "filePath" : "src/test/resources/samples/ruby/Sample.rb", "language" : "ruby", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "UserRepository", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@db", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@logger", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], "properties" : [ { "name" : "db", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] }, { "name" : "logger", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" } ] } ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "db", - "type" : null + "name" : "db" }, { - "name" : "logger", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "logger" + } ] }, { "name" : "find_by_id", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "id", - "type" : null + "name" : "id" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "expect", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "info", - "objectType" : null, "objectName" : "logger", "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "parse_float", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "query", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "to_be_greater_than", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "total", - "objectType" : null, "objectName" : "result", "callCount" : 1, "parameterCount" : 0 } ] }, { "name" : "find_all", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "query_list", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "save", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "user", - "type" : null + "name" : "user" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "id", - "objectType" : null, "objectName" : "user", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "insert", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "nil?", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "update", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "insert", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "user", - "type" : null + "name" : "user" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "email", - "objectType" : null, "objectName" : "user", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "execute", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 3 }, { "methodName" : "name", - "objectType" : null, "objectName" : "user", "callCount" : 1, "parameterCount" : 0 } ] }, { "name" : "update", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "user", - "type" : null + "name" : "user" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "email", - "objectType" : null, "objectName" : "user", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "execute", - "objectType" : null, "objectName" : "db", "callCount" : 1, "parameterCount" : 4 }, { "methodName" : "id", - "objectType" : null, "objectName" : "user", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "name", - "objectType" : null, "objectName" : "user", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "User", "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@id", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@name", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@email", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], "properties" : [ { "name" : "id", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" }, { - "kind" : "set", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "set" } ] }, { "name" : "name", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" }, { - "kind" : "set", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "set" } ] }, { "name" : "email", - "type" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "accessors" : [ { - "kind" : "get", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "get" }, { - "kind" : "set", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "kind" : "set" } ] } ], "methods" : [ { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "id", - "type" : null + "name" : "id" }, { - "name" : "name", - "type" : null + "name" : "name" }, { - "name" : "email", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "email" + } ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "require 'logger'" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_VisibilityAndClassMethodsSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_VisibilityAndClassMethodsSample.approved.txt index 34366b7..29180de 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_VisibilityAndClassMethodsSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.analyze_Ruby_VisibilityAndClassMethodsSample.approved.txt @@ -1,252 +1,125 @@ { "filePath" : "src/test/resources/samples/ruby/VisibilityAndClassMethodsSample.rb", "language" : "ruby", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "UserService", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@alias(old_public_method=another_public_method)" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@email", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@@service_count", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" }, { "name" : "@@settings", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "find_by_email", - "returnType" : null, "visibility" : "public", "modifiers" : [ "static" ], - "annotations" : [ ], "parameters" : [ { - "name" : "email", - "type" : null + "name" : "email" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "first", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "where", "objectType" : "User", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "create_guest", - "returnType" : null, "visibility" : "public", "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "new", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "initialize", - "returnType" : null, "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "email", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "email" + } ] }, { "name" : "process_user", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "public_method", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "public" }, { "name" : "inline_private", - "returnType" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "private" }, { "name" : "inline_private2", - "returnType" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "private" }, { "name" : "validate_email", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "include?", - "objectType" : null, "objectName" : "@email", "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "send_notification", - "returnType" : null, "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "puts", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "inline_protected", - "returnType" : null, - "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "protected" }, { "name" : "inline_protected2", - "returnType" : null, - "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "protected" }, { "name" : "internal_helper", - "returnType" : null, - "visibility" : "protected", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "visibility" : "protected" }, { "name" : "another_public_method", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "visibility" : "public" + } ] }, { "kind" : "class", "name" : "Calculator", "visibility" : "public", - "modifiers" : [ ], "annotations" : [ "@alias_method(sum=add)" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "@@ops", - "type" : null, - "visibility" : "private", - "modifiers" : [ ], - "annotations" : [ ] + "visibility" : "private" } ], - "properties" : [ ], "methods" : [ { "name" : "add", - "returnType" : null, "visibility" : "public", "modifiers" : [ "static" ], - "annotations" : [ ], "parameters" : [ { - "name" : "a", - "type" : null + "name" : "a" }, { - "name" : "b", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "b" + } ] }, { "name" : "multiply", - "returnType" : null, "visibility" : "public", "modifiers" : [ "static" ], - "annotations" : [ ], "parameters" : [ { - "name" : "a", - "type" : null + "name" : "a" }, { - "name" : "b", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "b" + } ] }, { "name" : "instance_method", - "returnType" : null, - "visibility" : "public", - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "visibility" : "public" + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.java index d27bd5d..5c66b98 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/ruby/RubyAnalyzeApprovalTest.java @@ -1,10 +1,9 @@ package org.dxworks.codeframe.analyzer.ruby; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.approvaltests.Approvals; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; +import org.dxworks.codeframe.TestUtils; import org.dxworks.codeframe.model.FileAnalysis; import org.junit.jupiter.api.Test; @@ -14,10 +13,6 @@ public class RubyAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_Ruby_Sample() throws IOException { verify(Paths.get("src/test/resources/samples/ruby/Sample.rb"), Language.RUBY); @@ -60,6 +55,6 @@ void analyze_Ruby_BlocksAndLambdasSample() throws IOException { private static void verify(Path file, Language language) throws IOException { FileAnalysis analysis = (FileAnalysis) App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_EnumsAndPatterns.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_EnumsAndPatterns.approved.txt index 9b33117..aae1202 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_EnumsAndPatterns.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_EnumsAndPatterns.approved.txt @@ -1,108 +1,55 @@ { "filePath" : "src/test/resources/samples/rust/EnumsAndPatterns.rs", "language" : "rust", - "packageName" : null, "types" : [ { "kind" : "enum", "name" : "Message", - "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "visibility" : "pub" }, { "kind" : "enum", "name" : "Result", - "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "visibility" : "pub" }, { "kind" : "impl", "name" : "Message", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "call", - "returnType" : null, "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 }, { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 4 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "impl", "name" : "Result", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "is_ok", "returnType" : "bool", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "matches!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -111,16 +58,11 @@ "returnType" : "bool", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "matches!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -129,54 +71,38 @@ "returnType" : "T", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "panic!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "process_message", "returnType" : "String", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { "name" : "msg", "type" : "Message" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "format!", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 3 }, { "methodName" : "format!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 4 }, { "methodName" : "from", "objectType" : "String", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_ModulesAndVisibility.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_ModulesAndVisibility.approved.txt index cc435a7..3a176a6 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_ModulesAndVisibility.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_ModulesAndVisibility.approved.txt @@ -1,30 +1,16 @@ { "filePath" : "src/test/resources/samples/rust/ModulesAndVisibility.rs", "language" : "rust", - "packageName" : null, "types" : [ { "kind" : "mod", "name" : "network", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "internal_helper", - "returnType" : null, "visibility" : "pub(crate)", "modifiers" : [ "pub(crate)" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -33,242 +19,140 @@ "kind" : "struct", "name" : "Server", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "address", - "type" : "String", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "String" }, { "name" : "port", - "type" : "u16", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "u16" + } ] }, { "kind" : "impl", "name" : "Server", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "new", "returnType" : "Self", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { "name" : "address", "type" : "String" }, { "name" : "port", "type" : "u16" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "start", - "returnType" : null, "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "bind", - "objectType" : null, "objectName" : "self", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "listen", - "objectType" : null, "objectName" : "self", "callCount" : 1, "parameterCount" : 0 } ] }, { "name" : "bind", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] }, { "name" : "listen", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] - } ], - "types" : [ ] + } ] } ] }, { "kind" : "mod", "name" : "tests", - "visibility" : null, - "modifiers" : [ ], "annotations" : [ "#[cfg(test)]" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "test_helper", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "config" ], "methodCalls" : [ { "methodName" : "assert_eq!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "from", "objectType" : "String", - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "new", "objectType" : "Config", - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "struct", "name" : "Config", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "host", "type" : "String", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] + "modifiers" : [ "pub" ] }, { "name" : "port", "type" : "u16", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] + "modifiers" : [ "pub" ] }, { "name" : "debug", - "type" : "bool", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "bool" + } ] }, { "kind" : "impl", "name" : "Config", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "new", "returnType" : "Self", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { "name" : "host", "type" : "String" }, { "name" : "port", "type" : "u16" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "enable_debug", - "returnType" : null, "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "self" + } ] }, { "name" : "is_debug", "returnType" : "bool", "visibility" : "pub(crate)", "modifiers" : [ "pub(crate)" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "self" + } ] + } ] } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "use super::*;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_Sample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_Sample.approved.txt index 0374286..8f9b98e 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_Sample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_Sample.approved.txt @@ -1,108 +1,61 @@ { "filePath" : "src/test/resources/samples/rust/Sample.rs", "language" : "rust", - "packageName" : null, "types" : [ { "kind" : "struct", "name" : "UserRepository", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "db", - "type" : "Database", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Database" }, { "name" : "cache", - "type" : "HashMap", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "HashMap" + } ] }, { "kind" : "struct", "name" : "User", "visibility" : "pub", - "modifiers" : [ ], "annotations" : [ "#[derive(Clone, Debug)]" ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "id", "type" : "u32", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] + "modifiers" : [ "pub" ] }, { "name" : "name", "type" : "String", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] + "modifiers" : [ "pub" ] }, { "name" : "email", "type" : "String", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "modifiers" : [ "pub" ] + } ] }, { "kind" : "struct", "name" : "Database", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "connection", - "type" : "String", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "String" + } ] }, { "kind" : "impl", "name" : "UserRepository", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "new", "returnType" : "Self", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { "name" : "db", "type" : "Database" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "new", "objectType" : "HashMap", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] @@ -111,10 +64,8 @@ "returnType" : "Option", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "id", "type" : "u32" @@ -122,32 +73,23 @@ "localVariables" : [ "user" ], "methodCalls" : [ { "methodName" : "Some", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 1 }, { "methodName" : "clone", - "objectType" : null, "objectName" : "user", "callCount" : 2, "parameterCount" : 0 }, { "methodName" : "get", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "insert", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 }, { "methodName" : "query_user", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] @@ -156,71 +98,44 @@ "returnType" : "Result<(), String>", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "user", "type" : "User" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Ok", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "execute_update", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "insert", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] }, { "name" : "clear_cache", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "clear", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "impl", "name" : "User", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "new", "returnType" : "Self", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "u32" @@ -230,58 +145,37 @@ }, { "name" : "email", "type" : "String" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "display_name", "returnType" : "String", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "format!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "impl", "name" : "Database", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "query_user", "returnType" : "Option", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "id", "type" : "u32" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] @@ -290,54 +184,39 @@ "returnType" : "Result<(), String>", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "user", "type" : "&User" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "Ok", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 }, { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 2 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "create_default_user", "returnType" : "User", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "from", "objectType" : "String", - "objectName" : null, "callCount" : 2, "parameterCount" : 1 }, { "methodName" : "new", "objectType" : "User", - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] } ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "use std::collections::HashMap;", "use std::fmt::Display;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_StructsAndImpls.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_StructsAndImpls.approved.txt index 39810e6..ec16b03 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_StructsAndImpls.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_StructsAndImpls.approved.txt @@ -1,92 +1,53 @@ { "filePath" : "src/test/resources/samples/rust/StructsAndImpls.rs", "language" : "rust", - "packageName" : null, "types" : [ { "kind" : "struct", "name" : "Point", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "x", "type" : "f64", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] + "modifiers" : [ "pub" ] }, { "name" : "y", "type" : "f64", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "modifiers" : [ "pub" ] + } ] }, { "kind" : "struct", "name" : "Rectangle", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "top_left", - "type" : "Point", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Point" }, { "name" : "bottom_right", - "type" : "Point", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "Point" + } ] }, { "kind" : "impl", "name" : "Point", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "new", "returnType" : "Self", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { "name" : "x", "type" : "f64" }, { "name" : "y", "type" : "f64" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "distance", "returnType" : "f64", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "other", "type" : "&Point" @@ -94,129 +55,76 @@ "localVariables" : [ "dx", "dy" ], "methodCalls" : [ { "methodName" : "sqrt", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] }, { "name" : "translate", - "returnType" : null, "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "dx", "type" : "f64" }, { "name" : "dy", "type" : "f64" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "impl", "name" : "Point", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Default" ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "default", - "returnType" : "Self", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "returnType" : "Self" + } ] }, { "kind" : "impl", "name" : "Rectangle", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "new", "returnType" : "Self", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "top_left", "type" : "Point" }, { "name" : "bottom_right", "type" : "Point" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "area", "returnType" : "f64", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], "localVariables" : [ "width", "height" ], "methodCalls" : [ { "methodName" : "abs", - "objectType" : null, - "objectName" : null, "callCount" : 2, "parameterCount" : 0 } ] }, { "name" : "contains", "returnType" : "bool", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "point", "type" : "&Point" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] } ], - "methods" : [ ], "fields" : [ { "name" : "MAX_POINTS", "type" : "usize", "visibility" : "pub", - "modifiers" : [ "const", "pub" ], - "annotations" : [ ] + "modifiers" : [ "const", "pub" ] }, { "name" : "POINT_COUNT", "type" : "usize", "visibility" : "pub", - "modifiers" : [ "static", "mut", "pub" ], - "annotations" : [ ] - } ], - "methodCalls" : [ ], - "imports" : [ ] + "modifiers" : [ "static", "mut", "pub" ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_TraitsAndGenerics.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_TraitsAndGenerics.approved.txt index 7eebaf6..bddc2ca 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_TraitsAndGenerics.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.analyze_Rust_TraitsAndGenerics.approved.txt @@ -1,139 +1,71 @@ { "filePath" : "src/test/resources/samples/rust/TraitsAndGenerics.rs", "language" : "rust", - "packageName" : null, "types" : [ { "kind" : "struct", "name" : "Circle", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "center_x", "type" : "T", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] + "modifiers" : [ "pub" ] }, { "name" : "center_y", "type" : "T", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] + "modifiers" : [ "pub" ] }, { "name" : "radius", "type" : "T", "visibility" : "pub", - "modifiers" : [ "pub" ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "modifiers" : [ "pub" ] + } ] }, { "kind" : "struct", "name" : "Container", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "items", - "type" : "Vec", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "Vec" + } ] }, { "kind" : "trait", "name" : "Drawable", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "draw", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + "name" : "self" + } ] }, { "name" : "bounds", "returnType" : "(f64, f64, f64, f64)", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "self" + } ] + } ] }, { "kind" : "trait", "name" : "Resizable", "visibility" : "pub", - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "resize", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "scale", "type" : "f64" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "impl", "name" : "Circle", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "new", "returnType" : "Self", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { "name" : "center_x", "type" : "T" @@ -143,148 +75,92 @@ }, { "name" : "radius", "type" : "T" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "impl", "name" : "Circle", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Drawable" ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "draw", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "println!", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 3 } ] }, { "name" : "bounds", "returnType" : "(f64, f64, f64, f64)", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "self" + } ] + } ] }, { "kind" : "impl", "name" : "Container", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "new", "returnType" : "Self", "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "new", "objectType" : "Vec", - "objectName" : null, "callCount" : 1, "parameterCount" : 0 } ] }, { "name" : "add", - "returnType" : null, "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" }, { "name" : "item", "type" : "T" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "push", - "objectType" : null, - "objectName" : null, "callCount" : 1, "parameterCount" : 1 } ] }, { "name" : "draw_all", - "returnType" : null, "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { - "name" : "self", - "type" : null + "name" : "self" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "draw", - "objectType" : null, "objectName" : "item", "callCount" : 1, "parameterCount" : 0 } ] - } ], - "types" : [ ] + } ] } ], "methods" : [ { "name" : "process", - "returnType" : null, "visibility" : "pub", "modifiers" : [ "pub" ], - "annotations" : [ ], "parameters" : [ { "name" : "item", "type" : "&mut T" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "draw", - "objectType" : null, "objectName" : "item", "callCount" : 1, "parameterCount" : 0 }, { "methodName" : "resize", - "objectType" : null, "objectName" : "item", "callCount" : 1, "parameterCount" : 1 } ] } ], - "fields" : [ ], - "methodCalls" : [ ], "imports" : [ "use std::fmt::Display;" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.java index 88868f4..e96e7f8 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/rust/RustAnalyzeApprovalTest.java @@ -1,10 +1,9 @@ package org.dxworks.codeframe.analyzer.rust; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.approvaltests.Approvals; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; +import org.dxworks.codeframe.TestUtils; import org.dxworks.codeframe.model.FileAnalysis; import org.junit.jupiter.api.Test; @@ -14,10 +13,6 @@ public class RustAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_Rust_Sample() throws IOException { verify(Paths.get("src/test/resources/samples/rust/Sample.rs"), Language.RUST); @@ -45,6 +40,6 @@ void analyze_Rust_ModulesAndVisibility() throws IOException { private static void verify(Path file, Language language) throws IOException { FileAnalysis analysis = (FileAnalysis) App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesMySQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesMySQL.approved.txt index c30cebf..94f4405 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesMySQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesMySQL.approved.txt @@ -1,17 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/alter_routines_mysql.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createProcedures" : [ { "procedureName" : "recalc_order_total", "schema" : "sales", @@ -51,46 +42,33 @@ } ], "createFunctions" : [ { "functionName" : "fn_net_amount", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "p_gross", - "type" : "DECIMAL(12,2)", - "direction" : null + "type" : "DECIMAL(12,2)" }, { "name" : "p_tax_rate_id", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "DECIMAL(12,2)", "references" : { "relations" : [ "active_discounts_view", "tax_rates" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "functionName" : "fn_get_stock_value", "schema" : "inventory", "orReplace" : false, "parameters" : [ { "name" : "p_warehouse_id", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "DECIMAL(12,2)", "references" : { "relations" : [ "inventory.stock", "inventory.current_prices_view", "inventory.products" ] }, "calls" : { - "functions" : [ "IFNULL", "SUM" ], - "procedures" : [ ] + "functions" : [ "IFNULL", "SUM" ] } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesPLSQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesPLSQL.approved.txt index 907febc..32c77eb 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesPLSQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesPLSQL.approved.txt @@ -1,17 +1,11 @@ { "filePath" : "src/test/resources/samples/sql/plsql_routine_bodies.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, + "topLevelReferences" : { }, "topLevelCalls" : { "functions" : [ "HR.CALC_DISCOUNT" ], "procedures" : [ "HR.GET_ORDER_INFO" ] }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], "createProcedures" : [ { "procedureName" : "GET_ORDERS_BY_CUSTOMER", "schema" : "HR", @@ -64,10 +58,7 @@ "references" : { "relations" : [ "HR.ORDERS" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } } ], "createFunctions" : [ { "functionName" : "TOTAL_AMOUNT", @@ -82,10 +73,7 @@ "references" : { "relations" : [ "HR.ORDER_ITEMS" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "functionName" : "ORDER_HAS_ITEM", "schema" : "HR", @@ -103,10 +91,7 @@ "references" : { "relations" : [ "HR.ORDER_ITEMS", "DUAL" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "functionName" : "CALC_DISCOUNT", "schema" : "HR", @@ -121,17 +106,7 @@ "direction" : "IN" } ], "returnType" : "NUMBER", - "references" : { - "relations" : [ ] - }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + "references" : { }, + "calls" : { } + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesPostgreSQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesPostgreSQL.approved.txt index 5d8a13d..9a9c411 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesPostgreSQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesPostgreSQL.approved.txt @@ -1,69 +1,44 @@ { "filePath" : "src/test/resources/samples/sql/alter_routines_postgresql.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], - "createTriggers" : [ ], - "alterViews" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "alterFunctions" : [ { "functionName" : "fn_net_amount", - "schema" : null, "parameters" : [ { "name" : "p_gross", - "type" : "DECIMAL(12,2)", - "direction" : null + "type" : "DECIMAL(12,2)" }, { "name" : "p_tax_rate_id", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "DECIMAL(12,2)", "references" : { "relations" : [ "active_discounts_view", "tax_rates" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "functionName" : "fn_get_low_stock_items", "schema" : "inventory", "parameters" : [ { "name" : "p_warehouse_id", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "TABLE(product_id INT,product_name VARCHAR,quantity INT,threshold INT)", "references" : { "relations" : [ "inventory.stock", "inventory.products", "inventory.reorder_thresholds_view" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } } ], "alterProcedures" : [ { "procedureName" : "recalc_order_total", "schema" : "sales", "parameters" : [ { "name" : "p_order_id", - "type" : "INT", - "direction" : null + "type" : "INT" }, { "name" : "p_customer_id", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "references" : { "relations" : [ "sales.order_items", "sales.orders", "sales.customer_tax_info_view" ] @@ -77,8 +52,7 @@ "schema" : "purchasing", "parameters" : [ { "name" : "p_po_id", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "references" : { "relations" : [ "purchasing.purchase_orders", "purchasing.approved_vendors_view" ] @@ -87,6 +61,5 @@ "functions" : [ "fn_calculate_discount" ], "procedures" : [ "update_expected_stock", "accounting.create_payable", "notifications.send_approval_notification" ] } - } ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesTSQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesTSQL.approved.txt index 77ef089..9a08572 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesTSQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterRoutinesTSQL.approved.txt @@ -1,17 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/alter_routines_tsql.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createProcedures" : [ { "procedureName" : "recalc_order_total", "schema" : "sales", @@ -51,7 +42,6 @@ } ], "createFunctions" : [ { "functionName" : "fn_net_amount", - "schema" : null, "orReplace" : true, "parameters" : [ { "name" : "@gross", @@ -66,10 +56,7 @@ "references" : { "relations" : [ "active_discounts_view", "tax_rates" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "functionName" : "fn_get_low_stock_items", "schema" : "inventory", @@ -83,14 +70,6 @@ "references" : { "relations" : [ "inventory.stock", "inventory.products", "inventory.reorder_thresholds_view" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + "calls" : { } + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterTablesViews.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterTablesViews.approved.txt index c1bf363..08fc102 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterTablesViews.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_AlterTablesViews.approved.txt @@ -1,14 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/alter_tables_views.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "alterTables" : [ { "tableName" : "users", "schema" : "public", @@ -16,54 +10,29 @@ "addedColumns" : [ { "name" : "last_login", "type" : "TIMESTAMP", - "nullable" : true, - "constraints" : [ ] - } ], - "droppedColumns" : [ ], - "modifiedColumns" : [ ], - "addedConstraints" : [ ], - "droppedConstraints" : [ ] + "nullable" : true + } ] }, { "tableName" : "orders", "schema" : "sales", "operationType" : "ADD_CONSTRAINT", - "addedColumns" : [ ], - "droppedColumns" : [ ], - "modifiedColumns" : [ ], - "addedConstraints" : [ "CONSTRAINT pk_orders PRIMARY KEY (order_id, user_id)" ], - "droppedConstraints" : [ ] + "addedConstraints" : [ "CONSTRAINT pk_orders PRIMARY KEY (order_id, user_id)" ] }, { "tableName" : "orders", "schema" : "sales", "operationType" : "ADD_CONSTRAINT", - "addedColumns" : [ ], - "droppedColumns" : [ ], - "modifiedColumns" : [ ], - "addedConstraints" : [ "CONSTRAINT fk_orders_user FOREIGN KEY (user_id) REFERENCES public.users(id)" ], - "droppedConstraints" : [ ] + "addedConstraints" : [ "CONSTRAINT fk_orders_user FOREIGN KEY (user_id) REFERENCES public.users(id)" ] }, { "tableName" : "orders", "schema" : "sales", "operationType" : "DROP_COLUMN", - "addedColumns" : [ ], - "droppedColumns" : [ "total_amount" ], - "modifiedColumns" : [ ], - "addedConstraints" : [ ], - "droppedConstraints" : [ ] + "droppedColumns" : [ "total_amount" ] } ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], - "createTriggers" : [ ], "alterViews" : [ { "viewName" : "active_users", "schema" : "reporting", "references" : { "relations" : [ "public.users" ] } - } ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_ConstraintsAndIndexes.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_ConstraintsAndIndexes.approved.txt index 36384f6..928e704 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_ConstraintsAndIndexes.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_ConstraintsAndIndexes.approved.txt @@ -1,13 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/constraints_and_indexes.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createTables" : [ { "tableName" : "users", "schema" : "public", @@ -28,8 +23,7 @@ "nullable" : false, "constraints" : [ "NOT NULL" ] } ], - "primaryKeys" : [ "id" ], - "foreignKeys" : [ ] + "primaryKeys" : [ "id" ] }, { "tableName" : "orders", "schema" : "sales", @@ -47,13 +41,11 @@ }, { "name" : "order_date", "type" : "DATE", - "nullable" : true, - "constraints" : [ ] + "nullable" : true }, { "name" : "total_amount", "type" : "DECIMAL(12,2)", - "nullable" : true, - "constraints" : [ ] + "nullable" : true } ], "primaryKeys" : [ "order_id", "user_id" ], "foreignKeys" : [ { @@ -63,7 +55,6 @@ "referencedColumns" : [ "id" ] } ] } ], - "alterTables" : [ ], "createViews" : [ { "viewName" : "v_orders", "schema" : "sales", @@ -77,21 +68,12 @@ "tableName" : "orders", "schema" : "sales", "unique" : false, - "columns" : [ "order_date", "total_amount" ], - "indexType" : null + "columns" : [ "order_date", "total_amount" ] }, { "indexName" : "ux_users_email", "tableName" : "users", "schema" : "public", "unique" : true, - "columns" : [ "email" ], - "indexType" : null - } ], - "createProcedures" : [ ], - "createFunctions" : [ ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + "columns" : [ "email" ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_DropStatements.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_DropStatements.approved.txt index 626f199..6b33ae5 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_DropStatements.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_DropStatements.approved.txt @@ -1,23 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/drop_statements.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "dropOperations" : [ { "objectType" : "TABLE", "objectName" : "legacy_users", diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_FunctionsCrossDialects.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_FunctionsCrossDialects.approved.txt index 3b3e908..0176c2b 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_FunctionsCrossDialects.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_FunctionsCrossDialects.approved.txt @@ -1,39 +1,19 @@ { "filePath" : "src/test/resources/samples/sql/functions_crossdialects.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createFunctions" : [ { "functionName" : "calc_tax", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "amount", - "type" : "DECIMAL(10,2)", - "direction" : null + "type" : "DECIMAL(10,2)" } ], "returnType" : "DECIMAL(10,2)", "references" : { "relations" : [ "shop.tax_rates" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + "calls" : { } + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_PLSQLPackages.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_PLSQLPackages.approved.txt index 9f01ccd..baa7f24 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_PLSQLPackages.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_PLSQLPackages.approved.txt @@ -1,17 +1,10 @@ { "filePath" : "src/test/resources/samples/sql/plsql_packages.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, + "topLevelReferences" : { }, "topLevelCalls" : { - "functions" : [ ], "procedures" : [ "ORDER_PKG.PROCESS", "HR.ORDER_PKG.PROCESS" ] }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], "createProcedures" : [ { "procedureName" : "ORDER_PKG.LOG_ORDER", "schema" : "HR", @@ -28,10 +21,7 @@ "references" : { "relations" : [ "HR.ORDER_LOG" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "procedureName" : "ORDER_PKG.PROCESS", "schema" : "HR", @@ -41,9 +31,7 @@ "type" : "NUMBER", "direction" : "IN" } ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { "functions" : [ "HR.ORDER_PKG.GET_TOTAL" ], "procedures" : [ "LOG_ORDER" ] @@ -61,11 +49,8 @@ "type" : "VARCHAR2", "direction" : "IN" } ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { - "functions" : [ ], "procedures" : [ "PROCESS", "HR.ORDER_PKG.LOG_ORDER" ] } } ], @@ -82,14 +67,6 @@ "references" : { "relations" : [ "HR.ORDER_ITEMS" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + "calls" : { } + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_PLSQLRoutineVariants.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_PLSQLRoutineVariants.approved.txt index f1be7e5..ad136e8 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_PLSQLRoutineVariants.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_PLSQLRoutineVariants.approved.txt @@ -8,10 +8,6 @@ "functions" : [ "HR.SIMPLE_TOTAL", "SIMPLE_TOTAL" ], "procedures" : [ "UPDATE_ORDER_STATUS", "HR.UPDATE_ORDER_STATUS" ] }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], "createProcedures" : [ { "procedureName" : "UPDATE_ORDER_STATUS", "schema" : "HR", @@ -29,12 +25,10 @@ "relations" : [ "HR.ORDERS" ] }, "calls" : { - "functions" : [ ], "procedures" : [ "HR.LOG_ACCESS", "LOG_ACCESS" ] } }, { "procedureName" : "UPDATE_ORDER_STATUS_NO_SCHEMA", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "p_order_id", @@ -49,12 +43,10 @@ "relations" : [ "ORDERS" ] }, "calls" : { - "functions" : [ ], "procedures" : [ "HR.LOG_ACCESS", "SIMPLE_TOTAL_NO_SCHEMA" ] } }, { "procedureName" : "UPDATE_ORDER_STATUS_OR_REPLACE", - "schema" : null, "orReplace" : true, "parameters" : [ { "name" : "p_order_id", @@ -89,7 +81,6 @@ "relations" : [ "ORDERS" ] }, "calls" : { - "functions" : [ ], "procedures" : [ "HR.LOG_ACCESS", "SIMPLE_TOTAL_OR_REPLACE", "LOG_ACCESS", "HR.SIMPLE_TOTAL_OR_REPLACE_SCHEMA" ] } } ], @@ -107,12 +98,10 @@ "relations" : [ "HR.ORDERS" ] }, "calls" : { - "functions" : [ "SIMPLE_TOTAL_NO_SCHEMA" ], - "procedures" : [ ] + "functions" : [ "SIMPLE_TOTAL_NO_SCHEMA" ] } }, { "functionName" : "SIMPLE_TOTAL_NO_SCHEMA", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "p_amount", @@ -124,12 +113,10 @@ "relations" : [ "ORDERS" ] }, "calls" : { - "functions" : [ ], "procedures" : [ "HR.LOG_ACCESS" ] } }, { "functionName" : "SIMPLE_TOTAL_OR_REPLACE", - "schema" : null, "orReplace" : true, "parameters" : [ { "name" : "p_amount", @@ -141,8 +128,7 @@ "relations" : [ "HR.ORDERS" ] }, "calls" : { - "functions" : [ "SIMPLE_TOTAL_NO_SCHEMA" ], - "procedures" : [ ] + "functions" : [ "SIMPLE_TOTAL_NO_SCHEMA" ] } }, { "functionName" : "SIMPLE_TOTAL_OR_REPLACE_SCHEMA", @@ -158,13 +144,7 @@ "relations" : [ "ORDERS" ] }, "calls" : { - "functions" : [ "SIMPLE_TOTAL_OR_REPLACE", "HR.SIMPLE_TOTAL" ], - "procedures" : [ ] + "functions" : [ "SIMPLE_TOTAL_OR_REPLACE", "HR.SIMPLE_TOTAL" ] } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_ProceduresFunctions.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_ProceduresFunctions.approved.txt index 8d7f780..be1e8e6 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_ProceduresFunctions.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_ProceduresFunctions.approved.txt @@ -1,15 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/procedures_functions.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createViews" : [ { "viewName" : "order_summaries", "schema" : "sales", @@ -18,7 +11,6 @@ "relations" : [ "sales.orders", "sales.order_lines" ] } } ], - "createIndexes" : [ ], "createProcedures" : [ { "procedureName" : "recalc_order_total", "schema" : "sales", @@ -44,13 +36,8 @@ "type" : "INT", "direction" : "IN" } ], - "references" : { - "relations" : [ ] - }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "references" : { }, + "calls" : { } } ], "createFunctions" : [ { "functionName" : "get_total", @@ -58,55 +45,42 @@ "orReplace" : false, "parameters" : [ { "name" : "order_id", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "DECIMAL(12,2)", "references" : { "relations" : [ "sales.order_lines" ] }, "calls" : { - "functions" : [ "COALESCE", "SUM" ], - "procedures" : [ ] + "functions" : [ "COALESCE", "SUM" ] } }, { "functionName" : "total_for_user", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "uid", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "DECIMAL(12,2)", "references" : { "relations" : [ "public.users", "sales.orders", "sales.order_lines" ] }, "calls" : { - "functions" : [ "COALESCE", "SUM" ], - "procedures" : [ ] + "functions" : [ "COALESCE", "SUM" ] } }, { "functionName" : "total_for_user_v2", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "uid", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "DECIMAL(12,2)", "references" : { "relations" : [ "sales.orders", "sales.order_summaries" ] }, "calls" : { - "functions" : [ "COALESCE", "sales.get_total", "SUM" ], - "procedures" : [ ] + "functions" : [ "COALESCE", "sales.get_total", "SUM" ] } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_Sample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_Sample.approved.txt index a598c04..33adfee 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_Sample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_Sample.approved.txt @@ -1,16 +1,10 @@ { "filePath" : "src/test/resources/samples/sql/sample.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createTables" : [ { "tableName" : "users", - "schema" : null, "ifNotExists" : false, "columns" : [ { "name" : "id", @@ -30,14 +24,11 @@ }, { "name" : "created_at", "type" : "TIMESTAMP", - "nullable" : true, - "constraints" : [ ] + "nullable" : true } ], - "primaryKeys" : [ "id" ], - "foreignKeys" : [ ] + "primaryKeys" : [ "id" ] }, { "tableName" : "orders", - "schema" : null, "ifNotExists" : false, "columns" : [ { "name" : "order_id", @@ -52,26 +43,21 @@ }, { "name" : "total_amount", "type" : "DECIMAL(10,2)", - "nullable" : true, - "constraints" : [ ] + "nullable" : true }, { "name" : "order_date", "type" : "DATE", - "nullable" : true, - "constraints" : [ ] + "nullable" : true } ], "primaryKeys" : [ "order_id" ], "foreignKeys" : [ { - "name" : null, "columns" : [ "user_id" ], "referencedTable" : "users", "referencedColumns" : [ "id" ] } ] } ], - "alterTables" : [ ], "createViews" : [ { "viewName" : "active_users", - "schema" : null, "orReplace" : false, "references" : { "relations" : [ "users" ] @@ -80,14 +66,11 @@ "createIndexes" : [ { "indexName" : "idx_username", "tableName" : "users", - "schema" : null, "unique" : false, - "columns" : [ "username" ], - "indexType" : null + "columns" : [ "username" ] } ], "createProcedures" : [ { "procedureName" : "GetUserById", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "userId", @@ -97,32 +80,19 @@ "references" : { "relations" : [ "users" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } } ], "createFunctions" : [ { "functionName" : "CalculateTotal", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "orderId", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "DECIMAL(10,2)", "references" : { "relations" : [ "orders" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + "calls" : { } + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_Sample_hideColumns.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_Sample_hideColumns.approved.txt index dcc474a..7551693 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_Sample_hideColumns.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_Sample_hideColumns.approved.txt @@ -1,37 +1,24 @@ { "filePath" : "src/test/resources/samples/sql/sample.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createTables" : [ { "tableName" : "users", - "schema" : null, "ifNotExists" : false, - "columns" : [ ], - "primaryKeys" : [ "id" ], - "foreignKeys" : [ ] + "primaryKeys" : [ "id" ] }, { "tableName" : "orders", - "schema" : null, "ifNotExists" : false, - "columns" : [ ], "primaryKeys" : [ "order_id" ], "foreignKeys" : [ { - "name" : null, "columns" : [ "user_id" ], "referencedTable" : "users", "referencedColumns" : [ "id" ] } ] } ], - "alterTables" : [ ], "createViews" : [ { "viewName" : "active_users", - "schema" : null, "orReplace" : false, "references" : { "relations" : [ "users" ] @@ -40,14 +27,11 @@ "createIndexes" : [ { "indexName" : "idx_username", "tableName" : "users", - "schema" : null, "unique" : false, - "columns" : [ "username" ], - "indexType" : null + "columns" : [ "username" ] } ], "createProcedures" : [ { "procedureName" : "GetUserById", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "userId", @@ -57,32 +41,19 @@ "references" : { "relations" : [ "users" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } } ], "createFunctions" : [ { "functionName" : "CalculateTotal", - "schema" : null, "orReplace" : false, "parameters" : [ { "name" : "orderId", - "type" : "INT", - "direction" : null + "type" : "INT" } ], "returnType" : "DECIMAL(10,2)", "references" : { "relations" : [ "orders" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + "calls" : { } + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TSqlRoutineBodies.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TSqlRoutineBodies.approved.txt index 93022b0..91300d8 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TSqlRoutineBodies.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TSqlRoutineBodies.approved.txt @@ -1,17 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/tsql_routine_bodies.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createProcedures" : [ { "procedureName" : "usp_GetOrdersByCustomer", "schema" : "dbo", @@ -42,10 +33,7 @@ "references" : { "relations" : [ "dbo.OrderItems" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "functionName" : "ufn_OrderHasItem", "schema" : "dbo", @@ -63,14 +51,6 @@ "references" : { "relations" : [ "dbo.OrderItems" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } - } ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + "calls" : { } + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatements.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatements.approved.txt index e38bb41..1a73a29 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatements.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatements.approved.txt @@ -7,16 +7,5 @@ "topLevelCalls" : { "functions" : [ "COALESCE", "sales.get_total", "SUM" ], "procedures" : [ "sales.recalc_order_total" ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsMySQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsMySQL.approved.txt index bf29fe4..18ef414 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsMySQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsMySQL.approved.txt @@ -7,16 +7,5 @@ "topLevelCalls" : { "functions" : [ "fn_net_amount" ], "procedures" : [ "purchasing.process_purchase_order" ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsPLSQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsPLSQL.approved.txt index 17e2908..1a16a5d 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsPLSQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsPLSQL.approved.txt @@ -7,16 +7,5 @@ "topLevelCalls" : { "functions" : [ "HR.TOTAL_AMOUNT" ], "procedures" : [ "GET_ORDERS_BY_CUSTOMER", "HR.GET_ORDERS_BY_CUSTOMER", "HR.REPORT_CUSTOMER_ORDERS" ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsTSQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsTSQL.approved.txt index a215198..b3febd7 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsTSQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TopLevelStatementsTSQL.approved.txt @@ -7,16 +7,5 @@ "topLevelCalls" : { "functions" : [ "dbo.ufn_TotalAmount" ], "procedures" : [ "dbo.usp_RecalcOrderTotal" ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], - "createTriggers" : [ ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersMySQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersMySQL.approved.txt index ce3b525..be5f676 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersMySQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersMySQL.approved.txt @@ -1,23 +1,11 @@ { "filePath" : "src/test/resources/samples/sql/triggers_mysql.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createTriggers" : [ { "triggerName" : "trg_users_before_insert", "tableName" : "users", - "schema" : null, "orReplace" : false, "timing" : "BEFORE", "events" : [ "INSERT" ], @@ -25,13 +13,11 @@ "relations" : [ "audit_log" ] }, "calls" : { - "functions" : [ "NOW" ], - "procedures" : [ ] + "functions" : [ "NOW" ] } }, { "triggerName" : "trg_orders_after_update", "tableName" : "orders", - "schema" : null, "orReplace" : false, "timing" : "AFTER", "events" : [ "UPDATE" ], @@ -45,7 +31,6 @@ }, { "triggerName" : "trg_products_before_delete", "tableName" : "products", - "schema" : null, "orReplace" : false, "timing" : "BEFORE", "events" : [ "DELETE" ], @@ -53,13 +38,11 @@ "relations" : [ "deleted_products" ] }, "calls" : { - "functions" : [ "CURRENT_USER", "NOW" ], - "procedures" : [ ] + "functions" : [ "CURRENT_USER", "NOW" ] } }, { "triggerName" : "trg_order_items_after_insert", "tableName" : "order_items", - "schema" : null, "orReplace" : false, "timing" : "AFTER", "events" : [ "INSERT" ], @@ -67,13 +50,11 @@ "relations" : [ "orders" ] }, "calls" : { - "functions" : [ "calculate_order_total", "NOW" ], - "procedures" : [ ] + "functions" : [ "calculate_order_total", "NOW" ] } }, { "triggerName" : "trg_simple_audit", "tableName" : "simple_table", - "schema" : null, "orReplace" : false, "timing" : "AFTER", "events" : [ "INSERT" ], @@ -81,12 +62,7 @@ "relations" : [ "simple_audit" ] }, "calls" : { - "functions" : [ "NOW" ], - "procedures" : [ ] + "functions" : [ "NOW" ] } - } ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersPLSQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersPLSQL.approved.txt index c1b8a5b..34d9456 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersPLSQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersPLSQL.approved.txt @@ -1,19 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/triggers_plsql.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createTriggers" : [ { "triggerName" : "trg_employees_bi", "tableName" : "hr.employees", @@ -24,10 +13,7 @@ "references" : { "relations" : [ "hr.audit_log" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "triggerName" : "trg_employees_salary_au", "tableName" : "hr.employees", @@ -39,7 +25,6 @@ "relations" : [ "hr.salary_history" ] }, "calls" : { - "functions" : [ ], "procedures" : [ "hr.pkg_notifications.send_update_alert" ] } }, { @@ -52,10 +37,7 @@ "references" : { "relations" : [ "sales.order_items", "sales.orders" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "triggerName" : "trg_employees_compound", "tableName" : "hr.employees", @@ -63,9 +45,7 @@ "orReplace" : true, "timing" : "COMPOUND", "events" : [ "INSERT", "UPDATE", "DELETE" ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { "functions" : [ "t_emp_ids", "g_emp_ids" ], "procedures" : [ "hr.process_employee_change" ] @@ -73,17 +53,13 @@ }, { "triggerName" : "trg_schema_ddl", "tableName" : "hr.SCHEMA", - "schema" : null, "orReplace" : true, "timing" : "AFTER", "events" : [ "CREATE", "ALTER", "DROP" ], "references" : { "relations" : [ "hr.ddl_log" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "triggerName" : "trg_orders_total", "tableName" : "sales.order_items", @@ -95,12 +71,7 @@ "relations" : [ "sales.orders" ] }, "calls" : { - "functions" : [ "sales.fn_calculate_order_total" ], - "procedures" : [ ] + "functions" : [ "sales.fn_calculate_order_total" ] } - } ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersPostgreSQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersPostgreSQL.approved.txt index 1ce4277..68cd185 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersPostgreSQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersPostgreSQL.approved.txt @@ -1,120 +1,77 @@ { "filePath" : "src/test/resources/samples/sql/triggers_postgresql.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createTriggers" : [ { "triggerName" : "trg_users_created_at", "tableName" : "public.users", - "schema" : null, "orReplace" : false, "timing" : "BEFORE", "events" : [ "INSERT" ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { - "functions" : [ "public.set_created_timestamp" ], - "procedures" : [ ] + "functions" : [ "public.set_created_timestamp" ] } }, { "triggerName" : "trg_orders_audit", "tableName" : "sales.orders", - "schema" : null, "orReplace" : false, "timing" : "AFTER", "events" : [ "UPDATE" ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { - "functions" : [ "sales.log_order_changes" ], - "procedures" : [ ] + "functions" : [ "sales.log_order_changes" ] } }, { "triggerName" : "trg_products_history", "tableName" : "inventory.products", - "schema" : null, "orReplace" : false, "timing" : "AFTER", "events" : [ "INSERT", "UPDATE", "DELETE" ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { - "functions" : [ "inventory.track_product_changes" ], - "procedures" : [ ] + "functions" : [ "inventory.track_product_changes" ] } }, { "triggerName" : "trg_v_customer_orders", "tableName" : "sales.v_customer_orders", - "schema" : null, "orReplace" : false, "timing" : "INSTEAD OF", "events" : [ "INSERT" ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { - "functions" : [ "sales.insert_customer_order" ], - "procedures" : [ ] + "functions" : [ "sales.insert_customer_order" ] } }, { "triggerName" : "trg_employees_salary", "tableName" : "hr.employees", - "schema" : null, "orReplace" : true, "timing" : "BEFORE", "events" : [ "UPDATE" ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { - "functions" : [ "hr.validate_salary_change" ], - "procedures" : [ ] + "functions" : [ "hr.validate_salary_change" ] } }, { "triggerName" : "trg_audit_log", "tableName" : "audit.events", - "schema" : null, "orReplace" : false, "timing" : "AFTER", "events" : [ "INSERT" ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { - "functions" : [ ], "procedures" : [ "audit.process_event" ] } }, { "triggerName" : "trg_table_modified", "tableName" : "config.settings", - "schema" : null, "orReplace" : false, "timing" : "AFTER", "events" : [ "INSERT" ], - "references" : { - "relations" : [ ] - }, + "references" : { }, "calls" : { - "functions" : [ "config.notify_settings_change" ], - "procedures" : [ ] + "functions" : [ "config.notify_settings_change" ] } - } ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersTSQL.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersTSQL.approved.txt index 1303b56..de601e3 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersTSQL.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.analyze_SQL_TriggersTSQL.approved.txt @@ -1,19 +1,8 @@ { "filePath" : "src/test/resources/samples/sql/triggers_tsql.sql", "language" : "sql", - "topLevelReferences" : { - "relations" : [ ] - }, - "topLevelCalls" : { - "functions" : [ ], - "procedures" : [ ] - }, - "createTables" : [ ], - "alterTables" : [ ], - "createViews" : [ ], - "createIndexes" : [ ], - "createProcedures" : [ ], - "createFunctions" : [ ], + "topLevelReferences" : { }, + "topLevelCalls" : { }, "createTriggers" : [ { "triggerName" : "tr_orders_insert", "tableName" : "dbo.orders", @@ -24,10 +13,7 @@ "references" : { "relations" : [ "inserted", "dbo.audit_log" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "triggerName" : "tr_customers_audit", "tableName" : "dbo.customers", @@ -38,10 +24,7 @@ "references" : { "relations" : [ "dbo.customer_history", "deleted", "inserted" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "triggerName" : "tr_v_order_summary_insert", "tableName" : "sales.v_order_summary", @@ -53,23 +36,18 @@ "relations" : [ "sales.orders", "inserted" ] }, "calls" : { - "functions" : [ ], "procedures" : [ "dbo.usp_notify_new_order" ] } }, { "triggerName" : "tr_ddl_audit", "tableName" : "DATABASE", - "schema" : null, "orReplace" : false, "timing" : "AFTER", "events" : [ "CREATE_TABLE", "ALTER_TABLE", "DROP_TABLE" ], "references" : { "relations" : [ "dbo.ddl_audit_log" ] }, - "calls" : { - "functions" : [ ], - "procedures" : [ ] - } + "calls" : { } }, { "triggerName" : "tr_employees_salary_check", "tableName" : "hr.employees", @@ -81,12 +59,7 @@ "relations" : [ "inserted" ] }, "calls" : { - "functions" : [ "hr.fn_get_max_salary" ], - "procedures" : [ ] + "functions" : [ "hr.fn_get_max_salary" ] } - } ], - "alterViews" : [ ], - "alterFunctions" : [ ], - "alterProcedures" : [ ], - "dropOperations" : [ ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.java index 80de96a..a49b9d4 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/sql/SQLAnalyzeApprovalTest.java @@ -1,10 +1,9 @@ package org.dxworks.codeframe.analyzer.sql; import org.approvaltests.Approvals; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; +import org.dxworks.codeframe.TestUtils; import org.dxworks.codeframe.CodeframeConfig; import org.dxworks.codeframe.model.Analysis; import org.junit.jupiter.api.Test; @@ -12,10 +11,6 @@ import java.nio.file.Paths; public class SQLAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_SQL_Sample() throws Exception { verify(Paths.get("src/test/resources/samples/sql/sample.sql"), Language.SQL); @@ -128,11 +123,11 @@ void analyze_SQL_Sample_hideColumns() throws Exception { Paths.get("src/test/resources/samples/sql/sample.sql"), Language.SQL, config); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } private static void verify(java.nio.file.Path file, Language language) throws Exception { Analysis analysis = App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_Tsx_ConfirmDiscardPrompt.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_Tsx_ConfirmDiscardPrompt.approved.txt index bc80af5..f021e41 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_Tsx_ConfirmDiscardPrompt.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_Tsx_ConfirmDiscardPrompt.approved.txt @@ -1,41 +1,19 @@ { "filePath" : "src/test/resources/samples/typescript/confirm-discard-prompt.tsx", "language" : "typescript", - "packageName" : null, "types" : [ { "kind" : "interface", "name" : "ConfirmDiscardPromptProps", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "when", - "type" : "boolean", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] + "type" : "boolean" }, { "name" : "redirect", - "type" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] - } ], - "methods" : [ ], - "types" : [ ] + "type" : "string" + } ] } ], "methods" : [ { "name" : "showModal", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "_id", "type" : "string" @@ -46,151 +24,86 @@ "name" : "onClosed", "type" : "() => void" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "onClosed", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "navigate", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "_opts", "type" : "{ to: string }" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "stripAppBaseFromUrl", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "url", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "split", - "objectType" : null, "objectName" : "url", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "ConfirmDiscardPrompt", "returnType" : "React.FC", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], "localVariables" : [ "ref", "target", "cancelUnload", "message", "cancelNavigation", "dispose" ], "methodCalls" : [ { "methodName" : "addEventListener", - "objectType" : null, "objectName" : "window", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "cancelNavigation", - "objectType" : null, "objectName" : "evt.detail", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "dispose", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "navigate", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "preventDefault", - "objectType" : null, "objectName" : "e", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "removeEventListener", - "objectType" : null, "objectName" : "window", - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "setTarget", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "showModal", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "stripAppBaseFromUrl", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "t", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "useCallback", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "useEffect", - "objectType" : null, - "objectName" : null, - "callCount" : 2, - "parameterCount" : null + "callCount" : 2 }, { "methodName" : "useRef", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "useState", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "useTranslation", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] } ], "fields" : [ { "name" : "APP_BASE", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] } ], - "methodCalls" : [ ], "imports" : [ "import type React from 'react';", "import { useCallback, useEffect, useRef, useState } from 'react';", "import { useTranslation } from 'react-i18next';" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_ClassFeatures.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_ClassFeatures.approved.txt index 5b7f53f..e26163c 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_ClassFeatures.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_ClassFeatures.approved.txt @@ -1,42 +1,28 @@ { "filePath" : "src/test/resources/samples/typescript/ClassFeatures.ts", "language" : "typescript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Point", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "x", "type" : "number", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ] + "modifiers" : [ "public" ] }, { "name" : "y", "type" : "number", "visibility" : "public", - "modifiers" : [ "public" ], - "annotations" : [ ] + "modifiers" : [ "public" ] }, { "name" : "label", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "x", "type" : "number" @@ -46,15 +32,10 @@ }, { "name" : "label", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "distanceTo", "returnType" : "number", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "other", "type" : "Point" @@ -62,151 +43,88 @@ "localVariables" : [ "dx", "dy" ], "methodCalls" : [ { "methodName" : "sqrt", - "objectType" : null, "objectName" : "Math", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Counter", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "instanceCount", "type" : "number", "visibility" : "private", - "modifiers" : [ "private", "static" ], - "annotations" : [ ] + "modifiers" : [ "private", "static" ] }, { "name" : "MAX_VALUE", "type" : "number", "visibility" : "public", - "modifiers" : [ "public", "static", "readonly" ], - "annotations" : [ ] + "modifiers" : [ "public", "static", "readonly" ] }, { "name" : "_value", "type" : "number", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "initial", "type" : "number" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "value", - "returnType" : "number", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "returnType" : "number" }, { "name" : "value", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "newValue", "type" : "number" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getInstanceCount", "returnType" : "number", - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "static" ] }, { "name" : "resetInstances", "returnType" : "void", - "visibility" : null, - "modifiers" : [ "static" ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] + "modifiers" : [ "static" ] }, { "name" : "increment", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "amount", "type" : "number" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Logger", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "prefix", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "enabled", "type" : "boolean", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "prefix", "type" : "string" }, { "name" : "enabled", "type" : "boolean" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "log", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "message", "type" : "string" @@ -214,20 +132,14 @@ "name" : "level", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "log", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "format", "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "template", "type" : "string" @@ -237,63 +149,33 @@ }, { "name" : "suffix", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "class", "name" : "Configuration", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "version", "type" : "string", - "visibility" : null, - "modifiers" : [ "readonly" ], - "annotations" : [ ] + "modifiers" : [ "readonly" ] }, { "name" : "settings", "type" : "ReadonlyArray", - "visibility" : null, - "modifiers" : [ "readonly" ], - "annotations" : [ ] + "modifiers" : [ "readonly" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "version", "type" : "string" }, { "name" : "settings", "type" : "string[]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getVersion", - "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "returnType" : "string" + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_ClassInheritance.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_ClassInheritance.approved.txt index 33b0eac..5d0b7b1 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_ClassInheritance.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_ClassInheritance.approved.txt @@ -1,36 +1,25 @@ { "filePath" : "src/test/resources/samples/typescript/ClassInheritance.ts", "language" : "typescript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "User", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "extendsType" : "Entity", "implementsInterfaces" : [ "Serializable" ], - "mixins" : [ ], "fields" : [ { "name" : "name", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "email", "type" : "string", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "string" @@ -40,73 +29,41 @@ }, { "name" : "email", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "validate", "returnType" : "boolean", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "includes", - "objectType" : null, "objectName" : "this.email", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "serialize", "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "stringify", - "objectType" : null, "objectName" : "JSON", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "getName", - "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "returnType" : "string" + } ] }, { "kind" : "class", "name" : "AdminUser", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "extendsType" : "User", "implementsInterfaces" : [ "Serializable", "Identifiable" ], - "mixins" : [ ], "fields" : [ { "name" : "permissions", "type" : "string[]", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "string" @@ -119,131 +76,64 @@ }, { "name" : "permissions", "type" : "string[]" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "hasPermission", "returnType" : "boolean", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "permission", "type" : "string" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "includes", - "objectType" : null, "objectName" : "this.permissions", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "validate", "returnType" : "boolean", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "validate", - "objectType" : null, "objectName" : "super", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] - } ], - "types" : [ ] + } ] }, { "kind" : "class", "name" : "Entity", - "visibility" : null, "modifiers" : [ "abstract", "export" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Identifiable" ], - "mixins" : [ ], "fields" : [ { "name" : "id", "type" : "string", "visibility" : "protected", - "modifiers" : [ "protected" ], - "annotations" : [ ] + "modifiers" : [ "protected" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getId", - "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "returnType" : "string" + } ] }, { "kind" : "interface", "name" : "Serializable", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "serialize", - "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "returnType" : "string" + } ] }, { "kind" : "interface", "name" : "Identifiable", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "getId", - "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "returnType" : "string" + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_InterfaceSample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_InterfaceSample.approved.txt index fc44950..5915bdd 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_InterfaceSample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_InterfaceSample.approved.txt @@ -1,69 +1,32 @@ { "filePath" : "src/test/resources/samples/typescript/interface-sample.ts", "language" : "typescript", - "packageName" : null, "types" : [ { "kind" : "interface", "name" : "IRepository", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "findById", "returnType" : "T", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "ID" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "save", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "entity", "type" : "T" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "interface", "name" : "INamed", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "getName", - "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "parameters" : [ ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] - } ], - "methods" : [ ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "returnType" : "string" + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_OrderParams.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_OrderParams.approved.txt index df48385..5fc08ab 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_OrderParams.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_OrderParams.approved.txt @@ -1,24 +1,13 @@ { "filePath" : "src/test/resources/samples/typescript/order-params.ts", "language" : "typescript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "C", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], "methods" : [ { "name" : "m", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "x", "type" : "string" @@ -26,20 +15,14 @@ "name" : "y", "type" : "number" }, { - "name" : "...z", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "...z" + } ] + } ] } ], "methods" : [ { "name" : "f", "returnType" : "void", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { "name" : "a", "type" : "number" @@ -47,13 +30,7 @@ "name" : "b", "type" : "string" }, { - "name" : "...rest", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + "name" : "...rest" + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_Sample.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_Sample.approved.txt index aa7e532..c182ec3 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_Sample.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_Sample.approved.txt @@ -1,51 +1,34 @@ { "filePath" : "src/test/resources/samples/typescript/sample.ts", "language" : "typescript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "UserService", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "logger", "type" : "Logger", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "config", "type" : "Config", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "logger", "type" : "Logger" }, { "name" : "config", "type" : "Config" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "getUser", "returnType" : "Promise", - "visibility" : null, "modifiers" : [ "async" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "string" @@ -55,178 +38,106 @@ "methodName" : "fetchFromDb", "objectType" : "UserService", "objectName" : "this", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "info", - "objectType" : null, "objectName" : "this.logger", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "fetchFromDb", "returnType" : "Promise", "visibility" : "private", "modifiers" : [ "private", "async" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "string" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "addTags", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { - "name" : "...tags", - "type" : null - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + "name" : "...tags" + } ] + } ] }, { "kind" : "class", "name" : "SavePatientTransactionManager", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "patientSaved", - "type" : "boolean", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "boolean" + } ] }, { "kind" : "interface", "name" : "User", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "id", - "type" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] + "type" : "string" }, { "name" : "name", - "type" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] + "type" : "string" }, { "name" : "email", - "type" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] - } ], - "methods" : [ ], - "types" : [ ] + "type" : "string" + } ] } ], "methods" : [ { "name" : "calculateTotal", "returnType" : "number", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { "name" : "items", "type" : "number[]" } ], - "localVariables" : [ ], "methodCalls" : [ { "methodName" : "expect", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "parseFloat", - "objectType" : null, - "objectName" : null, - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "reduce", - "objectType" : null, "objectName" : "items", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 }, { "methodName" : "toBeGreaterThan", - "objectType" : null, "objectName" : "expect()", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ] }, { "name" : "formatMessage", "returnType" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "name", "type" : "string" }, { "name" : "age", "type" : "number" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] } ], "fields" : [ { "name" : "API_VERSION", "type" : "string", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "MAX_RETRIES", "type" : "number", - "visibility" : null, - "modifiers" : [ "const" ], - "annotations" : [ ] + "modifiers" : [ "const" ] }, { "name" : "currentUser", "type" : "User | null", - "visibility" : null, - "modifiers" : [ "let" ], - "annotations" : [ ] + "modifiers" : [ "let" ] }, { "name" : "DEFAULT_TIMEOUT", "type" : "number", - "visibility" : null, - "modifiers" : [ "const", "export" ], - "annotations" : [ ] + "modifiers" : [ "const", "export" ] } ], "methodCalls" : [ { "methodName" : "log", - "objectType" : null, "objectName" : "console", - "callCount" : 1, - "parameterCount" : null + "callCount" : 1 } ], "imports" : [ "import { Logger } from './logger';", "import type { Config } from './config';" ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_TypeScriptTypes.approved.txt b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_TypeScriptTypes.approved.txt index f08a540..e6294bf 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_TypeScriptTypes.approved.txt +++ b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.analyze_TypeScript_TypeScriptTypes.approved.txt @@ -1,316 +1,154 @@ { "filePath" : "src/test/resources/samples/typescript/TypeScriptTypes.ts", "language" : "typescript", - "packageName" : null, "types" : [ { "kind" : "class", "name" : "Task", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "id", "type" : "ID", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "status", "type" : "Status", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] }, { "name" : "priority", "type" : "Priority", "visibility" : "private", - "modifiers" : [ "private" ], - "annotations" : [ ] + "modifiers" : [ "private" ] } ], - "properties" : [ ], "methods" : [ { "name" : "constructor", - "returnType" : null, - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "ID" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "setStatus", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "status", "type" : "Status" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] + } ] }, { "name" : "setPriority", "returnType" : "void", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], "parameters" : [ { "name" : "priority", "type" : "Priority" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "types" : [ ] + } ] + } ] }, { "kind" : "interface", "name" : "Named", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "name", - "type" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] - } ], - "methods" : [ ], - "types" : [ ] + "type" : "string" + } ] }, { "kind" : "interface", "name" : "Person", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Named" ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "age", - "type" : "number", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] - } ], - "methods" : [ ], - "types" : [ ] + "type" : "number" + } ] }, { "kind" : "interface", "name" : "Employee", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, "implementsInterfaces" : [ "Named", "Person" ], - "mixins" : [ ], - "fields" : [ ], "properties" : [ { "name" : "employeeId", - "type" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] + "type" : "string" }, { "name" : "department", - "type" : "string", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ], - "accessors" : [ ] - } ], - "methods" : [ ], - "types" : [ ] + "type" : "string" + } ] }, { "kind" : "interface", "name" : "Dictionary", - "visibility" : null, - "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "modifiers" : [ "export" ] }, { "kind" : "enum", "name" : "Status", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "Active", - "type" : "Status", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Status" }, { "name" : "Inactive", - "type" : "Status", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Status" }, { "name" : "Pending", - "type" : "Status", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "Status" + } ] }, { "kind" : "enum", "name" : "Priority", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "Low", - "type" : "Priority", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Priority" }, { "name" : "Medium", - "type" : "Priority", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Priority" }, { "name" : "High", - "type" : "Priority", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Priority" }, { "name" : "Critical", - "type" : "Priority", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "Priority" + } ] }, { "kind" : "enum", "name" : "Direction", - "visibility" : null, "modifiers" : [ "export", "const" ], - "annotations" : [ ], - "extendsType" : null, - "implementsInterfaces" : [ ], - "mixins" : [ ], "fields" : [ { "name" : "Up", - "type" : "Direction", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Direction" }, { "name" : "Down", - "type" : "Direction", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Direction" }, { "name" : "Left", - "type" : "Direction", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] + "type" : "Direction" }, { "name" : "Right", - "type" : "Direction", - "visibility" : null, - "modifiers" : [ ], - "annotations" : [ ] - } ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "type" : "Direction" + } ] }, { "kind" : "type", "name" : "ID", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : "string | number", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "extendsType" : "string | number" }, { "kind" : "type", "name" : "Coordinates", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : "{\n x: number;\n y: number;\n z?: number;\n}", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "extendsType" : "{\n x: number;\n y: number;\n z?: number;\n}" }, { "kind" : "type", "name" : "Result", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], - "extendsType" : "{ success: true; data: T } | { success: false; error: string }", - "implementsInterfaces" : [ ], - "mixins" : [ ], - "fields" : [ ], - "properties" : [ ], - "methods" : [ ], - "types" : [ ] + "extendsType" : "{ success: true; data: T } | { success: false; error: string }" } ], "methods" : [ { "name" : "processItem", "returnType" : "Result", - "visibility" : null, "modifiers" : [ "export" ], - "annotations" : [ ], "parameters" : [ { "name" : "id", "type" : "ID" }, { "name" : "status", "type" : "Status" - } ], - "localVariables" : [ ], - "methodCalls" : [ ] - } ], - "fields" : [ ], - "methodCalls" : [ ], - "imports" : [ ] + } ] + } ] } \ No newline at end of file diff --git a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.java b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.java index fbafb51..21345a7 100644 --- a/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.java +++ b/src/test/java/org/dxworks/codeframe/analyzer/typescript/TypeScriptAnalyzeApprovalTest.java @@ -1,10 +1,9 @@ package org.dxworks.codeframe.analyzer.typescript; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; import org.approvaltests.Approvals; import org.dxworks.codeframe.App; import org.dxworks.codeframe.Language; +import org.dxworks.codeframe.TestUtils; import org.dxworks.codeframe.model.FileAnalysis; import org.junit.jupiter.api.Test; @@ -14,10 +13,6 @@ public class TypeScriptAnalyzeApprovalTest { - private static final ObjectMapper MAPPER = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT) - .enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); - @Test void analyze_TypeScript_Sample() throws IOException { verify(Paths.get("src/test/resources/samples/typescript/sample.ts"), Language.TYPESCRIPT); @@ -55,6 +50,6 @@ void analyze_TypeScript_ClassFeatures() throws IOException { private static void verify(Path file, Language language) throws IOException { FileAnalysis analysis = (FileAnalysis) App.analyzeFile(file, language); - Approvals.verify(MAPPER.writeValueAsString(analysis)); + Approvals.verify(TestUtils.APPROVAL_MAPPER.writeValueAsString(analysis)); } } diff --git a/src/test/resources/samples/cobol/PROCEDURES.cpy b/src/test/resources/samples/cobol/PROCEDURES.cpy new file mode 100644 index 0000000..5a8f0c0 --- /dev/null +++ b/src/test/resources/samples/cobol/PROCEDURES.cpy @@ -0,0 +1,13 @@ +****************************************************************** + PROCESS-STRING SECTION. + PROCESS-STRING-PARAGRAPH. + MOVE "PROCESSED" TO FUNC-OUTPUT + MOVE 0 TO ERROR-CODE + EXIT PARAGRAPH. + + CALCULATE-SUM SECTION. + CALCULATE-SUM-PARAGRAPH. + MOVE 42 TO FUNC-RESULT + MOVE 0 TO ERROR-CODE + EXIT PARAGRAPH. +****************************************************************** diff --git a/src/test/resources/samples/cobol/SIMPLE.cpy b/src/test/resources/samples/cobol/SIMPLE.cpy new file mode 100644 index 0000000..f6e7643 --- /dev/null +++ b/src/test/resources/samples/cobol/SIMPLE.cpy @@ -0,0 +1,5 @@ +****************************************************************** + 01 SIMPLE-RECORD. + 05 FIELD-1 PIC 9(5). + 05 FIELD-2 PIC X(10). +****************************************************************** diff --git a/src/test/resources/samples/cobol/basic-program.cbl b/src/test/resources/samples/cobol/basic-program.cbl new file mode 100644 index 0000000..76c575c --- /dev/null +++ b/src/test/resources/samples/cobol/basic-program.cbl @@ -0,0 +1,77 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. HELLO-WORLD. + + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 WS-NAME PIC X(20). + 01 WS-TABLE. + 05 WS-ROW OCCURS 10 TIMES. + 10 WS-COL OCCURS 5 TIMES PIC 9(3). + 01 WS-INDEX1 PIC 9(2). + 01 WS-INDEX2 PIC 9(2). + 01 WS-FIRST-NAME PIC X(15). + 01 WS-MIDDLE-NAME PIC X(15). + 01 WS-LAST-NAME PIC X(20). + 01 WS-FULL-NAME PIC X(50). + 01 WS-STATUS-CODE PIC 9. + 01 WS-UNSTRING-FIRST PIC X(15). + 01 WS-UNSTRING-MIDDLE PIC X(15). + 01 WS-UNSTRING-LAST PIC X(20). + 01 WS-UNSTRING-SOURCE PIC X(50). + 01 WS-CORR-RECORD-1. + 05 WS-CORR-FIELD-1-1 PIC 9(5). + 05 WS-CORR-FIELD-1-2 PIC X(10). + 01 WS-CORR-RECORD-2. + 05 WS-CORR-FIELD-2-1 PIC 9(5). + 05 WS-CORR-FIELD-2-2 PIC X(10). + 01 WS-TRANSACTION-TABLE. + 05 WS-TRAN-REC OCCURS 100 TIMES. + 10 WS-TRAN-ID PIC 9(5). + 10 WS-TRAN-AMT PIC 9(8)V99. + 01 WS-TRAN-COUNTER PIC 9(3). + + PROCEDURE DIVISION. + 1000-MAIN. + MOVE "HELLO" TO WS-NAME + DISPLAY WS-NAME + + MOVE 1 TO WS-INDEX1 + MOVE 2 TO WS-INDEX2 + + MOVE 100 TO WS-COL(WS-INDEX1, WS-INDEX2) + ADD 50 TO WS-COL(WS-INDEX1, WS-INDEX2) + + COMPUTE WS-COL(WS-INDEX1, WS-INDEX2) = + WS-COL(WS-INDEX1, WS-INDEX2) + 25 + + * STRING statement test + STRING "HELLO" INTO WS-FULL-NAME + STRING WS-FIRST-NAME DELIMITED BY SPACE + WS-MIDDLE-NAME DELIMITED BY SPACE + WS-LAST-NAME DELIMITED BY SPACE + INTO WS-FULL-NAME + + * UNSTRING statement test + UNSTRING WS-UNSTRING-SOURCE + DELIMITED BY SPACE OR "," + INTO WS-UNSTRING-FIRST WS-UNSTRING-MIDDLE WS-UNSTRING-LAST + + * MOVE CORRESPONDING statement test + MOVE CORRESPONDING WS-CORR-RECORD-1 TO WS-CORR-RECORD-2 + + * EVALUATE statement test + EVALUATE WS-STATUS-CODE + WHEN 0 DISPLAY "Success" + WHEN 1 DISPLAY "Warning" + WHEN OTHER DISPLAY "Error" + END-EVALUATE + + * INITIALIZE statement test + INITIALIZE WS-TRANSACTION-TABLE + INITIALIZE WS-FIRST-NAME WS-LAST-NAME + + * Additional DISPLAY with identifier operands + DISPLAY WS-FULL-NAME + DISPLAY WS-TRAN-COUNTER + + STOP RUN. diff --git a/src/test/resources/samples/cobol/copybook-test.cbl b/src/test/resources/samples/cobol/copybook-test.cbl new file mode 100644 index 0000000..2fc8ea0 --- /dev/null +++ b/src/test/resources/samples/cobol/copybook-test.cbl @@ -0,0 +1,19 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. COPYBOOK-TEST. + + DATA DIVISION. + WORKING-STORAGE SECTION. + COPY SIMPLE. + + 01 FUNCTION-PARAMETERS. + 05 FUNC-INPUT PIC X(20). + 05 FUNC-OUTPUT PIC X(20). + 05 FUNC-RESULT PIC 9(3). + + 01 FUNCTION-ERRORS. + 05 ERROR-CODE PIC 9(2). + + 01 WS-RESULT PIC 9(5). + + PROCEDURE DIVISION. + COPY PROCEDURES. diff --git a/src/test/resources/samples/cobol/file-operations.cbl b/src/test/resources/samples/cobol/file-operations.cbl new file mode 100644 index 0000000..9addf9c --- /dev/null +++ b/src/test/resources/samples/cobol/file-operations.cbl @@ -0,0 +1,131 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. FILEOPS-DEMO. + AUTHOR. JOHNDOE. + ****************************************************************** + * Program : FILEOPS-DEMO.CBL + * Function : Demonstrate all COBOL file operation verbs + ****************************************************************** + + ENVIRONMENT DIVISION. + INPUT-OUTPUT SECTION. + FILE-CONTROL. + SELECT CUSTOMER-FILE + ASSIGN TO CUSTFILE + ORGANIZATION IS SEQUENTIAL + ACCESS MODE IS SEQUENTIAL. + SELECT TRANSACTION-FILE + ASSIGN TO TRNXFILE + ORGANIZATION IS INDEXED + ACCESS MODE IS DYNAMIC + RECORD KEY IS TRNX-ID. + SELECT REPORT-FILE + ASSIGN TO RPTFILE + ORGANIZATION IS SEQUENTIAL + ACCESS MODE IS SEQUENTIAL. + + DATA DIVISION. + FILE SECTION. + FD CUSTOMER-FILE. + 01 CUSTOMER-HEADER-RECORD. + 05 RECORD-TYPE PIC X(1). + 05 HEADER-DATE PIC X(8). + 05 RECORD-COUNT PIC 9(5). + 01 CUSTOMER-DETAIL-RECORD. + 05 RECORD-TYPE PIC X(1). + 05 CUST-ID PIC X(10). + 05 CUST-NAME PIC X(50). + 05 CUST-ADDRESS PIC X(100). + 01 CUSTOMER-TRAILER-RECORD. + 05 RECORD-TYPE PIC X(1). + 05 TRAILER-COUNT PIC 9(5). + + FD TRANSACTION-FILE. + 01 TRANSACTION-RECORD. + 05 TRNX-ID PIC X(15). + 05 TRNX-AMOUNT PIC 9(9)V99. + 05 TRNX-DATE PIC X(8). + 01 TRANSACTION-HEADER-RECORD. + 05 RECORD-TYPE PIC X(1). + 05 BATCH-NUMBER PIC 9(5). + 05 BATCH-DATE PIC X(8). + + FD REPORT-FILE. + 01 REPORT-HEADER-RECORD. + 05 REPORT-TITLE PIC X(50). + 05 REPORT-DATE PIC X(8). + 05 PAGE-NUMBER PIC 9(5). + 01 REPORT-DETAIL-RECORD. + 05 LINE-TYPE PIC X(1). + 05 LINE-TEXT PIC X(132). + + WORKING-STORAGE SECTION. + 01 WS-EOF-FLAG PIC X VALUE 'N'. + 88 END-OF-FILE VALUE 'Y'. + 01 WS-RECORD-COUNT PIC 9(5) VALUE 0. + 01 WS-COUNT PIC 9(5) VALUE 0. + 01 WS-INPUT PIC X(10). + 01 WS-OUTPUT PIC X(10). + + PROCEDURE DIVISION. + 1000-MAINLINE. + PERFORM 2000-OPEN-FILES + PERFORM 3000-PROCESS-FILES + PERFORM 9000-CLOSE-FILES + STOP RUN. + + ****************************************************************** + * File Operations Section + ****************************************************************** + 2000-OPEN-FILES. + OPEN INPUT CUSTOMER-FILE + OPEN I-O TRANSACTION-FILE + OPEN OUTPUT REPORT-FILE. + + 3000-PROCESS-FILES. + PERFORM 3100-READ-CUSTOMER + PERFORM 3200-UPDATE-TRANSACTIONS + PERFORM 3300-DELETE-OLD-RECORDS + PERFORM 3400-START-AT-KEY + PERFORM 3500-WRITE-REPORTS + PERFORM 3600-DATA-REFERENCES. + + 3100-READ-CUSTOMER. + READ CUSTOMER-FILE + AT END MOVE 'Y' TO WS-EOF-FLAG + END-READ. + + 3200-UPDATE-TRANSACTIONS. + REWRITE TRANSACTION-RECORD + INVALID KEY DISPLAY "REWRITE FAILED" + END-REWRITE. + + 3300-DELETE-OLD-RECORDS. + DELETE TRANSACTION-FILE + INVALID KEY DISPLAY "DELETE FAILED" + END-DELETE. + + 3400-START-AT-KEY. + START TRANSACTION-FILE + KEY IS GREATER THAN TRNX-ID + INVALID KEY DISPLAY "START FAILED" + END-START. + + 3500-WRITE-REPORTS. + WRITE REPORT-RECORD FROM SPACES + INVALID KEY DISPLAY "WRITE FAILED" + END-WRITE + ADD 1 TO WS-RECORD-COUNT. + + 3600-DATA-REFERENCES. + COMPUTE WS-RECORD-COUNT = WS-RECORD-COUNT + 1. + SET END-OF-FILE TO TRUE. + ADD WS-COUNT TO WS-RECORD-COUNT-ADD. + SUBTRACT 1 FROM WS-RECORD-COUNT-SUB. + MULTIPLY WS-RECORD-COUNT-MUL BY 2. + DIVIDE WS-RECORD-COUNT-DIV BY 2. + CALL 'SUBPROGRAM' USING WS-INPUT WS-OUTPUT. + + 9000-CLOSE-FILES. + CLOSE CUSTOMER-FILE + CLOSE TRANSACTION-FILE + CLOSE REPORT-FILE. diff --git a/src/test/resources/samples/cobol/procedure-prologue.cbl b/src/test/resources/samples/cobol/procedure-prologue.cbl new file mode 100644 index 0000000..4e9c301 --- /dev/null +++ b/src/test/resources/samples/cobol/procedure-prologue.cbl @@ -0,0 +1,13 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. PROLOGUE-DEMO. + + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 WS-NAME PIC X(8). + + PROCEDURE DIVISION. + CALL 'SUBPROG' USING WS-NAME. + MOVE 'ABC' TO WS-NAME. + + MAIN-PARA. + GOBACK. diff --git a/src/test/resources/samples/cobol/sections.cbl b/src/test/resources/samples/cobol/sections.cbl new file mode 100644 index 0000000..b143052 --- /dev/null +++ b/src/test/resources/samples/cobol/sections.cbl @@ -0,0 +1,62 @@ + IDENTIFICATION DIVISION. + PROGRAM-ID. LINKAGE-TEST. + + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 WS-INPUT PIC X(10). + 01 WS-PROGRAM-NAME PIC X(8). + 01 WS-COUNT PIC 9(5). + 01 WS-IMS-STATUS PIC S9(4) COMP. + COPY CUSTCOPY. + COPY ACCTLAY REPLACING ==:TAG:== BY ==WS-==. + + LINKAGE SECTION. + 01 LS-PARAMETERS. + 05 LS-INPUT-REC PIC X(10). + 05 LS-OUTPUT-REC PIC X(10). + + LOCAL-STORAGE SECTION. + 01 LS-COUNTER PIC 99. + + FILE SECTION. + FD INPUT-FILE. + 01 INPUT-RECORD PIC X(80). + + PROCEDURE DIVISION USING LS-PARAMETERS. + MAIN-LOGIC. + PERFORM INITIALIZATION + PERFORM PROCESS-DATA + PERFORM CLEANUP + GOBACK. + + INITIALIZATION. + MOVE SPACES TO WS-INPUT + MOVE "LINKAGE-TEST" TO WS-PROGRAM-NAME + MOVE 0 TO WS-COUNT. + + PROCESS-DATA. + ADD 1 TO WS-COUNT + MOVE LS-INPUT-REC TO WS-INPUT + DISPLAY "Processed: " WS-INPUT " Count: " WS-COUNT. + + CLEANUP. + DISPLAY "Program completed. Total processed: " WS-COUNT. + CALL 'SUBPROG' USING WS-INPUT LS-PARAMETERS. + CALL WS-PROGRAM-NAME USING WS-INPUT. + READ INPUT-FILE. + WRITE INPUT-RECORD. + MOVE WS-INPUT TO LS-PARAMETERS. + MOVE WS-IMS-STATUS TO WS-COUNT. + EXEC SQL + SELECT COUNT(*) INTO WS-COUNT + END-EXEC. + EXEC CICS + RECEIVE INTO WS-INPUT + END-EXEC. + EXEC SQLIMS + GET DIAGNOSTICS + END-EXEC. + CONTINUE. + STOP RUN. + EXIT PROGRAM. + RETURN INPUT-FILE.