diff --git a/.github/workflows/deploy_snapshot.yml b/.github/workflows/deploy_snapshot.yml index 7f04315b..9083cb7b 100644 --- a/.github/workflows/deploy_snapshot.yml +++ b/.github/workflows/deploy_snapshot.yml @@ -15,7 +15,7 @@ on: types: [ trigger_after_upstream_deploy ] env: - GRADLE_VERSION: 8.5 # Gradle version used + GRADLE_VERSION: 8.14.5 # Gradle version used JAVA_VERSION: 21 # Java version used GRADLE_CLI_OPTS: "-Pci --build-cache --refresh-dependencies" # CLI options passed to Gradle GRADLE_BUILD_ACTION_CACHE_KEY_JOB: "test-cache-${{ github.head_ref }}.${{ github.sha }}" diff --git a/.github/workflows/test_branch.yml b/.github/workflows/test_branch.yml index aeb5d8a9..5c846bd0 100644 --- a/.github/workflows/test_branch.yml +++ b/.github/workflows/test_branch.yml @@ -12,7 +12,7 @@ on: branches-ignore: [ "dev" ] # Do not run this on the default branch env: - GRADLE_VERSION: 8.5 # Gradle version used + GRADLE_VERSION: 8.14.5 # Gradle version used JAVA_VERSION: 21 # Java version used GRADLE_CLI_OPTS: "-Pci --build-cache --refresh-dependencies" # CLI options passed to Gradle GRADLE_BUILD_ACTION_CACHE_KEY_JOB: "test-cache-${{ github.head_ref }}.${{ github.sha }}" diff --git a/.gitignore b/.gitignore index 500d5bb5..2c6baa4b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ target/ **/.idea **/target .attach_pid* -gradle.properties **/.gradle gradle/ gradlew diff --git a/README.md b/README.md index 8ea25223..0a993d26 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,65 @@ -This documentation is intended for **modelers** who use the object diagram (OD) languages. A -detailed documentation for **language engineers** using or extending the OD language is -located **[here](src/main/grammars/de/monticore/OD4Report.md)**. We recommend that **language -engineers** read this documentation before reading the detailed documentation. - -# An Example Model - -The graphical syntax of an example OD -
Figure 1: The graphical syntax of an example OD. - -  - -Figure 1 depicts the OD ```MyFamily``` in graphical syntax. In textual syntax, the OD is defined as -follows: - -``` +This documentation is primarily intended for **modelers** who work with object diagrams +and want to use the **OD4Development** tool effectively. The goal is to help you become +productive quickly, perform common modeling tasks confidently, and generate direct value +from ODs (for example, deriving a class diagram). + +For **language engineers** (language development, grammar work, tool extensions), detailed +technical documentation is available at +[`src/main/grammars/de/monticore/OD4Development.md`](src/main/grammars/de/monticore/OD4Development.md). + +# Table of Contents + +- [What is OD4Development?](#what-is-od4development) +- [Example Model](#example-model) +- [OD Language Primer](#od-language-primer) + - [Object Diagrams](#object-diagrams) + - [Comments](#comments) + - [Packages and Imports](#packages-and-imports) + - [Objects](#objects) + - [Attributes and Values](#attributes-and-values) + - [Links](#links) + - [When CD References Are Required](#when-cd-references-are-required) +- [Setup and Build](#setup-and-build) + - [Prerequisites](#prerequisites) + - [Getting the Tools](#getting-the-tools) +- [Focus: OD4Development](#focus-od4development) + - [Quick Start](#quick-start) + - [CLI Reference: OD4Development](#cli-reference-od4development) + - [Typical Workflows](#typical-workflows) + - [1) Run CoCos](#1-run-cocos) + - [2) Pretty Printing](#2-pretty-printing) + - [3) Export Symbol Table](#3-export-symbol-table) + - [4) Resolve Symbols](#4-resolve-symbols-via--path) + - [5) Derive a Class Diagram from an OD](#5-derive-a-class-diagram-from-an-od--o) +- [Further Information](#further-information) + +# What is OD4Development? + +OD4Development provides a complete toolchain for working with object diagrams: + +- **Model validation**: Constraint-on-Context (CoCo) checks verify model consistency and correctness + beyond syntax—catching logical issues before downstream processing. +- **Model normalization**: Pretty printing reformats ODs into a canonical style, useful for version + control and team collaboration. +- **Symbol management**: Export and import symbol tables to share type information across models + and enable cross-model references. +- **Artifact derivation**: Generate class diagrams from ODs, creating a structured view of the + instances and relationships described in your model. +- **Transparent feedback**: All operations report their results clearly via the command line, + making it easy to diagnose issues and verify success. + +# Example Model + +
+ The graphical syntax of the example OD +
Figure 1: The graphical syntax of the example OD.
+
+ +Figure 1 shows the OD `MyFamily`. In textual form: + +```txt objectdiagram MyFamily { alice:Person { age = 29; @@ -39,330 +83,346 @@ objectdiagram MyFamily { } ``` -This was for us the most intuitive textual representation of ODs, which follows the syntax of class -diagrams. - -# Command Line Tool +This notation is intentionally aligned with the readability of class diagram syntax. -This section describes the command line tool of the OD language. The tool provides typical functionality -used when processing models. To this effect, it provides funcionality for +# OD Language Primer -* parsing, -* coco-checking, -* pretty-printing, -* creating symbol tables, -* storing symbols in symbol files, -* ,and loading symbols from symbol files. +This section gives a compact introduction to the OD language using the examples from this repository. -The requirements for building and using the OD tool are that Java 21, Git, and Gradle 8.5 are -installed and available for use in Bash. +## Object Diagrams -The following subsection describes how to download the tool. Then, this document describes how -to build the tool from the source files. Afterward, this document contains a tutorial for using -the tool. +OD models are stored in `.od` files. Each file starts with `objectdiagram { ... }` and +contains object instances and links between them. -## Tool Set Up - -This section explains how to set up the command line interface tools for the OD languages. Each tool -is contained in a separate jar file, which is produced as result of building the project with -gradle. The following explains this. +```txt +objectdiagram Example { + // objects and links +} +``` -### Tool Download +## Comments -* [**Download OD Language OD4Data**][od4data-link] -* [**Download OD Language OD4Report**][od4report-link] +The textual syntax supports Java-style comments. -Alternatively, the tools can be built from source code. +```txt +/** Multi-line comment */ +objectdiagram Example { + // Single-line comment +} +``` -### Prerequisites +## Packages and Imports -To build the project, it is required to install a Java 21 JDK and git. +You can organize models with `package` declarations and import symbols from other models. +Imports are especially useful when your OD references external types. -#### Step 1: Clone Project with git +```txt +package my.examples; +import Types.*; - git clone - cd od +objectdiagram Example { + ... +} +``` -#### Step 2: Build Project with gradle +## Objects - gradle build --refresh-dependencies +Objects are declared as `: { ... };`, for example `alice:Person { ... };`. +The `MyFamily` example also shows anonymous typed objects like `:BMW { ... }`. -Afterward, the jars of the tools are available in `od/target/libs`. +```txt +objectdiagram Example { + alice:Person { + age = 29; + }; -## Tutorial: Getting Started Using the OD Tool + :BMW { + color = BLUE; + }; +} +``` -The previous sections describe how to obtain an executable JAR file -(OD command line tool). This section provides a tutorial for using the OD tool. The following examples -assume that you locally named the tool `MCOD4Report`. Note that after setting up the tool in the -previous step, you will also find a `MCOD4Data`. The following instruction also hold for this tool. +## Attributes and Values -### Step 1: Laying the basis +Attributes are assigned inside object blocks using `name = value;`. Values can be literals, +lists, enum constants, and other expression forms supported by the language. -Executing the Jar file without any options prints usage information of the tool to the console: +```txt +objectdiagram Example { + tiger:Jaguar { + color = RED; + length = 5.3; + }; -``` -java -jar MCOD4Report.jar -usage: OD4ReportTool - -c,--coco Checks the CoCos for the input ODs. Possible - arguments are 'intra' and 'all'. When - given the argument 'intra', only the intra-model - CoCos are checked while when using 'all' all CoCos are - checked. When no argument is specified, all CoCos - are checked by default. - -h,--help Prints this help dialog. - -i,--input Processes the OD input artifacts specified as - arguments. At least one input OD is mandatory. - -path Sets the artifact path for imported symbols, space - separated. - -pp,--prettyprint Prints the input ODs to stdout or to the specified - files (optional). - -s,--symboltable Stores the serialized symbol tables of the input ODs - in the specified files. The n-th input OD is stored - in the file as specified by the n-th argument. If no - arguments are given, the serialized symbol tables - are stored in - 'target/symbols/{packageName}/{artifactName}.odsym' - by default. + bob:Person { + nicknames = ["Bob", "Bobby", "Robert"]; + }; +} ``` -To work properly, the tool needs the mandatory argument `-i,--input `, which takes the file -paths of at least one input file containing OD models. If no other arguments are specified, the -tool solely parses the model(s). +## Links -For trying this out, copy the `MCOD4Report.jar` into a directory of your choice. Afterward, create -a text file containing the following simple OD: +Links represent relationships between object instances. In this example, you can see both +top-level link statements and role-based references. -``` +```txt objectdiagram Example { - bob:Person { - age = 42; - }; - - alice:Person { - age =40; - }; - - link married bob <-> alice; + bob:Person { + cars -> tiger; + }; + tiger:Jaguar { }; + + link married bob <-> alice; } ``` -Save the text file as `Example.od` in the directory where `MCOD4Report.jar` is located. +## When CD References Are Required -Now execute the following command: +Referencing a class diagram (via imported symbol files) is **not always mandatory**. -``` -java -jar MCOD4Report.jar -i Example.od -c intra -``` +- You can use core tool functions like parsing and pretty printing without importing CD symbols. +- Intra-model CoCos can also be run without full external type resolution. +- CD symbol references become important when you want to resolve external types reliably, + for example in inter-model or full CoCo checks. -You may notice that the tool prints no output to the console. This means that the tool has -parsed the file `Example.od` successfully. Don't mind die option `c` at this point as it -will be discussed later in step 3. +In practice: start without imports for syntax and formatting tasks, and add `-path` plus `import` +statements once your workflow requires cross-model type resolution. -### Step 2: Pretty-Printing +# Setup and Build -The tool provides a pretty-printer for the OD language. A pretty-printer can be used, e.g., to -fix the formatting of files containing ODs. To execute the pretty-printer, the `-pp,--prettyprint` -option can be used. Using the option without any arguments pretty-prints the models contained in the -input files to the console. +## Prerequisites -Execute the following command for trying this out: +- Java 21 JDK +- Git +- Gradle 8.5+ -``` -java -jar MCOD4Report.jar -i Example.od -pp -c intra -``` +> Note: This project has **no Gradle wrapper**. Use your locally installed +> `gradle` command directly. + +## Getting the Tools + +You have two options: + +### Option A: Download Pre-built JARs (Recommended for Quick Start) + +Pre-built JARs are available for download: -The command prints the pretty-printed model contained in the input file to the console: +- [**OD4Development.jar**][od4dev-link] +- [**OD4Report.jar**][od4report-link] +Download the JAR you need and place it in your working directory. You can start using the tool immediately +without any compilation step. + +### Option B: Build from Source + +Clone the repository and build locally: + +```bash +git clone git@github.com:MontiCore/object-diagram.git +cd object-diagram +gradle build --refresh-dependencies ``` + +Afterwards, the JARs are available in `target/libs`, including: + +- `MCOD4Development.jar` +- `MCOD4Report.jar` + +# Focus: OD4Development + +## Quick Start + +Create an `Example.od` file: + +```txt objectdiagram Example { - bob:Person { - age = 42; - }; - - alice:Person { - age =40; - }; - - link married bob <-> alice; + bob:Person { + age = 42; + }; + + alice:Person { + age = 40; + }; + + link married bob <-> alice; } ``` -It is possible to pretty-print the models contained in the input files to output files. For this -task, it is possible to provide the names of output files as arguments to the `-pp,--prettyprint` -option. If arguments for output files are provided, then the number of output files must be equal to -the number of input files. The i-th input file is pretty-printed into the i-th output file. +This simple example defines two persons (Bob and Alice) with their respective +ages, and establishes a "married" link between them. It's a minimal but complete +object diagram and therefore a good introductory example to demonstrate the +basic syntax and testing the tool. -Execute the following command for trying this out: +Minimal command (parse only): -``` -java -jar MCOD4Report.jar -i Example.od -pp PPExample.od -c intra +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od ``` -The command prints the pretty-printed model contained in the input file into the file `PPExample.od` +Typical successful output: -### Step 3: Checking Context Conditions +```txt +Successfully parsed Example +``` -For checking context conditions, the `-c,--coco ` option can be used. Using this option without -any arguments checks whether the model satisfies all context conditions. +This confirms the OD has been read and parsed without errors. -If you are only interested in checking whether a model only satisfies a subset of the context -conditions or want to explicate that all context conditions should be checked, you can do this by -additionally providing one of the three arguments `intra` and `all`. +## CLI Reference: OD4Development -* Using the argument `intra` only executes context conditions concerning violations of intra-model - context conditions. These context conditions, for example, check naming conventions. -* Using the argument `all` executes all context conditions. These context conditions include - checking whether used types exist. The behavior when using the argument `all` is also the default - behavior when using no arguments. +| Option | Meaning | +| --- | --- | +| `-h`, `--help` | Show help | +| `-i`, `--input ` | **Required**: input OD | +| `-path ` | Model/symbol path (multiple entries supported) | +| `-pp`, `--prettyprint [file]` | Pretty print to stdout or file | +| `-s`, `--symboltable [file]` | Store symbol table (`.odsym`) | +| `-c`, `--coco [intra\|inter]` | Run CoCos (`no arg` = all CoCos) | +| `-o`, `--output ` | Derive class diagram from OD | +| `-d` | Enable debug logging | -Execute the following command for trying out a simple example: +## Typical Workflows -``` -java -jar MCOD4Report.jar -i Example.od -c intra -``` +### 1) Run CoCos -You may notice that the tool prints nothing to the console when executing this command. This means -that the model satisfies all context conditions. +**Why?** CoCos validate your model for consistency, type correctness, and naming +conventions to catch issues before they propagate downstream. -Let us now consider a more complex scenario. Note that these commands do not work with the -`MCOD4Data` Tool, since the `MyFamily.od` dates as attribute values. -You can check the different kinds of context -conditions, using the `-c,--coco ` option: +Use the following command to run intra-model CoCos only: -``` -java -jar MCOD4Report.jar -i MyFamily.od -c intra +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -c intra ``` -``` -java -jar MCOD4Report.jar -i MyFamily.od -c all +Use the following command to run inter-model CoCos only: + +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -c inter ``` +Use the following command to run all CoCos (intra + inter): + +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -c ``` -java -jar MCOD4Report.jar -i MyFamily.od -c + +If no issues are found, the tool reports: + +```txt +Successfully checked the CoCos for object diagram Example ``` -While the first call of the tool does not produce any errors, the others do. The error states -something about types, in this case `Person` not being defined while being used. So how do we solve -this problem? +### 2) Pretty Printing -The answer is that the symbol file of this model has to be imported by the OD model for accessing -the type. For the OD language, we have not fixed a language for defining types. Instead, the types -can be defined in arbitrary models of arbitrary languages, as long as the information about the -definitions of the types are stored in the symbol files of the models and the OD imports these -symbol files. This may sound complicated at this point, but conceptually it is actually quite -simple. This has even a huge advantage because it allows us to use the OD language with any other -language that defines types. You could even use languages that are not defined with MontiCore, as -long as suitable symbol files are generated from the models of these languages. +**Why?** Keep your ODs readable and consistent, especially in team environments. +Pretty printing normalizes whitespace, indentation, and layout without changing +the model's meaning. -The following subsection describes how to fix the error in the example model `Example.od` -by importing a symbol file defining the (yet undefined) types. . +Use the following command to pretty print to stdout: -### Step 4: Using the Model Path to Resolve Symbols +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -pp +``` -In this section we make use of the model path and provide the tool with a symbol file (stored -symbol table) of another model, which contains the necessary type information. +Use the following command to pretty print to a file: -Create a new directory `cd` in the directory where the tool `MCOD4Report.jar` is located. The -symbol file `MyFamily.cdsym` of a model, which provides all necessary type information, can be -found [here](doc/MyFamily.cdsym). Download the file, name it `MyFamily.cdsym`, and move it into the -directory `cd`. +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -pp Example.pp.od +``` -The contents of the symbol file are of minor importance for you as a language user. In case you are -curious and had a look into the symbol file: -The symbol file contains a JSON representation of the symbols defined in a model. In this case, the -symbol file contains information about all sorts of symbols defined in a class diagram. Usually, -the tools of MontiCore languages automatically generate the contents of these files and you, as -a language user, must not be concerned with their contents. +### 3) Export Symbol Table -The path containing the directory structure that contains the symbol file is called the "Model Path" -. If we provide the model path to the tool, it will search for symbols in symbol files, which are -stored in directories contained in the model path. So, if we want the tool to find our symbol file, -we have to provide the model path to the tool via the `-path ` option: +Use the following command to export a symbol table with the default name (next to the model, e.g. `Example.odsym`): -``` -java -jar MCOD4Report.jar -i Example.od -c -path +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -s ``` -where `` is the path where you stored the downloaded symbol file. In our example, in case -you stored the model in the directory `cd`, execute the following command: +Use the following command to export the symbol table to an explicit target path: -``` -java -jar MCOD4Report.jar -i Example.od -c -path cd +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -s syms/Example.odsym ``` -Well, executing the above command still produces the same error message. This is because the symbol -file needs to be imported first, just like in Java. Therefore, we add the following import statement -to the beginning of the contents contained in the file `MyFamily.od` containing the OD `MyFamily`: +On success, the tool reports: +```txt +Creation of symbol file successful ``` -import cd.MyFamily.*; + +### 4) Resolve Symbols via `-path` + +Object diagrams describe *instances* of types that must be defined elsewhere—typically in a class diagram. +For example, the `MyFamily` OD uses types like `Person`, `BMW`, and `Jaguar`. These types are +defined in a separate class diagram model, whose symbol information is stored in a symbol file +(`.cdsym`). + +To validate that your OD uses only types that actually exist, you must: + +1. Make the symbol file(s) discoverable by setting a model path with `-path`. +2. Import the symbol files in your OD using `import` statements. +3. Run CoCo validation to check type references. + +**Example workflow:** + +Suppose you have a class diagram that defines `Person`, `BMW`, and `Jaguar` in a file called `Types.cd`. +After processing that CD, you get a symbol file `Types.cdsym`. Now add to your OD: + +```txt +import Types.*; objectdiagram Example { ... } ``` -The added import statement means that the file containing the OD imports all symbols that are stored -in the symbol file `MyFamily`. Note that you may have to change the name here, depending on how you -named the symbol file from above. The concrete file ending `.cdsym` is not important in this case. -However, the file ending of the symbol file must end with `sym`, i.e., the name of the symbol file -must be compatible to the pattern `*.*sym`. If you strictly followed the instructions of this -tutorial, then you are fine. - -If we now execute the command again, the tool will print no output. This means that it processed -the model successfully without any context condition violations. Great! - -### Step 5: Storing Symbols - -The previous section describes how to load symbols from an existing symbol file. Now, we will use -the tool to store a symbol file for our `Example.od` model. The stored symbol file will contain -information about the objects defined in the OD. It can be imported by other models for using the -symbols introduced by these object definitions, similar to how we changed the file `Example.od` for -importing the symbols contained in the symbol file `MyFamily.cdsym`. - -Using the `-s,-symboltable ` option builds the symbol tables of the input models and stores -them in the file paths given as arguments. Either no file paths must be provided or exactly one file -path has to be provided for each input model. The symbol file for the i-th input model is stored in -the file defined by the i-th file path. If you do not provide any file paths, the tool stores -the symbol table of each input model in the symbol -file `target/symbols/{packageName}/{fileName}.odsym` -where `packageName` is the name of the package as specified in the file containing the model -and `fileName` is the name of the file containing the model. The file is stored relative to the -working directory, i.e., the directory in which you execute the command for storing the symbol -files. Furthermore, please notice that in order to store the symbols properly, the model has to be -well-formed in all regards, and therefore all context conditions are checked beforehand. - -For storing the symbol file of `Example.od`, execute the following command -(the implicit context condition checks require using the model path option): +Then run validation: -``` -java -jar MCOD4Report.jar -i Example.od -path cd -s +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -path cd -c ``` -The tool produces the file `target/symbols/MyFamily.odsym`, which can now be imported by other -models, e.g., by models that need to use some of the objects defined in the OD `MyFamily`. +Here, `cd` is the directory containing `Types.cdsym`. The tool will load the symbol file, resolve +the type references in your OD, and report any mismatches. -For storing the symbol file of `Example.od` in the file `syms/Example.odsym`, for example, execute -the following command -(again, the implicit context condition checks require using the model path option): +**Troubleshooting symbol resolution:** -``` -java -jar MCOD4Report.jar -i Example.od -path cd -s syms/Example.odsym +If types cannot be resolved, check: + +- whether matching `*sym` files exist on the model path (file extensions must end with `sym`), +- whether your OD `import` statements match the symbol file location and names, +- whether `-path` points to the correct root directory containing the symbol files. + +### 5) Derive a Class Diagram from an OD (`-o`) + +**Why?** An OD shows a concrete snapshot of object instances and their relationships at a specific point in time. +By analyzing these instances, you can reverse-engineer a class diagram that captures the underlying +structure—the types, attributes, and associations that make up the model. This is useful when: + +- You have detailed instance data but need a class-level abstraction, +- You want to document the structural design implied by your instances, +- You need a CD as input for downstream code generation or further modeling, +- You want to validate that your instances follow a coherent type structure. + +**Usage:** + +```bash +java -jar target/libs/MCOD4Development.jar -i Example.od -o out ``` -Congratulations, you have just finished the tutorial about saving OD symbol files and are pretty -much done reading this README! +This analyzes the OD and generates a class diagram, written to the `out` directory. +The resulting CD will contain classes for all object types referenced in the OD, their attributes, +and the associations between them—essentially a schema that your instance data conforms to. -## Further Information +# Further Information -* [Project root: MontiCore @github](https://github.com/MontiCore/monticore) -* [MontiCore documentation](http://www.monticore.de/) -* [**List of languages**](https://github.com/MontiCore/monticore/blob/opendev/docs/Languages.md) -* [**MontiCore Core Grammar Library**](https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/Grammars.md) -* [Best Practices](https://github.com/MontiCore/monticore/blob/opendev/docs/BestPractices.md) -* [Publications about MBSE and MontiCore](https://www.se-rwth.de/publications/) -* [Licence definition](https://github.com/MontiCore/monticore/blob/master/00.org/Licenses/LICENSE-MONTICORE-3-LEVEL.md) +- [Project root: MontiCore @github](https://github.com/MontiCore/monticore) +- [MontiCore documentation](http://www.monticore.de/) +- [List of languages](https://github.com/MontiCore/monticore/blob/dev/docs/Languages.md) +- [MontiCore Core Grammar Library](https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/Grammars.md) +- [Best Practices](https://github.com/MontiCore/monticore/blob/dev/docs/BestPractices.md) +- [Publications about MBSE and MontiCore](https://www.se-rwth.de/publications/) +- [Licence definition](https://github.com/MontiCore/monticore/blob/master/00.org/Licenses/LICENSE-MONTICORE-3-LEVEL.md) [od4report-link]: http://www.monticore.de/download/MCOD4Report.jar -[od4data-link]: http://www.monticore.de/download/MCOD4Data.jar +[od4dev-link]: http://www.monticore.de/download/MCOD4Development.jar diff --git a/build.gradle b/build.gradle index 73840e7e..e1e29968 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ java { dependencies { grammar("de.monticore:monticore-grammar:$mc_version") implementation "org.antlr:antlr4-runtime:4.12.0" - implementation 'net.sourceforge.plantuml:plantuml:1.2023.12' + implementation "net.sourceforge.plantuml:plantuml:$plantuml_version" implementation "de.se_rwth.commons:se-commons-logging:$mc_version" implementation "de.monticore:monticore-runtime:$mc_version" implementation "de.monticore.lang:cd4analysis:$mc_version" @@ -79,21 +79,9 @@ test { showStackTraces = true showStandardStreams = true } - - // listen to standard out and standard error of the test JVM(s) - addTestOutputListener(new TestOutputListener() { - @Override - void onOutput(TestDescriptor testDescriptor, TestOutputEvent outputEvent) { - logger.lifecycle("Test: " + testDescriptor.getName() + " produced standard out/err: " + outputEvent.getMessage()) - } - }) finalizedBy jacocoTestReport } -shadowJar { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - // build sources jar in addition tasks.register('sourcesJar', Jar) { from(sourceSets.main.allJava) @@ -103,7 +91,10 @@ tasks.register('sourcesJar', Jar) { sourcesJar.dependsOn project.collect { it.tasks.withType(MCGenTask) } tasks.withType(ShadowJar).configureEach { + // EXCLUDE must not be used: together with minimize() it produces jars without any files duplicatesStrategy = DuplicatesStrategy.INCLUDE + // signature files of signed dependencies are invalid for the merged jar + exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.EC' } // build grammar jar as well @@ -113,18 +104,6 @@ tasks.register('grammarJar', Jar) { } jar.dependsOn(grammarJar) -tasks.register('buildOD4DataTool', ShadowJar) { - minimize() - archiveFileName = 'MCOD4Data.jar' - archiveClassifier = "od4data-mc-tool" - manifest { - attributes('Main-Class': 'de.monticore.od4data.OD4DataTool') - } - from sourceSets.main.output - configurations = [project.configurations.runtimeClasspath] -} -jar.dependsOn(buildOD4DataTool) - tasks.register('buildOD4ReportTool', ShadowJar) { minimize() archiveFileName = 'MCOD4Report.jar' @@ -150,7 +129,7 @@ tasks.register('buildOD4DevelopmentTool', ShadowJar) { jar.dependsOn(buildOD4DevelopmentTool) tasks.register('testReport', TestReport) { - destinationDirectory = file("${layout.buildDirectory}/reports/allTests") + destinationDirectory = layout.buildDirectory.dir("reports/allTests") // Include the results from the 'test' task getTestResults().from(tasks.withType(Test)) } @@ -164,7 +143,6 @@ publishing { from components.java artifact sourcesJar artifact buildOD4DevelopmentTool - artifact buildOD4DataTool artifact buildOD4ReportTool } } @@ -192,13 +170,16 @@ tasks.register('showArtifacts') { group = "MLC" } tasks.register('checkArtifacts') {group = "MLC" } configurations { MLC } dependencies { - MLC("de.monticore.lang:mlc-gradle:$version") + MLC("de.monticore.lang:mlc-gradle:$mlc_version") } -def modelPath = []; -configurations.compileClasspath.resolve().each { modelPath.addAll(["-mp", it.toString()]) } -configurations.grammarSymbolDependencies.resolve().each { modelPath.addAll(["-mp", it.toString()]) } -modelPath.addAll(["-mp", "$projectDir/target/symbols"]) +// the model path is resolved when an MLC task is executed, not for every build +def mlcModelPath = { -> + (configurations.compileClasspath.files + configurations.grammarSymbolDependencies.files + + layout.buildDirectory.dir("symbols").get().asFile) + .collectMany { ["-mp", it.toString()] } +} +def mlcReportsDir = layout.buildDirectory.dir("reports").get().asFile.path // two tasks per MLC file // each task needs to depend on all internally promoted MLCs @@ -210,8 +191,8 @@ fileTree("src").matching { include '**/*.mlc' }.each { classpath = configurations.MLC group = 'MLC' mainClass = 'de.monticore.mlc.MLCTool' - args = [ "-input", f, "-projectDir", projectDir, "-s", "-reports", "${layout.buildDirectory}/reports", "-a", "-noFQ"] - args += modelPath + args = [ "-input", f, "-projectDir", projectDir, "-s", "-reports", mlcReportsDir, "-a", "-noFQ"] + argumentProviders.add({ mlcModelPath() } as CommandLineArgumentProvider) dependsOn("generateMCGrammars") } showArtifacts.dependsOn("showArtifacts${mlcName}") @@ -220,8 +201,8 @@ fileTree("src").matching { include '**/*.mlc' }.each { classpath = configurations.MLC group = 'MLC' mainClass = 'de.monticore.mlc.MLCTool' - args = ["-input", f, "-projectDir", projectDir, "-s", "-check", "-reports", "${layout.buildDirectory}/reports"] - args += modelPath + args = ["-input", f, "-projectDir", projectDir, "-s", "-check", "-reports", mlcReportsDir] + argumentProviders.add({ mlcModelPath() } as CommandLineArgumentProvider) dependsOn("generateMCGrammars") } checkArtifacts.dependsOn("checkArtifacts${mlcName}") @@ -233,13 +214,11 @@ checkArtifactsODLink.dependsOn(checkArtifactsODBasis) checkArtifactsODAttribute.dependsOn(checkArtifactsODBasis) -checkArtifactsOD4Data.dependsOn(checkArtifactsODLink) -checkArtifactsOD4Data.dependsOn(checkArtifactsODAttribute) - -checkArtifactsOD4Development.dependsOn(checkArtifactsOD4Data) +checkArtifactsOD4Development.dependsOn(checkArtifactsODLink) +checkArtifactsOD4Development.dependsOn(checkArtifactsODAttribute) checkArtifactsOD4Report.dependsOn(checkArtifactsDateLiterals) -checkArtifactsOD4Report.dependsOn(checkArtifactsOD4Data) +checkArtifactsOD4Report.dependsOn(checkArtifactsOD4Development) // MLC Show dependencies // always depend on the shows of the mlc models which are allowed by an mlc @@ -247,10 +226,8 @@ showArtifactsODLink.dependsOn(showArtifactsODBasis) showArtifactsODAttribute.dependsOn(showArtifactsODBasis) -showArtifactsOD4Data.dependsOn(showArtifactsODLink) -showArtifactsOD4Data.dependsOn(showArtifactsODAttribute) - -showArtifactsOD4Development.dependsOn(showArtifactsOD4Data) +showArtifactsOD4Development.dependsOn(showArtifactsODLink) +showArtifactsOD4Development.dependsOn(showArtifactsODAttribute) showArtifactsOD4Report.dependsOn(showArtifactsDateLiterals) -showArtifactsOD4Report.dependsOn(showArtifactsOD4Data) +showArtifactsOD4Report.dependsOn(showArtifactsOD4Development) diff --git a/gradle.properties b/gradle.properties index d4cf7d29..5b91f60f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,7 @@ guava_version=33.5.0-jre commons_lang3_version=3.20.0 commons_cli_version=1.11.0 junit_version=6.0.3 +plantuml_version=1.2026.6 org.gradle.jvmargs=-Xmx4096m org.gradle.parallel=true diff --git a/src/main/grammars/de/monticore/OD4Data.mc4 b/src/main/grammars/de/monticore/OD4Data.mc4 deleted file mode 100644 index 76723158..00000000 --- a/src/main/grammars/de/monticore/OD4Data.mc4 +++ /dev/null @@ -1,43 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore; - -/* This is a MontiCore stable grammar. - * Adaptations -- if any -- are conservative. */ - -/** - OD4Data is used to store and transport object-oriented data sets. - - OD4Data is thefore similar to e.g. JSON and XML. - The main difference is that OD4Data allows links to - be explicitely defined and thus can build complex link structures, - i.e. arbitrary object graphs directly (and not only trees). - - For that purpose, objects can have an explicit name. - - OD4Data fits very well to the class diagrams in CD4Analysis. - - This grammar brings together the following OD components - * ODBasis.mc4 - for the core structure of ODs - * ODAttribute.mc4 - for the forms of attribute values - * ODLink.mc4 - defining the links between objects - - It includes MCCommonLiterals to allow a rich set of values - (e.g. to define attribute and enum values.) -*/ - -grammar OD4Data extends de.monticore.ODAttribute, - de.monticore.ODLink { - - start ODArtifact; - - splittoken "->", "<-", "<->", "--"; - - // Certain keywords of the used grammars shall not become - // restricted words in other context: - nokeyword "aggregation", "composition", "link", "objectdiagram"; - nokeyword "conformsTo"; - -} diff --git a/src/main/grammars/de/monticore/OD4Data.mlc b/src/main/grammars/de/monticore/OD4Data.mlc deleted file mode 100644 index 66527e31..00000000 --- a/src/main/grammars/de/monticore/OD4Data.mlc +++ /dev/null @@ -1,28 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore; - -mlc OD4Data { - - export "$projectDir/src/main/grammars" { - include "**/OD4Data.mc4"; - } - - export "$projectDir/src/main/java" { - include "de/monticore/od4data/**.java"; - } - - export "$projectDir/target/generated-sources/monticore/sourcecode" { - include "de/monticore/od4data/**.java"; - } - - promote { - // allow apache.commons.lang3 - include "$mp/org/apache/commons/lang3/**"; - } - - promote { // allow using other languages - mlc "de.monticore.ODLink"; - mlc "de.monticore.ODAttribute"; - } - -} diff --git a/src/main/grammars/de/monticore/OD4Development.mc4 b/src/main/grammars/de/monticore/OD4Development.mc4 index d4cc71de..cbc8172e 100644 --- a/src/main/grammars/de/monticore/OD4Development.mc4 +++ b/src/main/grammars/de/monticore/OD4Development.mc4 @@ -43,7 +43,8 @@ package de.monticore; */ -grammar OD4Development extends de.monticore.OD4Data { +grammar OD4Development extends de.monticore.ODAttribute, + de.monticore.ODLink { start ODArtifact; diff --git a/src/main/grammars/de/monticore/OD4Report.md b/src/main/grammars/de/monticore/OD4Development.md similarity index 69% rename from src/main/grammars/de/monticore/OD4Report.md rename to src/main/grammars/de/monticore/OD4Development.md index 3674a9f3..0974e312 100644 --- a/src/main/grammars/de/monticore/OD4Report.md +++ b/src/main/grammars/de/monticore/OD4Development.md @@ -12,7 +12,7 @@ constraint language OCL This MontiCore project contains -* seven language components, defined by their own grammars, +* six language components, defined by their own grammars, * appropriate context conditions for each language component, * which also includes a symbol table infrastructure for managing and storing symbol tables, and * pretty-printers. @@ -47,10 +47,10 @@ objectdiagram MyFamily { examples.A graphical version is shown in Figure 1. -The graphical syntax of an example OD -
Figure 1: The graphical syntax of example OD MyFamiliy.
- -  +
+ The graphical syntax of the example OD +
Figure 1: The graphical syntax of the example OD.
+
The conceptual elements of ODs are similar to JSOM or XML, but deliver (hopefully) a better readable syntax: @@ -59,6 +59,7 @@ syntax: like `tiger`. * Objects also have a *type*, e.g. `:Person`. * UML allows both to be optional, if not needed or reconstructable from context. + * However, OD4Development allows anonymous objects but always requires a type. * *Attributes* are defined with their value, e.g. `color = RED`. * *Link*s can be explicitly defined, allowing *arbitrary graph structures*, e.g. use of `tiger` or the `alice <-> bob` link. @@ -71,30 +72,24 @@ syntax: Below follow more detailed explanations about the project: -## Tools: `OD4ReportTool` and `ODDataTool` +## Tools: `ODDataTool` and `OD4ReportTool` -By default, the project creates two tools, stored in `MCOD4Report.jar` and `MCODData.jar`. +By default, the project creates two tools, stored in `MCOD4Development.jar` and `MCOD4Report.jar`. -Both classes, [```OD4ReportTool```](../../../java/de/monticore/od4report/OD4ReportTool.java) -and [```OD4DataTool```](../../../java/de/monticore/od4data/OD4DataTool.java) provide typical -functionality used when processing models from commandlin. To this effect, the classes +Both classes, [```OD4DevelopmentTool```](../../../java/de/monticore/od4development/OD4DevelopmentTool.java) +and [```OD4ReportTool```](../../../java/de/monticore/od4report/OD4ReportTool.java) provide typical +functionality used when processing models from commandline. To this effect, the classes provide methods for parsing, pretty-printing, creating symbol tables, storing symbols, and loading symbols. Detailed information about the methods can be found in the Javadoc documentation of each class. -[```OD4DataTool```](../../../java/de/monticore/od4data/OD4DataTool.java) provides typical -functionality used when processing models from commandline. To this effect, the class provides -methods for parsing, pretty-printing, creating symbol tables, storing symbols, and loading symbols. -Detailed information about the methods can be found in the Javadoc documentation of the -class [```OD4DataTool```](../../../java/de/monticore/od4data/OD4DataTool.java). - -Each tool can be found in the ```target``` folder once the project build was successful. Each tool +Each tool can be found in the ```target\libs``` folder once the project build was successful. Each tool provides a ``-h`` parameter providing further information on how to use it. Example calls: ``` - java -jar target/libs/MCOD4Data.jar -h + java -jar target/libs/MCOD4Development.jar -h java -jar target/libs/MCOD4Report.jar -h // pretty print an OD: @@ -102,19 +97,19 @@ Example calls: -pp // read an OD and store the symbols it defines and exports in a symboltable: - java -jar target/libs/MCOD4Data.jar -i src/test/resources/examples/od/Teaser.od \ + java -jar target/libs/MCOD4Development.jar -i src/test/resources/examples/od/Teaser.od \ -s Teaser.symod ``` ## Grammars (i.e. language components) -This MontiCore project contains seven grammars, which provide the possibility to describe object +This MontiCore project contains six grammars, which provide the possibility to describe object diagrams in various extensions: * [ODBasis](../../../grammars/de/monticore/ODBasis.mc4), * [ODAttribute](../../../grammars/de/monticore/ODAttribute.mc4), * [ODLink](../../../grammars/de/monticore/ODLink.mc4), -* [OD4Data](../../../grammars/de/monticore/OD4Data.mc4), +* [OD4Development](../../../grammars/de/monticore/OD4Development.mc4), * [OD4Report](../../../grammars/de/monticore/OD4Report.mc4), and * [DateLiterals](../../../grammars/de/monticore/DateLiterals.mc4). @@ -131,60 +126,47 @@ The grammar [ODBasis](../../../grammars/de/monticore/ODBasis.mc4) defines the sy The grammar [ODBasis](../../../grammars/de/monticore/ODBasis.mc4) extends the grammars -* [MCBasicTypes](https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/types/MCBasicTypes.mc4) +* [MCBasicTypes](https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/types/MCBasicTypes.mc4) that provides possible object types. -* [OOSymbols](https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/symbols/OOSymbols.mc4) +* [OOSymbols](https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/symbols/OOSymbols.mc4) for using symbols of kind `Diagram` and `Variable`. -* [CommonExpressions](https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/expressions/CommonExpressions.mc4) +* [CommonExpressions](https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/expressions/CommonExpressions.mc4) to be able to reuse simple forms of expressions (and the typechecking functionality). -* [UMLStereotype](https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/UMLStereotype.mc4) +* [UMLModifier](https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/UMLModifier.mc4) for adding UMLStereotypes as possible extension points to the grammar. ### ODAttribute -The grammar [ODAttribute](../../../grammars/de/monticore/ODAttribute.mc4) adds more complex types of -attributes, i.e. *lists* and *maps*, to UML/P ODs. - -The grammar [ODAttribute](../../../grammars/de/monticore/ODAttribute.mc4) defines the syntax for - -* lists of values, -* and maps of key-value pairs. +The grammar [ODAttribute](../../../grammars/de/monticore/ODAttribute.mc4) adds +more complex types of attributes, i.e. *lists* and *maps*, to UML/P ODs by +defining the syntax for *lists of values* and *maps of key-value pairs*. ### ODLink -The grammar [ODLink](../../../grammars/de/monticore/ODLink.mc4) adds links to UML/P ODs. There are -two main types of link representations, namely the explicit mentioning as `link` -that connects two objects and the nested link, that occurs when the nesting objects into a -hierarchy. +The grammar [ODLink](../../../grammars/de/monticore/ODLink.mc4) adds links to +UML/P ODs. There are two main types of link representations, namely the explicit +mentioning as `link` that connects two objects and the nested link, that occurs +when the nesting objects into a hierarchy. -Furthermore, links may be *directed* and can be *ordinary*, *aggregations* or *compositions*, but -also -*derived*. - -### OD4Data - -The grammar [OD4Data](../../../grammars/de/monticore/OD4Data.mc4) only combines the language -components `ODAttribute` -and `ODLink` to form a variant of OD language mainly used for representing data. For that purpose, -the language component also offers to use *dates* as expressions in certain structures of a model, -e.g. attribute values. +Furthermore, links may be *directed* and can be *ordinary*, *aggregations* or +*compositions*, but also *derived*. ### OD4Development -The [OD4Development](../../../grammars/de/monticore/OD4Development.mc4) grammar extends -the `OD4Data` language by adding an extended namespace for objects and attribute values. - -It focusses on the modelling phase in typical object-oriented development projects and is therefore -mainly used for data modelling. Consequently, it omits method signatures and complex generics. +The [OD4Development](../../../grammars/de/monticore/OD4Development.mc4) grammar +combines the language components `ODAttribute` and `ODLink`. It focuses on the +modeling phase in typical object-oriented development projects and is therefore +mainly used for data modeling. Consequently, it omits method signatures and +complex generics. `OD4Development` is the textual representation to describe UML object diagrams -(it uses the UML/P variant). `OD4Development` covers objects, attributes with values (and optional) -types, and all kinds of associations and composition, including qualified and ordered associations. -It allows to define +(it uses the UML/P variant). `OD4Development` covers objects, attributes with +values (and optional) types, and all kinds of associations and composition, +including qualified and ordered associations. It allows to define * (1) desired object structures, * (2) unwanted object structures, -* (3) initial object structures e.g. for a test setup or the specifictaion of a construction method. +* (3) initial object structures e.g. for a test setup or the specification of a construction method. It allows incomplete structures (omitting uninteresting links or attributes); values can be either given directly or as expressions using other values and thus also allows to describe * (4) desired test results (oracle), and has also been used for @@ -192,13 +174,13 @@ It allows to define `OD4Development` fits very well to the `CD4Analysis`language component. -It builds on MCTypes, but disallows e.g. List as type, because they can be represented via +It builds on MCTypes, but disallows e.g. List as type, because they can be represented via associations. ### OD4Report -The [OD4Report](../../../grammars/de/monticore/OD4Report.mc4) grammar extends the `OD4Data` language -by adding an extended namespace for objects and attribute values. Its main appliciation are +The [OD4Report](../../../grammars/de/monticore/OD4Report.mc4) grammar extends the `OD4Development` language +by adding an extended namespace for objects and attribute values. Its main application are reporting, e.g. in MontiCore's generated reports, or data formats which need make use of the extended namespace, e.g. artifact-based analyses. For that purpose, it mainly extends the possibility to define names by nonterminal `ODSpecialName`, which encodes a number of additional @@ -206,7 +188,7 @@ information into the object name. An example for such a special name is `@State( this state has occurred in line 2, column 3. Moreover, the set of supported types is extended. The grammar therefore extends: -* [MCCollectionTypes](https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/types/MCCollectionTypes.mc4) +* [MCCollectionTypes](https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/types/MCCollectionTypes.mc4) for the extension of supported types. ### DateLiterals @@ -218,7 +200,7 @@ dates and times. Dates consist of a date part modeling year, month, and day, as modeling hour, minute, and second. The above defined object diagrams, especially the `OD4Report` language component makes heavy use of -this possbility. +this possibility. ## Context Conditions @@ -226,7 +208,6 @@ This section lists the context conditions for the [ODBasis](../../../grammars/de/monticore/ODBasis.mc4) grammar, context conditions for the [ODAttribute](../../../grammars/de/monticore/ODAttribute.mc4) grammar, context conditions for the [ODLink](../../../grammars/de/monticore/ODLink.mc4) grammar, context conditions for -the [OD4Data](../../../grammars/de/monticore/OD4Data.mc4) grammar context conditions for the [OD4Development](../../../grammars/de/monticore/OD4Development.mc4) grammar. context conditions for the [OD4Report](../../../grammars/de/monticore/OD4Report.mc4) grammar. context conditions for the [DateLiterals](../../../grammars/de/monticore/DateLiterals.mc4) grammar. @@ -257,6 +238,10 @@ located [here](../../../java/de/monticore/odbasis/_cocos). * The context condition [```ValidObjectReferenceCoCo```](../../../java/de/monticore/odbasis/_cocos/object/ValidObjectReferenceCoCo.java) checks object references as an attribute value actually exist. + +* The context + condition [```ValidObjectTypeCoCo```](../../../java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoCo.java) + checks object types actually exist. ### ODAttribute Context Conditions @@ -281,10 +266,6 @@ located [here](../../../java/de/monticore/odlink/_cocos). condition [```ValidLinkReferenceCoCo```](../../../java/de/monticore/odlink/_cocos/link/ValidLinkReferenceCoCo.java) checks if the object referenced actually exist. -### OD4Data Context Conditions - -None. - ### OD4Development Context Conditions None. @@ -300,7 +281,7 @@ the [DateLiterals](../../../grammars/de/monticore/DateLiterals.mc4) grammar are located [here](../../../java/de/monticore/dateliterals/_cocos). * The context - condition [```DateConcistencyCoCo```](../../../java/de/monticore/dateliterals/_cocos/date/DateConcistencyCoCo.java) + condition [```DateConsistencyCoCo```](../../../java/de/monticore/dateliterals/_cocos/date/DateConsistencyCoCo.java) checks if a date is consistent in termns of day of year as well as time of day. ## Symbol Table @@ -318,10 +299,10 @@ and [```OOTypeSymbols```][OOSymbolsRef]. ### Symbol Table Data Structure -The data structure of the symbol table of the OD language -
Figure 2: The data structure of the symbol table of the OD language. - -  +
+ The data structure of the symbol table of the OD language +
Figure 2: The data structure of the symbol table of the OD language.
+
Figure 2 depicts the symbol table data structure of the [```OD4Report```](../../../grammars/de/monticore/OD4Report.mc4) language, when then built from @@ -336,40 +317,36 @@ OD. As usual the `OD4DReportArtifactScope` is not stored in the symboltable, but the top level symbols and potentially associated scopes are. -Symbol table instance of the OD depicted in Figure 1 -
Figure 3: Symbol table instance of the OD depicted in Figure 1. - -  +
+ Symbol table instance of the OD depicted in Figure 1 +
Figure 3: Symbol table instance of the OD depicted in Figure 1.
+
Figure 3 depicts the symbol table instance for the OD ```MyFamily```. The three explicitly named objects ```alice:Person```, ```bob:Person``` and ```tiger:Jaguar``` are stored as [```VariableSymbol```][BasicSymbolsRef] -instances and maintaiend i the ```OD4ReportArtifactScope```. The object ```:DiagramSymbol``` +instances and are maintained in the ```OD4ReportArtifactScope```. The object ```:DiagramSymbol``` containing the name of the object diagram is also linked to that scope. As usual, symbols can only be accessed, if they have an explicit name, which is why an anonymous object, such as `:BMW`, as well as any form of links do not occur in the symbol table. Please also note, that types, such as `BMW` or `Person` -are imported by the object diagram, but not internally defined. +are imported by the object diagram, but are not internally defined. -Handwritten extensions of the symbol table creator can be found as follows: +Handwritten extensions of the ScopesGenitor can be found as follows: -* The creator for the [```ODBasis```](../../../grammars/de/monticore/ODBasis.mc4) grammar can be +* The genitor for the [```ODBasis```](../../../grammars/de/monticore/ODBasis.mc4) grammar can be found in the - class [```ODBasisSymbolTableCreator```](../../../java/de/monticore/odbasis/_symboltable/ODBasisSymbolTableCreator.java) + class [```ODBasisScopesGenitor```](../../../java/de/monticore/odbasis/_symboltable/ODBasisScopesGenitor.java) . * The creator for the [```ODAttribute```](../../../grammars/de/monticore/ODAttribute.mc4) grammar can be found in the - class [```ODAttributeSymbolTableCreator```](../../../java/de/monticore/odattribute/_symboltable/ODAttributeSymbolTableCreator.java) - . -* The creator for the [```ODLink```](../../../grammars/de/monticore/ODLink.mc4) grammar can be found - in the - class [```ODLinkSymbolTableCreator```](../../../java/de/monticore/odlink/_symboltable/ODLinkSymbolTableCreator.java) + class [```ODAttributeScopesGenitor```](../../../java/de/monticore/odattribute/_symboltable/ODAttributeScopesGenitor.java) . * The creator for the [```OD4Report```](../../../grammars/de/monticore/OD4Report.mc4) grammar can be found in the - class [```OD4ReportSymbolTableCreator```](../../../java/de/monticore/od4report/_symboltable/OD4ReportSymbolTableCreator.java) + class [```OD4ReportScopesGenitor```](../../../java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitor.java) . ### Symbol kinds used by the OD Language (importable or subclassed) @@ -384,7 +361,7 @@ None. ### Symbols imported by OD models: -* ODs import [```VariableSymbols```][BasicSymbolsRef] as externally defined objects. The importet +* ODs import [```VariableSymbols```][BasicSymbolsRef] as externally defined objects. The imported objects can be used as attribute values and link targets. * ODs import [```TypeSymbols```][BasicSymbolsRef] that can be used as types for objects. @@ -394,7 +371,7 @@ None. with explicit names are visible from outside the object diagram. There is no hiding, not even for nested objects (this was a deliberate design decision; alternatives would have been possible.) With this mechanism, object diagrams can extend each other, defining a more complex object - structure in several artefacts. + structure in several artifacts. * Each OD exports exactly one [```DiagramSymbol```][BasicSymbolsRef] corresponding to the ODArtifact. @@ -444,31 +421,31 @@ table instance depicted in Figure 3: } ``` -[BasicSymbolsRef]:https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/symbols/BasicSymbols.mc4 +[BasicSymbolsRef]:https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/symbols/BasicSymbols.mc4 -[TypeSymbolsRef]:https://github.com/MontiCore/monticore/tree/opendev/monticore-grammar/src/main/grammars/de/monticore/types +[TypeSymbolsRef]:https://github.com/MontiCore/monticore/tree/dev/monticore-grammar/src/main/grammars/de/monticore/types -[MCBasicTypesRef]:https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/types/MCBasicTypes.mc4 +[MCBasicTypesRef]:https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/types/MCBasicTypes.mc4 -[OOSymbolsRef]:https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/symbols/OOSymbols.mc4 +[OOSymbolsRef]:https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/symbols/OOSymbols.mc4 -[ExpressionsBasisRef]:https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/expressions/ExpressionsBasis.mc4 +[ExpressionsBasisRef]:https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/expressions/ExpressionsBasis.mc4 -[UMLStereotypeRef]:https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/UMLStereotype.mc4 +[UMLStereotypeRef]:https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/UMLStereotype.mc4 -[MCCommonLiteralsRef]:https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/literals/MCCommonLiterals.mc4 +[MCCommonLiteralsRef]:https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/literals/MCCommonLiterals.mc4 -[CommonExpressionsRef]:https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/expressions/CommonExpressions.mc4 +[CommonExpressionsRef]:https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/expressions/CommonExpressions.mc4 -[OCLExpressionsRef]:https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/expressions/OCLExpressions.mc4 +[OCLExpressionsRef]:https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/expressions/OCLExpressions.mc4 ## Further Information * [Project root: MontiCore @github](https://github.com/MontiCore/monticore) * [MontiCore documentation](http://www.monticore.de/) -* [**List of languages**](https://github.com/MontiCore/monticore/blob/opendev/docs/Languages.md) +* [**List of languages**](https://github.com/MontiCore/monticore/blob/dev/docs/Languages.md) * [**MontiCore Core Grammar - Library**](https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/Grammars.md) -* [Best Practices](https://github.com/MontiCore/monticore/blob/opendev/docs/BestPractices.md) + Library**](https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/Grammars.md) +* [Best Practices](https://github.com/MontiCore/monticore/blob/dev/docs/BestPractices.md) * [Publications about MBSE and MontiCore](https://www.se-rwth.de/publications/) * [Licence definition](https://github.com/MontiCore/monticore/blob/master/00.org/Licenses/LICENSE-MONTICORE-3-LEVEL.md) diff --git a/src/main/grammars/de/monticore/OD4Development.mlc b/src/main/grammars/de/monticore/OD4Development.mlc index 31e27320..cdc19ae0 100644 --- a/src/main/grammars/de/monticore/OD4Development.mlc +++ b/src/main/grammars/de/monticore/OD4Development.mlc @@ -24,7 +24,8 @@ mlc OD4Development { } promote { // allow using other languages - mlc "de.monticore.OD4Data"; - } + mlc "de.monticore.ODLink"; + mlc "de.monticore.ODAttribute"; + } } diff --git a/src/main/grammars/de/monticore/OD4Report.mc4 b/src/main/grammars/de/monticore/OD4Report.mc4 index 5c6472ce..8a140bad 100644 --- a/src/main/grammars/de/monticore/OD4Report.mc4 +++ b/src/main/grammars/de/monticore/OD4Report.mc4 @@ -23,11 +23,11 @@ package de.monticore; for the forms of attribute values * ODLink.mc4 defining the links between objects - * OD4Data.mc4 + * OD4Development.mc4 = ODAttribute.mc4 + ODLink.mc4 */ -grammar OD4Report extends de.monticore.OD4Data, +grammar OD4Report extends de.monticore.OD4Development, de.monticore.DateLiterals, de.monticore.types.MCCollectionTypes { diff --git a/src/main/grammars/de/monticore/OD4Report.mlc b/src/main/grammars/de/monticore/OD4Report.mlc index d4fbe9c8..6a686d2a 100644 --- a/src/main/grammars/de/monticore/OD4Report.mlc +++ b/src/main/grammars/de/monticore/OD4Report.mlc @@ -27,7 +27,7 @@ mlc OD4Report { promote { // allow using other languages mlc "de.monticore.DateLiterals"; - mlc "de.monticore.OD4Data"; + mlc "de.monticore.OD4Development"; mlc "de.monticore.types.MCCollectionTypes"; } diff --git a/src/main/grammars/de/monticore/ODLink.mc4 b/src/main/grammars/de/monticore/ODLink.mc4 index 7615dff1..e406403d 100644 --- a/src/main/grammars/de/monticore/ODLink.mc4 +++ b/src/main/grammars/de/monticore/ODLink.mc4 @@ -47,8 +47,9 @@ component grammar ODLink extends de.monticore.ODBasis { ODBiDir implements ODLinkDirection = "<->"; ODUnspecifiedDir implements ODLinkDirection = "--"; - // this is needed to parse e.g. -3<-2 correctly: - splittoken "<-"; + // this is needed to parse e.g. -3<-2 correctly, and nested + // lists or array accesses like [[1], [2]] or a[b[1]] in values: + splittoken "<-", "[[", "]]"; // if needed, the following splitting of token can be heplful, // and can be added in any subgrammar: // splittoken "->", "<->", "--"; diff --git a/src/main/java/de/monticore/dateliterals/_ast/ASTDate.java b/src/main/java/de/monticore/dateliterals/_ast/ASTDate.java index 0953e932..55788e04 100644 --- a/src/main/java/de/monticore/dateliterals/_ast/ASTDate.java +++ b/src/main/java/de/monticore/dateliterals/_ast/ASTDate.java @@ -63,7 +63,7 @@ public void setDate(LocalDateTime localDateTime) { * @return year as int value */ public int getYear() { - return Integer.valueOf(getDatePart().getYear().getDigits()).intValue(); + return Integer.parseInt(getDatePart().getYear().getDigits()); } /** @@ -72,7 +72,7 @@ public int getYear() { * @return month as int value */ public int getMonth() { - return Integer.valueOf(getDatePart().getMonth().getDigits()).intValue(); + return Integer.parseInt(getDatePart().getMonth().getDigits()); } /** @@ -81,7 +81,7 @@ public int getMonth() { * @return day as int value */ public int getDay() { - return Integer.valueOf(getDatePart().getDay().getDigits()).intValue(); + return Integer.parseInt(getDatePart().getDay().getDigits()); } /** @@ -90,7 +90,7 @@ public int getDay() { * @return hours as int value */ public int getHour() { - return Integer.valueOf(getTimePart().getHour().getDigits()).intValue(); + return Integer.parseInt(getTimePart().getHour().getDigits()); } /** @@ -99,7 +99,7 @@ public int getHour() { * @return minutes as int value */ public int getMinute() { - return Integer.valueOf(getTimePart().getMinute().getDigits()).intValue(); + return Integer.parseInt(getTimePart().getMinute().getDigits()); } /** @@ -108,7 +108,7 @@ public int getMinute() { * @return seconds as int value */ public int getSecond() { - return Integer.valueOf(getTimePart().getSecond().getDigits()).intValue(); + return Integer.parseInt(getTimePart().getSecond().getDigits()); } } diff --git a/src/main/java/de/monticore/dateliterals/_cocos/DateLiteralsCoCos.java b/src/main/java/de/monticore/dateliterals/_cocos/DateLiteralsCoCos.java index 090e9e15..d7f5fc43 100644 --- a/src/main/java/de/monticore/dateliterals/_cocos/DateLiteralsCoCos.java +++ b/src/main/java/de/monticore/dateliterals/_cocos/DateLiteralsCoCos.java @@ -2,14 +2,14 @@ package de.monticore.dateliterals._cocos; -import de.monticore.dateliterals._cocos.date.DateConcistencyCoCo; +import de.monticore.dateliterals._cocos.date.DateConsistencyCoCo; public class DateLiteralsCoCos { public DateLiteralsCoCoChecker getCheckerForAllCoCos() { final DateLiteralsCoCoChecker dateLiteralsCoCoChecker = new DateLiteralsCoCoChecker(); - dateLiteralsCoCoChecker.addCoCo(new DateConcistencyCoCo()); + dateLiteralsCoCoChecker.addCoCo(new DateConsistencyCoCo()); return dateLiteralsCoCoChecker; } diff --git a/src/main/java/de/monticore/dateliterals/_cocos/date/DateConcistencyCoCo.java b/src/main/java/de/monticore/dateliterals/_cocos/date/DateConsistencyCoCo.java similarity index 76% rename from src/main/java/de/monticore/dateliterals/_cocos/date/DateConcistencyCoCo.java rename to src/main/java/de/monticore/dateliterals/_cocos/date/DateConsistencyCoCo.java index b83673f8..6fd0000e 100644 --- a/src/main/java/de/monticore/dateliterals/_cocos/date/DateConcistencyCoCo.java +++ b/src/main/java/de/monticore/dateliterals/_cocos/date/DateConsistencyCoCo.java @@ -1,7 +1,5 @@ // (c) https://github.com/MontiCore/monticore -// (c) https://github.com/MontiCore/monticore - package de.monticore.dateliterals._cocos.date; import de.monticore.dateliterals._ast.ASTDate; @@ -15,7 +13,9 @@ /** * Check if the ODDate is a consistent Date. Consistency is checked using {@link LocalDate}. */ -public class DateConcistencyCoCo implements DateLiteralsASTDateCoCo { +public class DateConsistencyCoCo implements DateLiteralsASTDateCoCo { + + public static final String ERROR_INCONSISTENT_DATE = "0x0D030: Invalid date: %s"; @Override public void check(ASTDate node) { @@ -26,7 +26,8 @@ public void check(ASTDate node) { node.getTimePart().getMinute().getValue(), node.getTimePart().getSecond().getValue()); } catch (DateTimeException e) { - Log.error("0x0D009: Violation of CoCo 'DateConcistencyCoCo'", node.get_SourcePositionStart()); + Log.error(String.format(ERROR_INCONSISTENT_DATE, e.getMessage()), + node.get_SourcePositionStart()); } } diff --git a/src/main/java/de/monticore/od2cd/CompositionPrinter.java b/src/main/java/de/monticore/od2cd/CompositionPrinter.java index 6e768911..971656bc 100644 --- a/src/main/java/de/monticore/od2cd/CompositionPrinter.java +++ b/src/main/java/de/monticore/od2cd/CompositionPrinter.java @@ -14,8 +14,8 @@ public String create(ASTMCType type) { IOD4DevelopmentGlobalScope gs = OD4DevelopmentMill.globalScope(); - if (gs.getSubScopes().size() >= 1) { - IOD4DevelopmentArtifactScope as = (IOD4DevelopmentArtifactScope) gs.getSubScopes().get(0); + if (!gs.getSubScopes().isEmpty()) { + IOD4DevelopmentArtifactScope as = (IOD4DevelopmentArtifactScope) gs.getSubScopes().getFirst(); if (as.getTypeSymbols().containsKey(type.printType()) || as.getOOTypeSymbols().containsKey(type.printType()) || @@ -37,7 +37,7 @@ public String read() { public String write(String type) { IOD4DevelopmentGlobalScope gs = OD4DevelopmentMill.globalScope(); - if (gs.getSubScopes().size() >= 1) { + if (!gs.getSubScopes().isEmpty()) { return ".build().get()"; } return ".build()"; @@ -46,8 +46,8 @@ public String write(String type) { public String update(String attribute, String value) { IOD4DevelopmentGlobalScope gs = OD4DevelopmentMill.globalScope(); - if (gs.getSubScopes().size() >= 1) { - String asName = gs.getSubScopes().get(0).getName(); + if (!gs.getSubScopes().isEmpty()) { + String asName = gs.getSubScopes().getFirst().getName(); String res = ""; String line = ""; @@ -67,7 +67,7 @@ public String update(String attribute, String value) { public String genType(ASTMCType type) { IOD4DevelopmentGlobalScope gs = OD4DevelopmentMill.globalScope(); String genType = OD4DevelopmentMill.prettyPrint(type, false); - if (gs.getSubScopes().size() >= 1) { + if (!gs.getSubScopes().isEmpty()) { return genType + "Builder"; } else { return genType; diff --git a/src/main/java/de/monticore/od2cd/OD2CDObjectVisitor.java b/src/main/java/de/monticore/od2cd/OD2CDObjectVisitor.java index bc2c6553..90ac1b98 100644 --- a/src/main/java/de/monticore/od2cd/OD2CDObjectVisitor.java +++ b/src/main/java/de/monticore/od2cd/OD2CDObjectVisitor.java @@ -8,7 +8,6 @@ import de.monticore.cdbasis._ast.ASTCDDefinition; import de.monticore.cdbasis._ast.ASTCDPackage; import de.monticore.generating.templateengine.GlobalExtensionManagement; -import de.monticore.od4data._prettyprint.OD4DataFullPrettyPrinter; import de.monticore.od4development.OD4DevelopmentMill; import de.monticore.od4development._symboltable.CDRoleAdapter; import de.monticore.od4development._symboltable.CDRoleAdapter.LinkCardinality; @@ -16,7 +15,6 @@ import de.monticore.odbasis._visitor.ODBasisVisitor2; import de.monticore.odlink._ast.*; import de.monticore.odlink._symboltable.IODLinkScope; -import de.monticore.prettyprint.IndentPrinter; import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; import de.monticore.symbols.oosymbols._symboltable.FieldSymbol; import de.monticore.types.mcbasictypes._ast.ASTMCImportStatement; @@ -72,8 +70,8 @@ public void visit(ASTODArtifact odArtifact) { .setCDDefinition(cdDefinition) .build(); - if (odArtifact.getMCImportStatementList().size() > 0) { - ASTMCImportStatement i = odArtifact.getMCImportStatementList().get(0); + if (!odArtifact.getMCImportStatementList().isEmpty()) { + ASTMCImportStatement i = odArtifact.getMCImportStatementList().getFirst(); imp = CDBasisMill.mCImportStatementBuilder() .setMCQualifiedName(CDBasisMill.mCQualifiedNameBuilder().addParts(i.getQName().toLowerCase()).build()) .setStar(true).build(); @@ -94,12 +92,13 @@ public void visit(ASTODArtifact odArtifact) { .setModifier(CDBasisMill.modifierBuilder().PUBLIC().build()) .build(); - cd4C.addImport(instantiatorClass, imp.getQName() + ".*"); cd4C.addImport(instantiatorClass, "java.time.*"); - cd4C.addImport(instancesClass, imp.getQName() + ".*"); cd4C.addImport(instancesClass, "java.time.*"); - cd4C.addImport(checkerClass, imp.getQName() + ".*"); - + if (imp != null) { + cd4C.addImport(instantiatorClass, imp.getQName() + ".*"); + cd4C.addImport(instancesClass, imp.getQName() + ".*"); + cd4C.addImport(checkerClass, imp.getQName() + ".*"); + } this.cdPackage.addCDElement(instantiatorClass); this.cdPackage.addCDElement(instancesClass); @@ -136,7 +135,7 @@ public void createInstantiator(ASTODNamedObject odElement) { .collect(Collectors.toList()), odElement.getODAttributeList() .stream() - .map(a -> new OD4DataFullPrettyPrinter(new IndentPrinter()).prettyprint(a.getODValue())) + .map(a -> OD4DevelopmentMill.prettyPrint(a.getODValue(), false)) .collect(Collectors.toList()), odElement.getName()); @@ -156,15 +155,15 @@ public void createChecker(ASTODNamedObject odElement) { .collect(Collectors.toList()), odElement.getODAttributeList() .stream() - .map(a -> new OD4DataFullPrettyPrinter(new IndentPrinter()).prettyprint(a.getODValue())) + .map(a -> OD4DevelopmentMill.prettyPrint(a.getODValue(), false)) .collect(Collectors.toList()), odElement.getMCObjectType().printType()); } public void handleLinks(ASTODLink odLink) { - List leftSides = odLink.getODLinkLeftSide().getReferenceNamesList().stream().map(ASTODName::getName).collect(Collectors.toList()); + List leftSides = odLink.getODLinkLeftSide().getReferenceNamesList().stream().map(ASTODName::getName).toList(); - List rightSides = odLink.getODLinkRightSide().getReferenceNamesList().stream().map(ASTODName::getName).collect(Collectors.toList()); + List rightSides = odLink.getODLinkRightSide().getReferenceNamesList().stream().map(ASTODName::getName).toList(); String rightRoleName = odLink.getODLinkRightSide().isPresentRole() ? odLink.getODLinkRightSide().getRole() : ""; String leftRoleName = odLink.getODLinkLeftSide().isPresentRole() ? odLink.getODLinkLeftSide().getRole() : ""; @@ -213,9 +212,9 @@ public void handleLinks(ASTODLink odLink) { } } // in case of direction disruption, we choose how it is possible to navigate - else if (cdRoleOfLeft.isPresent() && !cdRoleOfRight.isPresent()) { + else if (cdRoleOfLeft.isPresent() && cdRoleOfRight.isEmpty()) { this.linkAttributeList.add(constructLink(left, right, rightRoleName, cdRoleOfLeft)); - } else if (!cdRoleOfLeft.isPresent() && cdRoleOfRight.isPresent()) { + } else if (cdRoleOfLeft.isEmpty() && cdRoleOfRight.isPresent()) { this.linkAttributeList.add(constructLink(right, left, leftRoleName, cdRoleOfRight)); } @@ -267,13 +266,20 @@ protected Optional findRole(String src, String tgt, String roleNa if (objSym.isPresent()) { // find type of object String typeName = objSym.get().getMCObjectType().printType(); - TypeSymbol type = OD4DevelopmentMill.globalScope().resolveType(typeName).get(); + Optional resolvedType = OD4DevelopmentMill.globalScope().resolveType(typeName); + if (resolvedType.isEmpty()) { + return res; + } + TypeSymbol type = resolvedType.get(); + if (!(type.getSpannedScope() instanceof IODLinkScope)) { + return res; + } // find hidden cdRole in resolved type String roleName2resolve = roleName.isEmpty() ? tgt : roleName; List types = ((IODLinkScope) type.getSpannedScope()).resolveFieldDownMany(roleName2resolve); - if (types.size() > 0 && types.get(0) instanceof CDRoleAdapter) { - res = Optional.of((CDRoleAdapter) types.get(0)); + if (!types.isEmpty() && types.getFirst() instanceof CDRoleAdapter) { + res = Optional.of((CDRoleAdapter) types.getFirst()); } } @@ -301,7 +307,7 @@ protected String constructLink(String src, String tgt, String roleName, Optional cardModifier = cardModifier(cdRole.get()); } - if (OD4DevelopmentMill.globalScope().getSubScopes().size() >= 1) { + if (!OD4DevelopmentMill.globalScope().getSubScopes().isEmpty()) { return src + "." + ((roleName.isEmpty()) ? findObjectAccessorName4Role(tgt) + cardModifier : roleName + cardModifier) + "(" + tgt + ")"; @@ -315,36 +321,16 @@ protected String constructLink(String src, String tgt, String roleName, Optional protected String cardModifier(CDRoleAdapter cdRole) { String cardModifier = ""; - if (OD4DevelopmentMill.globalScope().getSubScopes().size() >= 1) { - switch (cdRole.getCardinality()) { - case ONE: - cardModifier = ""; - break; - case OPTIONAL: - cardModifier = ""; - break; - case STAR: - cardModifier = "Add"; - break; - case PLUS: - cardModifier = "Add"; - break; - } + if (!OD4DevelopmentMill.globalScope().getSubScopes().isEmpty()) { + cardModifier = switch (cdRole.getCardinality()) { + case ONE, OPTIONAL -> ""; + case STAR, PLUS -> "Add"; + }; } else { - switch (cdRole.getCardinality()) { - case ONE: - cardModifier = "set"; - break; - case OPTIONAL: - cardModifier = "set"; - break; - case STAR: - cardModifier = "add"; - break; - case PLUS: - cardModifier = "add"; - break; - } + cardModifier = switch (cdRole.getCardinality()) { + case ONE, OPTIONAL -> "set"; + case STAR, PLUS -> "add"; + }; } return cardModifier; } diff --git a/src/main/java/de/monticore/od2plantuml/ODPlantUMLTool.java b/src/main/java/de/monticore/od2plantuml/ODPlantUMLTool.java index 1021b020..fcb311a5 100644 --- a/src/main/java/de/monticore/od2plantuml/ODPlantUMLTool.java +++ b/src/main/java/de/monticore/od2plantuml/ODPlantUMLTool.java @@ -2,43 +2,70 @@ import de.monticore.io.paths.MCPath; import de.monticore.od2plantuml.prettyprinter.PlantUMLODFullPrettyPrinter; -import de.monticore.od4data.trafo.OD4DataAttributeValueCompositionTrafo; -import de.monticore.od4data.trafo.OD4DataDeAnonymizeObjectsTrafo; import de.monticore.od4report.OD4ReportMill; import de.monticore.od4report._parser.OD4ReportParser; +import de.monticore.od4development._symboltable.CDRoleSymbolDeSer; import de.monticore.od4report._symboltable.IOD4ReportArtifactScope; import de.monticore.od4report._symboltable.OD4ReportScopesGenitorDelegator; +import de.monticore.od4development.trafo.OD4DevelopmentAttributeValueCompositionTrafo; +import de.monticore.od4development.trafo.OD4DevelopmentDeAnonymizeObjectsTrafo; import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.symbols.basicsymbols.BasicSymbolsMill; +import de.monticore.types.mcbasictypes._ast.ASTMCImportStatement; import de.se_rwth.commons.logging.Log; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.SourceStringReader; +import net.sourceforge.plantuml.syntax.SyntaxChecker; +import net.sourceforge.plantuml.syntax.SyntaxResult; import org.apache.commons.cli.*; +import org.apache.commons.cli.help.HelpFormatter; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Locale; import java.util.Optional; /** - * Base class that is used to define the PlantUML based pretty printer. + * Tool for generating PlantUML diagrams from Object Diagram (OD) models. */ public class ODPlantUMLTool { + public static final String PARSE_ERROR_CLI = "0xA7105 Could not process parameters: %s"; + public static final String PARSE_ERROR_MODEL = "0xA1050x51507 Model could not be parsed."; + public static final String PARSE_ERROR_IO = "0xA1051x70629 Failed to parse %s"; + public static final String ERROR_MISSING_EXTENSION = + "0x0D011: Missing output file extension for -pp. Supported examples: .png, .svg, .eps."; + public static final String ERROR_UNSUPPORTED_FORMAT = + "0x0D012: Unsupported output format '%s' for -pp."; + public static final String ERROR_GENERATE_IMAGE = "0x0D010: Error generating diagram image: %s"; + public static final String ERROR_INVALID_PLANTUML = "0x0D033: Generated PlantUML is invalid: %s"; + public static final String SUCCESS_IMAGE_GENERATED = "Diagram image generated and saved as: %s"; + /** - * This is the driver method responsible for PlantUML tool creation. + * Processes CLI arguments and executes parsing, symbol table creation and PlantUML image + * generation. + *
+   * 
    + *
  • {@code -h}/{@code --help}: prints the help dialog and exits.
  • + *
  • {@code -i}/{@code --input }: sets the mandatory input OD file to parse.
  • + *
  • {@code -path }: sets one or more symbol path entries for imported symbols.
  • + *
  • {@code -pp}/{@code --prettyprint [file]}: generates a PlantUML image to the given file, + * or prints the PlantUML source to stdout when no file is given.
  • + *
+ *
* - * @param args Command line arguments enabling different features in the tool
- * -h description and help dialog of the tool
- * -i (mandatory) parse input OD file and return if successful
-s - * specify the symbol table
-pp pretty printing the OD in different - * formats(e.g. - PNG) + * @param args command line arguments */ public void run(String[] args) { - Log.init(); OD4ReportMill.init(); + // needed to load imported symbols that use primitive types + BasicSymbolsMill.initializePrimitives(); Options options = initOptions(); try { @@ -67,37 +94,49 @@ public void run(String[] args) { return; } - if (cmd.hasOption("s")) { - MCPath mcPath = new MCPath(cmd.getOptionValue("s")); + // if -path is set: set symbol path and load imported diagrams + if (cmd.hasOption("path")) { + MCPath mcPath = new MCPath(); + String[] paths = cmd.getOptionValues("path"); + if (paths != null) { + // support multiple -path entries passed via CLI + Arrays.stream(paths).forEach(p -> mcPath.addEntry(Paths.get(p))); + } OD4ReportMill.globalScope().setSymbolPath(mcPath); - } - else { - createSymbolTable(ast.get()); + OD4ReportMill.globalScope() + .putTypeSymbolDeSer("de.monticore.cdbasis._symboltable.CDTypeSymbol"); + OD4ReportMill.globalScope() + .putSymbolDeSer("de.monticore.cdassociation._symboltable.CDRoleSymbol", + new CDRoleSymbolDeSer()); + + for (ASTMCImportStatement i : ast.get().getMCImportStatementList()) { + OD4ReportMill.globalScope().loadDiagram(i.getQName()); + } } - new OD4DataDeAnonymizeObjectsTrafo().transform(ast.get()); - new OD4DataAttributeValueCompositionTrafo().transform(ast.get()); + createSymbolTable(ast.get()); + + new OD4DevelopmentDeAnonymizeObjectsTrafo().transform(ast.get()); + new OD4DevelopmentAttributeValueCompositionTrafo().transform(ast.get()); // -option pretty print if (cmd.hasOption("pp")) { String path = cmd.getOptionValue("pp", StringUtils.EMPTY); - FileFormat extension = FileFormat.valueOf(FilenameUtils.getExtension(path).toUpperCase()); - String base = FilenameUtils.getBaseName(path); - prettyPrint(ast.get(), base, extension); + prettyPrint(ast.get(), path); } } catch (ParseException e) { // an unexpected error from the apache CLI parser: - Log.error("0xA7105 Could not process parameters: " + e.getMessage()); + Log.error(String.format(PARSE_ERROR_CLI, e.getMessage())); } } /** - * This method parses the provided OD file. + * Parses the given OD model file and returns the resulting AST. * - * @param model filename for the OD model, not null - * @return the ast for the OD artifact + * @param model path to the OD model file, not null + * @return the parsed {@link ASTODArtifact}, or {@link java.util.Optional#empty()} on failure */ private Optional parse(String model) { try { @@ -107,68 +146,58 @@ private Optional parse(String model) { if (!parser.hasErrors() && optAst.isPresent()) { return optAst; } - Log.error("0xA1050x51507 Model could not be parsed."); + Log.error(PARSE_ERROR_MODEL); } - catch (NullPointerException | IOException e) { - Log.error("0xA1051x70629 Failed to parse " + model, e); + catch (IOException e) { + Log.error(String.format(PARSE_ERROR_IO, model), e); } return Optional.empty(); } /** - * This method initializes the command line arguments + * Initializes the CLI options for this tool. * - * @return {@link Options} object + * @return configured {@link Options} instance */ private Options initOptions() { Options options = new Options(); - options.addOption(Option.builder("h") - .longOpt("help") - .desc("Prints this help dialog") - .build()); + options.addOption(Option.builder("h").longOpt("help").desc("Prints this help dialog").get()); - options.addOption(Option.builder("i") - .longOpt("input") - .argName("file") - .hasArg() - .desc("Reads the source file (mandatory) and parses the contents") - .build()); + options.addOption(Option.builder("i").longOpt("input").argName("file").hasArg() + .desc("Reads the source file (mandatory) and parses the contents").get()); - options.addOption(Option.builder("pp") - .longOpt("prettyprint") - .argName("file") - .optionalArg(true) - .numberOfArgs(1) - .desc("Prints the AST to stdout or the specified file (optional)") - .build()); + options.addOption(Option.builder("pp").longOpt("prettyprint").argName("file").optionalArg(true) + .numberOfArgs(1).desc("Prints the AST to stdout or the specified file (optional)").get()); - options.addOption(Option.builder("s") - .longOpt("symboltable") - .argName("file") - .hasArg() - .desc("Serialized the Symbol table of the given artifact.") - .build()); + options.addOption( + Option.builder("path").argName("dirlist").hasArgs() + .desc("Sets the artifact path for imported symbols").get()); return options; } /** - * This method prints the help dialog. + * Prints the help dialog to stdout. * - * @param options printing the initialized {@link Options} + * @param options the configured CLI options to display */ public void printHelp(Options options) { - HelpFormatter formatter = new HelpFormatter(); - formatter.setWidth(80); - formatter.printHelp("ODPlantUMLTool", options); + org.apache.commons.cli.help.HelpFormatter formatter = HelpFormatter.builder().get(); + try { + formatter.printHelp("ODPlantUMLTool", "", options, "", true); + } + catch (IOException e) { + throw new RuntimeException(e); + } } /** - * This method acts as a registry for injecting actual pretty printers into the framework. + * Generates a PlantUML image from the given AST and writes it to the given file using the + * specified format. * - * @param ast parsed ast for the OD - * @param file the OD file - * @param fileFormat pretty printed format of the OD(e.g. - PNG) + * @param ast parsed OD artifact + * @param file destination file path without extension + * @param fileFormat target image format (e.g. PNG) */ public void prettyPrint(ASTODArtifact ast, String file, FileFormat fileFormat) { PlantUMLODFullPrettyPrinter printer = new PlantUMLODFullPrettyPrinter(); @@ -177,34 +206,78 @@ public void prettyPrint(ASTODArtifact ast, String file, FileFormat fileFormat) { } /** - * Rendering the pretty printed OD into an image. + * Pretty prints the OD artifact either to stdout (when no path is given) or renders an image + * file. The image format is derived from the file extension of {@code path}. + * + * @param ast parsed OD artifact + * @param path output file path including extension; blank means stdout + */ + public void prettyPrint(ASTODArtifact ast, String path) { + PlantUMLODFullPrettyPrinter printer = new PlantUMLODFullPrettyPrinter(); + String result = printer.prettyprint(ast); + + if (StringUtils.isBlank(path)) { + System.out.println(result); + return; + } + + String extension = FilenameUtils.getExtension(path); + if (StringUtils.isBlank(extension)) { + Log.error(ERROR_MISSING_EXTENSION); + return; + } + + try { + FileFormat fileFormat = FileFormat.valueOf(extension.toUpperCase(Locale.ROOT)); + String destinationPath = FilenameUtils.removeExtension(path); + generateImage(result, destinationPath, fileFormat); + } + catch (IllegalArgumentException e) { + Log.error(String.format(ERROR_UNSUPPORTED_FORMAT, extension)); + } + } + + /** + * Renders the given PlantUML source string into an image file. * - * @param plantUMLSource pretty printed source OD string - * @param destinationPath path to store the generated image - * @param fileFormat format in which image must be generated(e.g. -PNG) + * @param plantUMLSource PlantUML source string to render + * @param destinationPath target file path without extension + * @param fileFormat target image format (e.g. PNG) */ public void generateImage(String plantUMLSource, String destinationPath, FileFormat fileFormat) { + // PlantUML renders an image showing the error for invalid sources, which must not be saved + SyntaxResult syntax = SyntaxChecker.checkSyntax(plantUMLSource); + if (syntax.isError()) { + Log.error(String.format(ERROR_INVALID_PLANTUML, String.join(", ", syntax.getErrors()))); + return; + } + try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); SourceStringReader reader = new SourceStringReader(plantUMLSource); - reader.outputImage(outputStream, new FileFormatOption(fileFormat)); - - try (FileOutputStream fileOutputStream = new FileOutputStream( - destinationPath + fileFormat.getFileSuffix())) { + if (reader.outputImage(outputStream, new FileFormatOption(fileFormat)) == null) { + Log.error(String.format(ERROR_GENERATE_IMAGE, "no diagram found")); + return; + } + + try ( + FileOutputStream fileOutputStream = new FileOutputStream( + destinationPath + fileFormat.getFileSuffix())) { outputStream.writeTo(fileOutputStream); } - Log.info("Diagram image generated and saved as: " + destinationPath, "SUCCESS"); + System.out.println( + String.format(SUCCESS_IMAGE_GENERATED, destinationPath + fileFormat.getFileSuffix())); } catch (IOException e) { - Log.error("0x0D010: Error generating diagram image: " + e.getMessage()); + Log.error(String.format(ERROR_GENERATE_IMAGE, e.getMessage())); } } /** - * Create symbol table from the ast. + * Creates the symbol table for the given OD artifact. * - * @param node parsed ast for the OD - * @return the symbol table + * @param node parsed OD artifact + * @return the resulting artifact scope */ public IOD4ReportArtifactScope createSymbolTable(ASTODArtifact node) { OD4ReportScopesGenitorDelegator genitor = OD4ReportMill.scopesGenitorDelegator(); @@ -212,12 +285,28 @@ public IOD4ReportArtifactScope createSymbolTable(ASTODArtifact node) { } /** - * The main method of the program. + * Entry point of the ODPlantUMLTool. Delegates to {@link #run(String[])} and exits with code + * {@code 0} on success or {@code 1} when errors occurred. * - * @param args The command-line arguments provided by the user. + * @param args command line arguments */ public static void main(String[] args) { - ODPlantUMLTool tool = new ODPlantUMLTool(); - tool.run(args); + // initialized here, not in run, to keep a log configured by callers of run + Log.init(); + try { + ODPlantUMLTool tool = new ODPlantUMLTool(); + tool.run(args); + } + catch (Exception exception) { + // ensure a sane exit + Log.ensureInitialization(); + Log.error( + "0xEEEEE an internal error occurred" + " during the execution of the ODPlantUMLTool." + + System.lineSeparator() + "This error is unexpected" + + " and does not indicate an issue with any provided models.", exception); + } + // properly exit with a code + Log.ensureInitialization(); + System.exit(Log.getErrorCount() == 0 ? 0 : 1); } } \ No newline at end of file diff --git a/src/main/java/de/monticore/od2plantuml/REPORT.md b/src/main/java/de/monticore/od2plantuml/REPORT.md index 0004fca3..ce4ced88 100644 --- a/src/main/java/de/monticore/od2plantuml/REPORT.md +++ b/src/main/java/de/monticore/od2plantuml/REPORT.md @@ -1,23 +1,60 @@ -# Object Diagram PlantUML Tool (ODPlantUMLTool) +# Object Diagram PlantUML Tool (`ODPlantUMLTool`) -The [ODPlantUMLTool](ODPlantUMLTool.java) is a Pretty Printer primarily used to pretty print -*MontiCore's Object Diagram* models first into the PlantUML syntax and then generate -the object diagrams as a diagrammatic image. Most of the information is kept, but some, e.g. -attribute types are lost. +The [`ODPlantUMLTool`](ODPlantUMLTool.java) is a pretty printer for MontiCore Object Diagrams (ODs). +It transforms OD models into PlantUML text and then renders that text as an image. +Most OD information is preserved during the transformation, but some details (for example attribute types) +are currently not included in the generated PlantUML output. -## Internal Structure of the Functionality +## Usage of ODPlantUMLTool + +### Dependencies +* Java 21 (or higher) +* Gradle 8.5 (or higher) + +### Contributing to the project +* Clone the project from GitHub +* This project has **no Gradle wrapper** (`gradlew` is not part of the repository). +* Ensure Gradle is installed locally and available on your `PATH`. + +```shell +gradle clean build +``` + +### Running the application -**Step 1. Parse the Object Diagrams** +* The tool can be found here: [ODPlantUMLTool](ODPlantUMLTool.java) + + +* Example invocations: + * Generate image output to file: + * ``` -i gentest/src/main/resources/Example.od -pp diagram.png ``` + * Print PlantUML text to stdout: + * ``` -i gentest/src/main/resources/Example.od -pp ``` + * Use symbol path(s) for imported symbols: + * ``` -i gentest/src/main/resources/Example.od -path some/symbol/dir another/symbol/dir -pp diagram.png ``` -1. The tool takes an Object Diagrams as input and parses it into -its abstract syntax tree (AST) based on the -[OD4Report](../../../grammar) grammar. -### Example Object Diagram +* Explanation of the CLI arguments: + * ``` -h ``` / ``` --help ``` prints CLI help and exits. + * ``` -i ``` / ``` --input ``` is **mandatory** and specifies the input `Object Diagram` model. + * ``` -pp ``` / ``` --prettyprint [file] ``` is optional: + * with a file argument, output is written/rendered to that file, + * without a file argument, generated PlantUML text is printed to stdout. + * ``` -path ``` is optional and takes one or more directories to configure symbol + paths. It can also be provided multiple times. + * If ``` -i ``` is missing, the tool prints help and exits. + +## How the Tool Works -Below is an OD defined as in MontiCore's textual notation: +### Step 1: Parse the Object Diagram -``` +The tool reads an Object Diagram model and parses it into an Abstract Syntax Tree (AST) +based on the OD4Report grammar. As OD4Report extends OD4Development, all OD4Development models +are supported, as well as models using OD4Report features such as dates. + +### Example OD Input + +```text objectdiagram Examples { foo: A { @@ -34,35 +71,35 @@ objectdiagram Examples { } ``` -Objects in ODs can also be nested, expressions be used to define values. Objects and attributes -are generally typed (here e.g. `A`, `B`), links can be explicitly defined quite like in -MontiCore's class diagrams. Further extensions e.g. through language composition allow -various forms and uses object diagrams. +ODs may contain nested objects and expressions. +Objects and attributes are typically typed (for example `A` and `B`), and links are modeled similarly to +MontiCore class diagram associations. -![*Figure 1:* The graphical syntax of an example OD.](../../../../../doc/pics/ODExample4DiagramTrafo.png) -
Figure 1: The OD ```Example``` in graphical syntax. +![Figure 1: Graphical syntax of an example OD.](../../../../../../doc/pics/ODExample4DiagramTrafo.png) +
Figure 1: The OD Examples in graphical syntax. +### Step 2: Pretty Print the OD to PlantUML -**Step 2. Pretty Print the Object Diagram as a PlantUML text.** +The tool uses MontiCore's visitor and handler infrastructure to traverse the AST and generate PlantUML text. -1. The tool uses the [Monticore](https://monticore.github.io/monticore/) `Visitor` and - `Handler` Infrastructure to iterate through the AST nodes and pretty prints the +1. The tool uses the [Monticore](https://monticore.github.io/monticore/) `Visitor` and + `Handler` Infrastructure to iterate through the AST nodes and pretty prints the PlantUML model. -2. Detailed Implementation can be found here: +2. Detailed Implementation can be found here: [PlantUMLODFullPrettyPrinter](PlantUMLODFullPrettyPrinter.java) This is the pretty-printed PlantUML model by the ODPlantUMLTool, which contains most of the -OD information (but missing e.g. attribute types): +OD information (but missing e.g. attribute types): -``` +```text @startuml note "OD" as tag #white object "__foo:A__" as foo { - x = 5 + x = 5 s = "hello" } object "__bar:B__" as bar { - b = false + b = false } foo--> "blub" bar @enduml @@ -70,91 +107,26 @@ foo--> "blub" bar **Step 3. Generate an image representing the OD as image.** -1. The tool uses the PlantUML Java library to take the pretty printed +1. The tool uses the PlantUML Java library to take the pretty printed PlantUML text as input and generates an image representing the OD. -2. Detailed Implementation can be found here: [generateImage](ODPlantUMLTool.java) +2. Detailed Implementation can be found here: [generateImage](ODPlantUMLTool.java) -![*Figure 2:* Generation of graphical OD from PlantUML text.](../../../../../doc/pics/GeneratePlantUMLDiagram.png) +![*Figure 2:* Generation of graphical OD from PlantUML text.](../../../../../../doc/pics/GeneratePlantUMLDiagram.png)
Figure 2: Generation of Object Diagram from PlantUML Model. -## Usage of ODPlantUMLTool - -### Dependencies -* Java 21 (or higher) -* Gradle 8.5 (or higher) - -### Installation of the project -* Clone the project from Gitlab -* run *./gradlew clean* -* run *./gradlew build* - -### Running the application - -* The tool can be found here: [ODPlantUMLTool](ODPlantUMLTool.java) - - -* Run the Tool using the following CLI arguments: - * ``` -i gentest/src/main/resources/Example.od -s gentest/src/main/resources/symboltable -pp diagram.png ``` - - -* Explanation of the CLI arguments: - * ``` -i ``` flag is used to specify the location of the input `Object Diagram` model - * ``` -s ``` flag is used to specify the location of the symbol table that must be used by the `Pretty Printer`. - * ``` pp ``` flag is used to specify the name of the output image of the `Object Diagram` that is generated from the pretty printed `PlantUML` model. - * These arguments values can be *modified according to individual user's requirements* like format of images (png, jpeg), location of models etc. - - -* To view the pretty printed `PlantUML` model, then following steps must be performed: - * Navigate to the tool: [ODPlantUMLTool](ODPlantUMLTool.java) - * Move to the `prettyPrint` function at `Line 124` - * Add and additional fragment to print the result `PlantUML model` at `Line 127` : Log.info(result,"INFO"); - * Build the project again. - * Run the `PlantUML` Tool using suitable CLI arguments. - * The pretty printed `PlantUML` model will be available in the logs. - -### Limitation of the Tool -* Handling of Complex `Object Diagrams` with lists of objects: - * The tool is not capable of handling OD models which have nested lists of objects within a given object. - * An Example is shown below where we have a nested list of `cars` within an object `alice`: - -``` -objectdiagram MyFamily { - alice:Person { - age = 29; - cars = [ - :BMW { - bought = 2020-01-05 15:30:00; - color = BLUE; - }, - tiger:Jaguar { - bought = 2000/01/05 15:00:00; - color = RED; - length = 5.3; - } - ]; - }; - bob:Person { - nicknames = ["Bob", "Bobby", "Robert"]; - cars -> tiger; - }; - link married alice <-> bob; -} -``` - - ## Further Information * [Project root: MontiCore @github](https://github.com/MontiCore/monticore) * [MontiCore documentation](http://www.monticore.de/) -* [**List of languages**](https://github.com/MontiCore/monticore/blob/opendev/docs/Languages.md) +* [**List of languages**](https://github.com/MontiCore/monticore/blob/dev/docs/Languages.md) * [**MontiCore Core Grammar - Library**](https://github.com/MontiCore/monticore/blob/opendev/monticore-grammar/src/main/grammars/de/monticore/Grammars.md) -* [Best Practices](https://github.com/MontiCore/monticore/blob/opendev/docs/BestPractices.md) + Library**](https://github.com/MontiCore/monticore/blob/dev/monticore-grammar/src/main/grammars/de/monticore/Grammars.md) +* [Best Practices](https://github.com/MontiCore/monticore/blob/dev/docs/BestPractices.md) * [Publications about MBSE and MontiCore](https://www.se-rwth.de/publications/) * [Licence definition](https://github.com/MontiCore/monticore/blob/master/00.org/Licenses/LICENSE-MONTICORE-3-LEVEL.md) [od4report-link]: http://www.monticore.de/download/MCOD4Report.jar -[od4data-link]: http://www.monticore.de/download/MCOD4Data.jar +[od4dev-link]: http://www.monticore.de/download/MCOD4Development.jar diff --git a/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODAttributePrettyPrinter.java b/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODAttributePrettyPrinter.java new file mode 100644 index 00000000..a029ad35 --- /dev/null +++ b/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODAttributePrettyPrinter.java @@ -0,0 +1,73 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.od2plantuml.prettyprinter; + +import de.monticore.odattribute._ast.ASTODList; +import de.monticore.odattribute._ast.ASTODMap; +import de.monticore.odattribute._ast.ASTODMapElement; +import de.monticore.odattribute._visitor.ODAttributeHandler; +import de.monticore.odattribute._visitor.ODAttributeTraverser; +import de.monticore.odbasis._ast.ASTODValue; +import de.monticore.prettyprint.IndentPrinter; + +import java.util.List; + +/** + * Pretty prints lists and maps as attribute values, e.g., {@code [1, 2]} and {@code [1 -> 2]}. + */ +public class PlantUMLODAttributePrettyPrinter implements ODAttributeHandler { + + private final IndentPrinter printer; + private ODAttributeTraverser traverser; + + public PlantUMLODAttributePrettyPrinter(IndentPrinter printer) { + this.printer = printer; + } + + @Override + public ODAttributeTraverser getTraverser() { + return traverser; + } + + @Override + public void setTraverser(ODAttributeTraverser traverser) { + this.traverser = traverser; + } + + @Override + public void handle(ASTODList node) { + List values = node.getODValueList(); + printer.print("["); + for (int i = 0; i < values.size(); i++) { + if (i > 0) { + printer.stripTrailing(); + printer.print(", "); + } + values.get(i).accept(getTraverser()); + } + printer.stripTrailing(); + printer.print("]"); + } + + @Override + public void handle(ASTODMap node) { + List elements = node.getODMapElementList(); + printer.print("["); + for (int i = 0; i < elements.size(); i++) { + if (i > 0) { + printer.stripTrailing(); + printer.print(", "); + } + elements.get(i).accept(getTraverser()); + } + printer.stripTrailing(); + printer.print("]"); + } + + @Override + public void handle(ASTODMapElement node) { + node.getKey().accept(getTraverser()); + printer.stripTrailing(); + printer.print(" -> "); + node.getVal().accept(getTraverser()); + } +} diff --git a/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODBasisPrettyPrinter.java b/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODBasisPrettyPrinter.java index a4b72037..b99ba1ea 100644 --- a/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODBasisPrettyPrinter.java +++ b/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODBasisPrettyPrinter.java @@ -17,7 +17,8 @@ public class PlantUMLODBasisPrettyPrinter implements ODBasisVisitor2, ODBasisHan private final IndentPrinter printer; private ODBasisTraverser traverser; - private final Map anonymousObjectsNameCache = new LinkedHashMap<>(); + /** Deterministic aliases for anonymous objects that were not named by a trafo. */ + private final Map anonymousObjectsNameCache = new LinkedHashMap<>(); public PlantUMLODBasisPrettyPrinter(IndentPrinter printer) { this.printer = printer; @@ -64,8 +65,8 @@ protected boolean hasBeenDeAnonymizedByTrafo(ASTODNamedObject node) { public void visit(ASTODAnonymousObject node) { var typesPrinter = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); var printedType = typesPrinter.prettyprint(node.getMCObjectType()); - this.anonymousObjectsNameCache.putIfAbsent(node, UUID.randomUUID()); - String nodeName = this.anonymousObjectsNameCache.get(node).toString(); + String nodeName = this.anonymousObjectsNameCache.computeIfAbsent(node, + n -> "__anonymous_" + (anonymousObjectsNameCache.size() + 1)); printer.println( String.format("object \"__:%2$s__\" as %1$s {", nodeName, printedType)); } @@ -104,4 +105,9 @@ public void endVisit(ASTObjectDiagram node) { public void visit(ASTODName node) { printer.print(node.getName()); } + + @Override + public void visit(ASTODAbsent node) { + printer.print("..."); + } } diff --git a/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODFullPrettyPrinter.java b/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODFullPrettyPrinter.java index bfe3a750..9194c370 100644 --- a/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODFullPrettyPrinter.java +++ b/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODFullPrettyPrinter.java @@ -2,6 +2,7 @@ import de.monticore.dateliterals._prettyprint.DateLiteralsPrettyPrinter; import de.monticore.expressions.commonexpressions._prettyprint.CommonExpressionsPrettyPrinter; +import de.monticore.expressions.expressionsbasis._prettyprint.ExpressionsBasisPrettyPrinter; import de.monticore.literals.mccommonliterals._prettyprint.MCCommonLiteralsPrettyPrinter; import de.monticore.od4report.OD4ReportMill; import de.monticore.od4report._visitor.OD4ReportTraverser; @@ -24,6 +25,14 @@ public PlantUMLODFullPrettyPrinter() { new MCCommonLiteralsPrettyPrinter(printer, false); traverser.add4MCCommonLiterals(literalsPrettyPrinter); traverser.setMCCommonLiteralsHandler(literalsPrettyPrinter); + ExpressionsBasisPrettyPrinter expressionsBasisPrettyPrinter = + new ExpressionsBasisPrettyPrinter(printer, false); + traverser.add4ExpressionsBasis(expressionsBasisPrettyPrinter); + traverser.setExpressionsBasisHandler(expressionsBasisPrettyPrinter); + // lists and maps as attribute values, printed in OD syntax + PlantUMLODAttributePrettyPrinter odAttributePrettyPrinter = + new PlantUMLODAttributePrettyPrinter(printer); + traverser.setODAttributeHandler(odAttributePrettyPrinter); CommonExpressionsPrettyPrinter commonExpressionsPrettyPrinter = new CommonExpressionsPrettyPrinter(printer, false); traverser.add4CommonExpressions(commonExpressionsPrettyPrinter); diff --git a/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODLinkPrettyPrinter.java b/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODLinkPrettyPrinter.java index 78bebe4b..deaa23a4 100644 --- a/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODLinkPrettyPrinter.java +++ b/src/main/java/de/monticore/od2plantuml/prettyprinter/PlantUMLODLinkPrettyPrinter.java @@ -2,9 +2,7 @@ import de.monticore.odbasis._visitor.ODBasisHandler; import de.monticore.odbasis._visitor.ODBasisVisitor2; -import de.monticore.odlink.ODLinkMill; import de.monticore.odlink._ast.*; -import de.monticore.odlink._util.IODLinkTypeDispatcher; import de.monticore.odlink._visitor.ODLinkHandler; import de.monticore.odlink._visitor.ODLinkTraverser; import de.monticore.odlink._visitor.ODLinkVisitor2; @@ -61,39 +59,47 @@ protected String getLinkRepresentation(ASTODLink node) { String linkRepresentation = "--"; ASTODLinkDirection linkDirection = node.getODLinkDirection(); - IODLinkTypeDispatcher typeDispatcher = ODLinkMill.typeDispatcher(); - - if (typeDispatcher.isODLinkASTODLeftToRightDir(linkDirection)) { - if (!symbol.isEmpty()) { - linkRepresentation = symbol + linkRepresentation; - } - linkRepresentation = linkRepresentation + ">"; - } - else if (typeDispatcher.isODLinkASTODRightToLeftDir(linkDirection)) { - if (!symbol.isEmpty()) { - linkRepresentation = linkRepresentation + symbol; - } - linkRepresentation = "<" + linkRepresentation; - } - else if (typeDispatcher.isODLinkASTODBiDir(linkDirection)) { - linkRepresentation = - (symbol.isEmpty() ? "<" : symbol) + linkRepresentation + (symbol.isEmpty() ? ">" - : symbol); - } + linkRepresentation = switch (linkDirection) { + case ASTODLeftToRightDir dir -> (symbol.isEmpty() ? "" : symbol) + linkRepresentation + ">"; + case ASTODRightToLeftDir dir -> "<" + linkRepresentation + (symbol.isEmpty() ? "" : symbol); + case ASTODBiDir dir -> (symbol.isEmpty() ? "<" : symbol) + linkRepresentation + (symbol.isEmpty() ? ">" + : symbol); + default -> symbol + linkRepresentation; + }; + return " " + linkRepresentation + " "; } - + + /** Prints {@code [qualifier] "role"}, as PlantUML expects it on the left side. */ @Override public void handle(ASTODLinkLeftSide node) { + printQualifier(node); if (node.isPresentRole()) { printer.print(" \"" + node.getRole() + "\" "); } } - + + /** Prints {@code "role" [qualifier]}, as PlantUML expects it on the right side. */ @Override public void handle(ASTODLinkRightSide node) { if (node.isPresentRole()) { printer.print(" \"" + node.getRole() + "\" "); } + printQualifier(node); + } + + protected void printQualifier(ASTODLinkSide node) { + if (!node.isPresentODLinkQualifier()) { + return; + } + ASTODLinkQualifier qualifier = node.getODLinkQualifier(); + printer.print(" ["); + if (qualifier.isPresentName()) { + printer.print(qualifier.getName()); + } + else { + qualifier.getODValue().accept(getTraverser()); + } + printer.print("] "); } } \ No newline at end of file diff --git a/src/main/java/de/monticore/od4data/OD4DataMill.java b/src/main/java/de/monticore/od4data/OD4DataMill.java deleted file mode 100644 index 0d41e774..00000000 --- a/src/main/java/de/monticore/od4data/OD4DataMill.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * (c) https://github.com/MontiCore/monticore - */ - -package de.monticore.od4data; - -import de.monticore.od4data.types3.OD4DataTypeCheck3; - -public class OD4DataMill extends OD4DataMillTOP { - - /** additionally inits the TypeCheck */ - public static void init() { - OD4DataMillTOP.init(); - OD4DataTypeCheck3.init(); - } -} diff --git a/src/main/java/de/monticore/od4data/OD4DataTool.java b/src/main/java/de/monticore/od4data/OD4DataTool.java deleted file mode 100644 index a34aac31..00000000 --- a/src/main/java/de/monticore/od4data/OD4DataTool.java +++ /dev/null @@ -1,258 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore.od4data; - -import de.monticore.io.paths.MCPath; -import de.monticore.od4data._symboltable.IOD4DataArtifactScope; -import de.monticore.od4data._prettyprint.OD4DataFullPrettyPrinter; -import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.prettyprint.IndentPrinter; -import de.monticore.symbols.basicsymbols.BasicSymbolsMill; -import de.se_rwth.commons.logging.Log; -import org.apache.commons.cli.*; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang3.StringUtils; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * Command line interface for the OD language and corresponding tooling. Defines, handles, and - * executes the corresponding command line options and arguments, such as --help - */ -public class OD4DataTool extends OD4DataToolTOP { - - protected static final String PARSE_SUCCESSFUL = "Successfully parsed %s\n"; - - protected static final String CHECK_SUCCESSFUL = - "Successfully checked the CoCos for class " + "diagram %s\n"; - - protected static final String CHECK_ERROR = "Error while parsing or CoCo checking"; - - protected static final String STEXPORT_SUCCESSFUL = "Creation of symbol file %s successful\n"; - - protected static final String INPUT_FILE_NOT_EXISTENT = "Input file '%s' does not exist\n"; - - /*=================================================================*/ - /* Part 1: Handling the arguments and options - /*=================================================================*/ - - /** - * Processes user input from command line and delegates to the corresponding tools. - * - * @param args The input parameters for configuring the OD tool. - */ - @Override - public void run(String[] args) { - init(); - Options options = initOptions(); - - try { - // create CLI parser and parse input options from command line - CommandLineParser cliparser = new DefaultParser(); - CommandLine cmd = cliparser.parse(options, args); - - // help: when --help - if (cmd.hasOption("h")) { - printHelp(options); - // do not continue, when help is printed - return; - } - - // if -i input is missing: also print help and stop - if (!cmd.hasOption("i")) { - printHelp(options); - // do not continue, when help is printed - return; - } - - // if -path is set: save the model paths - MCPath symbolPath = new MCPath(); - if (cmd.hasOption("path")) { - String[] paths = cmd.getOptionValues("path"); - Arrays.stream(paths).forEach(p -> symbolPath.addEntry(Paths.get(p))); - BasicSymbolsMill.initializePrimitives(); - OD4DataMill.globalScope().putTypeSymbolDeSer("de.monticore.cdbasis._symboltable.CDTypeSymbol"); - } - OD4DataMill.globalScope().setSymbolPath(symbolPath); - - // don't output to stdout when the prettyprint is output to stdout - final boolean doPrintToStdOut = !(cmd.hasOption("pp") && cmd.getOptionValue("pp") == null); - - // parse input file - String modelFile = cmd.getOptionValue("i"); - Path modelFilePath = Paths.get(modelFile); - if (!modelFilePath.toFile().exists()) { - System.out.printf(INPUT_FILE_NOT_EXISTENT, modelFile); - return; - } - - ASTODArtifact astodArtifact = parse(modelFile); - - if (doPrintToStdOut) { - System.out.printf(PARSE_SUCCESSFUL, astodArtifact.getObjectDiagram().getName()); - } - - // -option check cocos - Set cocoOptionValue = new LinkedHashSet<>(); - if (cmd.hasOption("c") && cmd.getOptionValues("c") != null) { - cocoOptionValue.addAll(Arrays.asList(cmd.getOptionValues("c"))); - } - - // create symbol table - IOD4DataArtifactScope od4DataArtifactScope = OD4DataToolAPI.createSymbolTable(astodArtifact, - !cocoOptionValue.contains("intra")); - - // run cocos - if (cmd.hasOption("c")) { - if (cocoOptionValue.contains("intra")) { - OD4DataToolAPI.runAllIntraCoCos(astodArtifact); - } - else { - OD4DataToolAPI.runAllCoCos(astodArtifact); - } - - if (doPrintToStdOut) { - if (Log.getErrorCount() == 0) { - System.out.printf(CHECK_SUCCESSFUL, astodArtifact.getObjectDiagram().getName()); - } - else { - System.out.println(CHECK_ERROR); - return; - } - } - } - - // -option pretty print - if (cmd.hasOption("pp")) { - String path = cmd.getOptionValue("pp", StringUtils.EMPTY); - prettyPrint(astodArtifact, path); - } - - // -option pretty print symboltable - if (cmd.hasOption("s")) { - Path symTabPath = storeSymTab(od4DataArtifactScope, modelFilePath,cmd.getOptionValue("s")); - if (doPrintToStdOut) { - System.out.printf(STEXPORT_SUCCESSFUL, symTabPath.toAbsolutePath()); - } - } - } - catch (ParseException e) { - // an unexpected error from the apache CLI parser: - Log.error("0xA7121 Could not process CLI parameters: " + e.getMessage()); - } - } - - /*=================================================================*/ - /* Part 2: Executing arguments - /*=================================================================*/ - - /** - * Prints the contents of the OD-AST to stdout or a specified file. - * - * @param astodArtifact The OD-AST to be pretty printed - * @param file The target file name for printing the OD artifact. If empty, the content - * is printed to stdout instead - */ - @Override - public void prettyPrint(ASTODArtifact astodArtifact, String file) { - // pretty print AST - OD4DataFullPrettyPrinter pp = new OD4DataFullPrettyPrinter(new IndentPrinter()); - String od = pp.prettyprint(astodArtifact); - print(od, file); - } - - - /*=================================================================*/ - /* Part 3: Defining the options incl. help-texts - /*=================================================================*/ - - /** - * Initializes the standard options for the OD tool. - * - * @return The CLI options with arguments. - */ - @Override - public Options addStandardOptions(Options options) { - // help dialog - options.addOption(Option.builder("h").longOpt("help").desc("Prints this help dialog").build()); - - // parse input file - options.addOption(Option.builder("i") - .longOpt("input") - .argName("file") - .hasArg() - .desc("Reads the source file (mandatory) and parses the contents as an " + "object diagram") - .build()); - - // model paths - options.addOption(Option.builder("path") - .argName("dirlist") - .numberOfArgs(Option.UNLIMITED_VALUES) - .hasArg() - .desc("Sets the artifact path for imported symbols") - .build()); - - // pretty print OD - options.addOption(Option.builder("pp") - .longOpt("prettyprint") - .argName("file") - .optionalArg(true) - .numberOfArgs(1) - .desc("Prints the OD-AST to stdout or the specified file (optional)") - .build()); - - // print OD symtab - options.addOption(Option.builder("s") - .longOpt("symboltable") - .argName("file") - .optionalArg(true) - .numberOfArgs(1) - .desc("Stores the symbol table of the OD. The default value is `{ODName}.odsym`.") - .build()); - - return options; - } - - @Override - public Options addAdditionalOptions(Options options) { - // check cocos - options.addOption(Option.builder("c") - .longOpt("coco") - .optionalArg(true) - .numberOfArgs(3) - .desc("Checks the CoCos for the input. Optional arguments are:\n" - + "-c intra to check only the" + " intra-model CoCos,\n" - + "-c inter checks also inter-model CoCos,\n" + "-c type " - + "(default) checks all CoCos.") - .build()); - return options; - } - - /** - * prints the symboltable of the given scope out to a file - * - * @param as symboltable to store - * @param modelPath location of the file containing the OD - * @param symTabPath location of the file or directory containing the printed table - */ - public Path storeSymTab(IOD4DataArtifactScope as, Path modelPath, String symTabPath) { - Path targetPath; - if (symTabPath == null || symTabPath.isBlank()) { - String symTabName = FilenameUtils.getBaseName(modelPath.toString()) + ".odsym"; - targetPath = modelPath.getParent().resolve(symTabName); - } - else { - targetPath = Paths.get(symTabPath); - if (targetPath.toFile().exists() && targetPath.toFile().isDirectory()) { - String symTabName = FilenameUtils.getBaseName(modelPath.toString()) + ".odsym"; - targetPath = targetPath.resolve(symTabName); - } - } - this.storeSymbols(as, targetPath.toString()); - return targetPath; - } - -} diff --git a/src/main/java/de/monticore/od4data/OD4DataToolAPI.java b/src/main/java/de/monticore/od4data/OD4DataToolAPI.java deleted file mode 100644 index 6960055a..00000000 --- a/src/main/java/de/monticore/od4data/OD4DataToolAPI.java +++ /dev/null @@ -1,65 +0,0 @@ -// (c) https://github.com/MontiCore/monticore - -package de.monticore.od4data; - -import de.monticore.od4data._cocos.OD4DataCoCos; -import de.monticore.od4data._parser.OD4DataParser; -import de.monticore.od4data._symboltable.IOD4DataArtifactScope; -import de.monticore.od4data._symboltable.OD4DataScopesGenitorDelegator; -import de.monticore.odbasis._ast.ASTODArtifact; -import de.se_rwth.commons.logging.Log; -import org.antlr.v4.runtime.RecognitionException; - -import java.io.IOException; -import java.util.Optional; - -public class OD4DataToolAPI { - - /** - * Parse the model contained in the specified file. - * - * @param model - file to parse - * @return Artifact containing the OD - */ - public static ASTODArtifact parse(String model) { - try { - OD4DataParser parser = OD4DataMill.parser(); - Optional optODArtifact = parser.parse(model); - - if (!parser.hasErrors() && optODArtifact.isPresent()) { - return optODArtifact.get(); - } - Log.error("0x0D011: Model could not be parsed."); - } - catch (RecognitionException | IOException e) { - Log.error("0x0D012: Failed to parse " + model, e); - } - return null; - } - - /** - * Create the symbol table from the parsed AST. - * - * @param ast ODArtifact ast - * @return Symboltable created form AST - */ - public static IOD4DataArtifactScope createSymbolTable(ASTODArtifact ast, boolean checkTypes) { - OD4DataScopesGenitorDelegator od4DataScopesGenitorDelegator = - OD4DataMill.scopesGenitorDelegator(); - od4DataScopesGenitorDelegator.setCheckTypes(checkTypes); - return od4DataScopesGenitorDelegator.createFromAST(ast); - } - - public static IOD4DataArtifactScope createSymbolTable(ASTODArtifact ast) { - return OD4DataToolAPI.createSymbolTable(ast, false); - } - - public static void runAllCoCos(ASTODArtifact ast) { - new OD4DataCoCos().getCheckerForAllCoCos().checkAll(ast); - } - - public static void runAllIntraCoCos(ASTODArtifact ast) { - new OD4DataCoCos().getCheckerForAllIntraCoCos().checkAll(ast); - } - -} diff --git a/src/main/java/de/monticore/od4data/_cocos/OD4DataCoCos.java b/src/main/java/de/monticore/od4data/_cocos/OD4DataCoCos.java deleted file mode 100644 index 6b3ee871..00000000 --- a/src/main/java/de/monticore/od4data/_cocos/OD4DataCoCos.java +++ /dev/null @@ -1,26 +0,0 @@ -// (c) https://github.com/MontiCore/monticore - -package de.monticore.od4data._cocos; - -import de.monticore.odbasis._cocos.ODBasicsCoCos; -import de.monticore.odlink._cocos.ODLinkCoCos; - -public class OD4DataCoCos { - - public OD4DataCoCoChecker getCheckerForAllIntraCoCos() { - final OD4DataCoCoChecker checker = new OD4DataCoCoChecker(); - checker.addChecker(new ODBasicsCoCos().getCheckerForAllIntraCoCos()); - checker.addChecker(new ODLinkCoCos().getCheckerForAllIntraCoCos()); - - return checker; - } - - public OD4DataCoCoChecker getCheckerForAllCoCos() { - final OD4DataCoCoChecker checker = new OD4DataCoCoChecker(); - checker.addChecker(new ODBasicsCoCos().getCheckerForAllCoCos()); - checker.addChecker(new ODLinkCoCos().getCheckerForAllCoCos()); - - return checker; - } - -} diff --git a/src/main/java/de/monticore/od4data/_symboltable/OD4DataGlobalScope.java b/src/main/java/de/monticore/od4data/_symboltable/OD4DataGlobalScope.java deleted file mode 100644 index e5225286..00000000 --- a/src/main/java/de/monticore/od4data/_symboltable/OD4DataGlobalScope.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - (c) https://github.com/MontiCore/monticore - */ - -package de.monticore.od4data._symboltable; - -import de.monticore.io.paths.MCPath; -import de.se_rwth.commons.Names; - -import java.util.Set; - -public class OD4DataGlobalScope extends OD4DataGlobalScopeTOP { - private OD4DataGlobalScope realThis; - - public OD4DataGlobalScope() { - realThis = this; - } - - public OD4DataGlobalScope(MCPath modelPath, String extension) { - super(modelPath, extension); - } - - @Override - public OD4DataGlobalScope getRealThis() { - return realThis; - } - - public void setRealThis(OD4DataGlobalScope realThis) { - this.realThis = realThis; - } - - @Override - public Set calculateModelNamesForOOType(String name) { - Set result = super.calculateModelNamesForOOType(name); - - while (name.contains(".")) { - name = Names.getQualifier(name); - result.add(name); - } - return result; - } - - @Override - public Set calculateModelNamesForType(String name) { - return calculateModelNamesForOOType(name); - } - -} diff --git a/src/main/java/de/monticore/od4data/_symboltable/OD4DataScopesGenitor.java b/src/main/java/de/monticore/od4data/_symboltable/OD4DataScopesGenitor.java deleted file mode 100644 index f4be5113..00000000 --- a/src/main/java/de/monticore/od4data/_symboltable/OD4DataScopesGenitor.java +++ /dev/null @@ -1,42 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore.od4data._symboltable; - -import com.google.common.base.Preconditions; -import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.odbasis._symboltable.ODBasisScopesGenitor; -import de.monticore.symboltable.ImportStatement; -import de.se_rwth.commons.logging.Log; - -import java.util.ArrayList; - -public class OD4DataScopesGenitor extends OD4DataScopesGenitorTOP { - - private ODBasisScopesGenitor odBasisScopesGenitor = new ODBasisScopesGenitor(); - - public OD4DataScopesGenitor() { - super(); - } - - @Override - public IOD4DataArtifactScope createFromAST(ASTODArtifact rootNode) { - Preconditions.checkNotNull(rootNode, - "0xAE882 Error by creating of the OD4DataScopesGenitor symbol table: top ast node" - + " is null"); - IOD4DataArtifactScope artifactScope = de.monticore.od4data.OD4DataMill.artifactScope(); - if (rootNode.isPresentMCPackageDeclaration()) { - artifactScope.setPackageName( - rootNode.getMCPackageDeclaration().getMCQualifiedName().getQName()); - } - else { - artifactScope.setPackageName(""); - } - artifactScope.setImportsList(new ArrayList<>()); - rootNode.getMCImportStatementList() - .forEach(i -> artifactScope.addImports(new ImportStatement(i.getQName(), i.isStar()))); - artifactScope.setName(rootNode.getObjectDiagram().getName()); - putOnStack(artifactScope); - rootNode.accept(getTraverser()); - return artifactScope; - } - -} diff --git a/src/main/java/de/monticore/od4data/_symboltable/OD4DataScopesGenitorDelegator.java b/src/main/java/de/monticore/od4data/_symboltable/OD4DataScopesGenitorDelegator.java deleted file mode 100644 index 5de5c4aa..00000000 --- a/src/main/java/de/monticore/od4data/_symboltable/OD4DataScopesGenitorDelegator.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - (c) https://github.com/MontiCore/monticore - */ - -package de.monticore.od4data._symboltable; - -import de.monticore.odbasis.ODBasisMill; -import de.monticore.odbasis._symboltable.ODBasisScopesGenitor; - -public class OD4DataScopesGenitorDelegator extends OD4DataScopesGenitorDelegatorTOP { - - public OD4DataScopesGenitorDelegator() { - super(); - } - - public void setCheckTypes(boolean typeCheck) { - traverser.getODBasisVisitorList().clear(); - ODBasisScopesGenitor odBasisScopesGenitor = ODBasisMill.scopesGenitor(); - odBasisScopesGenitor.setScopeStack(scopeStack); - odBasisScopesGenitor.setCheckTypes(typeCheck); - traverser.add4ODBasis(odBasisScopesGenitor); - traverser.setODBasisHandler(odBasisScopesGenitor); - } -} diff --git a/src/main/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafo.java b/src/main/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafo.java deleted file mode 100644 index f331e1b4..00000000 --- a/src/main/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafo.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * (c) https://github.com/MontiCore/monticore - */ - -/* - * (c) https://github.com/MontiCore/monticore - */ - -package de.monticore.od4data.trafo; - -import de.monticore.od4data.OD4DataMill; -import de.monticore.od4data._visitor.OD4DataTraverser; -import de.monticore.odbasis._ast.ASTODArtifact; - -public class OD4DataAttributeValueCompositionTrafo { - - protected OD4DataTraverser traverser; - - public OD4DataAttributeValueCompositionTrafo() { - this.traverser = OD4DataMill.inheritanceTraverser(); - - init(traverser); - } - - public static void init(OD4DataTraverser traverser) { - final OD4DataAttributeValueCompositionTrafoExtension trafo = - new OD4DataAttributeValueCompositionTrafoExtension(); - traverser.add4ODBasis(trafo); - traverser.add4ODAttribute(trafo); - traverser.add4ODLink(trafo); - } - - public OD4DataTraverser getTraverser() { - return traverser; - } - - public void setTraverser(OD4DataTraverser traverser) { - this.traverser = traverser; - } - - public void transform(ASTODArtifact diagram) { - diagram.accept(getTraverser()); - } -} diff --git a/src/main/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafo.java b/src/main/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafo.java deleted file mode 100644 index f4f0d761..00000000 --- a/src/main/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafo.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * (c) https://github.com/MontiCore/monticore - */ - -package de.monticore.od4data.trafo; - -import de.monticore.od4data.OD4DataMill; -import de.monticore.od4data._visitor.OD4DataTraverser; -import de.monticore.odbasis._ast.ASTODArtifact; - -public class OD4DataDeAnonymizeObjectsTrafo { - - protected OD4DataTraverser traverser; - - public OD4DataDeAnonymizeObjectsTrafo() { - this.traverser = OD4DataMill.inheritanceTraverser(); - - init(traverser); - } - - public static void init(OD4DataTraverser traverser) { - final OD4DataDeAnonymizeObjectsTrafoExtension trafo = - new OD4DataDeAnonymizeObjectsTrafoExtension(); - traverser.add4ODBasis(trafo); - traverser.add4ODAttribute(trafo); - } - - public OD4DataTraverser getTraverser() { - return traverser; - } - - public void setTraverser(OD4DataTraverser traverser) { - this.traverser = traverser; - } - - public void transform(ASTODArtifact diagram) { - diagram.accept(getTraverser()); - } -} diff --git a/src/main/java/de/monticore/od4data/types3/OD4DataTypeCheck3.java b/src/main/java/de/monticore/od4data/types3/OD4DataTypeCheck3.java deleted file mode 100644 index 43d28c95..00000000 --- a/src/main/java/de/monticore/od4data/types3/OD4DataTypeCheck3.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * (c) https://github.com/MontiCore/monticore - */ - -package de.monticore.od4data.types3; - -import de.monticore.expressions.commonexpressions.types3.CommonExpressionsCTTIVisitor; -import de.monticore.expressions.expressionsbasis.types3.ExpressionBasisCTTIVisitor; -import de.monticore.literals.mccommonliterals.types3.MCCommonLiteralsTypeVisitor; -import de.monticore.od4data.OD4DataMill; -import de.monticore.od4data._visitor.OD4DataTraverser; -import de.monticore.types.mcbasictypes.types3.MCBasicTypesTypeVisitor; -import de.monticore.types3.SymTypeRelations; -import de.monticore.types3.Type4Ast; -import de.monticore.types3.generics.context.InferenceContext4Ast; -import de.monticore.types3.util.*; -import de.monticore.visitor.ITraverser; -import de.se_rwth.commons.logging.Log; - -/** - * TypeCheck3 implementation for the OD4Data language. - * After calling {@link #init()}, - * this implementation will be available through the TypeCheck3 interface. - */ -public class OD4DataTypeCheck3 extends MapBasedTypeCheck3 { - - public static void init() { - initTC3Delegate(); - SymTypeRelations.init(); - OOWithinTypeBasicSymbolsResolver.init(); - OOWithinScopeBasicSymbolsResolver.init(); - TypeContextCalculator.init(); - TypeVisitorOperatorCalculator.init(); - TypeVisitorLifting.init(); - } - - protected static void initTC3Delegate() { - Log.trace("init OD4DataTypeCheck3", "TypeCheck setup"); - - OD4DataTraverser traverser = OD4DataMill.inheritanceTraverser(); - Type4Ast type4Ast = new Type4Ast(); - InferenceContext4Ast ctx4Ast = new InferenceContext4Ast(); - - // Expressions - - CommonExpressionsCTTIVisitor visCommonExpressions = new CommonExpressionsCTTIVisitor(); - visCommonExpressions.setType4Ast(type4Ast); - visCommonExpressions.setContext4Ast(ctx4Ast); - traverser.add4CommonExpressions(visCommonExpressions); - traverser.setCommonExpressionsHandler(visCommonExpressions); - - ExpressionBasisCTTIVisitor visExpressionBasis = new ExpressionBasisCTTIVisitor(); - visExpressionBasis.setType4Ast(type4Ast); - visExpressionBasis.setContext4Ast(ctx4Ast); - traverser.add4ExpressionsBasis(visExpressionBasis); - traverser.setExpressionsBasisHandler(visExpressionBasis); - - MCCommonLiteralsTypeVisitor visMCCommonLiterals = new MCCommonLiteralsTypeVisitor(); - visMCCommonLiterals.setType4Ast(type4Ast); - traverser.add4MCCommonLiterals(visMCCommonLiterals); - - // MCTypes - - MCBasicTypesTypeVisitor visMCBasicTypes = new MCBasicTypesTypeVisitor(); - visMCBasicTypes.setType4Ast(type4Ast); - traverser.add4MCBasicTypes(visMCBasicTypes); - - // create delegate - OD4DataTypeCheck3 oclTC3 = new OD4DataTypeCheck3(traverser, type4Ast, ctx4Ast); - oclTC3.setThisAsDelegate(); - } - - protected OD4DataTypeCheck3(ITraverser typeTraverser, Type4Ast type4Ast, - InferenceContext4Ast ctx4Ast) { - super(typeTraverser, type4Ast, ctx4Ast); - } -} diff --git a/src/main/java/de/monticore/od4development/OD4DevelopmentTool.java b/src/main/java/de/monticore/od4development/OD4DevelopmentTool.java index 13ecc0f4..cd4271b4 100644 --- a/src/main/java/de/monticore/od4development/OD4DevelopmentTool.java +++ b/src/main/java/de/monticore/od4development/OD4DevelopmentTool.java @@ -13,19 +13,25 @@ import de.monticore.od2cd.OD2CDConverter; import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; import de.monticore.od4development._cocos.OD4DevelopmentCoCos; +import de.monticore.od4development._prettyprint.OD4DevelopmentFullPrettyPrinter; import de.monticore.od4development._symboltable.CDRoleSymbolDeSer; import de.monticore.od4development._symboltable.IOD4DevelopmentArtifactScope; +import de.monticore.od4development._visitor.OD4DevelopmentTraverser; import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.odbasis._prettyprint.ODBasisFullPrettyPrinter; +import de.monticore.odbasis._symboltable.ODBasisSymbolTableCompleter; import de.monticore.prettyprint.IndentPrinter; import de.monticore.symbols.basicsymbols.BasicSymbolsMill; import de.monticore.types.mcbasictypes._ast.ASTMCImportStatement; import de.se_rwth.commons.logging.Log; -import org.apache.commons.cli.*; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import java.io.File; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; @@ -33,168 +39,256 @@ public class OD4DevelopmentTool extends OD4DevelopmentToolTOP { - protected static final String PARSE_SUCCESSFUL = "Successfully parsed %s\n"; + protected static final String PARSE_SUCCESSFUL = "Successfully parsed %s"; protected static final String CHECK_SUCCESSFUL = - "Successfully checked the CoCos for class " + "diagram %s\n"; + "Successfully checked the CoCos for object diagram %s"; - protected static final String CHECK_ERROR = "Error while parsing or CoCo checking"; + protected static final String CHECK_ERROR = "0x0D020 Error while processing the object diagram"; - protected static final String STEXPORT_SUCCESSFUL = "Creation of symbol file %s successful\n"; + protected static final String STEXPORT_SUCCESSFUL = "Creation of symbol file %s successful"; + protected static final String PRETTYPRINT_SUCCESSFUL = "Pretty printed OD to file %s"; - protected static final String INPUT_FILE_NOT_EXISTENT = "Input file '%s' does not exist\n"; - - public void run(String[] args) { - Log.init(); - OD4DevelopmentMill.init(); - Options options = initOptions(); - - try { - - // create CLI parser and parse input options from command line - CommandLineParser cliParser = new DefaultParser(); - CommandLine cmd = cliParser.parse(options, args); - - // help: when --help - if (cmd.hasOption("h")) { - printHelp(options); - // do not continue, when help is printed - return; - } - - // if -i input is missing: also print help and stop - if (!cmd.hasOption("i")) { - printHelp(options); - // do not continue, when help is printed - return; - } + protected static final String INPUT_FILE_NOT_EXISTENT = "0x0D015 Input file '%s' does not exist"; + protected static final String INPUT_OPTION_NOT_PRESENT = "0x0D026 No input file given. Use -i to declare the tool input."; + protected static final String OUTPUT_PATH_INVALID = + "0x0D016 Output path '%s' is not a valid directory path"; + protected static final String OUTPUT_OPTION_MISSING_ARG = + "0x0D017 Option -o requires an argument specifying the output directory."; + protected static final String COCO_OPTION_INVALID = + "0x0D018 Invalid argument '%s' for option -c. Allowed values are: intra, inter."; + protected static final String COCO_OPTION_TOO_MANY_ARGS = + "0x0D019 Option -c accepts at most one argument: intra or inter."; + protected static final String PARSE_EXCEPTION_MSG = "0x0D021 Could not process parameters: %s"; + protected static final String REPORT_OPTION_NOT_SUPPORTED = + "0x0D028 Option -r is not supported by the OD4Development tool."; + /** + * Processes CLI arguments and executes parsing, symbol table creation, CoCo checks, + * pretty printing, symbol export and optional OD-to-CD generation. + *
+   * 
    + *
  • {@code -h}/{@code --help}: prints the help dialog and exits.
  • + *
  • {@code -v}/{@code --version}: prints version information and exits.
  • + *
  • {@code -i}/{@code --input }: sets the mandatory input OD file to parse.
  • + *
  • {@code -path }: sets one or more symbol path entries for imported symbols.
  • + *
  • {@code -pp}/{@code --prettyprint [file]}: pretty prints the AST to stdout or the optional file.
  • + *
  • {@code -s}/{@code --symboltable [file]}: writes the symbol table to the optional file or a default name.
  • + *
  • {@code -c}/{@code --coco [intra|inter]}: runs all CoCos by default, or only intra/inter CoCos when specified.
  • + *
  • {@code -o}/{@code --output }: generates a class diagram into the given output directory.
  • + *
  • {@code --stacktrace}: prints stack traces for errors.
  • + *
  • {@code -r}/{@code --report}: generated standard option, not supported by this tool.
  • + *
+ *
+ * + * @param cmd command line + */ + public void doRun(CommandLine cmd) { + if (cmd.hasOption("r")) { + Log.error(REPORT_OPTION_NOT_SUPPORTED); + return; + } - // -option developer logging - if (cmd.hasOption("d")) { - Log.initDEBUG(); - } else { - Log.init(); + // if -i input is missing: stop + if (!cmd.hasOption("i")) { + Log.error(INPUT_OPTION_NOT_PRESENT); + return; + } + + // avoid duplicate console output when pretty print already writes to stdout + final boolean doPrintToStdOut = !(cmd.hasOption("pp") && cmd.getOptionValue("pp") == null); + + // parse input file + String modelFile = cmd.getOptionValue("i"); + Path modelFilePath = Paths.get(modelFile); + if (!modelFilePath.toFile().exists()) { + Log.error(String.format(INPUT_FILE_NOT_EXISTENT, modelFile)); + return; + } + + ASTODArtifact ast = parse(modelFile); + + if (doPrintToStdOut) { + Log.info(String.format(PARSE_SUCCESSFUL, ast.getObjectDiagram().getName()), + getClass().getName()); + } + + // initialize primitives + BasicSymbolsMill.initializePrimitives(); + + // if -path is set: set symbol path and load imported diagrams + if (cmd.hasOption("path")) { + MCPath mcPath = new MCPath(); + String[] paths = cmd.getOptionValues("path"); + if (paths != null) { + // support multiple -path entries passed via CLI + Arrays.stream(paths).forEach(p -> mcPath.addEntry(Paths.get(p))); } + OD4DevelopmentMill.globalScope().setSymbolPath(mcPath); + OD4DevelopmentMill.globalScope() + .putTypeSymbolDeSer("de.monticore.cdbasis._symboltable.CDTypeSymbol"); + OD4DevelopmentMill.globalScope() + .putSymbolDeSer("de.monticore.cdassociation._symboltable.CDRoleSymbol", + new CDRoleSymbolDeSer()); - // don't output to stdout when the prettyprint is output to stdout - final boolean doPrintToStdOut = !(cmd.hasOption("pp") && cmd.getOptionValue("pp") == null); - - // parse input file - String modelFile = cmd.getOptionValue("i"); - Path modelFilePath = Paths.get(modelFile); - if (!modelFilePath.toFile().exists()) { - System.out.printf(INPUT_FILE_NOT_EXISTENT, modelFile); - return; + for (ASTMCImportStatement i : ast.getMCImportStatementList()) { + OD4DevelopmentMill.globalScope().loadDiagram(i.getQName()); } - - ASTODArtifact ast = parse(modelFile); - + } + + IOD4DevelopmentArtifactScope as = createSymbolTable(ast); + + boolean checkTypes = cmd.hasOption("s") || cmd.hasOption("o") || (cmd.hasOption("c") && ( + cmd.getOptionValue("c") == null || cmd.getOptionValue("c").equals("inter"))); + completeSymbolTable(ast, checkTypes); + + if (cmd.hasOption("s")) { + Path symTabPath = storeSymTab(as, modelFilePath, cmd.getOptionValue("s")); if (doPrintToStdOut) { - System.out.printf(PARSE_SUCCESSFUL, ast.getObjectDiagram().getName()); + Log.info(String.format(STEXPORT_SUCCESSFUL, symTabPath.toAbsolutePath()), + getClass().getName()); } - - if(cmd.hasOption("path")) { - MCPath mcPath = new MCPath(cmd.getOptionValue("path")); - OD4DevelopmentMill.globalScope().setSymbolPath(mcPath); - OD4DevelopmentMill.globalScope().putTypeSymbolDeSer("de.monticore.cdbasis._symboltable.CDTypeSymbol"); - OD4DevelopmentMill.globalScope().putSymbolDeSer("de.monticore.cdassociation._symboltable.CDRoleSymbol", new CDRoleSymbolDeSer()); - BasicSymbolsMill.initializePrimitives(); - - for (ASTMCImportStatement i : ast.getMCImportStatementList()) { - OD4DevelopmentMill.globalScope().loadDiagram(i.getQName()); + } + + // -option check cocos + if (cmd.hasOption("c")) { + String[] cocoArgs = cmd.getOptionValues("c"); + if (cocoArgs == null || cocoArgs.length == 0) { + runAllCoCos(ast); + } + else if (cocoArgs.length == 1) { + String cocoArg = cocoArgs[0]; + if ("intra".equals(cocoArg)) { + runDefaultCoCos(ast); + } + else if ("inter".equals(cocoArg)) { + runInterCoCos(ast); + } + else { + Log.error(String.format(COCO_OPTION_INVALID, cocoArg)); + return; } } + else { + Log.error(COCO_OPTION_TOO_MANY_ARGS); + return; + } - IOD4DevelopmentArtifactScope as = createSymbolTable(ast); - - if (cmd.hasOption("s")) { - Path symTabPath = storeSymTab(as, modelFilePath, cmd.getOptionValue("s")); - if (doPrintToStdOut) { - System.out.printf(STEXPORT_SUCCESSFUL, symTabPath.toAbsolutePath()); + if (doPrintToStdOut) { + if (Log.getErrorCount() == 0) { + Log.info(String.format(CHECK_SUCCESSFUL, ast.getObjectDiagram().getName()), + getClass().getName()); } - } - - if (cmd.hasOption("c")) { - runDefaultCoCos(ast); - - if (doPrintToStdOut) { - if (Log.getErrorCount() == 0) { - System.out.printf(CHECK_SUCCESSFUL, ast.getObjectDiagram().getName()); - } - else { - System.out.println(CHECK_ERROR); - return; - } + else { + Log.error(CHECK_ERROR); + return; } } - - // -option pretty print - if (cmd.hasOption("pp")) { - String path = cmd.getOptionValue("pp", StringUtils.EMPTY); - prettyPrint(ast, path); + } + + // -option pretty print + if (cmd.hasOption("pp")) { + String path = cmd.getOptionValue("pp", StringUtils.EMPTY); + prettyPrint(ast, path); + if (StringUtils.isNotBlank(path)) { + Log.info(PRETTYPRINT_SUCCESSFUL.formatted(path), getClass().getName()); } - - String outputDir = cmd.hasOption("o") - ? cmd.getOptionValue("o") - : "target/gen-test/"; - if(cmd.hasOption("o")) { - generateCD(ast, outputDir); + } + + if (cmd.hasOption("o")) { + String outputDirArgument = cmd.getOptionValue("o"); + if (outputDirArgument == null || outputDirArgument.isBlank()) { + Log.error(OUTPUT_OPTION_MISSING_ARG); + return; + } + try { + Path outputDirPath = Paths.get(outputDirArgument); + // allow non-existing directory paths; reject only existing non-directory targets + if (!Files.exists(outputDirPath) || Files.isDirectory(outputDirPath)) { + generateCD(ast, outputDirPath); + } + else { + Log.error(String.format(OUTPUT_PATH_INVALID, outputDirArgument)); + } + } + catch (InvalidPathException e) { + Log.error(String.format(OUTPUT_PATH_INVALID, outputDirArgument)); } - - } catch (ParseException e) { - // an unexpected error from the apache CLI parser: - Log.error("0xA7105 Could not process parameters: " + e.getMessage()); } } - + + /** + * Pretty prints the OD artifact either to stdout or to the given target file. + * + * @param ast parsed OD artifact + * @param file target file path; empty means stdout + */ @Override public void prettyPrint(ASTODArtifact ast, String file) { - ODBasisFullPrettyPrinter printer = new ODBasisFullPrettyPrinter(new IndentPrinter()); + OD4DevelopmentFullPrettyPrinter printer = new OD4DevelopmentFullPrettyPrinter(new IndentPrinter()); String result = printer.prettyprint(ast); print(result, file); } - + + /** + * Runs only intra-model CoCos. + * + * @param ast parsed OD artifact + */ @Override public void runDefaultCoCos(ASTODArtifact ast) { + OD4DevelopmentCoCoChecker checker = new OD4DevelopmentCoCos().getCheckerForAllIntraCoCos(); + checker.checkAll(ast); + } + + /** + * Runs all available CoCos (intra- and inter-model checks). + * + * @param ast parsed OD artifact + */ + public void runAllCoCos(ASTODArtifact ast) { OD4DevelopmentCoCoChecker checker = new OD4DevelopmentCoCos().getCheckerForAllCoCos(); checker.checkAll(ast); } - - public void generateCD(ASTODArtifact ast, String outputDir) { + + /** + * Runs only inter-model CoCos. + * + * @param ast parsed OD artifact + */ + public void runInterCoCos(ASTODArtifact ast) { + OD4DevelopmentCoCoChecker checker = new OD4DevelopmentCoCos().getCheckerForAllInterCoCos(); + checker.checkAll(ast); + } + + /** + * Generates a class diagram from the given OD artifact into the provided output directory. + * + * @param ast parsed OD artifact + * @param outputDir target directory for generated files + */ + public void generateCD(ASTODArtifact ast, Path outputDir) { GeneratorSetup setup = new GeneratorSetup(); GlobalExtensionManagement glex = new GlobalExtensionManagement(); setup.setGlex(glex); glex.setGlobalValue("cdPrinter", new CdUtilsPrinter()); glex.setGlobalValue("cp", new CompositionPrinter()); - - if (!outputDir.isEmpty()){ - File targetDir = new File(outputDir); - setup.setOutputDirectory(targetDir); - } - + + File targetDir = outputDir.toFile(); + setup.setOutputDirectory(targetDir); + String configTemplate = "od2cd.OD2CD"; TemplateController tc = setup.getNewTemplateController(configTemplate); CDGenerator generator = new CDGenerator(setup); TemplateHookPoint hpp = new TemplateHookPoint(configTemplate); List configTemplateArgs; - // select the conversion variant: + // template arguments define converter variant and generator context OD2CDConverter converter = new OD2CDConverter(); configTemplateArgs = Arrays.asList(glex, converter, setup.getHandcodedPath(), generator); - + hpp.processValue(tc, ast, configTemplateArgs); } - @Override - public Options addAdditionalOptions(Options options) { - options.addOption(new Option("o", "output", true, "Sets the output path")); - // check cocos - options.addOption( - Option.builder("c").longOpt("coco").desc("Checks the intra-model CoCos for the input.") - .build()); - return options; - } - /** * prints the symboltable of the given scope out to a file * @@ -206,7 +300,9 @@ public Path storeSymTab(IOD4DevelopmentArtifactScope as, Path modelPath, String Path targetPath; if (symTabPath == null || symTabPath.isBlank()) { String symTabName = FilenameUtils.getBaseName(modelPath.toString()) + ".odsym"; - targetPath = modelPath.getParent().resolve(symTabName); + Path modelParent = modelPath.getParent(); + // handle relative input files that do not have an explicit parent directory + targetPath = modelParent != null ? modelParent.resolve(symTabName) : Paths.get(symTabName); } else { targetPath = Paths.get(symTabPath); @@ -218,4 +314,62 @@ public Path storeSymTab(IOD4DevelopmentArtifactScope as, Path modelPath, String this.storeSymbols(as, targetPath.toString()); return targetPath; } + + public void completeSymbolTable(ASTODArtifact ast, boolean checkObjectTypes) { + OD4DevelopmentTraverser traverser = OD4DevelopmentMill.inheritanceTraverser(); + + ODBasisSymbolTableCompleter odBasisCompleter = + new ODBasisSymbolTableCompleter(checkObjectTypes); + traverser.add4ODBasis(odBasisCompleter); + odBasisCompleter.setTraverser(traverser); + ast.accept(traverser); + } + + /*=================================================================*/ + /* Defining the options incl. help-texts + /*=================================================================*/ + + /** + * Initializes the standard options for the OD tool. + * + * @return The CLI options with arguments. + */ + @Override + public Options addStandardOptions(Options options) { + super.addStandardOptions(options); + + // print OD symtab: replaces the generated option, as the file is optional here + options.addOption( + Option.builder("s").longOpt("symboltable").argName("file").optionalArg(true).numberOfArgs(1) + .desc("Stores the symbol table of the OD. The default value is `{ODName}.odsym`.") + .get()); + + // reports: generated standard option, rejected in doRun + options.addOption(Option.builder("r").longOpt("report").argName("dir").hasArg() + .desc("Not supported by this tool").get()); + + return options; + } + + /** + * Adds tool-specific CLI options beyond the standard options. + * + * @param options current options instance + * @return options including additional OD4Development options + */ + @Override + public Options addAdditionalOptions(Options options) { + // check cocos + options.addOption(Option.builder("c").longOpt("coco").optionalArg(true).numberOfArgs(1).desc(""" + Checks the CoCos for the input. Optional arguments are: + -c intra to check only the\ + intra-model CoCos, + -c inter to check only inter-model CoCos.\ + Without an argument, all CoCos are checked.""").get()); + + options.addOption( + Option.builder("o").longOpt("output").optionalArg(true).hasArg().numberOfArgs(1) + .desc("The output path for the generated/derived classdiagram").get()); + return options; + } } \ No newline at end of file diff --git a/src/main/java/de/monticore/od4development/_cocos/OD4DevelopmentCoCos.java b/src/main/java/de/monticore/od4development/_cocos/OD4DevelopmentCoCos.java index ff57b54f..7064e8e8 100644 --- a/src/main/java/de/monticore/od4development/_cocos/OD4DevelopmentCoCos.java +++ b/src/main/java/de/monticore/od4development/_cocos/OD4DevelopmentCoCos.java @@ -1,15 +1,35 @@ /* (c) https://github.com/MontiCore/monticore */ package de.monticore.od4development._cocos; -import de.monticore.odbasis._cocos.ODBasicsCoCos; +import de.monticore.od4development._cocos.link.ValidLinkQualifierCoCo; +import de.monticore.odbasis._cocos.ODBasisCoCos; import de.monticore.odlink._cocos.ODLinkCoCos; public class OD4DevelopmentCoCos { + + public OD4DevelopmentCoCoChecker getCheckerForAllIntraCoCos() { + final OD4DevelopmentCoCoChecker checker = new OD4DevelopmentCoCoChecker(); + checker.addChecker(new ODBasisCoCos().getCheckerForAllIntraCoCos()); + checker.addChecker(new ODLinkCoCos().getCheckerForAllIntraCoCos()); + checker.addCoCo(new ValidLinkQualifierCoCo()); + + return checker; + } public OD4DevelopmentCoCoChecker getCheckerForAllCoCos() { final OD4DevelopmentCoCoChecker checker = new OD4DevelopmentCoCoChecker(); + checker.addChecker(new ODBasisCoCos().getCheckerForAllCoCos()); checker.addChecker(new ODLinkCoCos().getCheckerForAllCoCos()); - checker.addChecker(new ODBasicsCoCos().getCheckerForAllCoCos()); + checker.addCoCo(new ValidLinkQualifierCoCo()); + + return checker; + } + + public OD4DevelopmentCoCoChecker getCheckerForAllInterCoCos() { + final OD4DevelopmentCoCoChecker checker = new OD4DevelopmentCoCoChecker(); + checker.addChecker(new ODBasisCoCos().getCheckerForAllInterCoCos()); + checker.addChecker(new ODLinkCoCos().getCheckerForAllInterCoCos()); + return checker; } diff --git a/src/main/java/de/monticore/od4development/_cocos/link/ValidLinkQualifierCoCo.java b/src/main/java/de/monticore/od4development/_cocos/link/ValidLinkQualifierCoCo.java new file mode 100644 index 00000000..d7453228 --- /dev/null +++ b/src/main/java/de/monticore/od4development/_cocos/link/ValidLinkQualifierCoCo.java @@ -0,0 +1,53 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package de.monticore.od4development._cocos.link; + +import de.monticore.odattribute._ast.ASTODList; +import de.monticore.odattribute._ast.ASTODMap; +import de.monticore.odbasis._ast.ASTODObject; +import de.monticore.odbasis._ast.ASTODValue; +import de.monticore.odlink._ast.ASTODLinkQualifier; +import de.monticore.odlink._cocos.ODLinkASTODLinkQualifierCoCo; +import de.se_rwth.commons.logging.Log; + +/** + * Checks that the value of an {@link ASTODLinkQualifier} is neither a list, a map, nor an object, + * e.g., that {@code link a [ [1, 2] ] -> b;}, {@code link a [ [1 -> 2] ] -> b;} and + * {@code link a [ :A {} ] -> b;} are rejected. References to objects by name, e.g., + * {@code link a [c] -> b;}, are allowed. + *

+ * The CoCo is part of OD4Development, as lists and maps are introduced by ODAttribute, which + * ODLink does not know. + */ +public class ValidLinkQualifierCoCo implements ODLinkASTODLinkQualifierCoCo { + + public static final String ERROR_OBJECT_QUALIFIER = + "0x0D007: The qualifier of a link must not be an object."; + + public static final String ERROR_LIST_QUALIFIER = + "0x0D00E: The qualifier of a link must not be a list."; + + public static final String ERROR_MAP_QUALIFIER = + "0x0D00F: The qualifier of a link must not be a map."; + + @Override + public void check(ASTODLinkQualifier node) { + if (!node.isPresentODValue()) { + return; + } + ASTODValue value = node.getODValue(); + if (value instanceof ASTODObject) { + Log.error(ERROR_OBJECT_QUALIFIER, node.get_SourcePositionStart(), + node.get_SourcePositionEnd()); + } + else if (value instanceof ASTODList) { + Log.error(ERROR_LIST_QUALIFIER, node.get_SourcePositionStart(), + node.get_SourcePositionEnd()); + } + else if (value instanceof ASTODMap) { + Log.error(ERROR_MAP_QUALIFIER, node.get_SourcePositionStart(), + node.get_SourcePositionEnd()); + } + } + +} diff --git a/src/main/java/de/monticore/od4development/_symboltable/CDRoleAdapter.java b/src/main/java/de/monticore/od4development/_symboltable/CDRoleAdapter.java index db4bd4eb..d28d287f 100644 --- a/src/main/java/de/monticore/od4development/_symboltable/CDRoleAdapter.java +++ b/src/main/java/de/monticore/od4development/_symboltable/CDRoleAdapter.java @@ -11,8 +11,6 @@ */ public class CDRoleAdapter extends FieldSymbol { - - protected FieldSymbol original; protected LinkCardinality cardinality; @@ -63,7 +61,7 @@ public enum LinkCardinality { STAR("[*]"), PLUS("[+]"); - protected String val; + private final String val; LinkCardinality(String val) { this.val = val; @@ -73,7 +71,7 @@ public static LinkCardinality fromValue(String value) { Optional res = Arrays.stream(values()) .filter(c -> c.val.equals(value)) .findAny(); - return res.isPresent() ? res.get() : ONE; + return res.orElse(ONE); } } diff --git a/src/main/java/de/monticore/od4development/_symboltable/OD4DevelopmentScopesGenitor.java b/src/main/java/de/monticore/od4development/_symboltable/OD4DevelopmentScopesGenitor.java index 648ce1b5..e7053619 100644 --- a/src/main/java/de/monticore/od4development/_symboltable/OD4DevelopmentScopesGenitor.java +++ b/src/main/java/de/monticore/od4development/_symboltable/OD4DevelopmentScopesGenitor.java @@ -2,9 +2,9 @@ package de.monticore.od4development._symboltable; import com.google.common.base.Preconditions; +import de.monticore.od4development.OD4DevelopmentMill; import de.monticore.odbasis._ast.ASTODArtifact; import de.monticore.symboltable.ImportStatement; -import de.se_rwth.commons.logging.Log; import java.util.ArrayList; @@ -12,7 +12,7 @@ public class OD4DevelopmentScopesGenitor extends OD4DevelopmentScopesGenitorTOP public IOD4DevelopmentArtifactScope createFromAST (ASTODArtifact rootNode) { Preconditions.checkNotNull(rootNode, "0xA7004x78995 Error by creating of the OD4DevelopmentScopesGenitor symbol table: top ast node is null"); - IOD4DevelopmentArtifactScope artifactScope = de.monticore.od4development.OD4DevelopmentMill.artifactScope(); + IOD4DevelopmentArtifactScope artifactScope = OD4DevelopmentMill.artifactScope(); // set package if (rootNode.isPresentMCPackageDeclaration()) { @@ -34,6 +34,7 @@ public IOD4DevelopmentArtifactScope createFromAST (ASTODArtifact rootNode) { initArtifactScopeHP1(artifactScope); rootNode.accept(getTraverser()); initArtifactScopeHP2(artifactScope); + scopeStack.remove(artifactScope); return artifactScope; } diff --git a/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafo.java b/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafo.java new file mode 100644 index 00000000..7efa2d3b --- /dev/null +++ b/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafo.java @@ -0,0 +1,44 @@ +/* + * (c) https://github.com/MontiCore/monticore + */ + +/* + * (c) https://github.com/MontiCore/monticore + */ + +package de.monticore.od4development.trafo; + +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development._visitor.OD4DevelopmentTraverser; +import de.monticore.odbasis._ast.ASTODArtifact; + +public class OD4DevelopmentAttributeValueCompositionTrafo { + + protected OD4DevelopmentTraverser traverser; + + public OD4DevelopmentAttributeValueCompositionTrafo() { + this.traverser = OD4DevelopmentMill.inheritanceTraverser(); + + init(traverser); + } + + public static void init(OD4DevelopmentTraverser traverser) { + final OD4DevelopmentAttributeValueCompositionTrafoExtension trafo = + new OD4DevelopmentAttributeValueCompositionTrafoExtension(); + traverser.add4ODBasis(trafo); + traverser.add4ODAttribute(trafo); + traverser.add4ODLink(trafo); + } + + public OD4DevelopmentTraverser getTraverser() { + return traverser; + } + + public void setTraverser(OD4DevelopmentTraverser traverser) { + this.traverser = traverser; + } + + public void transform(ASTODArtifact diagram) { + diagram.accept(getTraverser()); + } +} diff --git a/src/main/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafoExtension.java b/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafoExtension.java similarity index 67% rename from src/main/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafoExtension.java rename to src/main/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafoExtension.java index 2e3b5079..c9fdc221 100644 --- a/src/main/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafoExtension.java +++ b/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafoExtension.java @@ -2,9 +2,8 @@ * (c) https://github.com/MontiCore/monticore */ -package de.monticore.od4data.trafo; +package de.monticore.od4development.trafo; -import de.monticore.od4data.OD4DataMill; import de.monticore.odattribute._ast.ASTODList; import de.monticore.odattribute._ast.ASTODMap; import de.monticore.odattribute._ast.ASTODMapElement; @@ -13,28 +12,23 @@ import de.monticore.odbasis._ast.ASTODNamedObject; import de.monticore.odbasis._ast.ASTODObject; import de.monticore.odbasis._ast.ASTODValue; -import de.monticore.odlink.ODLinkMill; import de.monticore.odlink._ast.ASTODLink; import de.monticore.odlink.trafo.ODLinkAttributeValueCompositionTrafo; import java.util.ArrayList; import java.util.List; -public class OD4DataAttributeValueCompositionTrafoExtension +public class OD4DevelopmentAttributeValueCompositionTrafoExtension extends ODLinkAttributeValueCompositionTrafo implements ODAttributeVisitor2 { @Override public void endVisit(ASTODObject node) { for (ASTODAttribute attribute : node.getODAttributeList()) { if (attribute.isPresentODValue()) { - if (OD4DataMill.typeDispatcher().isODAttributeASTODList(attribute.getODValue())) { - ASTODList list = - OD4DataMill.typeDispatcher().asODAttributeASTODList(attribute.getODValue()); + if (attribute.getODValue() instanceof ASTODList list) { List valueToRemove = new ArrayList<>(); for (ASTODValue value : list.getODValueList()) { - if (OD4DataMill.typeDispatcher().isODBasisASTODNamedObject(value)) { - ASTODNamedObject namedObject = - ODLinkMill.typeDispatcher().asODBasisASTODNamedObject(value); + if (value instanceof ASTODNamedObject namedObject && !isAnonymousParent(node, value)) { valueToRemove.add(value); objectsToMove.add(namedObject); @@ -48,14 +42,11 @@ public void endVisit(ASTODObject node) { attributesToRemove.add(attribute); } } - else if (OD4DataMill.typeDispatcher().isODAttributeASTODMap(attribute.getODValue())) { - ASTODMap map = OD4DataMill.typeDispatcher().asODAttributeASTODMap(attribute.getODValue()); + else if (attribute.getODValue() instanceof ASTODMap map) { List mapElementsToRemove = new ArrayList<>(); for (ASTODMapElement mapElement : map.getODMapElementList()) { - - if (OD4DataMill.typeDispatcher().isODBasisASTODNamedObject(mapElement.getVal())) { - ASTODNamedObject namedObject = - ODLinkMill.typeDispatcher().asODBasisASTODNamedObject(mapElement.getVal()); + if (mapElement.getVal() instanceof ASTODNamedObject namedObject + && !isAnonymousParent(node, mapElement.getVal())) { mapElementsToRemove.add(mapElement); objectsToMove.add(namedObject); diff --git a/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafo.java b/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafo.java new file mode 100644 index 00000000..351d5a5c --- /dev/null +++ b/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafo.java @@ -0,0 +1,39 @@ +/* + * (c) https://github.com/MontiCore/monticore + */ + +package de.monticore.od4development.trafo; + +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development._visitor.OD4DevelopmentTraverser; +import de.monticore.odbasis._ast.ASTODArtifact; + +public class OD4DevelopmentDeAnonymizeObjectsTrafo { + + protected OD4DevelopmentTraverser traverser; + + public OD4DevelopmentDeAnonymizeObjectsTrafo() { + this.traverser = OD4DevelopmentMill.inheritanceTraverser(); + + init(traverser); + } + + public static void init(OD4DevelopmentTraverser traverser) { + final OD4DevelopmentDeAnonymizeObjectsTrafoExtension trafo = + new OD4DevelopmentDeAnonymizeObjectsTrafoExtension(); + traverser.add4ODBasis(trafo); + traverser.add4ODAttribute(trafo); + } + + public OD4DevelopmentTraverser getTraverser() { + return traverser; + } + + public void setTraverser(OD4DevelopmentTraverser traverser) { + this.traverser = traverser; + } + + public void transform(ASTODArtifact diagram) { + diagram.accept(getTraverser()); + } +} diff --git a/src/main/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafoExtension.java b/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafoExtension.java similarity index 71% rename from src/main/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafoExtension.java rename to src/main/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafoExtension.java index cf1ee8b7..9db126f7 100644 --- a/src/main/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafoExtension.java +++ b/src/main/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafoExtension.java @@ -2,9 +2,8 @@ * (c) https://github.com/MontiCore/monticore */ -package de.monticore.od4data.trafo; +package de.monticore.od4development.trafo; -import de.monticore.od4data.OD4DataMill; import de.monticore.odattribute._ast.ASTODList; import de.monticore.odattribute._ast.ASTODMap; import de.monticore.odattribute._ast.ASTODMapElement; @@ -31,21 +30,19 @@ * * will be transformed to *

- *   __a_anonymous_0:A {
- *     foo = __b_anonymous_0:B {};
+ *   __a_anonymous_1:A {
+ *     foo = __b_anonymous_1:B {};
  *   };
  * 
*/ -public class OD4DataDeAnonymizeObjectsTrafoExtension extends ODBasisDeAnonymizeObjectsTrafo +public class OD4DevelopmentDeAnonymizeObjectsTrafoExtension extends ODBasisDeAnonymizeObjectsTrafo implements ODAttributeVisitor2 { @Override public void endVisit(ASTODList node) { for (int i = 0; i < node.getODValueList().size(); i++) { ASTODValue value = node.getODValue(i); - if (OD4DataMill.typeDispatcher().isODBasisASTODAnonymousObject(value)) { - ASTODAnonymousObject anonymousObject = - OD4DataMill.typeDispatcher().asODBasisASTODAnonymousObject(value); + if (value instanceof ASTODAnonymousObject anonymousObject) { ASTODNamedObject namedObject = copyToNamedObject(anonymousObject); node.setODValue(i, namedObject); } @@ -58,9 +55,7 @@ public void endVisit(ASTODMap node) { ASTODMapElement mapElement = node.getODMapElement(i); ASTODValue value = mapElement.getVal(); - if (OD4DataMill.typeDispatcher().isODBasisASTODAnonymousObject(value)) { - ASTODAnonymousObject anonymousObject = - OD4DataMill.typeDispatcher().asODBasisASTODAnonymousObject(value); + if (value instanceof ASTODAnonymousObject anonymousObject) { ASTODNamedObject namedObject = copyToNamedObject(anonymousObject); mapElement.setVal(namedObject); } diff --git a/src/main/java/de/monticore/od4report/OD4ReportTool.java b/src/main/java/de/monticore/od4report/OD4ReportTool.java index 081f1fa4..19290071 100644 --- a/src/main/java/de/monticore/od4report/OD4ReportTool.java +++ b/src/main/java/de/monticore/od4report/OD4ReportTool.java @@ -1,16 +1,15 @@ /* (c) https://github.com/MontiCore/monticore */ package de.monticore.od4report; -//import com.sun.tools.javac.code.Symbol; import de.monticore.grammar.grammar._symboltable.AdditionalAttributeSymbolDeSer; import de.monticore.grammar.grammar._symboltable.MCGrammarSymbolDeSer; import de.monticore.grammar.grammar._symboltable.ProdSymbolDeSer; import de.monticore.grammar.grammar._symboltable.RuleComponentSymbolDeSer; import de.monticore.io.paths.MCPath; import de.monticore.javalight._symboltable.JavaMethodSymbolDeSer; +import de.monticore.od4report._prettyprint.OD4ReportFullPrettyPrinter; import de.monticore.od4report._symboltable.IOD4ReportArtifactScope; import de.monticore.od4report._symboltable.IOD4ReportGlobalScope; -import de.monticore.od4report._prettyprint.OD4ReportFullPrettyPrinter; import de.monticore.odbasis._ast.ASTODArtifact; import de.monticore.prettyprint.IndentPrinter; import de.monticore.statements.mclowlevelstatements._symboltable.LabelSymbolDeSer; @@ -20,182 +19,231 @@ import de.monticore.symbols.oosymbols._symboltable.MethodSymbolDeSer; import de.monticore.symbols.oosymbols._symboltable.OOTypeSymbolDeSer; import de.se_rwth.commons.logging.Log; -import org.apache.commons.cli.*; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.Set; +/** + * OD4Report tool for parsing, checking, pretty printing, and exporting OD4Report models. + */ public class OD4ReportTool extends OD4ReportToolTOP { - protected static final String PARSE_SUCCESSFUL = "Successfully parsed %s\n"; + protected static final String PARSE_SUCCESSFUL = "Successfully parsed %s"; protected static final String CHECK_SUCCESSFUL = - "Successfully checked the CoCos for class " + "diagram %s\n"; + "Successfully checked the CoCos for object diagram %s"; + + protected static final String CHECK_ERROR = "0x0D023 Error while processing the object diagram"; + + protected static final String COCO_OPTION_INVALID = + "0x0D024 Invalid argument '%s' for option -c. Allowed values are: intra, inter."; + + protected static final String COCO_OPTION_TOO_MANY_ARGS = + "0x0D025 Option -c accepts at most one argument: intra or inter."; + + protected static final String WARN_NO_SYMBOLTYPES_ARGS = + "No arguments provided for parameter -symboltypes. Skipping custom symbol deserializer mapping."; + + protected static final String WARN_ODD_SYMBOLTYPES_ARGS = + "Odd number of arguments for parameter -symboltypes! Ignoring last argument."; + + protected static final String WARN_INVALID_SYMBOL_DESER = + "%s is not a valid Symbol Deserializer and has been assumed as TypeSymbolDeSer"; - protected static final String CHECK_ERROR = "Error while parsing or CoCo checking"; + protected static final String STEXPORT_SUCCESSFUL = "Creation of symbol file %s successful"; - protected static final String STEXPORT_SUCCESSFUL = "Creation of symbol file %s successful\n"; + protected static final String INPUT_FILE_NOT_EXISTENT = "0x0D022 Input file '%s' does not exist"; + + protected static final String INPUT_OPTION_NOT_PRESENT = "0x0D027 No input file given. Use -i to declare the tool input."; + + protected static final String REPORT_OPTION_NOT_SUPPORTED = + "0x0D029 Option -r is not supported by the OD4Report tool."; - protected static final String INPUT_FILE_NOT_EXISTENT = "Input file '%s' does not exist\n"; /*=================================================================*/ /* Part 1: Handling the arguments and options /*=================================================================*/ - + /** - * Processes user input from command line and delegates to the corresponding tools. + * Processes CLI arguments and executes parsing, symbol table creation, CoCo checks, pretty + * printing and symbol export. + *
+   * 
    + *
  • {@code -h}/{@code --help}: prints the help dialog and exits.
  • + *
  • {@code -v}/{@code --version}: prints version information and exits.
  • + *
  • {@code -i}/{@code --input }: sets the mandatory input OD file to parse.
  • + *
  • {@code -symtypes}/{@code --symboltypes ...}: registers custom symbol + * deserializers for foreign-language symbols.
  • + *
  • {@code -path }: sets one or more symbol path entries for imported symbols.
  • + *
  • {@code -c}/{@code --coco [intra|inter]}: runs all CoCos by default, or only + * intra-model or inter-model CoCos when specified.
  • + *
  • {@code -pp}/{@code --prettyprint [file]}: pretty prints the AST to stdout or the + * optional file.
  • + *
  • {@code -s}/{@code --symboltable [file]}: writes the symbol table to the optional file + * or to the default location.
  • + *
  • {@code --stacktrace}: prints stack traces for errors.
  • + *
  • {@code -r}/{@code --report}: generated standard option, not supported by this tool.
  • + *
+ *
* - * @param args The input parameters for configuring the OD tool. + * @param cmd command line */ @Override - public void run(String[] args) { - init(); - Options options = initOptions(); - - try { - // create CLI parser and parse input options from command line - CommandLineParser cliparser = new DefaultParser(); - CommandLine cmd = cliparser.parse(options, args); - - // help: when --help - if (cmd.hasOption("h")) { - printHelp(options); - // do not continue, when help is printed - return; - } + public void doRun(CommandLine cmd) { + if (cmd.hasOption("r")) { + Log.error(REPORT_OPTION_NOT_SUPPORTED); + return; + } - // if -i input is missing: also print help and stop - if (!cmd.hasOption("i")) { - printHelp(options); - // do not continue, when help is printed - return; + // if -i input is missing: also print help and stop + if (!cmd.hasOption("i")) { + Log.error(INPUT_OPTION_NOT_PRESENT); + return; + } + + // don't output to stdout when the prettyprint is output to stdout + final boolean doPrintToStdOut = !(cmd.hasOption("pp") && cmd.getOptionValue("pp") == null); + + // if -symbols is set: Add symbol types from file to global scope + if (cmd.hasOption("symtypes")) { + String[] cmdVals = cmd.getOptionValues("symtypes"); + if (cmdVals == null || cmdVals.length == 0) { + Log.warn(WARN_NO_SYMBOLTYPES_ARGS); } - - - // don't output to stdout when the prettyprint is output to stdout - final boolean doPrintToStdOut = !(cmd.hasOption("pp") && cmd.getOptionValue("pp") == null); - - // if -symbols is set: Add symbol types from file to global scope - if (cmd.hasOption("symtypes")) { - String[] cmdVals = cmd.getOptionValues("symboltypes"); - if(cmdVals.length % 2 != 0){ - Log.warn("Odd number of arguments for parameter -symboltypes! Ignoring last argument."); + else { + if (cmdVals.length % 2 != 0) { + Log.warn(WARN_ODD_SYMBOLTYPES_ARGS); } - OD4ReportMill.reset(); - OD4ReportMill.init(); - OD4ReportMill.globalScope().clear(); - BasicSymbolsMill.initializePrimitives(); + IOD4ReportGlobalScope gs = OD4ReportMill.globalScope(); for (int i = 0; i < cmdVals.length - 1; i += 2) { - switch(cmdVals[i+1]){ - case "TypeSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new TypeSymbolDeSer()); break; - case "DiagramSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new DiagramSymbolDeSer()); break; - case "FunctionSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new FunctionSymbolDeSer()); break; - case "TypeVarSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new TypeVarSymbolDeSer()); break; - case "VariableSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new VariableSymbolDeSer()); break; - case "FieldSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new FieldSymbolDeSer()); break; - case "MethodSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new MethodSymbolDeSer()); break; - case "OOTypeSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new OOTypeSymbolDeSer()); break; - case "MCGrammarSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new MCGrammarSymbolDeSer()); break; - case "AdditionalAttributeSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new AdditionalAttributeSymbolDeSer()); break; - case "ProdSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new ProdSymbolDeSer()); break; - case "RuleComponentSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new RuleComponentSymbolDeSer()); break; - case "JavaMethodSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new JavaMethodSymbolDeSer()); break; - case "LabelSymbolDeSer": gs.putSymbolDeSer(cmdVals[i], new LabelSymbolDeSer()); break; - default: Log.warn(cmdVals[i+1] + " is not a valid Symbol Deserializer and has been assumed as TypeSymbolDeSer"); - gs.putSymbolDeSer(cmdVals[i], new TypeSymbolDeSer()); break; + switch (cmdVals[i + 1]) { + case "TypeSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new TypeSymbolDeSer()); + case "DiagramSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new DiagramSymbolDeSer()); + case "FunctionSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new FunctionSymbolDeSer()); + case "TypeVarSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new TypeVarSymbolDeSer()); + case "VariableSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new VariableSymbolDeSer()); + case "FieldSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new FieldSymbolDeSer()); + case "MethodSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new MethodSymbolDeSer()); + case "OOTypeSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new OOTypeSymbolDeSer()); + case "MCGrammarSymbolDeSer" -> + gs.putSymbolDeSer(cmdVals[i], new MCGrammarSymbolDeSer()); + case "AdditionalAttributeSymbolDeSer" -> + gs.putSymbolDeSer(cmdVals[i], new AdditionalAttributeSymbolDeSer()); + case "ProdSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new ProdSymbolDeSer()); + case "RuleComponentSymbolDeSer" -> + gs.putSymbolDeSer(cmdVals[i], new RuleComponentSymbolDeSer()); + case "JavaMethodSymbolDeSer" -> + gs.putSymbolDeSer(cmdVals[i], new JavaMethodSymbolDeSer()); + case "LabelSymbolDeSer" -> gs.putSymbolDeSer(cmdVals[i], new LabelSymbolDeSer()); + default -> { + Log.warn(String.format(WARN_INVALID_SYMBOL_DESER, cmdVals[i + 1])); + gs.putSymbolDeSer(cmdVals[i], new TypeSymbolDeSer()); + } } } } - - // if -path is set: save the model paths - MCPath symbolPath = new MCPath(); - if (cmd.hasOption("path")) { - String[] paths = cmd.getOptionValues("path"); - Arrays.stream(paths).forEach(p -> symbolPath.addEntry(Paths.get(p))); - } - OD4ReportMill.globalScope().setSymbolPath(symbolPath); - - // parse input file - String modelFile = cmd.getOptionValue("i"); - Path modelFilePath = Paths.get(modelFile); - if (!modelFilePath.toFile().exists()) { - System.out.printf(INPUT_FILE_NOT_EXISTENT, modelFile); - return; - } - - ASTODArtifact astodArtifact = parse(modelFile); - - if (doPrintToStdOut) { - System.out.printf(PARSE_SUCCESSFUL, astodArtifact.getObjectDiagram().getName()); - } - - // -option check cocos - Set cocoOptionValue = new LinkedHashSet<>(); - if (cmd.hasOption("c") && cmd.getOptionValues("c") != null) { - cocoOptionValue.addAll(Arrays.asList(cmd.getOptionValues("c"))); + } + + // if -path is set: save the model paths + MCPath symbolPath = new MCPath(); + if (cmd.hasOption("path")) { + String[] paths = cmd.getOptionValues("path"); + Arrays.stream(paths).forEach(p -> symbolPath.addEntry(Paths.get(p))); + } + OD4ReportMill.globalScope().setSymbolPath(symbolPath); + + // parse input file + String modelFile = cmd.getOptionValue("i"); + Path modelFilePath = Paths.get(modelFile); + if (!modelFilePath.toFile().exists()) { + Log.error(String.format(INPUT_FILE_NOT_EXISTENT, modelFile)); + return; + } + + ASTODArtifact astodArtifact = parse(modelFile); + + if (doPrintToStdOut) { + Log.info(String.format(PARSE_SUCCESSFUL, astodArtifact.getObjectDiagram().getName()), + getClass().getName()); + } + + // create symbol table (primitives are added once, as they are not checked for duplicates) + BasicSymbolsMill.initializePrimitives(); + IOD4ReportArtifactScope oD4ReportArtifactScope = + OD4ReportToolAPI.createSymbolTable(astodArtifact); + + boolean checkTypes = cmd.hasOption("s") || (cmd.hasOption("c") && ( + cmd.getOptionValue("c") == null || cmd.getOptionValue("c").equals("inter"))); + OD4ReportToolAPI.completeSymbolTable(astodArtifact, checkTypes); + + // run cocos + if (cmd.hasOption("c")) { + String[] cocoArgs = cmd.getOptionValues("c"); + if (cocoArgs == null || cocoArgs.length == 0) { + OD4ReportToolAPI.runAllCoCos(astodArtifact); } - - // create symbol table - IOD4ReportArtifactScope oD4ReportArtifactScope = OD4ReportToolAPI.createSymbolTable( - astodArtifact, !cocoOptionValue.contains("intra")); - - // run cocos - if (cmd.hasOption("c")) { - if (cocoOptionValue.contains("intra")) { + else if (cocoArgs.length == 1) { + String cocoArg = cocoArgs[0]; + if ("intra".equals(cocoArg)) { OD4ReportToolAPI.runAllIntraCoCos(astodArtifact); } - else { - OD4ReportToolAPI.runAllCoCos(astodArtifact); + else if ("inter".equals(cocoArg)) { + OD4ReportToolAPI.runAllInterCoCos(astodArtifact); } - - if (doPrintToStdOut) { - if (Log.getErrorCount() == 0) { - System.out.printf(CHECK_SUCCESSFUL, astodArtifact.getObjectDiagram().getName()); - } - else { - System.out.println(CHECK_ERROR); - return; - } + else { + Log.error(String.format(COCO_OPTION_INVALID, cocoArg)); + return; } } - - // -option pretty print - if (cmd.hasOption("pp")) { - String path = cmd.getOptionValue("pp", StringUtils.EMPTY); - prettyPrint(astodArtifact, path); + else { + Log.error(COCO_OPTION_TOO_MANY_ARGS); + return; } - - // -option pretty print symboltable - if (cmd.hasOption("s")) { - Path symTabPath = storeSymTab(oD4ReportArtifactScope, modelFilePath, cmd.getOptionValue("s")); - if (doPrintToStdOut) { - System.out.printf(STEXPORT_SUCCESSFUL, symTabPath.toAbsolutePath()); + + if (doPrintToStdOut) { + if (Log.getErrorCount() == 0) { + Log.info(String.format(CHECK_SUCCESSFUL, astodArtifact.getObjectDiagram().getName()), + getClass().getName()); + } + else { + Log.error(CHECK_ERROR); + return; } } } - catch (ParseException e) { - // an unexpected error from the apache CLI parser: - Log.error("0xA7110 Could not process CLI parameters: " + e.getMessage()); + + // -option pretty print + if (cmd.hasOption("pp")) { + String path = cmd.getOptionValue("pp", StringUtils.EMPTY); + prettyPrint(astodArtifact, path); + } + + // -option pretty print symboltable + if (cmd.hasOption("s")) { + Path symTabPath = storeSymTab(oD4ReportArtifactScope, modelFilePath, cmd.getOptionValue("s")); + if (doPrintToStdOut) { + Log.info(String.format(STEXPORT_SUCCESSFUL, symTabPath.toAbsolutePath()), + getClass().getName()); + } } - } - + /*=================================================================*/ /* Part 2: Executing arguments /*=================================================================*/ - + /** - * Prints the contents of the OD-AST to stdout or a specified file. + * Pretty prints the OD artifact either to stdout or to the given target file. * - * @param astodArtifact The OD-AST to be pretty printed - * @param file The target file name for printing the OD artifact. If empty, the content - * is printed to stdout instead + * @param astodArtifact parsed OD artifact + * @param file target file path; empty means stdout */ @Override public void prettyPrint(ASTODArtifact astodArtifact, String file) { @@ -204,92 +252,68 @@ public void prettyPrint(ASTODArtifact astodArtifact, String file) { String od = pp.prettyprint(astodArtifact); print(od, file); } - + /*=================================================================*/ /* Part 3: Defining the options incl. help-texts /*=================================================================*/ - + /** * Initializes the standard CLI options for the OD tool. * - * @return The CLI options with arguments. + * @return configured {@link Options} instance */ @Override public Options addStandardOptions(Options options) { - // help dialog - options.addOption(Option.builder("h").longOpt("help").desc("Prints this help dialog").build()); - - // parse input file - options.addOption(Option.builder("i") - .longOpt("input") - .argName("file") - .hasArg() - .desc("Reads the source file (mandatory) and parses the contents as an object diagram") - .build()); - - // Read file to add symboltypes to global scope - options.addOption(Option.builder("symtypes") - .longOpt("symboltypes") - .argName("string") - .optionalArg(true) - .hasArgs() - .desc("Symbol type followed by deser (repeat for multiple) to be able to resolve smbols from foreign languages.") - .build()); - - // model paths - options.addOption(Option.builder("path") - .argName("dirlist") - .hasArgs() - .desc("Sets the artifact path for imported symbols") - .build()); - - // pretty print OD - options.addOption(Option.builder("pp") - .longOpt("prettyprint") - .argName("file") - .optionalArg(true) - .numberOfArgs(1) - .desc("Prints the OD-AST to stdout or the specified file (optional)") - .build()); - - // print OD symtab - options.addOption(Option.builder("s") - .longOpt("symboltable") - .argName("file") - .optionalArg(true) - .numberOfArgs(1) - .desc("Stores the symbol table of the OD. The default value is `{ODName}.odsym`.") - .build()); + super.addStandardOptions(options); + + // print OD symtab: replaces the generated option, as the file is optional here + options.addOption( + Option.builder("s").longOpt("symboltable").argName("file").optionalArg(true).numberOfArgs(1) + .desc("Stores the symbol table of the OD. The default value is `{ODName}.odsym`.") + .get()); + + // reports: generated standard option, rejected in doRun + options.addOption(Option.builder("r").longOpt("report").argName("dir").hasArg() + .desc("Not supported by this tool").get()); + return options; } - + @Override public Options addAdditionalOptions(Options options) { + // Read file to add symboltypes to global scope + options.addOption( + Option.builder("symtypes").longOpt("symboltypes").argName("string").optionalArg(true) + .hasArgs().desc( + "Symbol type followed by deser (repeat for multiple) to be able to resolve smbols from foreign languages.") + .get()); + // check cocos - options.addOption(Option.builder("c") - .longOpt("coco") - .optionalArg(true) - .numberOfArgs(3) - .desc("Checks the CoCos for the input. Optional arguments are:\n" - + "-c intra to check only the" + " intra-model CoCos,\n" - + "-c inter checks also inter-model CoCos,\n" + "-c type " - + "(default) checks all CoCos.") - .build()); + options.addOption(Option.builder("c").longOpt("coco").optionalArg(true).numberOfArgs(1).desc( + """ + Checks the CoCos for the input. Optional arguments are: + -c intra to check only the intra-model CoCos, + -c inter to check only inter-model CoCos. + Without an argument, all CoCos are checked. + """.stripIndent()).get()); return options; } /** - * prints the symboltable of the given scope out to a file + * Writes the symbol table of the given scope to a file. * - * @param as symboltable to store + * @param as symbol table to store * @param modelPath location of the file containing the OD * @param symTabPath location of the file or directory containing the printed table + * @return the resolved target path */ public Path storeSymTab(IOD4ReportArtifactScope as, Path modelPath, String symTabPath) { Path targetPath; if (symTabPath == null || symTabPath.isBlank()) { String symTabName = FilenameUtils.getBaseName(modelPath.toString()) + ".odsym"; - targetPath = modelPath.getParent().resolve(symTabName); + Path modelParent = modelPath.getParent(); + // handle relative input files that do not have an explicit parent directory + targetPath = modelParent != null ? modelParent.resolve(symTabName) : Paths.get(symTabName); } else { targetPath = Paths.get(symTabPath); @@ -301,5 +325,5 @@ public Path storeSymTab(IOD4ReportArtifactScope as, Path modelPath, String symTa this.storeSymbols(as, targetPath.toString()); return targetPath; } - + } diff --git a/src/main/java/de/monticore/od4report/OD4ReportToolAPI.java b/src/main/java/de/monticore/od4report/OD4ReportToolAPI.java index 2c132b58..bd15e7f7 100644 --- a/src/main/java/de/monticore/od4report/OD4ReportToolAPI.java +++ b/src/main/java/de/monticore/od4report/OD4ReportToolAPI.java @@ -6,7 +6,9 @@ import de.monticore.od4report._parser.OD4ReportParser; import de.monticore.od4report._symboltable.IOD4ReportArtifactScope; import de.monticore.od4report._symboltable.OD4ReportScopesGenitorDelegator; +import de.monticore.od4report._visitor.OD4ReportTraverser; import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.odbasis._symboltable.ODBasisSymbolTableCompleter; import de.se_rwth.commons.logging.Log; import org.antlr.v4.runtime.RecognitionException; @@ -43,15 +45,19 @@ public static ASTODArtifact parse(String model) { * @param ast ODArtifact AST * @return SymbolTable created from AST */ - public static IOD4ReportArtifactScope createSymbolTable(ASTODArtifact ast, boolean checkTypes) { + public static IOD4ReportArtifactScope createSymbolTable(ASTODArtifact ast) { OD4ReportScopesGenitorDelegator od4ReportScopesGenitorDelegator = OD4ReportMill.scopesGenitorDelegator(); - od4ReportScopesGenitorDelegator.setCheckTypes(checkTypes); return od4ReportScopesGenitorDelegator.createFromAST(ast); } - - public static IOD4ReportArtifactScope createSymbolTable(ASTODArtifact ast) { - return OD4ReportToolAPI.createSymbolTable(ast, false); + + public static void completeSymbolTable(ASTODArtifact ast, boolean checkObjectTypes) { + OD4ReportTraverser traverser = OD4ReportMill.inheritanceTraverser(); + + ODBasisSymbolTableCompleter odbasisSymbolTableCompleter = new ODBasisSymbolTableCompleter(checkObjectTypes); + traverser.add4ODBasis(odbasisSymbolTableCompleter); + odbasisSymbolTableCompleter.setTraverser(traverser); + ast.accept(traverser); } public static void runAllCoCos(ASTODArtifact ast) { @@ -62,4 +68,8 @@ public static void runAllIntraCoCos(ASTODArtifact ast) { new OD4ReportCoCos().getCheckerForAllIntraCoCos().checkAll(ast); } + public static void runAllInterCoCos(ASTODArtifact ast) { + new OD4ReportCoCos().getCheckerForAllInterCoCos().checkAll(ast); + } + } diff --git a/src/main/java/de/monticore/od4report/_cocos/OD4ReportCoCos.java b/src/main/java/de/monticore/od4report/_cocos/OD4ReportCoCos.java index c542f10b..fc38b7db 100644 --- a/src/main/java/de/monticore/od4report/_cocos/OD4ReportCoCos.java +++ b/src/main/java/de/monticore/od4report/_cocos/OD4ReportCoCos.java @@ -3,15 +3,17 @@ package de.monticore.od4report._cocos; import de.monticore.dateliterals._cocos.DateLiteralsCoCos; -import de.monticore.odbasis._cocos.ODBasicsCoCos; +import de.monticore.od4development._cocos.link.ValidLinkQualifierCoCo; +import de.monticore.odbasis._cocos.ODBasisCoCos; import de.monticore.odlink._cocos.ODLinkCoCos; public class OD4ReportCoCos { public OD4ReportCoCoChecker getCheckerForAllIntraCoCos() { final OD4ReportCoCoChecker checker = new OD4ReportCoCoChecker(); - checker.addChecker(new ODBasicsCoCos().getCheckerForAllIntraCoCos()); + checker.addChecker(new ODBasisCoCos().getCheckerForAllIntraCoCos()); checker.addChecker(new ODLinkCoCos().getCheckerForAllIntraCoCos()); + checker.addCoCo(new ValidLinkQualifierCoCo()); checker.addChecker(new DateLiteralsCoCos().getCheckerForAllCoCos()); return checker; @@ -19,9 +21,16 @@ public OD4ReportCoCoChecker getCheckerForAllIntraCoCos() { public OD4ReportCoCoChecker getCheckerForAllCoCos() { final OD4ReportCoCoChecker checker = new OD4ReportCoCoChecker(); - checker.addChecker(new ODBasicsCoCos().getCheckerForAllCoCos()); - checker.addChecker(new ODLinkCoCos().getCheckerForAllCoCos()); - checker.addChecker(new DateLiteralsCoCos().getCheckerForAllCoCos()); + checker.addChecker(getCheckerForAllIntraCoCos()); + checker.addChecker(getCheckerForAllInterCoCos()); + + return checker; + } + + public OD4ReportCoCoChecker getCheckerForAllInterCoCos() { + final OD4ReportCoCoChecker checker = new OD4ReportCoCoChecker(); + checker.addChecker(new ODBasisCoCos().getCheckerForAllInterCoCos()); + checker.addChecker(new ODLinkCoCos().getCheckerForAllInterCoCos()); return checker; } diff --git a/src/main/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitor.java b/src/main/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitor.java index 21da41ff..fe263f97 100644 --- a/src/main/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitor.java +++ b/src/main/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitor.java @@ -5,7 +5,6 @@ import de.monticore.od4report.OD4ReportMill; import de.monticore.od4report._ast.ASTODReportObject; import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.odbasis._symboltable.ODBasisScopesGenitor; import de.monticore.symbols.basicsymbols._symboltable.VariableSymbol; import de.monticore.symbols.basicsymbols._symboltable.VariableSymbolBuilder; import de.monticore.symboltable.ImportStatement; @@ -14,17 +13,11 @@ import java.util.ArrayList; public class OD4ReportScopesGenitor extends OD4ReportScopesGenitorTOP { - - private ODBasisScopesGenitor odBasisScopesGenitor = new ODBasisScopesGenitor(); - + public OD4ReportScopesGenitor() { super(); } - - public void setCheckTypes(boolean checkTypes) { - odBasisScopesGenitor.setCheckTypes(checkTypes); - } - + @Override public void visit(ASTODReportObject astodReportObject) { VariableSymbol symbol = create_ODReportObject(astodReportObject).build(); @@ -38,17 +31,11 @@ public void visit(ASTODReportObject astodReportObject) { astodReportObject.setSymbol(symbol); astodReportObject.setEnclosingScope(symbol.getEnclosingScope()); } - - @Override - public void endVisit(ASTODReportObject astodReportObject) { - super.endVisit(astodReportObject); - odBasisScopesGenitor.endVisit(astodReportObject); - } - + private VariableSymbolBuilder create_ODReportObject(ASTODReportObject astodReportObject) { return OD4ReportMill.variableSymbolBuilder().setName(astodReportObject.getName()); } - + @Override public IOD4ReportArtifactScope createFromAST(ASTODArtifact rootNode) { Preconditions.checkNotNull(rootNode, @@ -67,9 +54,13 @@ public IOD4ReportArtifactScope createFromAST(ASTODArtifact rootNode) { .forEach(i -> artifactScope.addImports(new ImportStatement(i.getQName(), i.isStar()))); artifactScope.setName(rootNode.getObjectDiagram().getName()); + artifactScope.setAstNode(rootNode); putOnStack(artifactScope); + initArtifactScopeHP1(artifactScope); rootNode.accept(getTraverser()); + initArtifactScopeHP2(artifactScope); + scopeStack.remove(artifactScope); return artifactScope; } - + } diff --git a/src/main/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitorDelegator.java b/src/main/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitorDelegator.java deleted file mode 100644 index c4180f5e..00000000 --- a/src/main/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitorDelegator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore.od4report._symboltable; - -import de.monticore.od4report.OD4ReportMill; -import de.monticore.odbasis.ODBasisMill; -import de.monticore.odbasis._symboltable.ODBasisScopesGenitor; - -public class OD4ReportScopesGenitorDelegator extends OD4ReportScopesGenitorDelegatorTOP { - - public OD4ReportScopesGenitorDelegator() { - super(); - } - - public void setCheckTypes(boolean typeCheck) { - traverser.getODBasisVisitorList().clear(); - ODBasisScopesGenitor odBasisScopesGenitor = ODBasisMill.scopesGenitor(); - odBasisScopesGenitor.setScopeStack(scopeStack); - odBasisScopesGenitor.setCheckTypes(typeCheck); - traverser.add4ODBasis(odBasisScopesGenitor); - traverser.setODBasisHandler(odBasisScopesGenitor); - - traverser.getOD4ReportVisitorList().clear(); - OD4ReportScopesGenitor od4ReportScopesGenitor = OD4ReportMill.scopesGenitor(); - od4ReportScopesGenitor.setScopeStack(scopeStack); - od4ReportScopesGenitor.setCheckTypes(typeCheck); - traverser.add4OD4Report(od4ReportScopesGenitor); - traverser.setOD4ReportHandler(od4ReportScopesGenitor); - } -} diff --git a/src/main/java/de/monticore/od4report/report/AST2ODReporter.java b/src/main/java/de/monticore/od4report/report/AST2ODReporter.java index bd7a5dac..11cdc9af 100644 --- a/src/main/java/de/monticore/od4report/report/AST2ODReporter.java +++ b/src/main/java/de/monticore/od4report/report/AST2ODReporter.java @@ -6,18 +6,17 @@ import de.monticore.generating.templateengine.reporting.commons.AReporter; import de.monticore.generating.templateengine.reporting.commons.ReportingConstants; import de.monticore.generating.templateengine.reporting.commons.ReportingRepository; -import de.monticore.od4data._prettyprint.OD4DataFullPrettyPrinter; +import de.monticore.od4report.OD4ReportMill; import de.monticore.odbasis._ast.ASTODBasisNode; -import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.Names; import java.io.File; public class AST2ODReporter extends AReporter { - private String modelName; + private final String modelName; - private ReportingRepository reporting; + private final ReportingRepository reporting; public AST2ODReporter(String outputDir, String modelName, ReportingRepository reporting) { super( @@ -55,7 +54,7 @@ public void flush(ASTNode ast) { * @param ast {@link ASTNode} */ private void writeContent(ASTODBasisNode ast) { - writeLine(new OD4DataFullPrettyPrinter(new IndentPrinter()).prettyprint(ast)); + writeLine(OD4ReportMill.prettyPrint(ast, false)); } } diff --git a/src/main/java/de/monticore/od4report/util/OD4ReportCollector.java b/src/main/java/de/monticore/od4report/util/OD4ReportCollector.java index e694fb78..0372127a 100644 --- a/src/main/java/de/monticore/od4report/util/OD4ReportCollector.java +++ b/src/main/java/de/monticore/od4report/util/OD4ReportCollector.java @@ -12,76 +12,56 @@ import de.monticore.odbasis.utils.ODBasisObjectCollector; import de.monticore.odlink._ast.ASTODLink; import de.monticore.odlink.utils.ODLinkCollector; -import de.monticore.prettyprint.IndentPrinter; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +/** + * Collects the objects and links of an OD4Report object diagram. Each query traverses the + * diagram with fresh collectors, so a collector instance can be reused for any number of queries. + */ public class OD4ReportCollector { - protected OD4ReportTraverser traverser = OD4ReportMill.traverser(); - - protected IndentPrinter printer; - - private OD4ReportObjectCollector od4ReportObjectCollector = new OD4ReportObjectCollector(); - - private ODBasisObjectCollector odBasisObjectCollector = new ODBasisObjectCollector(); - - private ODLinkCollector odLinkCollector = new ODLinkCollector(); - - public OD4ReportCollector() { - init(); - } - public List getReportObjects(ASTObjectDiagram objectDiagram) { - objectDiagram.accept(traverser); - List result = od4ReportObjectCollector.getNamedObjects(); - reset(); - return result; + return collect(objectDiagram).reportObjects().getNamedObjects(); } public List getNamedObjects(ASTObjectDiagram objectDiagram) { - objectDiagram.accept(traverser); - List result = Stream.concat(odBasisObjectCollector.getNamedObjects().stream(), - od4ReportObjectCollector.getNamedObjects().stream()).collect(Collectors.toList()); - reset(); - return result; + Collected collected = collect(objectDiagram); + return Stream.concat(collected.basisObjects().getNamedObjects().stream(), + collected.reportObjects().getNamedObjects().stream()).collect(Collectors.toList()); } public List getAnonymousObjects(ASTObjectDiagram objectDiagram) { - objectDiagram.accept(traverser); - List result = odBasisObjectCollector.getAnonymousObjects(); - reset(); - return result; + return collect(objectDiagram).basisObjects().getAnonymousObjects(); } public List getODObjects(ASTObjectDiagram objectDiagram) { - objectDiagram.accept(traverser); - List result = Stream.concat(odBasisObjectCollector.getODObjects().stream(), - od4ReportObjectCollector.getNamedObjects().stream()).collect(Collectors.toList()); - reset(); - return result; + Collected collected = collect(objectDiagram); + return Stream.concat(collected.basisObjects().getODObjects().stream(), + collected.reportObjects().getNamedObjects().stream()).collect(Collectors.toList()); } public List getODLinks(ASTObjectDiagram objectDiagram) { - objectDiagram.accept(traverser); - List result = odLinkCollector.getLinks(); - reset(); - return result; + return collect(objectDiagram).links().getLinks(); } - private void init() { - traverser.add4ODBasis(odBasisObjectCollector); - traverser.add4ODLink(odLinkCollector); - traverser.add4OD4Report(od4ReportObjectCollector); + protected Collected collect(ASTObjectDiagram objectDiagram) { + Collected collected = new Collected(new OD4ReportObjectCollector(), + new ODBasisObjectCollector(), new ODLinkCollector()); + + OD4ReportTraverser traverser = OD4ReportMill.traverser(); + traverser.add4OD4Report(collected.reportObjects()); + traverser.add4ODBasis(collected.basisObjects()); + traverser.add4ODLink(collected.links()); + objectDiagram.accept(traverser); + + return collected; } - private void reset() { - od4ReportObjectCollector = new OD4ReportObjectCollector(); - odBasisObjectCollector = new ODBasisObjectCollector(); - odLinkCollector = new ODLinkCollector(); - init(); + protected record Collected(OD4ReportObjectCollector reportObjects, + ODBasisObjectCollector basisObjects, ODLinkCollector links) { } } diff --git a/src/main/java/de/monticore/od4report/util/OD4ReportObjectCollector.java b/src/main/java/de/monticore/od4report/util/OD4ReportObjectCollector.java index 3d3f1702..6de83d31 100644 --- a/src/main/java/de/monticore/od4report/util/OD4ReportObjectCollector.java +++ b/src/main/java/de/monticore/od4report/util/OD4ReportObjectCollector.java @@ -10,7 +10,7 @@ public class OD4ReportObjectCollector implements OD4ReportVisitor2 { - private List namedObjects = new ArrayList<>(); + private final List namedObjects = new ArrayList<>(); @Override public void visit(ASTODReportObject reportObject) { diff --git a/src/main/java/de/monticore/odbasis/_cocos/ODBasicsCoCos.java b/src/main/java/de/monticore/odbasis/_cocos/ODBasisCoCos.java similarity index 67% rename from src/main/java/de/monticore/odbasis/_cocos/ODBasicsCoCos.java rename to src/main/java/de/monticore/odbasis/_cocos/ODBasisCoCos.java index f084949c..f8c86a05 100644 --- a/src/main/java/de/monticore/odbasis/_cocos/ODBasicsCoCos.java +++ b/src/main/java/de/monticore/odbasis/_cocos/ODBasisCoCos.java @@ -5,10 +5,11 @@ import de.monticore.odbasis._cocos.attributes.NoAbstractAttributesCoCo; import de.monticore.odbasis._cocos.attributes.PartialAndCompleteAttributesCoCo; import de.monticore.odbasis._cocos.attributes.UniqueAttributeNamesCoCo; +import de.monticore.odbasis._cocos.attributes.ValidObjectAttributesCoCo; import de.monticore.odbasis._cocos.names.UniqueObjectNamesCoCo; -import de.monticore.odbasis._cocos.object.ValidObjectTypeCoco; +import de.monticore.odbasis._cocos.object.ValidObjectTypeCoCo; -public class ODBasicsCoCos { +public class ODBasisCoCos { public ODBasisCoCoChecker getCheckerForAllIntraCoCos() { final ODBasisCoCoChecker checker = new ODBasisCoCoChecker(); @@ -28,9 +29,19 @@ public ODBasisCoCoChecker getCheckerForAllIntraCoCos() { public ODBasisCoCoChecker getCheckerForAllCoCos() { final ODBasisCoCoChecker checker = new ODBasisCoCoChecker(); checker.addChecker(this.getCheckerForAllIntraCoCos()); + checker.addChecker(this.getCheckerForAllInterCoCos()); + + return checker; + } + + public ODBasisCoCoChecker getCheckerForAllInterCoCos() { + final ODBasisCoCoChecker checker = new ODBasisCoCoChecker(); + + // attributes + checker.addCoCo(new ValidObjectAttributesCoCo()); // types - checker.addCoCo(new ValidObjectTypeCoco()); + checker.addCoCo(new ValidObjectTypeCoCo()); return checker; } diff --git a/src/main/java/de/monticore/odbasis/_cocos/attributes/NoAbstractAttributesCoCo.java b/src/main/java/de/monticore/odbasis/_cocos/attributes/NoAbstractAttributesCoCo.java index f3cfb192..a3c9c3f7 100644 --- a/src/main/java/de/monticore/odbasis/_cocos/attributes/NoAbstractAttributesCoCo.java +++ b/src/main/java/de/monticore/odbasis/_cocos/attributes/NoAbstractAttributesCoCo.java @@ -8,15 +8,22 @@ import de.se_rwth.commons.logging.Log; /** - * Attributes shouldn't be abstract. + * Checks that an {@link ASTODAttribute} is not declared with the {@code abstract} modifier. + *

+ * Object diagram attributes represent concrete attribute values or declarations of objects. + * Therefore, an abstract modifier is not allowed on such attributes. If an attribute is declared + * as abstract, an error is reported at the start position of that attribute. */ public class NoAbstractAttributesCoCo implements ODBasisASTODAttributeCoCo { + public static final String ERROR_ABSTRACT_ATTRIBUTE = + "0x0D005: An object diagram attribute must not be declared abstract."; + @Override public void check(ASTODAttribute node) { ASTModifier attrModifier = node.getModifier(); if (attrModifier.isAbstract()) { - Log.error("0x0D005: Violation of CoCo 'NoAbstractAttributesCoCo'", node.get_SourcePositionStart()); + Log.error(ERROR_ABSTRACT_ATTRIBUTE, node.get_SourcePositionStart()); } } diff --git a/src/main/java/de/monticore/odbasis/_cocos/attributes/PartialAndCompleteAttributesCoCo.java b/src/main/java/de/monticore/odbasis/_cocos/attributes/PartialAndCompleteAttributesCoCo.java index 3b6327a6..0d75c88d 100644 --- a/src/main/java/de/monticore/odbasis/_cocos/attributes/PartialAndCompleteAttributesCoCo.java +++ b/src/main/java/de/monticore/odbasis/_cocos/attributes/PartialAndCompleteAttributesCoCo.java @@ -8,23 +8,31 @@ import de.se_rwth.commons.logging.Log; /** - * Attributes defined with a partial operator must not be defined in a complete attribute definition - * and vice versa. + * Checks that an attribute name is not used both as a partial attribute and as a complete + * attribute within the same {@link ASTODObject}. + *

+ * The CoCo compares all attributes of an object pairwise. If two attributes with the same name + * are declared and exactly one of them is a complete attribute declaration, the combination is + * invalid because partial and complete declarations for the same attribute name must not be mixed. + * In that case, an error is reported at the start position of the second attribute. + * Two complete declarations are reported by {@link UniqueAttributeNamesCoCo}. */ public class PartialAndCompleteAttributesCoCo implements ODBasisASTODObjectCoCo { + public static final String ERROR_PARTIAL_AND_COMPLETE_ATTRIBUTE_MIX = + "0x0D004: The attribute '%s' must not be declared as both a partial and a complete attribute within the same object."; + @Override public void check(ASTODObject node) { for (int i = 0; i < node.getODAttributeList().size(); i++) { ASTODAttribute firstAttribute = node.getODAttributeList().get(i); for (int j = i + 1; j < node.getODAttributeList().size(); j++) { ASTODAttribute secondAttribute = node.getODAttributeList().get(j); - if (firstAttribute.getName().equals(secondAttribute.getName())) { - if (firstAttribute.isPresentComplete() || (!firstAttribute.isPresentComplete() - && secondAttribute.isPresentComplete())) { - Log.error("0x0D004: Violation of CoCo 'PartialAndCompleteAttributesCoCo'", - node.get_SourcePositionStart()); - } + if (firstAttribute.getName().equals(secondAttribute.getName()) + && firstAttribute.isPresentComplete() != secondAttribute.isPresentComplete()) { + Log.error(String.format(ERROR_PARTIAL_AND_COMPLETE_ATTRIBUTE_MIX, + firstAttribute.getName()), + secondAttribute.get_SourcePositionStart()); } } } diff --git a/src/main/java/de/monticore/odbasis/_cocos/attributes/UniqueAttributeNamesCoCo.java b/src/main/java/de/monticore/odbasis/_cocos/attributes/UniqueAttributeNamesCoCo.java index 808f2e83..fa9dc0dd 100644 --- a/src/main/java/de/monticore/odbasis/_cocos/attributes/UniqueAttributeNamesCoCo.java +++ b/src/main/java/de/monticore/odbasis/_cocos/attributes/UniqueAttributeNamesCoCo.java @@ -10,17 +10,26 @@ import java.util.List; /** - * Checks whether the attribute names within an object are unique + * Checks that all complete attributes of an {@link ASTODObject} have unique names within that + * object. + *

+ * The CoCo only considers attributes that are marked as complete. If the same complete attribute + * name occurs more than once in a single object, the object contains an invalid duplicate + * attribute declaration and an error is reported at the start position of the duplicate + * attribute. */ public class UniqueAttributeNamesCoCo implements ODBasisASTODObjectCoCo { + public static final String ERROR_ATTRIBUTE_NAME_NOT_UNIQUE = + "0x0D003: The attribute name '%s' is declared more than once within the same object."; + @Override public void check(ASTODObject node) { List attributeNames = new ArrayList<>(); node.getODAttributeList().forEach(attribute -> { if (attribute.isPresentComplete()) { if (attributeNames.contains(attribute.getName())) { - Log.error("0x0D003: Violation of CoCo 'UniqueAttributeNamesCoCo'", + Log.error(String.format(ERROR_ATTRIBUTE_NAME_NOT_UNIQUE, attribute.getName()), attribute.get_SourcePositionStart()); } else { diff --git a/src/main/java/de/monticore/odbasis/_cocos/attributes/ValidObjectAttributesCoCo.java b/src/main/java/de/monticore/odbasis/_cocos/attributes/ValidObjectAttributesCoCo.java new file mode 100644 index 00000000..e2a98667 --- /dev/null +++ b/src/main/java/de/monticore/odbasis/_cocos/attributes/ValidObjectAttributesCoCo.java @@ -0,0 +1,42 @@ +package de.monticore.odbasis._cocos.attributes; + +import de.monticore.odbasis._ast.ASTODAttribute; +import de.monticore.odbasis._ast.ASTODObject; +import de.monticore.odbasis._cocos.ODBasisASTODObjectCoCo; +import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; +import de.monticore.symbols.basicsymbols._symboltable.VariableSymbol; +import de.monticore.symbols.oosymbols._symboltable.FieldSymbol; +import de.se_rwth.commons.logging.Log; + +import java.util.Optional; + +/** + * Checks that every attribute declared in an {@link ASTODObject} is defined as a field in the + * referenced type of the object. + *

+ * For each attribute of an object, this CoCo attempts to resolve the attribute name to a + * {@link FieldSymbol} in the enclosing scope. If an attribute name cannot be resolved, it is + * considered undefined and an error is reported at the start position of that attribute. + */ +public class ValidObjectAttributesCoCo implements ODBasisASTODObjectCoCo { + + public static final String ERROR_ATTRIBUTE_NOT_DEFINED = + "0x0D006: The attribute '%s' is not defined as a field in type '%s'."; + + @Override + public void check(ASTODObject node) { + Optional objectType = + node.getEnclosingScope().resolveType(node.getMCObjectType().printType()); + if (objectType.isPresent()) { + for (ASTODAttribute attribute : node.getODAttributeList()) { + Optional field = + objectType.get().getSpannedScope().resolveVariableDown(attribute.getName()); + if (field.isEmpty()) { + Log.error(ERROR_ATTRIBUTE_NOT_DEFINED.formatted(attribute.getName(), + node.getMCObjectType().printType()), + attribute.get_SourcePositionStart()); + } + } + } + } +} diff --git a/src/main/java/de/monticore/odbasis/_cocos/names/UniqueObjectNamesCoCo.java b/src/main/java/de/monticore/odbasis/_cocos/names/UniqueObjectNamesCoCo.java index 9e6a5891..89c2e8ed 100644 --- a/src/main/java/de/monticore/odbasis/_cocos/names/UniqueObjectNamesCoCo.java +++ b/src/main/java/de/monticore/odbasis/_cocos/names/UniqueObjectNamesCoCo.java @@ -9,14 +9,25 @@ import java.util.List; +/** + * Checks that each named object in an object diagram has a unique name in the enclosing scope. + *

+ * The CoCo is only applied to named objects. For each named object, the symbol of the object is + * resolved in its enclosing scope by name. If the name is not unique in that scope, the object + * name is considered invalid and an error is reported at the start position of the object. + */ public class UniqueObjectNamesCoCo implements ODBasisASTODNamedObjectCoCo { + public static final String ERROR_OBJECT_NAME_NOT_UNIQUE = + "0x0D002: The object name '%s' is not unique in the enclosing scope."; + @Override public void check(ASTODNamedObject node) { VariableSymbol symbol = node.getSymbol(); List symbols = symbol.getEnclosingScope().resolveVariableMany(symbol.getName()); if (symbols.size() != 1) { - Log.error("0x0D002: Violation of CoCo 'UniqueObjectNamesCoCo'", node.get_SourcePositionStart()); + Log.error(String.format(ERROR_OBJECT_NAME_NOT_UNIQUE, symbol.getName()), + node.get_SourcePositionStart()); } } diff --git a/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectReferenceCoCo.java b/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectReferenceCoCo.java index 2f993921..7e29678c 100644 --- a/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectReferenceCoCo.java +++ b/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectReferenceCoCo.java @@ -12,20 +12,29 @@ import java.util.Optional; +/** + * Checks that every object attribute reference used inside an {@link ASTODObject} resolves to a + * variable that is available in the enclosing scope of that object. + *

+ * The CoCo inspects simple attribute values whose expression is a name expression. If such a name + * cannot be resolved to a {@link VariableSymbol}, the attribute reference is considered invalid + * and an error is reported at the start position of the object. + */ public class ValidObjectReferenceCoCo implements ODBasisASTODObjectCoCo { + public static final String ERROR_UNRESOLVED_OBJECT_REFERENCE = + "0x0D001: The referenced object attribute '%s' cannot be resolved in the enclosing scope."; + @Override public void check(ASTODObject node) { for (ASTODAttribute astodAttribute : node.getODAttributeList()) { if (astodAttribute.isPresentODValue()) { ASTODValue astodValue = astodAttribute.getODValue(); - if (astodValue instanceof ASTODSimpleAttributeValue) { - ASTODSimpleAttributeValue simpleAttributeValue = (ASTODSimpleAttributeValue) astodValue; - if (simpleAttributeValue.getExpression() instanceof ASTNameExpression && !this - .checkReference((ASTNameExpression) simpleAttributeValue.getExpression(), node)) { - Log.error("0x0D001: Violation of CoCo 'ValidObjectReferenceCoCo'", - node.get_SourcePositionStart()); - } + if (astodValue instanceof ASTODSimpleAttributeValue simpleAttributeValue + && simpleAttributeValue.getExpression() instanceof ASTNameExpression astNameExpression + && !this.checkReference(astNameExpression, node)) { + Log.error(String.format(ERROR_UNRESOLVED_OBJECT_REFERENCE, astNameExpression.getName()), + node.get_SourcePositionStart()); } } } diff --git a/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoCo.java b/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoCo.java new file mode 100644 index 00000000..fab625a4 --- /dev/null +++ b/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoCo.java @@ -0,0 +1,43 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package de.monticore.odbasis._cocos.object; + +import de.monticore.odbasis._ast.ASTODObject; +import de.monticore.odbasis._cocos.ODBasisASTODObjectCoCo; +import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; +import de.se_rwth.commons.logging.Log; + +import java.util.List; + +/** + * Checks that every object type used in an object diagram can be resolved to exactly one + * available type symbol in the enclosing scope. + *

+ * For each {@link ASTODObject} in the artifact, this CoCo resolves the object's declared type by + * combining the current package, the import statements, and the declared type name. If no type + * symbol can be found, the object type is considered undefined. If more than one type symbol can + * be resolved, the type usage is considered ambiguous. + */ +public class ValidObjectTypeCoCo implements ODBasisASTODObjectCoCo { + + public static final String ERROR_TYPE_DEFINED_MULTIPLE_TIMES = + "0xB0032: Type '%s' is defined more than once."; + + public static final String ERROR_TYPE_USED_BUT_UNDEFINED = + "0xB0035: Type '%s' is used but not defined."; + + @Override + public void check(ASTODObject node) { + String typeName = node.getMCObjectType().printType(); + List typeSymbols = node.getEnclosingScope().resolveTypeMany(typeName); + + if (typeSymbols.isEmpty()) { + Log.error(String.format(ERROR_TYPE_USED_BUT_UNDEFINED, typeName), + node.get_SourcePositionStart()); + } + else if (typeSymbols.size() > 1) { + Log.error(String.format(ERROR_TYPE_DEFINED_MULTIPLE_TIMES, typeName), + node.get_SourcePositionStart()); + } + } +} diff --git a/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoco.java b/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoco.java deleted file mode 100644 index 40121884..00000000 --- a/src/main/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoco.java +++ /dev/null @@ -1,68 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ - -package de.monticore.odbasis._cocos.object; - -import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.odbasis._ast.ASTODObject; -import de.monticore.odbasis._cocos.ODBasisASTODArtifactCoCo; -import de.monticore.odbasis._cocos.ODBasisASTODObjectCoCo; -import de.monticore.odbasis._cocos.ODBasisCoCoChecker; -import de.monticore.odbasis.utils.FullQualifiedNameCalculator; -import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; -import de.monticore.types.mcbasictypes._ast.ASTMCImportStatement; -import de.monticore.types.mcbasictypes._ast.ASTMCPackageDeclaration; -import de.se_rwth.commons.logging.Log; - -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -/** - * This is a inter model coco checking if the type of the object is defined. - */ -public class ValidObjectTypeCoco implements ODBasisASTODArtifactCoCo { - - private final String TYPE_DEFINED_MUTLIPLE_TIMES = - "0xB0032: Type '%s' is defined more " + "than once."; - - private final String TYPE_USED_BUT_UNDEFINED = "0xB0035: Type '%s' is used but not " + "defined."; - - private List importStatementList; - - private ASTMCPackageDeclaration packageDeclaration; - - @Override - public void check(ASTODArtifact node) { - importStatementList = node.getMCImportStatementList(); - packageDeclaration = node.getMCPackageDeclaration(); - - ODBasisASTODObjectCoCo odBasisASTODObjectCoCo = new ODBasisASTODObjectCoCo() { - @Override - public void check(ASTODObject node) { - this.resolveTypeSymbol(node, node.getMCObjectType().printType()); - } - - private void resolveTypeSymbol(ASTODObject node, String typeName) { - Set typeSymbols = new LinkedHashSet<>(); - for (String fqNameCandidate : FullQualifiedNameCalculator.calcFQNameCandidates( - importStatementList, packageDeclaration.getMCQualifiedName(), typeName)) { - typeSymbols.addAll(node.getEnclosingScope().resolveTypeMany(fqNameCandidate)); - } - - if (typeSymbols.isEmpty()) { - Log.error(String.format(TYPE_USED_BUT_UNDEFINED, typeName), - node.get_SourcePositionStart()); - } - else if (typeSymbols.size() > 1) { - Log.error(String.format(TYPE_DEFINED_MUTLIPLE_TIMES, typeName), - node.get_SourcePositionStart()); - } - } - }; - - ODBasisCoCoChecker odBasisCoCoChecker = new ODBasisCoCoChecker(); - odBasisCoCoChecker.addCoCo(odBasisASTODObjectCoCo); - odBasisCoCoChecker.checkAll(node); - } - -} diff --git a/src/main/java/de/monticore/odbasis/_symboltable/ODBasisScopesGenitor.java b/src/main/java/de/monticore/odbasis/_symboltable/ODBasisScopesGenitor.java index c4f4fe8c..34a0d120 100644 --- a/src/main/java/de/monticore/odbasis/_symboltable/ODBasisScopesGenitor.java +++ b/src/main/java/de/monticore/odbasis/_symboltable/ODBasisScopesGenitor.java @@ -2,63 +2,24 @@ package de.monticore.odbasis._symboltable; -import de.monticore.odbasis._ast.ASTODArtifact; import de.monticore.odbasis._ast.ASTODNamedObject; import de.monticore.odbasis._ast.ASTObjectDiagram; -import de.monticore.types.check.SymTypeExpression; -import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; -import de.monticore.types3.TypeCheck3; -import de.se_rwth.commons.logging.Log; public class ODBasisScopesGenitor extends ODBasisScopesGenitorTOP { - - private boolean checkTypes = true; - - private ASTODArtifact rootNode; - + public ODBasisScopesGenitor() { super(); } - - @Override - public void visit(ASTODArtifact astodArtifact) { - this.rootNode = astodArtifact; - } - + @Override public void endVisit(ASTObjectDiagram node) { super.endVisit(node); node.getEnclosingScope().setName(node.getName()); } - + @Override public void visit(ASTODNamedObject node) { super.visit(node); node.getSymbol().setName(node.getName()); } - - @Override - public void endVisit(ASTODNamedObject node) { - super.endVisit(node); - if (checkTypes) { - ASTMCObjectType objectType = node.getMCObjectType(); - final SymTypeExpression typeResult = TypeCheck3.symTypeFromAST(objectType); - if (typeResult.isObscureType()) { - Log.error(String.format("0x0D013: The type of the return type (%s) could not be calculated", - node.getMCObjectType().getClass().getSimpleName()), - node.getMCObjectType().get_SourcePositionStart()); - } else { - node.getSymbol().setType(typeResult); - } - } - } - - public boolean isCheckTypes() { - return checkTypes; - } - - public void setCheckTypes(boolean checkTypes) { - this.checkTypes = checkTypes; - } - } diff --git a/src/main/java/de/monticore/odbasis/_symboltable/ODBasisSymbolTableCompleter.java b/src/main/java/de/monticore/odbasis/_symboltable/ODBasisSymbolTableCompleter.java new file mode 100644 index 00000000..0528df60 --- /dev/null +++ b/src/main/java/de/monticore/odbasis/_symboltable/ODBasisSymbolTableCompleter.java @@ -0,0 +1,87 @@ +package de.monticore.odbasis._symboltable; + +import de.monticore.odbasis.ODBasisMill; +import de.monticore.odbasis._ast.ASTODNamedObject; +import de.monticore.odbasis._visitor.ODBasisHandler; +import de.monticore.odbasis._visitor.ODBasisTraverser; +import de.monticore.odbasis._visitor.ODBasisVisitor2; +import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; +import de.monticore.symboltable.modifiers.AccessModifier; +import de.monticore.types.check.SymTypeExpression; +import de.monticore.types.check.SymTypeExpressionFactory; +import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; +import de.monticore.types3.TypeCheck3; +import de.se_rwth.commons.logging.Log; + +public class ODBasisSymbolTableCompleter implements ODBasisVisitor2, ODBasisHandler { + + public static final String ERROR_TYPE_NOT_CALCULATED = + "0x0D031: The type '%s' of object '%s' could not be calculated."; + + /** Name of the type used for all objects if the types are not checked. */ + public static final String DEFAULT_OBJECT = "de.monticore.internal._DefaultObject"; + + protected ODBasisTraverser traverser; + + protected boolean checkTypes; + + /** Created when it is needed for the first time, as it is not used if types are checked. */ + private SymTypeExpression defaultObjectType; + + + public ODBasisSymbolTableCompleter(boolean checkTypes) { + this.traverser = null; + this.checkTypes = checkTypes; + } + + @Override + public void endVisit(ASTODNamedObject node) { + if (checkTypes) { + ASTMCObjectType objectType = node.getMCObjectType(); + final SymTypeExpression typeResult = TypeCheck3.symTypeFromAST(objectType); + if (typeResult.isObscureType()) { + Log.error(String.format(ERROR_TYPE_NOT_CALCULATED, objectType.printType(), node.getName()), + objectType.get_SourcePositionStart()); + } else { + node.getSymbol().setType(typeResult); + } + } else { + node.getSymbol().setType(getDefaultObjectType()); + } + } + + /** + * Returns the type for all objects if the types are not checked. The type symbol is added to + * the global scope only once, also if several completers are used. + */ + protected SymTypeExpression getDefaultObjectType() { + if (defaultObjectType == null) { + IODBasisGlobalScope gs = ODBasisMill.globalScope(); + TypeSymbol defaultObjectTypeSymbol = gs.getTypeSymbols().get(DEFAULT_OBJECT).stream() + .findFirst() + .orElseGet(() -> { + TypeSymbol symbol = ODBasisMill.typeSymbolBuilder() + .setName(DEFAULT_OBJECT) + .setFullName(DEFAULT_OBJECT) + .setEnclosingScope(gs) + .setSpannedScope(ODBasisMill.scope()) + .setAccessModifier(AccessModifier.ALL_INCLUSION) + .build(); + gs.add(symbol); + return symbol; + }); + defaultObjectType = SymTypeExpressionFactory.createTypeObject(defaultObjectTypeSymbol); + } + return defaultObjectType; + } + + @Override + public ODBasisTraverser getTraverser() { + return this.traverser; + } + + @Override + public void setTraverser(ODBasisTraverser traverser) { + this.traverser = traverser; + } +} diff --git a/src/main/java/de/monticore/odbasis/trafo/ODBasisDeAnonymizeObjectsTrafo.java b/src/main/java/de/monticore/odbasis/trafo/ODBasisDeAnonymizeObjectsTrafo.java index 460f56c5..4ad065e6 100644 --- a/src/main/java/de/monticore/odbasis/trafo/ODBasisDeAnonymizeObjectsTrafo.java +++ b/src/main/java/de/monticore/odbasis/trafo/ODBasisDeAnonymizeObjectsTrafo.java @@ -7,7 +7,6 @@ import de.monticore.odbasis.ODBasisMill; import de.monticore.odbasis._ast.*; import de.monticore.odbasis._visitor.ODBasisVisitor2; -import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import java.util.LinkedHashMap; import java.util.Map; @@ -28,23 +27,24 @@ * * will be transformed to *

- *   __a_anonymous_0:A {
- *     foo = __b_anonymous_0:B {};
+ *   __a_anonymous_1:A {
+ *     foo = __b_anonymous_1:B {};
  *   };
  * 
*/ public class ODBasisDeAnonymizeObjectsTrafo implements ODBasisVisitor2 { - protected Map pseudoCounts = new LinkedHashMap<>(); + /** + * Number of generated names per type. Keyed by the printed type, as AST + * nodes are compared by identity and each object has its own type node. + */ + protected Map pseudoCounts = new LinkedHashMap<>(); @Override public void endVisit(ASTObjectDiagram node) { for (int i = 0; i < node.getODElementList().size(); i++) { ASTODElement element = node.getODElementList().get(i); - if (ODBasisMill.typeDispatcher().isODBasisASTODAnonymousObject(element)) { - ASTODAnonymousObject anonymousObject = - ODBasisMill.typeDispatcher().asODBasisASTODAnonymousObject(element); - + if (element instanceof ASTODAnonymousObject anonymousObject) { ASTODNamedObject namedCopy = copyToNamedObject(anonymousObject); node.setODElement(i, namedCopy); } @@ -55,9 +55,7 @@ public void endVisit(ASTObjectDiagram node) { public void endVisit(ASTODAttribute node) { if (node.isPresentODValue()) { ASTODValue value = node.getODValue(); - if (ODBasisMill.typeDispatcher().isODBasisASTODAnonymousObject(value)) { - ASTODAnonymousObject anonymousObject = - ODBasisMill.typeDispatcher().asODBasisASTODAnonymousObject(value); + if (value instanceof ASTODAnonymousObject anonymousObject) { ASTODNamedObject namedCopy = copyToNamedObject(anonymousObject); node.setODValue(namedCopy); } @@ -65,21 +63,11 @@ public void endVisit(ASTODAttribute node) { } protected String generateObjectPseudoName(ASTODObject object) { - ASTMCObjectType type = object.getMCObjectType(); - String typeName = type.printType().toLowerCase().replaceAll("\\.", "_"); - - pseudoCounts.putIfAbsent(type, 0); - int pseudoIdx = pseudoCounts.merge(type, 1, Integer::sum); - - StringBuilder sb = new StringBuilder(); - sb.append("__"); - sb.append(typeName); - sb.append("_anonymous_"); - sb.append(pseudoIdx); - - String generatedName = sb.toString(); - - return generatedName; + String typeName = object.getMCObjectType().printType().toLowerCase().replaceAll("\\.", "_"); + + int pseudoIdx = pseudoCounts.merge(typeName, 1, Integer::sum); + + return "__" + typeName + "_anonymous_" + pseudoIdx; } protected ASTODNamedObject copyToNamedObject(ASTODAnonymousObject object) { @@ -90,6 +78,7 @@ protected ASTODNamedObject copyToNamedObject(ASTODAnonymousObject object) { builder.setMCObjectType(object.getMCObjectType()); builder.set_SourcePositionStart(object.get_SourcePositionStart()); builder.set_SourcePositionEnd(object.get_SourcePositionEnd()); + builder.set_PreCommentList(object.get_PreCommentList()); builder.set_PostCommentList(object.get_PostCommentList()); ASTODNamedObject namedObject = builder.build(); diff --git a/src/main/java/de/monticore/odbasis/utils/ODBasisObjectCollector.java b/src/main/java/de/monticore/odbasis/utils/ODBasisObjectCollector.java index 76705dd6..768f256e 100644 --- a/src/main/java/de/monticore/odbasis/utils/ODBasisObjectCollector.java +++ b/src/main/java/de/monticore/odbasis/utils/ODBasisObjectCollector.java @@ -14,9 +14,9 @@ public class ODBasisObjectCollector implements ODBasisVisitor2 { - private List namedObjects = new ArrayList<>(); + private final List namedObjects = new ArrayList<>(); - private List anonymousObjects = new ArrayList<>(); + private final List anonymousObjects = new ArrayList<>(); @Override public void visit(ASTODNamedObject namedObject) { diff --git a/src/main/java/de/monticore/odlink/_cocos/ODLinkCoCos.java b/src/main/java/de/monticore/odlink/_cocos/ODLinkCoCos.java index 0a20e225..e3196380 100644 --- a/src/main/java/de/monticore/odlink/_cocos/ODLinkCoCos.java +++ b/src/main/java/de/monticore/odlink/_cocos/ODLinkCoCos.java @@ -32,4 +32,13 @@ public ODLinkCoCoChecker getCheckerForAllCoCos() { return checker; } + public ODLinkCoCoChecker getCheckerForAllInterCoCos() { + final ODLinkCoCoChecker checker = new ODLinkCoCoChecker(); + + // links + checker.addCoCo(new LinkEndConsistencyCoCo()); + + return checker; + } + } diff --git a/src/main/java/de/monticore/odlink/_cocos/link/LinkEndConsistencyCoCo.java b/src/main/java/de/monticore/odlink/_cocos/link/LinkEndConsistencyCoCo.java index c07c6d30..7ef10b5c 100644 --- a/src/main/java/de/monticore/odlink/_cocos/link/LinkEndConsistencyCoCo.java +++ b/src/main/java/de/monticore/odlink/_cocos/link/LinkEndConsistencyCoCo.java @@ -10,58 +10,46 @@ import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** - * Check whether named links consists of the same object type references on the left and right side - * of the definition + * Checks that both sides of a named link are internally type-consistent. + *

+ * For each side, all resolved variables on that side must have the same + * {@link SymTypeExpression}. References that cannot be resolved are skipped, as they are reported + * by {@link ValidLinkReferenceCoCo}. + * The left and right side are checked independently; this CoCo does not compare the two sides + * with each other. */ public class LinkEndConsistencyCoCo implements ODLinkASTODLinkCoCo { + + public static final String ERROR_INCONSISTENT_REFERENCE_TYPES = + "0x0D009: All references on the %s of a named link must resolve to variables of the same type, but '%s' resolves to type '%s' and '%s' resolves to type '%s'."; @Override public void check(ASTODLink node) { - List leftSymbols = node.getLeftReferenceNames().stream().map(refName -> { - Optional symbol = node.getEnclosingScope().resolveVariable(refName); - if (symbol.isEmpty()) { - Log.error("0x0D008: Violation of CoCo 'LinkEndConsistencyCoCo'", - node.get_SourcePositionStart()); - } - return symbol.get(); - }).collect(Collectors.toList()); - - if (hasMultipleTypes(leftSymbols)) { - Log.error("0x0D008: Violation of CoCo 'LinkEndConsistencyCoCo'", - node.get_SourcePositionStart()); - } - - List rightSymbols = node.getRightReferenceNames().stream().map(refName -> { - Optional symbol = node.getEnclosingScope().resolveVariable(refName); - if (symbol.isEmpty()) { - Log.error("0x0D008: Violation of CoCo 'LinkEndConsistencyCoCo'", - node.get_SourcePositionStart()); - } - return symbol.get(); - }).collect(Collectors.toList()); - - if (hasMultipleTypes(rightSymbols)) { - Log.error("0x0D008: Violation of CoCo 'LinkEndConsistencyCoCo'", - node.get_SourcePositionStart()); - } + checkReferenceSide(node, node.getLeftReferenceNames(), "left side"); + checkReferenceSide(node, node.getRightReferenceNames(), "right side"); } - protected boolean hasMultipleTypes(List symbols) { - if (symbols.isEmpty()) { - return false; - } - VariableSymbol firstSymbol = symbols.get(0); - SymTypeExpression firstSymbolType = firstSymbol.getType(); - for (VariableSymbol symbol : symbols) { - SymTypeExpression symbolType = symbol.getType(); - if (!firstSymbolType.deepEquals(symbolType)) { - return true; + protected void checkReferenceSide(ASTODLink node, List referenceNames, String sideName) { + String firstReferenceName = null; + SymTypeExpression firstReferenceType = null; + + for (String referenceName : referenceNames) { + Optional symbol = node.getEnclosingScope().resolveVariable(referenceName); + if (symbol.isPresent()) { + SymTypeExpression currentType = symbol.get().getType(); + if (firstReferenceType == null) { + firstReferenceName = referenceName; + firstReferenceType = currentType; + } + else if (!firstReferenceType.deepEquals(currentType)) { + Log.error(String.format(ERROR_INCONSISTENT_REFERENCE_TYPES, sideName, firstReferenceName, + firstReferenceType.printFullName(), referenceName, currentType.printFullName()), node.get_SourcePositionStart()); + return; + } } } - return false; } } diff --git a/src/main/java/de/monticore/odlink/_cocos/link/NoAbstractLinkCoCo.java b/src/main/java/de/monticore/odlink/_cocos/link/NoAbstractLinkCoCo.java index 76bf92fa..9a6eb23b 100644 --- a/src/main/java/de/monticore/odlink/_cocos/link/NoAbstractLinkCoCo.java +++ b/src/main/java/de/monticore/odlink/_cocos/link/NoAbstractLinkCoCo.java @@ -8,20 +8,30 @@ import de.se_rwth.commons.logging.Log; /** - * Links with an abstract modifier are not allowed. + * Checks that no link end of an {@link ASTODLink} is declared with the {@code abstract} modifier. + *

+ * This CoCo validates both link ends independently: + * the modifier of the left link end and the modifier of the right link end must not be abstract. + * If one side is abstract, an error is reported at the start position of the link. */ public class NoAbstractLinkCoCo implements ODLinkASTODLinkCoCo { + public static final String ERROR_LEFT_SIDE_ABSTRACT = + "0x0D00A: The left side of a link must not be declared abstract."; + + public static final String ERROR_RIGHT_SIDE_ABSTRACT = + "0x0D00B: The right side of a link must not be declared abstract."; + @Override public void check(ASTODLink node) { ASTModifier linkLeftModifier = node.getODLinkLeftSide().getModifier(); if (linkLeftModifier.isAbstract()) { - Log.error("0x0D007: Violation of CoCo 'NoAbstractAttributesCoCo'", node.get_SourcePositionStart()); + Log.error(ERROR_LEFT_SIDE_ABSTRACT, node.get_SourcePositionStart()); } ASTModifier linkRightModifier = node.getODLinkRightSide().getModifier(); if (linkRightModifier.isAbstract()) { - Log.error("0x0D007: Violation of CoCo 'NoAbstractAttributesCoCo'", node.get_SourcePositionStart()); + Log.error(ERROR_RIGHT_SIDE_ABSTRACT, node.get_SourcePositionStart()); } } diff --git a/src/main/java/de/monticore/odlink/_cocos/link/ValidLinkReferenceCoCo.java b/src/main/java/de/monticore/odlink/_cocos/link/ValidLinkReferenceCoCo.java index 8ed72436..d7b0fe66 100644 --- a/src/main/java/de/monticore/odlink/_cocos/link/ValidLinkReferenceCoCo.java +++ b/src/main/java/de/monticore/odlink/_cocos/link/ValidLinkReferenceCoCo.java @@ -9,24 +9,34 @@ import java.util.Optional; +/** + * Checks that every reference used in an {@link ASTODLink} can be resolved in the enclosing + * scope. + *

+ * The CoCo validates the left and right reference lists independently. Every referenced name on + * the left side and every referenced name on the right side must resolve to an existing + * {@link VariableSymbol}; otherwise an error is reported at the start position of the link. + */ public class ValidLinkReferenceCoCo implements ODLinkASTODLinkCoCo { + public static final String ERROR_LEFT_REFERENCE_UNRESOLVED = + "0x0D00C: The left reference '%s' of a named link cannot be resolved in the enclosing scope."; + + public static final String ERROR_RIGHT_REFERENCE_UNRESOLVED = + "0x0D00D: The right reference '%s' of a named link cannot be resolved in the enclosing scope."; + @Override public void check(ASTODLink node) { node.getLeftReferenceNames().forEach(refName -> { Optional variableSymbol = node.getEnclosingScope().resolveVariable(refName); - if (!variableSymbol.isPresent()) { - Log.error( - "0x0D006: Violation of CoCo 'ValidLinkReferenceCoCo': " + refName + " cannot be resolved", - node.get_SourcePositionStart()); + if (variableSymbol.isEmpty()) { + Log.error(String.format(ERROR_LEFT_REFERENCE_UNRESOLVED, refName), node.get_SourcePositionStart()); } }); node.getRightReferenceNames().forEach(refName -> { - if (!node.getEnclosingScope().resolveVariable(refName).isPresent()) { - Log.error( - "0x0D006: Violation of CoCo 'ValidLinkReferenceCoCo': " + refName + " cannot be resolved", - node.get_SourcePositionStart()); + if (node.getEnclosingScope().resolveVariable(refName).isEmpty()) { + Log.error(String.format(ERROR_RIGHT_REFERENCE_UNRESOLVED, refName), node.get_SourcePositionStart()); } }); } diff --git a/src/main/java/de/monticore/odlink/_visitor/LinkVisitor.java b/src/main/java/de/monticore/odlink/_visitor/LinkVisitor.java index 74f5708d..6dea991a 100644 --- a/src/main/java/de/monticore/odlink/_visitor/LinkVisitor.java +++ b/src/main/java/de/monticore/odlink/_visitor/LinkVisitor.java @@ -9,7 +9,7 @@ public class LinkVisitor implements ODLinkVisitor2 { - private List links = new ArrayList<>(); + private final List links = new ArrayList<>(); @Override public void visit(ASTODLink link) { diff --git a/src/main/java/de/monticore/odlink/trafo/ODLinkAttributeValueCompositionTrafo.java b/src/main/java/de/monticore/odlink/trafo/ODLinkAttributeValueCompositionTrafo.java index 6cb4036e..d37815dd 100644 --- a/src/main/java/de/monticore/odlink/trafo/ODLinkAttributeValueCompositionTrafo.java +++ b/src/main/java/de/monticore/odlink/trafo/ODLinkAttributeValueCompositionTrafo.java @@ -16,7 +16,10 @@ import java.util.*; public class ODLinkAttributeValueCompositionTrafo implements ODBasisVisitor2, ODLinkVisitor2 { - + + public static final String WARN_ANONYMOUS_PARENT = + "0x0D034: Could not extract composed object because its parent object is anonymous!"; + protected List objectsToMove = new ArrayList<>(); protected List attributesToRemove = new ArrayList<>(); protected List compositionsToCreate = new ArrayList<>(); @@ -26,35 +29,37 @@ public void endVisit(ASTODObject node) { for (ASTODAttribute attribute : node.getODAttributeList()) { if (attribute.isPresentODValue()) { ASTODValue value = attribute.getODValue(); - if (ODLinkMill.typeDispatcher().isODBasisASTODNamedObject(value)) { - ASTODNamedObject namedObject = - ODLinkMill.typeDispatcher().asODBasisASTODNamedObject(value); - attributesToRemove.add(attribute); - objectsToMove.add(namedObject); - - ASTODLink link = createComposition(node.getName(), namedObject.getName(), attribute.getName()); - compositionsToCreate.add(link); - } - else if (ODLinkMill.typeDispatcher().isODBasisASTODAnonymousObject(value)) { - Log.warn("0x0D021: Could not extract composed object because its anonymous!", + switch (value) { + case ASTODNamedObject namedObject -> { + if (isAnonymousParent(node, value)) { + break; + } + attributesToRemove.add(attribute); + objectsToMove.add(namedObject); + + ASTODLink link = createComposition(node.getName(), namedObject.getName(), attribute.getName()); + compositionsToCreate.add(link); + } + case ASTODAnonymousObject anonymousObject -> Log.warn("0x0D032: Could not extract composed object because its anonymous!", value.get_SourcePositionStart()); - } - else if (ODLinkMill.typeDispatcher().isODBasisASTODName(value)) { - ASTODName odName = ODLinkMill.typeDispatcher().asODBasisASTODName(value); - ASTODLink link = createAssociation(node.getName(), odName.getName(), attribute.getName()); - attributesToRemove.add(attribute); - compositionsToCreate.add(link); - } - else if (ODLinkMill.typeDispatcher().isODBasisASTODSimpleAttributeValue(value)) { - ASTODSimpleAttributeValue simpleValue = ODLinkMill.typeDispatcher().asODBasisASTODSimpleAttributeValue(value); - if (ODLinkMill.typeDispatcher().isExpressionsBasisASTNameExpression(simpleValue.getExpression())) { - // TODO JRa: Use Typecheck3 to check the reference of the NameExpression. Do not transform, if its an ENUM value! - ASTNameExpression nameExpression = - ODLinkMill.typeDispatcher().asExpressionsBasisASTNameExpression(simpleValue.getExpression()); - ASTODLink link = createAssociation(node.getName(), nameExpression.getName(), attribute.getName()); + case ASTODName odName -> { + if (isAnonymousParent(node, value)) { + break; + } + ASTODLink link = createAssociation(node.getName(), odName.getName(), attribute.getName()); attributesToRemove.add(attribute); compositionsToCreate.add(link); } + case ASTODSimpleAttributeValue simpleAttributeValue -> { + if (simpleAttributeValue.getExpression() instanceof ASTNameExpression nameExpression + && !isAnonymousParent(node, value)) { + // TODO JRa: Use Typecheck3 to check the reference of the NameExpression. Do not transform, if its an ENUM value! + ASTODLink link = createAssociation(node.getName(), nameExpression.getName(), attribute.getName()); + attributesToRemove.add(attribute); + compositionsToCreate.add(link); + } + } + default -> {} // ignore } } } @@ -66,8 +71,23 @@ public void endVisit(ASTODArtifact node) { node.getObjectDiagram().addAllODElements(objectsToMove); node.getObjectDiagram().addAllODElements(compositionsToCreate); objectsToMove.clear(); + attributesToRemove.clear(); compositionsToCreate.clear(); } + + /** + * Links require the name of the parent object, so no links can be created for values of + * anonymous objects. In this case, a warning is logged at the value. + * + * @return {@code true} if the parent object is anonymous and the value must be skipped + */ + protected boolean isAnonymousParent(ASTODObject parent, ASTODValue value) { + if (parent instanceof ASTODAnonymousObject) { + Log.warn(WARN_ANONYMOUS_PARENT, value.get_SourcePositionStart()); + return true; + } + return false; + } protected ASTODLinkBuilder createLinkBase(String sourceName, String targetName, String roleName) { ASTODName leftSideName = ODLinkMill.oDNameBuilder().setName(sourceName).build(); diff --git a/src/main/java/de/monticore/odlink/utils/ODLinkCollector.java b/src/main/java/de/monticore/odlink/utils/ODLinkCollector.java index 5eac2dc6..fc8b3993 100644 --- a/src/main/java/de/monticore/odlink/utils/ODLinkCollector.java +++ b/src/main/java/de/monticore/odlink/utils/ODLinkCollector.java @@ -10,7 +10,7 @@ public class ODLinkCollector implements ODLinkVisitor2 { - private List links = new ArrayList<>(); + private final List links = new ArrayList<>(); @Override public void visit(ASTODLink link) { diff --git a/src/main/resources/od2cd/Check.ftl b/src/main/resources/od2cd/Check.ftl index 2c56a608..3b9121f4 100644 --- a/src/main/resources/od2cd/Check.ftl +++ b/src/main/resources/od2cd/Check.ftl @@ -1,4 +1,10 @@ <#-- (c) https://github.com/MontiCore/monticore --> +<#-- @ftlvariable name="tc" type="de.monticore.generating.templateengine.TemplateController" --> +<#-- @ftlvariable name="cd4c" type="de.monticore.cd.methodtemplates.CD4C" --> +<#-- @ftlvariable name="name" type="java.lang.String" --> +<#-- @ftlvariable name="attributes" type="java.util.List" --> +<#-- @ftlvariable name="values" type="java.util.List" --> +<#-- @ftlvariable name="type" type="java.lang.String" --> ${tc.signature("name", "attributes", "values", "type")} ${cd4c.method("public void check${name?capFirst}(${type?capFirst} ${name})")} diff --git a/src/main/resources/od2cd/InstList.ftl b/src/main/resources/od2cd/InstList.ftl index 6d5b829f..99948e9b 100644 --- a/src/main/resources/od2cd/InstList.ftl +++ b/src/main/resources/od2cd/InstList.ftl @@ -1,4 +1,12 @@ <#-- (c) https://github.com/MontiCore/monticore --> +<#-- @ftlvariable name="tc" type="de.monticore.generating.templateengine.TemplateController" --> +<#-- @ftlvariable name="cd4c" type="de.monticore.cd.methodtemplates.CD4C" --> +<#-- @ftlvariable name="cp" type="de.monticore.od2cd.CompositionPrinter" --> +<#-- @ftlvariable name="types" type="java.util.List" --> +<#-- @ftlvariable name="names" type="java.util.List" --> +<#-- @ftlvariable name="links" type="java.util.List" --> +<#-- @ftlvariable name="objects" type="java.util.List" --> +<#-- @ftlvariable name="odname" type="java.lang.String" --> ${tc.signature("types", "names", "links", "objects", "odname")} ${cd4c.method("public " + odname + "ODInstances instantiate()")} diff --git a/src/main/resources/od2cd/Instantiate.ftl b/src/main/resources/od2cd/Instantiate.ftl index 7013fbc4..b9a7afc8 100644 --- a/src/main/resources/od2cd/Instantiate.ftl +++ b/src/main/resources/od2cd/Instantiate.ftl @@ -1,4 +1,12 @@ <#-- (c) https://github.com/MontiCore/monticore --> +<#-- @ftlvariable name="tc" type="de.monticore.generating.templateengine.TemplateController" --> +<#-- @ftlvariable name="cd4c" type="de.monticore.cd.methodtemplates.CD4C" --> +<#-- @ftlvariable name="cp" type="de.monticore.od2cd.CompositionPrinter" --> +<#-- @ftlvariable name="type" type="de.monticore.types.mcbasictypes._ast.ASTMCType" --> +<#-- @ftlvariable name="printInfo" type="java.lang.String" --> +<#-- @ftlvariable name="attributes" type="java.util.List" --> +<#-- @ftlvariable name="values" type="java.util.List" --> +<#-- @ftlvariable name="objectname" type="java.lang.String" --> ${tc.signature("type", "printInfo", "attributes", "values", "objectname")} ${cd4c.method("public ${printInfo} instantiate${objectname?capFirst}()")} diff --git a/src/main/resources/od2cd/OD2CD.ftl b/src/main/resources/od2cd/OD2CD.ftl index f130c0c5..51eda694 100644 --- a/src/main/resources/od2cd/OD2CD.ftl +++ b/src/main/resources/od2cd/OD2CD.ftl @@ -1,4 +1,10 @@ <#-- (c) https://github.com/MontiCore/monticore --> +<#-- @ftlvariable name="tc" type="de.monticore.generating.templateengine.TemplateController" --> +<#-- @ftlvariable name="glex" type="de.monticore.generating.templateengine.GlobalExtensionManagement" --> +<#-- @ftlvariable name="converter" type="de.monticore.od2cd.OD2CDConverter" --> +<#-- @ftlvariable name="generator" type="de.monticore.cd.codegen.CDGenerator" --> +<#-- @ftlvariable name="ast" type="de.monticore.odbasis._ast.ASTODArtifact" --> +<#-- @ftlvariable name="cdata" type="de.monticore.od2cd.OD2CDData" --> ${tc.signature("glex", "converter", "hwPath", "generator")} b\n@enduml\n", + destination.toString(), FileFormat.SVG); + + MCAssertions.assertHasFindingStartingWith("0x0D033"); + assertFalse(Files.exists(tmp.resolve("invalid.svg"))); + } +} diff --git a/src/test/java/de/monticore/od2plantuml/ODPlantUMLToolTest.java b/src/test/java/de/monticore/od2plantuml/ODPlantUMLToolTest.java new file mode 100644 index 00000000..3f943b98 --- /dev/null +++ b/src/test/java/de/monticore/od2plantuml/ODPlantUMLToolTest.java @@ -0,0 +1,148 @@ +package de.monticore.od2plantuml; + +import de.monticore.ODTestBasis; +import de.se_rwth.commons.logging.RichConsoleLogHook; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +public class ODPlantUMLToolTest extends ODTestBasis { + + private final Path INPUT_OD = PATH.resolve(Paths.get("examples", "od2cd", "Example.od")); + private final Path INPUT_PATH_DIR = PATH.resolve(Paths.get("symboltable", "tooltest")); + + @Test + void testHelp() { + String[] args = new String[] { "-h" }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals(11, out.size(), String.join("\n", out)); + assertEquals(" usage: ODPlantUMLTool [-h] [-i ] [-path ] [-pp ]", + out.getFirst()); + } + + @Test + void testMissingInputPrintsHelp() { + String[] args = new String[] {}; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals(11, out.size(), String.join("\n", out)); + assertEquals(" usage: ODPlantUMLTool [-h] [-i ] [-path ] [-pp ]", + out.getFirst()); + } + + @Test + void testPrettyPrintToStdout() { + String[] args = + new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-pp" }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals(11, out.size(), String.join("\n", out)); + assertEquals("@startuml", out.getFirst()); + assertEquals("note \"OD\" as tag #white", out.get(1)); + assertEquals("@enduml", out.getLast()); + } + + /** OD4Report models, e.g., with dates, are supported, too. */ + @Test + void testPrettyPrintOD4ReportModel() { + Path input = PATH.resolve(Paths.get("examples", "od2cd", "MyFamily.od")); + String[] args = new String[] { "-i", input.toString(), "-path", PATH.toString(), "-pp" }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals("@startuml", out.getFirst(), String.join("\n", out)); + assertTrue(out.contains(" bought = 2020-01-05 15:30:00"), String.join("\n", out)); + assertEquals("@enduml", out.getLast()); + } + + @Test + @Disabled("Disabled because PlantUML currently requires local GraphViz installation on Linux") + void testPrettyPrintToPngFile() { + Path output = getTmpFilePath("diagram.png"); + + String[] args = + new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-pp", + output.toString() }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals(1, out.size(), String.join("\n", out)); + assertEquals(ODPlantUMLTool.SUCCESS_IMAGE_GENERATED.formatted(output.toString()), out.getFirst()); + + assertTrue(Files.exists(output)); + } + + @Test + void testPrettyPrintWithUnsupportedFormat() { + Path output = getTmpFilePath("diagram.xyz"); + + String[] args = + new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-pp", + output.toString() }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals(1, out.size(), String.join("\n", out)); + assertEquals(getAsError(ODPlantUMLTool.ERROR_UNSUPPORTED_FORMAT, "xyz"), out.getFirst()); + + assertFalse(Files.exists(output)); + } + + @Test + void testPrettyPrintWithMissingExtension() { + Path output = getTmpFilePath("diagram"); + + String[] args = + new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-pp", + output.toString() }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals(1, out.size(), String.join("\n", out)); + assertEquals(getAsError(ODPlantUMLTool.ERROR_MISSING_EXTENSION), out.getFirst()); + assertFalse(Files.exists(output)); + } + + @Test + @Disabled("Disabled because PlantUML currently requires local GraphViz installation on Linux") + void testPrettyPrintToSvgFile() { + Path output = getTmpFilePath("diagram.svg"); + + String[] args = + new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-pp", + output.toString() }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals(1, out.size(), String.join("\n", out)); + assertEquals(ODPlantUMLTool.SUCCESS_IMAGE_GENERATED.formatted(output.toString()), out.getFirst()); + assertTrue(Files.exists(output)); + } + + @Test + void testParseOnlyWithoutPrettyPrint() { + String[] args = new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString() }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + // no output expected: no -pp given + assertEquals(0, out.size()); + } + + @Test + void testNonExistentInputFile() { + String[] args = + new String[] { "-i", "nonexistent/does_not_exist.od", "-path", INPUT_PATH_DIR.toString(), + "-pp" }; + List out = ODPlantUMLTestUtil.runToolInSeparateProcess(args); + + assertEquals(1, out.size()); + assertEquals(getAsError(ODPlantUMLTool.PARSE_ERROR_IO, "nonexistent/does_not_exist.od"), + out.getFirst()); + } + + protected String getAsError(String base, String... data) { + return RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " " + base.formatted(data).strip(); + } +} diff --git a/src/test/java/de/monticore/od2plantuml/PlantUMLODFullPrettyPrinterTest.java b/src/test/java/de/monticore/od2plantuml/PlantUMLODFullPrettyPrinterTest.java index 08e9185a..8016e27f 100644 --- a/src/test/java/de/monticore/od2plantuml/PlantUMLODFullPrettyPrinterTest.java +++ b/src/test/java/de/monticore/od2plantuml/PlantUMLODFullPrettyPrinterTest.java @@ -3,12 +3,14 @@ import de.monticore.ODTestBasis; import de.monticore.io.paths.MCPath; import de.monticore.od2plantuml.prettyprinter.PlantUMLODFullPrettyPrinter; -import de.monticore.od4data.trafo.OD4DataAttributeValueCompositionTrafo; -import de.monticore.od4data.trafo.OD4DataDeAnonymizeObjectsTrafo; +import de.monticore.od4development.trafo.OD4DevelopmentAttributeValueCompositionTrafo; +import de.monticore.od4development.trafo.OD4DevelopmentDeAnonymizeObjectsTrafo; import de.monticore.od4report.OD4ReportMill; import de.monticore.od4report.OD4ReportTestUtil; import de.monticore.odbasis._ast.ASTODArtifact; import de.monticore.runtime.junit.TestWithMCLanguage; +import net.sourceforge.plantuml.syntax.SyntaxChecker; +import net.sourceforge.plantuml.syntax.SyntaxResult; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -19,6 +21,7 @@ import java.nio.file.Paths; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * This class contains test cases for the PlantUMLODFullPrettyPrinter, which is responsible for @@ -54,7 +57,8 @@ public class PlantUMLODFullPrettyPrinterTest extends ODTestBasis { "od2cd/ProjectListOD", "od2cd/Variants", "od2cd/InnerObject", - "od2cd/MyFamily" + "od2cd/MyFamily", + "od2cd/PlantUMLConstructs" }) public void test(String input) throws IOException { Path inputPath = Paths.get(basedir + input+".od"); @@ -62,8 +66,8 @@ public void test(String input) throws IOException { ASTODArtifact transformableArtifact = OD4ReportTestUtil.loadModelAndST(inputPath, new MCPath(PATH)); - new OD4DataDeAnonymizeObjectsTrafo().transform(transformableArtifact); - new OD4DataAttributeValueCompositionTrafo().transform(transformableArtifact); + new OD4DevelopmentDeAnonymizeObjectsTrafo().transform(transformableArtifact); + new OD4DevelopmentAttributeValueCompositionTrafo().transform(transformableArtifact); PlantUMLODFullPrettyPrinter prettyPrinter = new PlantUMLODFullPrettyPrinter(); String plantUML = prettyPrinter.prettyprint(transformableArtifact); @@ -77,8 +81,10 @@ public void test(String input) throws IOException { "The printed output\n\n\"\"\"\n%s\n\"\"\"\n\ndoes not match with the expected PlantUML output\n\n\"\"\"\n%s\n\"\"\"\n.", plantUML, expectedPlantUML) ); - - // TODO MSm parse PlantUML + + // the comparison ignores whitespace, so additionally check that PlantUML accepts the output + SyntaxResult syntax = SyntaxChecker.checkSyntax(plantUML); + assertFalse(syntax.isError(), () -> "Invalid PlantUML: " + syntax.getErrors() + "\n" + plantUML); } /** diff --git a/src/test/java/de/monticore/od4data/OD4DataTestUtil.java b/src/test/java/de/monticore/od4data/OD4DataTestUtil.java deleted file mode 100644 index 7466d4b7..00000000 --- a/src/test/java/de/monticore/od4data/OD4DataTestUtil.java +++ /dev/null @@ -1,57 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.monticore.od4data; - -import com.google.common.collect.Lists; -import de.monticore.io.paths.MCPath; -import de.monticore.od4data._symboltable.IOD4DataArtifactScope; -import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.symbols.basicsymbols.BasicSymbolsMill; -import de.monticore.symboltable.ImportStatement; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.fail; - -public class OD4DataTestUtil { - - public static ASTODArtifact loadModelAndST(String pathToArtifact, MCPath symbolPath) { - Path path = Paths.get(pathToArtifact); - return loadModelAndST(path, symbolPath); - } - - public static ASTODArtifact loadModelAndST(Path pathToArtifact, MCPath symbolPath) { - ASTODArtifact artifact = loadModel(pathToArtifact, symbolPath); - createSymbolTableFromAST(artifact); - return artifact; - } - - public static ASTODArtifact loadModel(String pathToArtifact, MCPath symbolPath) { - Path path = Paths.get(pathToArtifact); - return loadModel(path, symbolPath); - } - - public static ASTODArtifact loadModel(Path pathToArtifact, MCPath symbolPath) { - BasicSymbolsMill.initializePrimitives(); - OD4DataMill.globalScope().setSymbolPath(symbolPath); - OD4DataMill.globalScope().putTypeSymbolDeSer("de.monticore.cdbasis._symboltable.CDTypeSymbol"); - ASTODArtifact artifact = OD4DataToolAPI.parse(pathToArtifact.toString()); - if (artifact == null) { - fail("Loading artifact: " + pathToArtifact + " failed!"); - } - return artifact; - } - - public static IOD4DataArtifactScope createSymbolTableFromAST(ASTODArtifact ast) { - IOD4DataArtifactScope as = OD4DataToolAPI.createSymbolTable(ast, true); - - // add imports - List imports = Lists.newArrayList(); - ast.getMCImportStatementList() - .forEach(i -> imports.add(new ImportStatement(i.getQName(), i.isStar()))); - as.setImportsList(imports); - - return as; - } -} diff --git a/src/test/java/de/monticore/od4data/OD4DataToolTest.java b/src/test/java/de/monticore/od4data/OD4DataToolTest.java deleted file mode 100644 index ef3ce92f..00000000 --- a/src/test/java/de/monticore/od4data/OD4DataToolTest.java +++ /dev/null @@ -1,118 +0,0 @@ -// (c) https://github.com/MontiCore/monticore - -package de.monticore.od4data; - -import de.monticore.ODOutTestBasis; -import de.monticore.runtime.junit.MCAssertions; - -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.*; - -public class OD4DataToolTest extends ODOutTestBasis { - - private final Path INPUT_DIR = PATH.resolve(Paths.get("examples", "od")); - private final Path INPUT_OD = INPUT_DIR.resolve("SimpleOD2.od"); - - @BeforeEach - void setUp() { - OD4DataMill.reset(); - } - - @Test - public void testOD4DataToolHelp() { - String[] help = { "-h" }; - new OD4DataTool().run(help); - - assertContains(getOut(), "usage: OD4DataTool [-c ] [-h]"); - MCAssertions.assertNoFindings(); - } - - @Test - public void testOD4DataToolMissingInput() { - String[] input = {}; - new OD4DataTool().run(input); - - assertContains(getOut(), "usage: OD4DataTool [-c ] [-h]"); - MCAssertions.assertNoFindings(); - } - - @Test - public void testOD4DataToolPath() { - String[] input = { "-i", INPUT_OD.toString(), "-path", PATH.toString(), - Paths.get(INPUT_DIR.toString(), "cocos").toString() }; - new OD4DataTool().run(input); - - assertEquals(String.format(OD4DataTool.PARSE_SUCCESSFUL, "SimpleOD2"), getOut()); - MCAssertions.assertNoFindings(); - } - - @Test - public void testOD4DataToolIntraCoCos() { - String[] input = { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-c", "intra" }; - new OD4DataTool().run(input); - - assertEquals(String.format(OD4DataTool.PARSE_SUCCESSFUL, "SimpleOD2") + String.format( - OD4DataTool.CHECK_SUCCESSFUL, "SimpleOD2"), getOut()); - MCAssertions.assertNoFindings(); - } - - @Test - public void testOD4ToolPrettyPrint() { - String ppOutPath = getTmpFilePath("pp.od").toString(); - String[] input = { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-pp", ppOutPath }; - new OD4DataTool().run(input); - - assertTrue(Paths.get(ppOutPath).toFile().exists()); - MCAssertions.assertNoFindings(); - } - - @Test - public void testOD4DataStoreST() { - String symOutPath = getTmpFilePath("SimpleOD2.odsym").toString(); - String[] input = { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-s", symOutPath }; - new OD4DataTool().run(input); - - assertTrue(Paths.get(symOutPath).toFile().exists()); - MCAssertions.assertNoFindings(); - } - - @Test - public void testStoreSymtabFile() { - Path stTargetPath = getTmpFilePath("symboltable", "examples", "od", "SimpleOD2.odsym"); - new OD4DataTool().run(new String[] { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-s", - stTargetPath.toString() }); - File symTab = stTargetPath.toFile(); - assertTrue(symTab.exists() && symTab.isFile()); - MCAssertions.assertNoFindings(); - } - - @Test - public void testStoreSymtabFile2() { - Path existingTargetDirPath = getTmpFilePath("existing"); - assertTrue(existingTargetDirPath.toFile().mkdir()); - new OD4DataTool().run(new String[] { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-s", - existingTargetDirPath.toString() }); - File symTab = existingTargetDirPath.resolve("SimpleOD2.odsym").toFile(); - assertTrue(symTab.exists() && symTab.isFile()); - MCAssertions.assertNoFindings(); - } - - @Test - public void testStoreSymtabFile3() { - Path copiedInputFile = getTmpFilePath("examples", "od", "SimpleOD2.od"); - assertDoesNotThrow(() -> FileUtils.copyFile(INPUT_OD.toFile(), copiedInputFile.toFile())); - new OD4DataTool().run( - new String[] { "-i", copiedInputFile.toString(), "-path", PATH.toString(), "-s" }); - File symTab = copiedInputFile.getParent().resolve("SimpleOD2.odsym").toFile(); - assertTrue(symTab.exists() && symTab.isFile()); - MCAssertions.assertNoFindings(); - } - -} diff --git a/src/test/java/de/monticore/od4data/_cocos/OD4DataCoCoCheckerTest.java b/src/test/java/de/monticore/od4data/_cocos/OD4DataCoCoCheckerTest.java deleted file mode 100644 index 61b8645f..00000000 --- a/src/test/java/de/monticore/od4data/_cocos/OD4DataCoCoCheckerTest.java +++ /dev/null @@ -1,97 +0,0 @@ -// (c) https://github.com/MontiCore/monticore - -package de.monticore.od4data._cocos; - -import de.monticore.ODOutTestBasis; -import de.monticore.io.paths.MCPath; -import de.monticore.od4data.OD4DataMill; -import de.monticore.od4data.OD4DataTestUtil; -import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.odbasis._cocos.attributes.PartialAndCompleteAttributesCoCo; -import de.monticore.odbasis._cocos.names.UniqueObjectNamesCoCo; -import de.monticore.odbasis._cocos.object.ValidObjectReferenceCoCo; -import de.monticore.odlink._cocos.link.LinkEndConsistencyCoCo; -import de.monticore.odlink._cocos.link.ValidLinkReferenceCoCo; -import de.monticore.runtime.junit.MCAssertions; -import de.monticore.runtime.junit.TestWithMCLanguage; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.nio.file.Path; - -@TestWithMCLanguage(OD4DataMill.class) -public class OD4DataCoCoCheckerTest extends ODOutTestBasis { - - private final Path cocoExamples = PATH.resolve("cocos"); - - private OD4DataCoCoChecker odCoCoChecker; - - @BeforeEach - public void setUp() { - odCoCoChecker = new OD4DataCoCoChecker(); - } - - @Test - public void checkUniqueObjectNamesCoCo() { - String testOD = cocoExamples.resolve("NoUniqueNames.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); - - odCoCoChecker.addCoCo(new UniqueObjectNamesCoCo()); - odCoCoChecker.checkAll(artifact); - MCAssertions.assertHasFindingStartingWith("0x0D002"); - MCAssertions.assertHasFindingStartingWith("0x0D002"); - } - - @Test - public void checkAnonymousObjectsValid() { - String testOD = cocoExamples.resolve("AnonymousObject.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); - - odCoCoChecker.addCoCo(new UniqueObjectNamesCoCo()); - odCoCoChecker.checkAll(artifact); - } - - @Test - public void checkValidReferenceCoCo() { - String testOD = cocoExamples.resolve("InvalidLinkReference.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); - - odCoCoChecker.addCoCo(new ValidLinkReferenceCoCo()); - odCoCoChecker.checkAll(artifact); - MCAssertions.assertHasFindingStartingWith("0x0D006"); - } - - @Test - public void checkObjectReferenceCoCo() { - String testOD = cocoExamples.resolve("InvalidObjectReference.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); - - odCoCoChecker.addCoCo(new ValidObjectReferenceCoCo()); - odCoCoChecker.checkAll(artifact); - MCAssertions.assertHasFindingStartingWith("0x0D001"); - } - - @Test - public void checkPartialAndCompleteAttributesCoCo() { - String testOD = cocoExamples.resolve("PartialAndCompleteAttributes.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); - - odCoCoChecker.addCoCo(new PartialAndCompleteAttributesCoCo()); - odCoCoChecker.checkAll(artifact); - MCAssertions.assertHasFindingStartingWith("0x0D004"); - MCAssertions.assertHasFindingStartingWith("0x0D004"); - MCAssertions.assertHasFindingStartingWith("0x0D004"); - } - - @Test - public void checkLinkEndConsistencyCoCo() { - String testOD = cocoExamples.resolve("InvalidLinkEndConsistency.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); - - odCoCoChecker.addCoCo(new LinkEndConsistencyCoCo()); - odCoCoChecker.checkAll(artifact); - MCAssertions.assertHasFindingStartingWith("0x0D008"); - } - -} diff --git a/src/test/java/de/monticore/od4data/_parser/ODBasicsParserTest.java b/src/test/java/de/monticore/od4data/_parser/ODBasicsParserTest.java deleted file mode 100644 index 40c2b07c..00000000 --- a/src/test/java/de/monticore/od4data/_parser/ODBasicsParserTest.java +++ /dev/null @@ -1,59 +0,0 @@ -// (c) https://github.com/MontiCore/monticore - -package de.monticore.od4data._parser; - -import de.monticore.ODTestBasis; -import de.monticore.od4data.OD4DataMill; -import de.monticore.odlink._ast.*; - -import de.monticore.runtime.junit.TestWithMCLanguage; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.*; - -@TestWithMCLanguage(OD4DataMill.class) -public class ODBasicsParserTest extends ODTestBasis { - - @Test - public void testODLinkLeftSide() throws IOException { - OD4DataParser odBasicsParser = OD4DataMill.parser(); - Optional linkLeftSide = - odBasicsParser.parse_StringODLinkLeftSide("public " + "A1,A2 [[test]] (eineRolle)"); - assertTrue(linkLeftSide.isPresent()); - assertEquals(2, linkLeftSide.get().sizeReferenceNames()); - assertEquals("test", linkLeftSide.get().getODLinkQualifier().getName()); - assertFalse(linkLeftSide.get().getODLinkQualifier().isPresentODValue()); - } - - @Test - public void testODLinkRightSide() throws IOException { - OD4DataParser odBasicsParser = OD4DataMill.parser(); - Optional linkRightSide = - odBasicsParser.parse_StringODLinkRightSide("(eineRolle) [[test]] A1,A2 private"); - assertTrue(linkRightSide.isPresent()); - assertEquals(2, linkRightSide.get().sizeReferenceNames()); - assertEquals("test", linkRightSide.get().getODLinkQualifier().getName()); - assertFalse(linkRightSide.get().getODLinkQualifier().isPresentODValue()); - } - - @Test - public void testODLink() throws IOException { - OD4DataParser odBasicsParser = OD4DataMill.parser(); - Optional link = odBasicsParser.parse_StringODLink("link A -- B"); - assertTrue(link.isPresent()); - } - - @Test - public void testODLinkDirection() throws IOException { - OD4DataParser odBasicsParser = OD4DataMill.parser(); - Optional unspecifiedDir = - odBasicsParser.parse_StringODUnspecifiedDir("--"); - Optional linkDirection = odBasicsParser.parse_StringODLinkDirection("--"); - assertTrue(unspecifiedDir.isPresent()); - assertTrue(linkDirection.isPresent()); - } - -} diff --git a/src/test/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafoTest.java b/src/test/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafoTest.java deleted file mode 100644 index 5cbe1429..00000000 --- a/src/test/java/de/monticore/od4data/trafo/OD4DataDeAnonymizeObjectsTrafoTest.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * (c) https://github.com/MontiCore/monticore - */ - -package de.monticore.od4data.trafo; - -import de.monticore.ODTestBasis; -import de.monticore.io.paths.MCPath; -import de.monticore.od4data.OD4DataMill; -import de.monticore.od4data.OD4DataTestUtil; -import de.monticore.odattribute._ast.ASTODList; -import de.monticore.odattribute._ast.ASTODMap; -import de.monticore.odbasis._ast.*; -import de.monticore.runtime.junit.TestWithMCLanguage; -import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Test; - -import java.nio.file.Path; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; - -@TestWithMCLanguage(OD4DataMill.class) -public class OD4DataDeAnonymizeObjectsTrafoTest extends ODTestBasis { - - private final Path TRAFO_EXAMPLES = PATH.resolve("trafos"); - - @Test - void testDeAnonymizationOuterObject() { - String testOD = TRAFO_EXAMPLES.resolve("AnonymousObjects.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModel(testOD, new MCPath(PATH)); - - ASTObjectDiagram diagram = artifact.getObjectDiagram(); - - // Assertions pre trafo - ASTODAnonymousObject foo = assertAndGetAsODAnonymousObject(diagram.getODElement(0)); - ASTODNamedObject bar = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar.getName()); - ASTODNamedObject barAttr = assertAndGetAsODNamedObject(bar.getODAttribute(1).getODValue()); - - new OD4DataDeAnonymizeObjectsTrafo().transform(artifact); - - // Assertions post trafo - ASTODNamedObject foo2 = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertContains(foo2.getName(), "_anonymous_"); - ASTODNamedObject bar2 = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar2.getName()); - ASTODNamedObject barAttr2 = assertAndGetAsODNamedObject(bar2.getODAttribute(1).getODValue()); - - assertEquals(0, Log.getFindingsCount()); - } - - @Test - void testDeAnonymizationInnerObject() { - String testOD = TRAFO_EXAMPLES.resolve("AnonymousObjects2.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModel(testOD, new MCPath(PATH)); - - ASTObjectDiagram diagram = artifact.getObjectDiagram(); - - // Assertions pre trafo - ASTODNamedObject foo = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertEquals("foo", foo.getName()); - ASTODNamedObject bar = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar.getName()); - ASTODAnonymousObject barAttr = - assertAndGetAsODAnonymousObject(bar.getODAttribute(1).getODValue()); - - new OD4DataDeAnonymizeObjectsTrafo().transform(artifact); - - // Assertions post trafo - ASTODNamedObject foo2 = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertEquals("foo", foo2.getName()); - ASTODNamedObject bar2 = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar2.getName()); - ASTODNamedObject barAttr2 = assertAndGetAsODNamedObject(bar2.getODAttribute(1).getODValue()); - assertContains(barAttr2.getName(), "_anonymous_"); - - assertEquals(0, Log.getFindingsCount()); - } - - @Test - void testDeAnonymizationInnerList() { - String testOD = TRAFO_EXAMPLES.resolve("AnonymousObjects3.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModel(testOD, new MCPath(PATH)); - - ASTObjectDiagram diagram = artifact.getObjectDiagram(); - - // Assertions pre trafo - ASTODNamedObject foo = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertEquals("foo", foo.getName()); - ASTODNamedObject bar = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar.getName()); - ASTODList fooList = assertAndGetAsODList(foo.getODAttribute(0).getODValue()); - ASTODNamedObject fooListVal1 = assertAndGetAsODNamedObject(fooList.getODValue(0)); - assertEquals("foo1", fooListVal1.getName()); - ASTODAnonymousObject fooListVal2 = assertAndGetAsODAnonymousObject(fooList.getODValue(1)); - - new OD4DataDeAnonymizeObjectsTrafo().transform(artifact); - - // Assertions post trafo - ASTODNamedObject foo2 = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertEquals("foo", foo2.getName()); - ASTODNamedObject bar2 = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar2.getName()); - ASTODList fooList2 = assertAndGetAsODList(foo2.getODAttribute(0).getODValue()); - ASTODNamedObject fooList2Val1 = assertAndGetAsODNamedObject(fooList2.getODValue(0)); - assertEquals("foo1", fooList2Val1.getName()); - ASTODNamedObject fooList2Val2 = assertAndGetAsODNamedObject(fooList2.getODValue(1)); - assertContains(fooList2Val2.getName(), "_anonymous_"); - - assertEquals(0, Log.getFindingsCount()); - } - - @Test - void testDeAnonymizationInnerMap() { - String testOD = TRAFO_EXAMPLES.resolve("AnonymousObjects4.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModel(testOD, new MCPath(PATH)); - - ASTObjectDiagram diagram = artifact.getObjectDiagram(); - - // Assertions pre trafo - ASTODNamedObject foo = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertEquals("foo", foo.getName()); - ASTODNamedObject bar = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar.getName()); - ASTODMap fooMap = assertAndGetAsODMap(foo.getODAttribute(0).getODValue()); - ASTODNamedObject fooMapVal1 = assertAndGetAsODNamedObject(fooMap.getODMapElement(0).getVal()); - assertEquals("foo1", fooMapVal1.getName()); - ASTODAnonymousObject fooMapVal2 = - assertAndGetAsODAnonymousObject(fooMap.getODMapElement(1).getVal()); - - new OD4DataDeAnonymizeObjectsTrafo().transform(artifact); - - // Assertions post trafo - ASTODNamedObject foo2 = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertEquals("foo", foo2.getName()); - ASTODNamedObject bar2 = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar2.getName()); - ASTODMap fooMap2 = assertAndGetAsODMap(foo2.getODAttribute(0).getODValue()); - ASTODNamedObject fooMap2Val1 = assertAndGetAsODNamedObject(fooMap2.getODMapElement(0).getVal()); - assertEquals("foo1", fooMap2Val1.getName()); - ASTODNamedObject fooMap2Val2 = assertAndGetAsODNamedObject(fooMap2.getODMapElement(1).getVal()); - assertContains(fooMap2Val2.getName(), "_anonymous_"); - - assertEquals(0, Log.getFindingsCount()); - } - - @Test - void testDeAnonymizationNested() { - String testOD = TRAFO_EXAMPLES.resolve("AnonymousObjects5.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModel(testOD, new MCPath(PATH)); - - ASTObjectDiagram diagram = artifact.getObjectDiagram(); - - // Assertions pre trafo - ASTODNamedObject foo = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertEquals("foo", foo.getName()); - ASTODNamedObject bar = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar.getName()); - ASTODMap fooMap = assertAndGetAsODMap(foo.getODAttribute(0).getODValue()); - ASTODNamedObject fooMapVal1 = assertAndGetAsODNamedObject(fooMap.getODMapElement(0).getVal()); - assertEquals("foo1", fooMapVal1.getName()); - ASTODAnonymousObject fooMapVal2 = - assertAndGetAsODAnonymousObject(fooMap.getODMapElement(1).getVal()); - ASTODList fooMapVal1List = assertAndGetAsODList(fooMapVal1.getODAttribute(0).getODValue()); - ASTODNamedObject fooMapVal1ListVal1 = assertAndGetAsODNamedObject(fooMapVal1List.getODValue(0)); - assertEquals("innerA", fooMapVal1ListVal1.getName()); - ASTODAnonymousObject fooMapVal1ListVal2 = - assertAndGetAsODAnonymousObject(fooMapVal1List.getODValue(1)); - ASTODNamedObject fooMapVal1ListVal3 = assertAndGetAsODNamedObject(fooMapVal1List.getODValue(2)); - assertEquals("innerC", fooMapVal1ListVal3.getName()); - ASTODAnonymousObject fooMapVal1ListVal3FB1 = - assertAndGetAsODAnonymousObject(fooMapVal1ListVal3.getODAttribute(0).getODValue()); - ASTODNamedObject fooMapVal1ListVal3FB2 = - assertAndGetAsODNamedObject(fooMapVal1ListVal3.getODAttribute(1).getODValue()); - assertEquals("innerE", fooMapVal1ListVal3FB2.getName()); - - new OD4DataDeAnonymizeObjectsTrafo().transform(artifact); - - ASTODNamedObject foo2 = assertAndGetAsODNamedObject(diagram.getODElement(0)); - assertEquals("foo", foo2.getName()); - ASTODNamedObject bar2 = assertAndGetAsODNamedObject(diagram.getODElement(1)); - assertEquals("bar", bar2.getName()); - ASTODMap fooMap2 = assertAndGetAsODMap(foo2.getODAttribute(0).getODValue()); - ASTODNamedObject fooMap2Val1 = assertAndGetAsODNamedObject(fooMap2.getODMapElement(0).getVal()); - assertEquals("foo1", fooMap2Val1.getName()); - ASTODNamedObject fooMap2Val2 = assertAndGetAsODNamedObject(fooMap2.getODMapElement(1).getVal()); - assertContains(fooMap2Val2.getName(), "_anonymous_"); - ASTODList fooMap2Val1List = assertAndGetAsODList(fooMap2Val1.getODAttribute(0).getODValue()); - ASTODNamedObject fooMap2Val1ListVal1 = - assertAndGetAsODNamedObject(fooMap2Val1List.getODValue(0)); - assertEquals("innerA", fooMap2Val1ListVal1.getName()); - ASTODNamedObject fooMap2Val1ListVal2 = - assertAndGetAsODNamedObject(fooMap2Val1List.getODValue(1)); - assertContains(fooMap2Val1ListVal2.getName(), "_anonymous_"); - ASTODNamedObject fooMap2Val1ListVal3 = - assertAndGetAsODNamedObject(fooMap2Val1List.getODValue(2)); - assertEquals("innerC", fooMap2Val1ListVal3.getName()); - ASTODNamedObject fooMap2Val1ListVal3FB1 = - assertAndGetAsODNamedObject(fooMap2Val1ListVal3.getODAttribute(0).getODValue()); - assertContains(fooMap2Val1ListVal3FB1.getName(), "_anonymous_"); - ASTODNamedObject fooMap2Val1ListVal3FB2 = - assertAndGetAsODNamedObject(fooMap2Val1ListVal3.getODAttribute(1).getODValue()); - assertEquals("innerE", fooMap2Val1ListVal3FB2.getName()); - } - - protected ASTODList assertAndGetAsODList(ASTODValue value) { - assertInstanceOf(ASTODList.class, value); - return OD4DataMill.typeDispatcher().asODAttributeASTODList(value); - } - - protected ASTODMap assertAndGetAsODMap(ASTODValue value) { - assertInstanceOf(ASTODMap.class, value); - return OD4DataMill.typeDispatcher().asODAttributeASTODMap(value); - } - - protected ASTODNamedObject assertAndGetAsODNamedObject(ASTODElement element) { - assertInstanceOf(ASTODNamedObject.class, element); - return OD4DataMill.typeDispatcher().asODBasisASTODNamedObject(element); - } - - protected ASTODAnonymousObject assertAndGetAsODAnonymousObject(ASTODElement element) { - assertInstanceOf(ASTODAnonymousObject.class, element); - return OD4DataMill.typeDispatcher().asODBasisASTODAnonymousObject(element); - } - - protected ASTODNamedObject assertAndGetAsODNamedObject(ASTODValue value) { - assertInstanceOf(ASTODNamedObject.class, value); - return OD4DataMill.typeDispatcher().asODBasisASTODNamedObject(value); - } - - protected ASTODAnonymousObject assertAndGetAsODAnonymousObject(ASTODValue value) { - assertInstanceOf(ASTODAnonymousObject.class, value); - return OD4DataMill.typeDispatcher().asODBasisASTODAnonymousObject(value); - } -} diff --git a/src/test/java/de/monticore/od4data/OD4DataExamplesTest.java b/src/test/java/de/monticore/od4development/OD4DevelopmentExamplesTest.java similarity index 74% rename from src/test/java/de/monticore/od4data/OD4DataExamplesTest.java rename to src/test/java/de/monticore/od4development/OD4DevelopmentExamplesTest.java index 99c7b18c..cbec3e8c 100644 --- a/src/test/java/de/monticore/od4data/OD4DataExamplesTest.java +++ b/src/test/java/de/monticore/od4development/OD4DevelopmentExamplesTest.java @@ -1,14 +1,12 @@ // (c) https://github.com/MontiCore/monticore -package de.monticore.od4data; +package de.monticore.od4development; import de.monticore.ODTestBasis; import de.monticore.io.paths.MCPath; -import de.monticore.od4data._parser.OD4DataParser; -import de.monticore.od4data._prettyprint.OD4DataFullPrettyPrinter; -import de.monticore.od4data._symboltable.IOD4DataArtifactScope; +import de.monticore.od4development._parser.OD4DevelopmentParser; +import de.monticore.od4development._symboltable.IOD4DevelopmentArtifactScope; import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.prettyprint.IndentPrinter; import de.monticore.runtime.junit.MCAssertions; import de.monticore.runtime.junit.TestWithMCLanguage; import org.antlr.v4.runtime.RecognitionException; @@ -27,8 +25,8 @@ * This test compares the ASTs of the files in the examples folder with the pretty-printed versions * of these files. */ -@TestWithMCLanguage(OD4DataMill.class) -public class OD4DataExamplesTest extends ODTestBasis { +@TestWithMCLanguage(OD4DevelopmentMill.class) +public class OD4DevelopmentExamplesTest extends ODTestBasis { @ParameterizedTest @ValueSource(strings = { "examples/od/SpecialValues.od", "examples/od/QualifiedLinks.od", @@ -39,17 +37,17 @@ public class OD4DataExamplesTest extends ODTestBasis { public void test(String modelName) throws RecognitionException, IOException { Path model = PATH.resolve(Paths.get(modelName)); - ASTODArtifact artifact = OD4DataTestUtil.loadModel(model, new MCPath(PATH)); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModel(model, new MCPath(PATH)); - IOD4DataArtifactScope odBasicsArtifactScope = - OD4DataTestUtil.createSymbolTableFromAST(artifact); + IOD4DevelopmentArtifactScope odBasicsArtifactScope = + OD4DevelopmentTestUtil.createSymbolTableFromAST(artifact); assertNotNull(odBasicsArtifactScope); // pretty print the AST - String ppResult = new OD4DataFullPrettyPrinter(new IndentPrinter()).prettyprint(artifact); + String ppResult = OD4DevelopmentMill.prettyPrint(artifact, false); // parse the printers content - OD4DataParser parser = OD4DataMill.parser(); + OD4DevelopmentParser parser = OD4DevelopmentMill.parser(); Optional ppOd = parser.parse_StringODArtifact(ppResult); assertFalse(parser.hasErrors()); @@ -63,7 +61,7 @@ public void test(String modelName) throws RecognitionException, IOException { @ValueSource(strings = { "src/test/resources/examples/od/InnerObjectWithoutLink.od" }) public void negativTest(String modelName) throws RecognitionException, IOException { Path model = Paths.get(modelName); - OD4DataParser parser = OD4DataMill.parser(); + OD4DevelopmentParser parser = OD4DevelopmentMill.parser(); parser.parseODArtifact(model.toString()); assertTrue(parser.hasErrors()); MCAssertions.assertHasFindingStartingWith("missing ';' at '}' in rule stack"); diff --git a/src/test/java/de/monticore/od4development/OD4DevelopmentTestUtil.java b/src/test/java/de/monticore/od4development/OD4DevelopmentTestUtil.java new file mode 100644 index 00000000..311326d8 --- /dev/null +++ b/src/test/java/de/monticore/od4development/OD4DevelopmentTestUtil.java @@ -0,0 +1,91 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.od4development; + +import com.google.common.collect.Lists; +import de.monticore.ToolProcessRunner; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development._symboltable.IOD4DevelopmentArtifactScope; +import de.monticore.od4development._visitor.OD4DevelopmentTraverser; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.odbasis._symboltable.ODBasisSymbolTableCompleter; +import de.monticore.symbols.basicsymbols.BasicSymbolsMill; +import de.monticore.symboltable.ImportStatement; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.fail; + +public class OD4DevelopmentTestUtil { + + public static ASTODArtifact loadModelAndST(String pathToArtifact, MCPath symbolPath) { + Path path = Paths.get(pathToArtifact); + return loadModelAndST(path, symbolPath); + } + + public static ASTODArtifact loadModelAndST(Path pathToArtifact, MCPath symbolPath) { + ASTODArtifact artifact = loadModel(pathToArtifact, symbolPath); + createSymbolTableFromAST(artifact); + return artifact; + } + + public static ASTODArtifact loadModel(String pathToArtifact, MCPath symbolPath) { + Path path = Paths.get(pathToArtifact); + return loadModel(path, symbolPath); + } + + public static ASTODArtifact loadModel(Path pathToArtifact, MCPath symbolPath) { + BasicSymbolsMill.initializePrimitives(); + OD4DevelopmentMill.globalScope().setSymbolPath(symbolPath); + OD4DevelopmentMill.globalScope().putTypeSymbolDeSer("de.monticore.cdbasis._symboltable.CDTypeSymbol"); + Optional artifact = assertDoesNotThrow(() -> OD4DevelopmentMill.parser().parse(pathToArtifact.toString())); + if (artifact.isEmpty()) { + fail("Loading artifact: " + pathToArtifact + " failed!"); + } + return artifact.get(); + } + + public static IOD4DevelopmentArtifactScope createSymbolTableFromAST(ASTODArtifact ast) { + IOD4DevelopmentArtifactScope as = OD4DevelopmentMill.scopesGenitorDelegator().createFromAST(ast); + + // add imports + List imports = Lists.newArrayList(); + ast.getMCImportStatementList() + .forEach(i -> imports.add(new ImportStatement(i.getQName(), i.isStar()))); + as.setImportsList(imports); + return as; + } + + public static void completeSymbolTable(ASTODArtifact ast, boolean checkObjectTypes) { + OD4DevelopmentTraverser traverser = OD4DevelopmentMill.inheritanceTraverser(); + + ODBasisSymbolTableCompleter odBasisCompleter = + new ODBasisSymbolTableCompleter(checkObjectTypes); + traverser.add4ODBasis(odBasisCompleter); + odBasisCompleter.setTraverser(traverser); + ast.accept(traverser); + } + + /** + * Runs the OD tool in a separate JVM process and returns the merged console output. + * + * @see ToolProcessRunner + */ + public static List runToolInSeparateProcess(String... args) { + return runToolInSeparateProcess(null, args); + } + + /** + * Runs the OD tool in a separate JVM process with the given working directory and returns the + * merged console output. + * + * @param workingDir working directory of the process, {@code null} for the current one + * @see ToolProcessRunner + */ + public static List runToolInSeparateProcess(Path workingDir, String... args) { + return ToolProcessRunner.run(OD4DevelopmentTool.class, workingDir, args); + } +} diff --git a/src/test/java/de/monticore/od4development/OD4DevelopmentToolTest.java b/src/test/java/de/monticore/od4development/OD4DevelopmentToolTest.java index 8a9c0163..72d3e25e 100644 --- a/src/test/java/de/monticore/od4development/OD4DevelopmentToolTest.java +++ b/src/test/java/de/monticore/od4development/OD4DevelopmentToolTest.java @@ -1,18 +1,22 @@ /* (c) https://github.com/MontiCore/monticore */ package de.monticore.od4development; -import de.monticore.ODOutTestBasis; -import de.monticore.runtime.junit.MCAssertions; +import de.monticore.ODTestBasis; +import de.se_rwth.commons.logging.RichConsoleLogHook; +import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.File; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.*; -public class OD4DevelopmentToolTest extends ODOutTestBasis { +public class OD4DevelopmentToolTest extends ODTestBasis { private final Path INPUT_OD = PATH.resolve(Paths.get("examples", "od2cd", "Example.od")); private final Path INPUT_PATH_DIR = PATH.resolve(Paths.get("symboltable", "tooltest")); @@ -25,89 +29,243 @@ void setUp() { @Test public void testOD4DevelopmentToolHelp() { String[] help = { "-h" }; - new OD4DevelopmentTool().run(help); + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(help); - assertContains(getOut(), "usage: OD4DevelopmentTool [-c] [-h]"); - MCAssertions.assertNoFindings(); + assertEquals(29, out.size()); + assertContains(out.getFirst(), "usage: OD4DevelopmentTool [-c ] [-h] [-i ]"); } + @Test + public void testOD4DevelopmentToolVersion() { + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess("-v"); + + assertEquals(1, out.size()); + assertContains(out.getFirst(), "based on MontiCore version"); + } + + @Test + public void testOD4DevelopmentToolStacktrace() { + List out = + OD4DevelopmentTestUtil.runToolInSeparateProcess("-i", INPUT_OD.toString(), "--stacktrace"); + + assertEquals(1, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + } + + @Test + public void testOD4DevelopmentToolReportNotSupported() { + List out = + OD4DevelopmentTestUtil.runToolInSeparateProcess("-i", INPUT_OD.toString(), "-r", "reports"); + + assertEquals(1, out.size()); + assertEquals(getAsError(OD4DevelopmentTool.REPORT_OPTION_NOT_SUPPORTED), out.getFirst()); + } + @Test public void testOD4DevelopmentToolMissingInput() { String[] input = {}; - new OD4DevelopmentTool().run(input); + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); - assertContains(getOut(), "usage: OD4DevelopmentTool [-c] [-h]"); - MCAssertions.assertNoFindings(); + assertEquals(1, out.size()); + assertEquals(getAsError(OD4DevelopmentTool.INPUT_OPTION_NOT_PRESENT), out.getFirst()); } @Test public void testOD4DevelopmentToolPath() { String[] input = { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), Paths.get(INPUT_PATH_DIR.toString(), "cocos").toString() }; - new OD4DevelopmentTool().run(input); - assertEquals(String.format(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), getOut()); - MCAssertions.assertNoFindings(); + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(1, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); } @Test public void testOD4DevelopmentToolIntraCoCos() { String[] input = - { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-c", "intra" }; + { "-i", INPUT_OD.toString(), "-c", "intra" }; new OD4DevelopmentTool().run(input); - - assertEquals(String.format(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples") + String.format( - OD4DevelopmentTool.CHECK_SUCCESSFUL, "Examples"), getOut()); - MCAssertions.assertNoFindings(); + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4DevelopmentTool.CHECK_SUCCESSFUL, "Examples"), out.get(1)); + } + + @Test + public void testOD4DevelopmentToolAllCoCosWithoutArgument() { + String[] input = { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-c" }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4DevelopmentTool.CHECK_SUCCESSFUL, "Examples"), out.get(1)); + } + + @Test + public void testOD4DevelopmentToolCocoInvalidArgument() { + String[] input = { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-c", + "foo" }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsError(OD4DevelopmentTool.COCO_OPTION_INVALID, "foo"), out.get(1)); + } + + @Test + public void testOD4DevelopmentToolCocoTooManyArguments() { + String[] input = { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-c", + "intra", "-c", "inter" }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsError(OD4DevelopmentTool.COCO_OPTION_TOO_MANY_ARGS), out.get(1)); + } + + @Test + public void testOD4DevelopmentToolPrettyPrintToStdout() { + String[] input = { "-i", INPUT_OD.toString(), "-pp" }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(18, out.size()); + assertEquals("/* (c) https://github.com/MontiCore/monticore */", out.getFirst()); + assertEquals("package examples.od2cd;", out.get(1)); + assertEquals("objectdiagram Examples { ", out.get(2)); + } + + @Test + public void testOD4DevelopmentToolOutputWithoutArgument() { + String[] input = { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-o" }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsError(OD4DevelopmentTool.OUTPUT_OPTION_MISSING_ARG), out.get(1)); + } + + @Test + public void testOD4DevelopmentToolOutputWithBlankArgument() { + String[] input = { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-o", " " }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsError(OD4DevelopmentTool.OUTPUT_OPTION_MISSING_ARG), out.get(1)); + } + + @Test + public void testOD4DevelopmentToolOutputDirectoryGeneration() throws Exception { + Path outputDir = getTmpFilePath("generated-cd"); + String[] input = { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-o", outputDir.toString() }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertTrue(Files.isDirectory(outputDir)); + try (Stream generatedFiles = Files.walk(outputDir)) { + assertTrue(generatedFiles.anyMatch(Files::isRegularFile)); + } + } + + @Test + public void testOD4DevelopmentToolOutputPathInvalidFile() throws Exception { + Path invalidOutput = getTmpFilePath("output-target.txt"); + Files.writeString(invalidOutput, "dummy"); + + String[] input = { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-o", invalidOutput.toString() }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsError(OD4DevelopmentTool.OUTPUT_PATH_INVALID, invalidOutput.toString()), out.get(1)); } @Test public void testOD4ToolPrettyPrint() { String ppOutPath = getTmpFilePath("pp.od").toString(); String[] input = - { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-pp", ppOutPath }; - new OD4DevelopmentTool().run(input); + { "-i", INPUT_OD.toString(), "-pp", ppOutPath }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(input); + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4DevelopmentTool.PRETTYPRINT_SUCCESSFUL, ppOutPath), out.get(1)); assertTrue(Paths.get(ppOutPath).toFile().exists()); - MCAssertions.assertNoFindings(); - } - - @Test - public void testAddSymtabFile() { - String[] args = new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString() }; - assertTrue(OD4DevelopmentMill.globalScope().getSymbolPath().isEmpty()); - new OD4DevelopmentTool().run(args); - assertTrue(OD4DevelopmentMill.globalScope().getSymbolPath().toString() - .endsWith("resources/symboltable/tooltest/]")); - - assertEquals(String.format(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), getOut()); - MCAssertions.assertNoFindings(); } @Test public void testStoreSymtabFile() { Path stTargetPath = getTmpFilePath("symboltable", "examples", "od2cd", "Examples.odsym"); - new OD4DevelopmentTool().run( - new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-s", - stTargetPath.toString() }); + String[] args = new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-s", + stTargetPath.toString() }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(args); File symTab = stTargetPath.toFile(); assertTrue(symTab.exists() && symTab.isFile()); - assertEquals(String.format(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples") + String.format( - OD4DevelopmentTool.STEXPORT_SUCCESSFUL, symTab.getAbsolutePath()), getOut()); - MCAssertions.assertNoFindings(); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4DevelopmentTool.STEXPORT_SUCCESSFUL, symTab.getAbsolutePath()), out.get(1)); } @Test public void testStoreSymtabFile2() { Path existingTargetDirPath = getTmpFilePath("existing"); assertTrue(existingTargetDirPath.toFile().mkdir()); - new OD4DevelopmentTool().run( - new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-s", - existingTargetDirPath.toString() }); + String[] args = new String[] { "-i", INPUT_OD.toString(), "-path", INPUT_PATH_DIR.toString(), "-s", + existingTargetDirPath.toString() }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(args); + File symTab = getTmpFilePath("existing", "Example.odsym").toFile(); assertTrue(symTab.exists() && symTab.isFile()); - assertEquals(String.format(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples") + String.format( - OD4DevelopmentTool.STEXPORT_SUCCESSFUL, symTab.getAbsolutePath()), getOut()); - MCAssertions.assertNoFindings(); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4DevelopmentTool.STEXPORT_SUCCESSFUL, symTab.getAbsolutePath()), out.get(1)); + } + + @Test + public void testStoreSymtabFile3() { + Path copiedInputFile = getTmpFilePath("examples", "od", "SimpleOD2.od"); + assertDoesNotThrow(() -> FileUtils.copyFile(INPUT_OD.toFile(), copiedInputFile.toFile())); + String[] args = new String[] { "-i", copiedInputFile.toString(), "-path", INPUT_PATH_DIR.toString(), "-s" }; + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(args); + + File symTab = copiedInputFile.getParent().resolve("SimpleOD2.odsym").toFile(); + assertTrue(symTab.exists() && symTab.isFile()); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4DevelopmentTool.STEXPORT_SUCCESSFUL, symTab.getAbsolutePath()), out.get(1)); + } + + /** The symbol table is stored next to an input file that is given without a directory. */ + @Test + public void testStoreSymtabFileWithoutParentPath() { + Path workingDir = getTmpFilePath("relative-input"); + assertDoesNotThrow(() -> Files.createDirectories(workingDir)); + assertDoesNotThrow(() -> Files.copy(INPUT_OD, workingDir.resolve("Example.od"))); + + List out = OD4DevelopmentTestUtil.runToolInSeparateProcess(workingDir, "-i", + "Example.od", "-path", INPUT_PATH_DIR.toAbsolutePath().toString(), "-s"); + + Path symTab = workingDir.resolve("Example.odsym"); + assertEquals(2, out.size(), String.join("\n", out)); + assertEquals(getAsInfo(OD4DevelopmentTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4DevelopmentTool.STEXPORT_SUCCESSFUL, + symTab.toAbsolutePath().toString()), out.get(1)); + assertTrue(Files.isRegularFile(symTab)); + } + + protected String getAsInfo(String base, String... data) { + return RichConsoleLogHook.BLUE + "[INFO]" + RichConsoleLogHook.RESET + + " de.monticore.od4development.OD4DevelopmentTool " + base.formatted(data).strip(); + } + + protected String getAsError(String base, String... data) { + return RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " " + + base.formatted(data).strip(); } } diff --git a/src/test/java/de/monticore/od4development/_cocos/OD4DevelopmentCoCoCheckerTest.java b/src/test/java/de/monticore/od4development/_cocos/OD4DevelopmentCoCoCheckerTest.java new file mode 100644 index 00000000..81838646 --- /dev/null +++ b/src/test/java/de/monticore/od4development/_cocos/OD4DevelopmentCoCoCheckerTest.java @@ -0,0 +1,136 @@ +// (c) https://github.com/MontiCore/monticore + +package de.monticore.od4development._cocos; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.odbasis._cocos.attributes.PartialAndCompleteAttributesCoCo; +import de.monticore.odbasis._cocos.attributes.UniqueAttributeNamesCoCo; +import de.monticore.odbasis._cocos.attributes.ValidObjectAttributesCoCo; +import de.monticore.odbasis._cocos.names.UniqueObjectNamesCoCo; +import de.monticore.odbasis._cocos.object.ValidObjectReferenceCoCo; +import de.monticore.odlink._cocos.link.LinkEndConsistencyCoCo; +import de.monticore.odlink._cocos.link.ValidLinkReferenceCoCo; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@TestWithMCLanguage(OD4DevelopmentMill.class) +public class OD4DevelopmentCoCoCheckerTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + public void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + } + + @Test + public void checkUniqueObjectNamesCoCo() { + String testOD = cocoExamples.resolve("NoUniqueNames.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + + odCoCoChecker.addCoCo(new UniqueObjectNamesCoCo()); + odCoCoChecker.checkAll(artifact); + MCAssertions.assertHasFindingStartingWith("0x0D002"); + MCAssertions.assertHasFindingStartingWith("0x0D002"); + } + + @Test + public void checkAnonymousObjectsValid() { + String testOD = cocoExamples.resolve("AnonymousObject.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + + odCoCoChecker.addCoCo(new UniqueObjectNamesCoCo()); + odCoCoChecker.checkAll(artifact); + } + + @Test + public void checkValidReferenceCoCo() { + String testOD = cocoExamples.resolve("InvalidLeftLinkReference.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + + odCoCoChecker.addCoCo(new ValidLinkReferenceCoCo()); + odCoCoChecker.checkAll(artifact); + MCAssertions.assertHasFindingStartingWith("0x0D00C"); + } + + @Test + public void checkObjectReferenceCoCo() { + String testOD = cocoExamples.resolve("InvalidSingleObjectReference.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + + odCoCoChecker.addCoCo(new ValidObjectReferenceCoCo()); + odCoCoChecker.checkAll(artifact); + MCAssertions.assertHasFindingStartingWith("0x0D001"); + } + + @Test + public void checkPartialAndCompleteAttributesCoCo() { + String testOD = cocoExamples.resolve("PartialAndCompleteAttributes.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + + odCoCoChecker.addCoCo(new PartialAndCompleteAttributesCoCo()); + odCoCoChecker.checkAll(artifact); + // bar2 and bar3 mix partial and complete, bar4 is reported by UniqueAttributeNamesCoCo + assertEquals(2, MCAssertions.assertHasFindingsStartingWith("0x0D004").size()); + } + + @Test + public void checkTwoCompleteAttributesAreReportedOnlyOnce() { + String testOD = cocoExamples.resolve("PartialAndCompleteAttributes.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + + odCoCoChecker.addCoCo(new PartialAndCompleteAttributesCoCo()); + odCoCoChecker.addCoCo(new UniqueAttributeNamesCoCo()); + odCoCoChecker.checkAll(artifact); + assertEquals(2, MCAssertions.assertHasFindingsStartingWith("0x0D004").size()); + assertEquals(1, MCAssertions.assertHasFindingsStartingWith("0x0D003").size()); + assertEquals(3, Log.getFindings().size()); + } + + @Test + public void checkUniqueAttributeNamesCoCo() { + String testOD = cocoExamples.resolve("InvalidDuplicateAttributeNames.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + + odCoCoChecker.addCoCo(new UniqueAttributeNamesCoCo()); + odCoCoChecker.checkAll(artifact); + MCAssertions.assertHasFindingStartingWith("0x0D003"); + } + + @Test + public void checkLinkEndConsistencyCoCo() { + String testOD = cocoExamples.resolve("InvalidLinkEndConsistency.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + OD4DevelopmentTestUtil.completeSymbolTable(artifact, true); + + odCoCoChecker.addCoCo(new LinkEndConsistencyCoCo()); + odCoCoChecker.checkAll(artifact); + MCAssertions.assertHasFindingStartingWith("0x0D009"); + } + + @Test + public void checkValidObjectAttributeCoCo() { + String testOD = cocoExamples.resolve("InvalidObjectAttributes.od").toString(); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + OD4DevelopmentTestUtil.completeSymbolTable(artifact, true); + + odCoCoChecker.addCoCo(new ValidObjectAttributesCoCo()); + odCoCoChecker.checkAll(artifact); + MCAssertions.assertHasFindingStartingWith("0x0D006"); + } + +} diff --git a/src/test/java/de/monticore/od4development/_cocos/link/ValidLinkQualifierCoCoTest.java b/src/test/java/de/monticore/od4development/_cocos/link/ValidLinkQualifierCoCoTest.java new file mode 100644 index 00000000..581109de --- /dev/null +++ b/src/test/java/de/monticore/od4development/_cocos/link/ValidLinkQualifierCoCoTest.java @@ -0,0 +1,65 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.od4development._cocos.link; + +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.od4development._parser.OD4DevelopmentParser; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +/** + * Tests for {@link ValidLinkQualifierCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class ValidLinkQualifierCoCoTest { + + @ParameterizedTest + @ValueSource(strings = { "[[name]]", "[1]", "[\"key\"]", "[name]" }) + void shouldAcceptValidQualifier(String qualifier) throws IOException { + check(qualifier); + + MCAssertions.assertNoFindings(); + } + + @ParameterizedTest + @ValueSource(strings = { "[ [1, 2] ]", "[[1, 2]]", "[ [name] ]", "[ [] ]" }) + void shouldReportListQualifier(String qualifier) throws IOException { + check(qualifier); + + MCAssertions.assertHasFindingStartingWith(ValidLinkQualifierCoCo.ERROR_LIST_QUALIFIER); + } + + @ParameterizedTest + @ValueSource(strings = { "[ [1 -> 2] ]", "[[1 -> 2]]", "[ [\"a\" -> 1, \"b\" -> 2] ]" }) + void shouldReportMapQualifier(String qualifier) throws IOException { + check(qualifier); + + MCAssertions.assertHasFindingStartingWith(ValidLinkQualifierCoCo.ERROR_MAP_QUALIFIER); + } + + @ParameterizedTest + @ValueSource(strings = { "[ :C {} ]", "[ c:C {} ]", "[ :C { x = 1; } ]" }) + void shouldReportObjectQualifier(String qualifier) throws IOException { + check(qualifier); + + MCAssertions.assertHasFindingStartingWith(ValidLinkQualifierCoCo.ERROR_OBJECT_QUALIFIER); + } + + private static void check(String qualifier) throws IOException { + OD4DevelopmentParser parser = OD4DevelopmentMill.parser(); + ASTODArtifact artifact = parser.parse_StringODArtifact( + "objectdiagram Q { a:A {}; b:B {}; link a " + qualifier + " -> b; }").orElseThrow(); + assertFalse(parser.hasErrors()); + + OD4DevelopmentCoCoChecker checker = new OD4DevelopmentCoCoChecker(); + checker.addCoCo(new ValidLinkQualifierCoCo()); + checker.checkAll(artifact); + } +} diff --git a/src/test/java/de/monticore/od4development/_parser/ODBasicsParserTest.java b/src/test/java/de/monticore/od4development/_parser/ODBasicsParserTest.java new file mode 100644 index 00000000..d012c3fa --- /dev/null +++ b/src/test/java/de/monticore/od4development/_parser/ODBasicsParserTest.java @@ -0,0 +1,95 @@ +// (c) https://github.com/MontiCore/monticore + +package de.monticore.od4development._parser; + +import de.monticore.ODTestBasis; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.odattribute._ast.ASTODList; +import de.monticore.odbasis._ast.ASTODValue; +import de.monticore.odlink._ast.*; + +import de.monticore.runtime.junit.TestWithMCLanguage; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.io.IOException; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.*; + +@TestWithMCLanguage(OD4DevelopmentMill.class) +public class ODBasicsParserTest extends ODTestBasis { + + @Test + public void testODLinkLeftSide() throws IOException { + OD4DevelopmentParser odBasicsParser = OD4DevelopmentMill.parser(); + Optional linkLeftSide = + odBasicsParser.parse_StringODLinkLeftSide("public " + "A1,A2 [[test]] (eineRolle)"); + assertTrue(linkLeftSide.isPresent()); + assertEquals(2, linkLeftSide.get().sizeReferenceNames()); + assertEquals("test", linkLeftSide.get().getODLinkQualifier().getName()); + assertFalse(linkLeftSide.get().getODLinkQualifier().isPresentODValue()); + } + + @Test + public void testODLinkRightSide() throws IOException { + OD4DevelopmentParser odBasicsParser = OD4DevelopmentMill.parser(); + Optional linkRightSide = + odBasicsParser.parse_StringODLinkRightSide("(eineRolle) [[test]] A1,A2 private"); + assertTrue(linkRightSide.isPresent()); + assertEquals(2, linkRightSide.get().sizeReferenceNames()); + assertEquals("test", linkRightSide.get().getODLinkQualifier().getName()); + assertFalse(linkRightSide.get().getODLinkQualifier().isPresentODValue()); + } + + @Test + public void testODLink() throws IOException { + OD4DevelopmentParser odBasicsParser = OD4DevelopmentMill.parser(); + Optional link = odBasicsParser.parse_StringODLink("link A -- B"); + assertTrue(link.isPresent()); + } + + /** "[[" and "]]" are split tokens, so they may appear in values. */ + @ParameterizedTest + @ValueSource(strings = { "[[1, 2], [3]]", "[ [1, 2], [3]]", "a[b[1]]" }) + public void testODValueWithDoubleBrackets(String input) throws IOException { + OD4DevelopmentParser parser = OD4DevelopmentMill.parser(); + Optional value = parser.parse_StringODValue(input); + assertFalse(parser.hasErrors()); + assertTrue(value.isPresent()); + } + + @ParameterizedTest + @ValueSource(strings = { "[[x]]", "[[ x ]]" }) + public void testODLinkQualifierName(String input) throws IOException { + OD4DevelopmentParser parser = OD4DevelopmentMill.parser(); + Optional qualifier = parser.parse_StringODLinkQualifier(input); + assertFalse(parser.hasErrors()); + assertTrue(qualifier.isPresent()); + assertEquals("x", qualifier.get().getName()); + } + + /** Brackets separated by whitespace denote a list value, not a name qualifier. */ + @ParameterizedTest + @ValueSource(strings = { "[ [x] ]", "[ [x]]", "[[1, 2]]" }) + public void testODLinkQualifierListValue(String input) throws IOException { + OD4DevelopmentParser parser = OD4DevelopmentMill.parser(); + Optional qualifier = parser.parse_StringODLinkQualifier(input); + assertFalse(parser.hasErrors()); + assertTrue(qualifier.isPresent()); + assertFalse(qualifier.get().isPresentName()); + assertInstanceOf(ASTODList.class, qualifier.get().getODValue()); + } + + @Test + public void testODLinkDirection() throws IOException { + OD4DevelopmentParser odBasicsParser = OD4DevelopmentMill.parser(); + Optional unspecifiedDir = + odBasicsParser.parse_StringODUnspecifiedDir("--"); + Optional linkDirection = odBasicsParser.parse_StringODLinkDirection("--"); + assertTrue(unspecifiedDir.isPresent()); + assertTrue(linkDirection.isPresent()); + } + +} diff --git a/src/test/java/de/monticore/od4data/_symboltable/OD4DataDeSerTest.java b/src/test/java/de/monticore/od4development/_symboltable/OD4DevelopmentDeSerTest.java similarity index 74% rename from src/test/java/de/monticore/od4data/_symboltable/OD4DataDeSerTest.java rename to src/test/java/de/monticore/od4development/_symboltable/OD4DevelopmentDeSerTest.java index ae1b46f1..e8ae05f9 100644 --- a/src/test/java/de/monticore/od4data/_symboltable/OD4DataDeSerTest.java +++ b/src/test/java/de/monticore/od4development/_symboltable/OD4DevelopmentDeSerTest.java @@ -1,12 +1,11 @@ // (c) https://github.com/MontiCore/monticore -package de.monticore.od4data._symboltable; +package de.monticore.od4development._symboltable; import de.monticore.ODTestBasis; import de.monticore.io.paths.MCPath; -import de.monticore.od4data.OD4DataMill; -import de.monticore.od4data.OD4DataTestUtil; -import de.monticore.od4data.OD4DataToolAPI; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development.OD4DevelopmentMill; import de.monticore.odbasis._ast.ASTODArtifact; import de.monticore.runtime.junit.TestWithMCLanguage; import de.monticore.symbols.basicsymbols._symboltable.VariableSymbol; @@ -20,8 +19,8 @@ import static org.junit.jupiter.api.Assertions.*; -@TestWithMCLanguage(OD4DataMill.class) -public class OD4DataDeSerTest extends ODTestBasis { +@TestWithMCLanguage(OD4DevelopmentMill.class) +public class OD4DevelopmentDeSerTest extends ODTestBasis { private final Path SIMPLEOD2 = PATH.resolve(Paths.get("examples", "od", "SimpleOD2.od")); @@ -29,13 +28,13 @@ public class OD4DataDeSerTest extends ODTestBasis { public void testOD4DataDeSer() { String artifact = SIMPLEOD2.toString(); MCPath symbolPath = new MCPath(PATH); - ASTODArtifact astodArtifact = OD4DataTestUtil.loadModel(artifact, symbolPath); + ASTODArtifact astodArtifact = OD4DevelopmentTestUtil.loadModel(artifact, symbolPath); - IOD4DataArtifactScope od4DataArtifactScope = - OD4DataToolAPI.createSymbolTable(astodArtifact, true); + IOD4DevelopmentArtifactScope od4DataArtifactScope = OD4DevelopmentTestUtil.createSymbolTableFromAST(astodArtifact); + OD4DevelopmentTestUtil.completeSymbolTable(astodArtifact, true); // serialize - OD4DataSymbols2Json od4DataSymbols2Json = new OD4DataSymbols2Json(); + OD4DevelopmentSymbols2Json od4DataSymbols2Json = new OD4DevelopmentSymbols2Json(); String fileName = Paths.get(SIMPLEOD2.toString()).getFileName().toString() + "sym"; String pathFromQualifiedName = Names.getPathFromQualifiedName( astodArtifact.getMCPackageDeclaration().getMCQualifiedName().getQName() + "." @@ -47,7 +46,7 @@ public void testOD4DataDeSer() { assertTrue(storedSymTable.toFile().exists()); // deserialize - IOD4DataArtifactScope loadedBasicsArtifactScope = + IOD4DevelopmentArtifactScope loadedBasicsArtifactScope = od4DataSymbols2Json.load(storedSymTable.toString()); // clear buffer of traverser, as elements should be traversed again @@ -61,17 +60,18 @@ public void testOD4DataDeSer() { public void serializationTest() { String artifact = SIMPLEOD2.toString(); MCPath symbolPath = new MCPath(PATH); - ASTODArtifact ast = OD4DataTestUtil.loadModel(artifact, symbolPath); + ASTODArtifact ast = OD4DevelopmentTestUtil.loadModel(artifact, symbolPath); // create symbol table - IOD4DataArtifactScope artifactScope = OD4DataTestUtil.createSymbolTableFromAST(ast); - OD4DataSymbols2Json symbols2Json = new OD4DataSymbols2Json(); + IOD4DevelopmentArtifactScope artifactScope = OD4DevelopmentTestUtil.createSymbolTableFromAST(ast); + OD4DevelopmentTestUtil.completeSymbolTable(ast, true); + OD4DevelopmentSymbols2Json symbols2Json = new OD4DevelopmentSymbols2Json(); String serialized = symbols2Json.serialize(artifactScope); assertNotNull(serialized); assertNotEquals("", serialized); // check for contents - IOD4DataArtifactScope deserialized = symbols2Json.deserialize(serialized); + IOD4DevelopmentArtifactScope deserialized = symbols2Json.deserialize(serialized); assertEquals("SimpleOD2", deserialized.getName()); Optional myObject1 = deserialized.resolveVariable("myObject1"); assertEquals("examples.od.myObject1", myObject1.get().getFullName()); @@ -84,7 +84,7 @@ public void serializationTest() { @Test public void deserializationTest() { - IOD4DataGlobalScope gs = OD4DataMill.globalScope(); + IOD4DevelopmentGlobalScope gs = OD4DevelopmentMill.globalScope(); gs.clear(); gs.setSymbolPath(new MCPath(PATH)); assertTrue(gs.getSubScopes().isEmpty()); diff --git a/src/test/java/de/monticore/od4development/_symboltable/OD4DevelopmentScopesGenitorTest.java b/src/test/java/de/monticore/od4development/_symboltable/OD4DevelopmentScopesGenitorTest.java new file mode 100644 index 00000000..cb31f749 --- /dev/null +++ b/src/test/java/de/monticore/od4development/_symboltable/OD4DevelopmentScopesGenitorTest.java @@ -0,0 +1,41 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package de.monticore.od4development._symboltable; + +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.TestWithMCLanguage; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + +@TestWithMCLanguage(OD4DevelopmentMill.class) +public class OD4DevelopmentScopesGenitorTest { + + /** The genitor can be reused, each artifact scope is a sub scope of the global scope. */ + @Test + public void testReusedGenitor() throws IOException { + ASTODArtifact first = parse("package p; objectdiagram A { a:T {}; }"); + ASTODArtifact second = parse("objectdiagram B { b:T {}; }"); + OD4DevelopmentScopesGenitorDelegator genitor = OD4DevelopmentMill.scopesGenitorDelegator(); + + IOD4DevelopmentArtifactScope firstScope = genitor.createFromAST(first); + IOD4DevelopmentArtifactScope secondScope = genitor.createFromAST(second); + + assertSame(OD4DevelopmentMill.globalScope(), firstScope.getEnclosingScope()); + assertSame(OD4DevelopmentMill.globalScope(), secondScope.getEnclosingScope()); + assertSame(first, firstScope.getAstNode()); + assertSame(second, secondScope.getAstNode()); + assertEquals("p", firstScope.getPackageName()); + assertEquals("", secondScope.getPackageName()); + assertEquals("A", firstScope.getName()); + assertEquals("B", secondScope.getName()); + } + + protected ASTODArtifact parse(String model) throws IOException { + return OD4DevelopmentMill.parser().parse_StringODArtifact(model).orElseThrow(); + } +} diff --git a/src/test/java/de/monticore/od4data/_symboltable/ODSymbolTableCreatorTest.java b/src/test/java/de/monticore/od4development/_symboltable/ODSymbolTableCreatorTest.java similarity index 85% rename from src/test/java/de/monticore/od4data/_symboltable/ODSymbolTableCreatorTest.java rename to src/test/java/de/monticore/od4development/_symboltable/ODSymbolTableCreatorTest.java index a2194119..3c58245f 100644 --- a/src/test/java/de/monticore/od4data/_symboltable/ODSymbolTableCreatorTest.java +++ b/src/test/java/de/monticore/od4development/_symboltable/ODSymbolTableCreatorTest.java @@ -1,11 +1,11 @@ // (c) https://github.com/MontiCore/monticore -package de.monticore.od4data._symboltable; +package de.monticore.od4development._symboltable; import de.monticore.ODTestBasis; import de.monticore.io.paths.MCPath; -import de.monticore.od4data.OD4DataMill; -import de.monticore.od4data.OD4DataTestUtil; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development.OD4DevelopmentMill; import de.monticore.odbasis._ast.ASTODArtifact; import de.monticore.runtime.junit.TestWithMCLanguage; import de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol; @@ -19,7 +19,7 @@ import static org.junit.jupiter.api.Assertions.*; -@TestWithMCLanguage(OD4DataMill.class) +@TestWithMCLanguage(OD4DevelopmentMill.class) public class ODSymbolTableCreatorTest extends ODTestBasis { @Test @@ -74,9 +74,9 @@ public void testAvoidanceOfUnnamedObjects() { private DiagramSymbol createObjectDiagramFromAST(String odName) { Path odPath = PATH.resolve(Paths.get("symboltable", odName + ".od")); - ASTODArtifact artifact = OD4DataTestUtil.loadModel(odPath, new MCPath(PATH)); - IOD4DataArtifactScope odBasisArtifactScope = OD4DataTestUtil.createSymbolTableFromAST(artifact); - return odBasisArtifactScope.getDiagramSymbols().get(odName).get(0); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModel(odPath, new MCPath(PATH)); + IOD4DevelopmentArtifactScope odBasisArtifactScope = OD4DevelopmentMill.scopesGenitorDelegator().createFromAST(artifact); + return odBasisArtifactScope.getDiagramSymbols().get(odName).getFirst(); } } diff --git a/src/test/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafoTest.java b/src/test/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafoTest.java similarity index 70% rename from src/test/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafoTest.java rename to src/test/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafoTest.java index d3392373..d9e25be7 100644 --- a/src/test/java/de/monticore/od4data/trafo/OD4DataAttributeValueCompositionTrafoTest.java +++ b/src/test/java/de/monticore/od4development/trafo/OD4DevelopmentAttributeValueCompositionTrafoTest.java @@ -2,33 +2,37 @@ * (c) https://github.com/MontiCore/monticore */ -package de.monticore.od4data.trafo; +package de.monticore.od4development.trafo; import de.monticore.ODTestBasis; import de.monticore.expressions.expressionsbasis._ast.ASTLiteralExpression; import de.monticore.io.paths.MCPath; -import de.monticore.od4data.OD4DataMill; -import de.monticore.od4data.OD4DataTestUtil; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development.OD4DevelopmentMill; import de.monticore.odattribute._ast.ASTODList; import de.monticore.odattribute._ast.ASTODMap; import de.monticore.odbasis._ast.*; +import de.monticore.odlink._ast.ASTODLeftToRightDir; import de.monticore.odlink._ast.ASTODLink; +import de.monticore.odlink.trafo.ODLinkAttributeValueCompositionTrafo; +import de.monticore.runtime.junit.MCAssertions; import de.monticore.runtime.junit.TestWithMCLanguage; import org.junit.jupiter.api.Test; +import java.io.IOException; import java.nio.file.Path; import static org.junit.jupiter.api.Assertions.*; -@TestWithMCLanguage(OD4DataMill.class) -public class OD4DataAttributeValueCompositionTrafoTest extends ODTestBasis { +@TestWithMCLanguage(OD4DevelopmentMill.class) +public class OD4DevelopmentAttributeValueCompositionTrafoTest extends ODTestBasis { private final Path TRAFO_EXAMPLES = PATH.resolve("trafos"); @Test void testAttributeCompositionTrafo() { String testOD = TRAFO_EXAMPLES.resolve("AttributeObjectComposition.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); ASTObjectDiagram diagram = artifact.getObjectDiagram(); @@ -42,7 +46,7 @@ void testAttributeCompositionTrafo() { ASTODNamedObject barAttr = assertAndGetAsODNamedObject(bar.getODAttribute(1).getODValue()); assertEquals("blaa", barAttr.getName()); - new OD4DataAttributeValueCompositionTrafo().transform(artifact); + new OD4DevelopmentAttributeValueCompositionTrafo().transform(artifact); // Assertions post trafo assertEquals(5, diagram.getODElementList().size()); @@ -59,10 +63,32 @@ void testAttributeCompositionTrafo() { assertLinkCompositionConfig(blaaLink, "bar", "blaa", "foobar2"); } + /** No links can be created for values of anonymous objects, as they cannot be referenced. */ + @Test + void testAttributeCompositionTrafoWithAnonymousParent() throws IOException { + ASTODArtifact artifact = OD4DevelopmentMill.parser().parse_StringODArtifact( + "objectdiagram T { :A { b = c:B {}; l = [d:B {}]; m = [1 -> e:B {}]; r = foo; }; }") + .orElseThrow(); + ASTObjectDiagram diagram = artifact.getObjectDiagram(); + + new OD4DevelopmentAttributeValueCompositionTrafo().transform(artifact); + + assertEquals(4, MCAssertions.assertHasFindingsStartingWith( + ODLinkAttributeValueCompositionTrafo.WARN_ANONYMOUS_PARENT).size()); + assertEquals(1, diagram.getODElementList().size()); + ASTODAnonymousObject parent = assertInstanceOf(ASTODAnonymousObject.class, + diagram.getODElement(0)); + assertEquals(4, parent.getODAttributeList().size()); + assertEquals(1, assertInstanceOf(ASTODList.class, + parent.getODAttribute(1).getODValue()).sizeODValues()); + assertEquals(1, assertInstanceOf(ASTODMap.class, + parent.getODAttribute(2).getODValue()).sizeODMapElements()); + } + @Test void testAttributeCompositionTrafoInList() { String testOD = TRAFO_EXAMPLES.resolve("AttributeObjectComposition2.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); ASTObjectDiagram diagram = artifact.getObjectDiagram(); @@ -78,7 +104,7 @@ void testAttributeCompositionTrafoInList() { ASTODNamedObject fooListVal1 = assertAndGetAsODNamedObject(fooList.getODValue(0)); assertEquals("foo1", fooListVal1.getName()); - new OD4DataAttributeValueCompositionTrafo().transform(artifact); + new OD4DevelopmentAttributeValueCompositionTrafo().transform(artifact); // Assertions post trafo assertEquals(4, diagram.getODElementList().size()); @@ -98,7 +124,7 @@ void testAttributeCompositionTrafoInList() { @Test void testAttributeCompositionTrafoInMap() { String testOD = TRAFO_EXAMPLES.resolve("AttributeObjectComposition3.od").toString(); - ASTODArtifact artifact = OD4DataTestUtil.loadModelAndST(testOD, new MCPath(PATH)); + ASTODArtifact artifact = OD4DevelopmentTestUtil.loadModelAndST(testOD, new MCPath(PATH)); ASTObjectDiagram diagram = artifact.getObjectDiagram(); @@ -114,7 +140,7 @@ void testAttributeCompositionTrafoInMap() { ASTODNamedObject fooMapVal1 = assertAndGetAsODNamedObject(fooMap.getODMapElement(0).getVal()); assertEquals("foo1", fooMapVal1.getName()); - new OD4DataAttributeValueCompositionTrafo().transform(artifact); + new OD4DevelopmentAttributeValueCompositionTrafo().transform(artifact); // Assertions post trafo assertEquals(4, diagram.getODElementList().size()); @@ -134,27 +160,27 @@ void testAttributeCompositionTrafoInMap() { protected ASTODList assertAndGetAsODList(ASTODValue value) { assertInstanceOf(ASTODList.class, value); - return OD4DataMill.typeDispatcher().asODAttributeASTODList(value); + return (ASTODList) value; } protected ASTODMap assertAndGetAsODMap(ASTODValue value) { assertInstanceOf(ASTODMap.class, value); - return OD4DataMill.typeDispatcher().asODAttributeASTODMap(value); + return (ASTODMap) value; } protected ASTODNamedObject assertAndGetAsODNamedObject(ASTODElement element) { assertInstanceOf(ASTODNamedObject.class, element); - return OD4DataMill.typeDispatcher().asODBasisASTODNamedObject(element); + return (ASTODNamedObject) element; } protected ASTODNamedObject assertAndGetAsODNamedObject(ASTODValue value) { assertInstanceOf(ASTODNamedObject.class, value); - return OD4DataMill.typeDispatcher().asODBasisASTODNamedObject(value); + return (ASTODNamedObject) value; } protected ASTODLink assertAndGetAsODLink(ASTODElement element) { assertInstanceOf(ASTODLink.class, element); - return OD4DataMill.typeDispatcher().asODLinkASTODLink(element); + return (ASTODLink) element; } protected void assertLinkCompositionConfig(ASTODLink link, String source, String target, @@ -165,28 +191,24 @@ protected void assertLinkCompositionConfig(ASTODLink link, String source, String protected void assertLinkConfig(ASTODLink link, String source, String target, String role, boolean isComposition) { assertEquals(1, link.getLeftReferenceNames().size()); - assertEquals(source, link.getLeftReferenceNames().get(0)); + assertEquals(source, link.getLeftReferenceNames().getFirst()); assertEquals(1, link.getRightReferenceNames().size()); - assertEquals(target, link.getRightReferenceNames().get(0)); + assertEquals(target, link.getRightReferenceNames().getFirst()); assertEquals(isComposition, link.isComposition()); assertFalse(link.isLink()); assertFalse(link.isAggregation()); - assertTrue(OD4DataMill.typeDispatcher().isODLinkASTODLeftToRightDir(link.getODLinkDirection())); + assertInstanceOf(ASTODLeftToRightDir.class, link.getODLinkDirection()); assertEquals(role, link.getODLinkRightSide().getRole()); } protected void assertLinkQualifier(ASTODLink link, int qualifier) { ASTODValue qualifierValue = link.getODLinkLeftSide().getODLinkQualifier().getODValue(); - if (OD4DataMill.typeDispatcher().isODBasisASTODSimpleAttributeValue(qualifierValue)) { - ASTODSimpleAttributeValue value = - OD4DataMill.typeDispatcher().asODBasisASTODSimpleAttributeValue(qualifierValue); - ASTLiteralExpression expectedExpression = OD4DataMill.literalExpressionBuilder() - .setLiteral(OD4DataMill.natLiteralBuilder().setDigits(String.valueOf(qualifier)).build()) + if (qualifierValue instanceof ASTODSimpleAttributeValue simpleAttributeValue) { + ASTLiteralExpression expectedExpression = OD4DevelopmentMill.literalExpressionBuilder() + .setLiteral(OD4DevelopmentMill.natLiteralBuilder().setDigits(String.valueOf(qualifier)).build()) .build(); - assertTrue(value.getExpression().deepEquals(expectedExpression)); - } - else if (OD4DataMill.typeDispatcher().isODBasisASTODName(qualifierValue)) { - ASTODName name = OD4DataMill.typeDispatcher().asODBasisASTODName(qualifierValue); + assertTrue(simpleAttributeValue.getExpression().deepEquals(expectedExpression)); + } else if (qualifierValue instanceof ASTODName name) { assertEquals(String.valueOf(qualifier), name.getName()); } } diff --git a/src/test/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafoTest.java b/src/test/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafoTest.java new file mode 100644 index 00000000..9262b4e9 --- /dev/null +++ b/src/test/java/de/monticore/od4development/trafo/OD4DevelopmentDeAnonymizeObjectsTrafoTest.java @@ -0,0 +1,210 @@ +/* + * (c) https://github.com/MontiCore/monticore + */ + +package de.monticore.od4development.trafo; + +import de.monticore.ODTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development._visitor.OD4DevelopmentTraverser; +import de.monticore.odattribute._ast.ASTODList; +import de.monticore.odattribute._ast.ASTODMap; +import de.monticore.odbasis._ast.*; +import de.monticore.odbasis.utils.ODBasisObjectCollector; +import de.monticore.runtime.junit.TestWithMCLanguage; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; +import java.util.function.Consumer; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Tests for {@link OD4DevelopmentDeAnonymizeObjectsTrafo}. Anonymous objects are named when the + * trafo leaves their containing node, so nested objects are numbered first. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +public class OD4DevelopmentDeAnonymizeObjectsTrafoTest extends ODTestBasis { + + private final Path TRAFO_EXAMPLES = PATH.resolve("trafos"); + + @Test + void testDeAnonymizationOuterObject() { + ASTObjectDiagram diagram = loadAndTransform("AnonymousObjects.od", artifact -> { + assertAndGetAsODAnonymousObject(artifact.getObjectDiagram().getODElement(0)); + }); + + assertEquals("__objecttype1_anonymous_1", + assertAndGetAsODNamedObject(diagram.getODElement(0)).getName()); + ASTODNamedObject bar = assertAndGetAsODNamedObject(diagram.getODElement(1)); + assertEquals("bar", bar.getName()); + assertEquals("blaa", assertAndGetAsODNamedObject(bar.getODAttribute(1).getODValue()).getName()); + } + + @Test + void testDeAnonymizationInnerObject() { + ASTObjectDiagram diagram = loadAndTransform("AnonymousObjects2.od", artifact -> { + ASTODNamedObject bar = assertAndGetAsODNamedObject(artifact.getObjectDiagram().getODElement(1)); + assertAndGetAsODAnonymousObject(bar.getODAttribute(1).getODValue()); + }); + + assertEquals("foo", assertAndGetAsODNamedObject(diagram.getODElement(0)).getName()); + ASTODNamedObject bar = assertAndGetAsODNamedObject(diagram.getODElement(1)); + assertEquals("bar", bar.getName()); + assertEquals("__objecttype2_anonymous_1", + assertAndGetAsODNamedObject(bar.getODAttribute(1).getODValue()).getName()); + } + + @Test + void testDeAnonymizationInnerList() { + ASTObjectDiagram diagram = loadAndTransform("AnonymousObjects3.od", artifact -> { + ASTODNamedObject foo = assertAndGetAsODNamedObject(artifact.getObjectDiagram().getODElement(0)); + assertAndGetAsODAnonymousObject(assertAndGetAsODList(foo.getODAttribute(0).getODValue()).getODValue(1)); + }); + + ASTODNamedObject foo = assertAndGetAsODNamedObject(diagram.getODElement(0)); + assertEquals("foo", foo.getName()); + assertEquals("bar", assertAndGetAsODNamedObject(diagram.getODElement(1)).getName()); + ASTODList fooList = assertAndGetAsODList(foo.getODAttribute(0).getODValue()); + assertEquals("foo1", assertAndGetAsODNamedObject(fooList.getODValue(0)).getName()); + assertEquals("__objecttype_anonymous_1", + assertAndGetAsODNamedObject(fooList.getODValue(1)).getName()); + } + + @Test + void testDeAnonymizationInnerMap() { + ASTObjectDiagram diagram = loadAndTransform("AnonymousObjects4.od", artifact -> { + ASTODNamedObject foo = assertAndGetAsODNamedObject(artifact.getObjectDiagram().getODElement(0)); + assertAndGetAsODAnonymousObject( + assertAndGetAsODMap(foo.getODAttribute(0).getODValue()).getODMapElement(1).getVal()); + }); + + ASTODNamedObject foo = assertAndGetAsODNamedObject(diagram.getODElement(0)); + assertEquals("foo", foo.getName()); + assertEquals("bar", assertAndGetAsODNamedObject(diagram.getODElement(1)).getName()); + ASTODMap fooMap = assertAndGetAsODMap(foo.getODAttribute(0).getODValue()); + assertEquals("foo1", assertAndGetAsODNamedObject(fooMap.getODMapElement(0).getVal()).getName()); + assertEquals("__objecttype_anonymous_1", + assertAndGetAsODNamedObject(fooMap.getODMapElement(1).getVal()).getName()); + } + + @Test + void testDeAnonymizationNested() { + ASTObjectDiagram diagram = loadAndTransform("AnonymousObjects5.od", artifact -> {}); + + ASTODNamedObject foo = assertAndGetAsODNamedObject(diagram.getODElement(0)); + assertEquals("foo", foo.getName()); + assertEquals("bar", assertAndGetAsODNamedObject(diagram.getODElement(1)).getName()); + ASTODMap fooMap = assertAndGetAsODMap(foo.getODAttribute(0).getODValue()); + ASTODNamedObject foo1 = assertAndGetAsODNamedObject(fooMap.getODMapElement(0).getVal()); + assertEquals("foo1", foo1.getName()); + ASTODList foo1List = assertAndGetAsODList(foo1.getODAttribute(0).getODValue()); + assertEquals("innerA", assertAndGetAsODNamedObject(foo1List.getODValue(0)).getName()); + ASTODNamedObject innerC = assertAndGetAsODNamedObject(foo1List.getODValue(2)); + assertEquals("innerC", innerC.getName()); + assertEquals("innerE", + assertAndGetAsODNamedObject(innerC.getODAttribute(1).getODValue()).getName()); + + // innermost first: attribute of innerC, then the list element, then the map value + assertEquals("__objecttype_anonymous_1", + assertAndGetAsODNamedObject(innerC.getODAttribute(0).getODValue()).getName()); + assertEquals("__objecttype_anonymous_2", + assertAndGetAsODNamedObject(foo1List.getODValue(1)).getName()); + assertEquals("__objecttype_anonymous_3", + assertAndGetAsODNamedObject(fooMap.getODMapElement(1).getVal()).getName()); + } + + @Test + void testDeAnonymizationGeneratesUniqueNamesPerType() throws IOException { + ASTODArtifact artifact = OD4DevelopmentMill.parser().parse_StringODArtifact( + "objectdiagram Unique { :A {}; :A {}; :B { a = :A {}; }; }").orElseThrow(); + ASTObjectDiagram diagram = artifact.getObjectDiagram(); + + new OD4DevelopmentDeAnonymizeObjectsTrafo().transform(artifact); + + ASTODNamedObject a1 = assertAndGetAsODNamedObject(diagram.getODElement(0)); + ASTODNamedObject a2 = assertAndGetAsODNamedObject(diagram.getODElement(1)); + ASTODNamedObject b = assertAndGetAsODNamedObject(diagram.getODElement(2)); + ASTODNamedObject nestedA = assertAndGetAsODNamedObject(b.getODAttribute(0).getODValue()); + + // the nested object is renamed first, as attributes are visited before the diagram ends + assertEquals("__a_anonymous_1", nestedA.getName()); + assertEquals("__a_anonymous_2", a1.getName()); + assertEquals("__a_anonymous_3", a2.getName()); + assertEquals("__b_anonymous_1", b.getName()); + } + + /** + * The named copy keeps the type, the modifier, the attributes, and the comments of the + * anonymous object. + */ + @Test + void testDeAnonymizationKeepsObjectContent() throws IOException { + ASTODArtifact artifact = OD4DevelopmentMill.parser().parse_StringODArtifact( + "objectdiagram Copy { a:A { b = /* pre */ public :B { x = 1; y = \"z\"; }; }; }") + .orElseThrow(); + ASTODNamedObject a = assertAndGetAsODNamedObject(artifact.getObjectDiagram().getODElement(0)); + ASTODAnonymousObject original = assertAndGetAsODAnonymousObject(a.getODAttribute(0).getODValue()); + List originalAttributes = List.copyOf(original.getODAttributeList()); + assertEquals(1, original.get_PreCommentList().size(), "comment not attached to the object"); + + new OD4DevelopmentDeAnonymizeObjectsTrafo().transform(artifact); + + ASTODNamedObject copy = assertAndGetAsODNamedObject(a.getODAttribute(0).getODValue()); + assertEquals("__b_anonymous_1", copy.getName()); + assertEquals("B", copy.getMCObjectType().printType()); + assertTrue(copy.getModifier().isPublic()); + assertEquals(originalAttributes, copy.getODAttributeList()); + assertEquals(original.get_SourcePositionStart(), copy.get_SourcePositionStart()); + assertEquals(original.get_PreCommentList(), copy.get_PreCommentList()); + } + + /** + * Loads the model, runs the given assertions on the model before the trafo, applies the trafo, + * and checks that no anonymous object is left. + */ + protected ASTObjectDiagram loadAndTransform(String model, + Consumer assertionsBeforeTrafo) { + ASTODArtifact artifact = + OD4DevelopmentTestUtil.loadModel(TRAFO_EXAMPLES.resolve(model).toString(), new MCPath(PATH)); + assertionsBeforeTrafo.accept(artifact); + + new OD4DevelopmentDeAnonymizeObjectsTrafo().transform(artifact); + + ODBasisObjectCollector collector = new ODBasisObjectCollector(); + OD4DevelopmentTraverser traverser = OD4DevelopmentMill.traverser(); + traverser.add4ODBasis(collector); + artifact.accept(traverser); + assertEquals(List.of(), collector.getAnonymousObjects(), "anonymous objects left"); + + return artifact.getObjectDiagram(); + } + + protected ASTODList assertAndGetAsODList(ASTODValue value) { + return assertInstanceOf(ASTODList.class, value); + } + + protected ASTODMap assertAndGetAsODMap(ASTODValue value) { + return assertInstanceOf(ASTODMap.class, value); + } + + protected ASTODNamedObject assertAndGetAsODNamedObject(ASTODElement element) { + return assertInstanceOf(ASTODNamedObject.class, element); + } + + protected ASTODAnonymousObject assertAndGetAsODAnonymousObject(ASTODElement element) { + return assertInstanceOf(ASTODAnonymousObject.class, element); + } + + protected ASTODNamedObject assertAndGetAsODNamedObject(ASTODValue value) { + return assertInstanceOf(ASTODNamedObject.class, value); + } + + protected ASTODAnonymousObject assertAndGetAsODAnonymousObject(ASTODValue value) { + return assertInstanceOf(ASTODAnonymousObject.class, value); + } +} diff --git a/src/test/java/de/monticore/od4report/OD4ReportTestUtil.java b/src/test/java/de/monticore/od4report/OD4ReportTestUtil.java index b33775de..3b6fda9d 100644 --- a/src/test/java/de/monticore/od4report/OD4ReportTestUtil.java +++ b/src/test/java/de/monticore/od4report/OD4ReportTestUtil.java @@ -2,6 +2,7 @@ package de.monticore.od4report; import com.google.common.collect.Lists; +import de.monticore.ToolProcessRunner; import de.monticore.io.paths.MCPath; import de.monticore.od4report._symboltable.IOD4ReportArtifactScope; @@ -45,7 +46,9 @@ public static ASTODArtifact loadModel(Path pathToArtifact, MCPath symbolPath) { } public static IOD4ReportArtifactScope createSymbolTableFromAST(ASTODArtifact ast) { - IOD4ReportArtifactScope as = OD4ReportToolAPI.createSymbolTable(ast, true); + IOD4ReportArtifactScope as = OD4ReportToolAPI.createSymbolTable(ast); + + OD4ReportToolAPI.completeSymbolTable(ast, true); // add imports List imports = Lists.newArrayList(); @@ -55,4 +58,24 @@ public static IOD4ReportArtifactScope createSymbolTableFromAST(ASTODArtifact ast return as; } + + /** + * Runs the OD tool in a separate JVM process and returns the merged console output. + * + * @see ToolProcessRunner + */ + public static List runToolInSeparateProcess(String... args) { + return runToolInSeparateProcess(null, args); + } + + /** + * Runs the OD tool in a separate JVM process with the given working directory and returns the + * merged console output. + * + * @param workingDir working directory of the process, {@code null} for the current one + * @see ToolProcessRunner + */ + public static List runToolInSeparateProcess(Path workingDir, String... args) { + return ToolProcessRunner.run(OD4ReportTool.class, workingDir, args); + } } diff --git a/src/test/java/de/monticore/od4report/OD4ReportToolAggregationTest.java b/src/test/java/de/monticore/od4report/OD4ReportToolAggregationTest.java index 06ce4c11..53bcb06b 100644 --- a/src/test/java/de/monticore/od4report/OD4ReportToolAggregationTest.java +++ b/src/test/java/de/monticore/od4report/OD4ReportToolAggregationTest.java @@ -2,65 +2,86 @@ package de.monticore.od4report; -import de.monticore.ODOutTestBasis; -import de.monticore.runtime.junit.MCAssertions; +import de.monticore.ODTestBasis; +import de.se_rwth.commons.logging.RichConsoleLogHook; import org.apache.commons.lang3.ArrayUtils; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.nio.file.Path; import java.util.Arrays; +import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests that {@code -symboltypes} makes symbols of foreign languages, here of CDs, loadable, such + * that the object types of an OD can be resolved. The CoCos are checked ({@code -c}), as the types + * are only resolved when they are checked. + */ +public class OD4ReportToolAggregationTest extends ODTestBasis { + + private final Path AGGREGATION = PATH.resolve("symboltable").resolve("aggregation"); -public class OD4ReportToolAggregationTest extends ODOutTestBasis { - private final String[] SYMTYPE_ARGS = { "-symboltypes", "de.monticore.cdbasis._symboltable.CDTypeSymbol", "TypeSymbolDeSer", - "de.monticore.types.check.SymTypeOfObject", "TypeSymbolDeSer", - "de.monticore.cdassociation._symboltable.CDRoleSymbol", "FieldSymbolDeSer", - "de.monticore.cdbasis._symboltable.CDTypeSymbol", "TypeSymbolDeSer", - "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", "FieldSymbolDeSer" }; - - @BeforeEach - void setUp() { - OD4ReportMill.reset(); - } - + "de.monticore.cdassociation._symboltable.CDRoleSymbol", "FieldSymbolDeSer" }; + @Test public void testOD4ReportSymboltypesTOGS() { - String[] basisArgs = { "-i", "src/test/resources/symboltable/aggregation/TestOD.od", "-path", - "src/test/resources/symboltable/aggregation/cd" }; - String[] testArgs = ArrayUtils.addAll(basisArgs, SYMTYPE_ARGS); - new OD4ReportTool().run(testArgs); - - assertEquals(String.format(OD4ReportTool.PARSE_SUCCESSFUL, "TestOD"), getOut()); - MCAssertions.assertNoFindings(); + List out = runTool("TestOD.od", "cd", SYMTYPE_ARGS); + + assertEquals(2, out.size(), String.join("\n", out)); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "TestOD"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "TestOD"), out.get(1)); } - + @Test public void testOD4ReportSymboltypesTOGS2() { - String[] basisArgs = - { "-i", "src/test/resources/symboltable/aggregation/BasicGameOD.od", "-path", - "src/test/resources/symboltable/aggregation/basicgame_cd" }; - String[] testArgs = ArrayUtils.addAll(basisArgs, SYMTYPE_ARGS); - new OD4ReportTool().run(testArgs); - - assertEquals(String.format(OD4ReportTool.PARSE_SUCCESSFUL, "BasicGameOD"), getOut()); - MCAssertions.assertNoFindings(); + List out = runTool("BasicGameOD.od", "basicgame_cd", SYMTYPE_ARGS); + + assertEquals(2, out.size(), String.join("\n", out)); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "BasicGameOD"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "BasicGameOD"), out.get(1)); } - + + /** Without {@code -symboltypes}, the CD types cannot be loaded and resolved. */ + @Test + public void testOD4ReportWithoutSymboltypes() { + List out = runTool("TestOD.od", "cd"); + + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "TestOD"), out.getFirst()); + assertTrue(out.stream().anyMatch(line -> + line.contains("0xA0324 Cannot find symbol BasicGameCD.basic.game.Game")), + String.join("\n", out)); + } + + /** The last argument without a deserializer is ignored, the other pairs are still used. */ @Test public void testOD4ReportSymboltypesOdd() { - String[] basisArgs = - { "-i", "src/test/resources/symboltable/aggregation/BasicGameOD.od", "-path", - "src/test/resources/symboltable/aggregation/basicgame_cd" }; String[] oddSymtypeArgs = Arrays.copyOf(SYMTYPE_ARGS, SYMTYPE_ARGS.length - 1); - String[] testArgs = ArrayUtils.addAll(basisArgs, oddSymtypeArgs); - new OD4ReportTool().run(testArgs); - - assertEquals(String.format(OD4ReportTool.PARSE_SUCCESSFUL, "BasicGameOD"), getOut()); - MCAssertions.assertHasFindingStartingWith( - "Odd number of arguments for parameter -symboltypes! Ignoring last argument."); + List out = runTool("BasicGameOD.od", "basicgame_cd", oddSymtypeArgs); + + assertEquals(3, out.size(), String.join("\n", out)); + assertEquals(getAsWarn(OD4ReportTool.WARN_ODD_SYMBOLTYPES_ARGS), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "BasicGameOD"), out.get(1)); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "BasicGameOD"), out.get(2)); + } + + /** Runs the tool on the model with the symbol path and checks all CoCos. */ + protected List runTool(String model, String symbolPath, String... additionalArgs) { + String[] args = { "-i", AGGREGATION.resolve(model).toString(), "-path", + AGGREGATION.resolve(symbolPath).toString(), "-c" }; + return OD4ReportTestUtil.runToolInSeparateProcess(ArrayUtils.addAll(args, additionalArgs)); + } + + protected String getAsInfo(String base, String... data) { + return RichConsoleLogHook.BLUE + "[INFO]" + RichConsoleLogHook.RESET + + " de.monticore.od4report.OD4ReportTool " + base.formatted(data).strip(); + } + + protected String getAsWarn(String base, String... data) { + return RichConsoleLogHook.YELLOW + "[WARN]" + RichConsoleLogHook.RESET + " " + + base.formatted(data).strip(); } - } diff --git a/src/test/java/de/monticore/od4report/OD4ReportToolTest.java b/src/test/java/de/monticore/od4report/OD4ReportToolTest.java index 5368ea37..ce37dbc8 100644 --- a/src/test/java/de/monticore/od4report/OD4ReportToolTest.java +++ b/src/test/java/de/monticore/od4report/OD4ReportToolTest.java @@ -2,148 +2,281 @@ package de.monticore.od4report; -import de.monticore.ODOutTestBasis; -import de.monticore.runtime.junit.MCAssertions; -import de.monticore.runtime.junit.TestWithMCLanguage; +import de.monticore.ODTestBasis; +import de.se_rwth.commons.logging.RichConsoleLogHook; import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.BeforeEach; +import org.apache.commons.lang3.ArrayUtils; import org.junit.jupiter.api.Test; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; import static org.junit.jupiter.api.Assertions.*; -@TestWithMCLanguage(OD4ReportMill.class) -public class OD4ReportToolTest extends ODOutTestBasis { +public class OD4ReportToolTest extends ODTestBasis { private final Path INPUT_DIR = PATH.resolve(Paths.get("examples", "od")); private final Path INPUT_OD = INPUT_DIR.resolve("Examples.od"); - - @BeforeEach - void setUp() { - OD4ReportMill.reset(); - } - + @Test public void testOD4ReportToolHelp() { String[] help = { "-h" }; - new OD4ReportTool().run(help); + List out = OD4ReportTestUtil.runToolInSeparateProcess(help); - assertContains(getOut(), "usage: OD4ReportTool [-c ] [-h]"); - MCAssertions.assertNoFindings(); + assertEquals(35, out.size()); + assertContains(out.getFirst(), "usage: OD4ReportTool [-c ] [-h] [-i ]"); } + @Test + public void testOD4ReportToolVersion() { + List out = OD4ReportTestUtil.runToolInSeparateProcess("-v"); + + assertEquals(1, out.size()); + assertContains(out.getFirst(), "based on MontiCore version"); + } + + @Test + public void testOD4ReportToolStacktrace() { + List out = + OD4ReportTestUtil.runToolInSeparateProcess("-i", INPUT_OD.toString(), "--stacktrace"); + + assertEquals(1, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + } + + @Test + public void testOD4ReportToolReportNotSupported() { + List out = + OD4ReportTestUtil.runToolInSeparateProcess("-i", INPUT_OD.toString(), "-r", "reports"); + + assertEquals(1, out.size()); + assertEquals(getAsError(OD4ReportTool.REPORT_OPTION_NOT_SUPPORTED), out.getFirst()); + } + @Test public void testOD4ReportToolMissingInput() { String[] input = {}; - new OD4ReportTool().run(input); + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); - assertContains(getOut(), "usage: OD4ReportTool [-c ] [-h]"); - MCAssertions.assertNoFindings(); + assertEquals(1, out.size()); + assertEquals(getAsError(OD4ReportTool.INPUT_OPTION_NOT_PRESENT, "Examples"), out.getFirst()); } @Test public void testOD4ReportToolPath() { String[] input = { "-i", INPUT_OD.toString(), "-path", PATH.toString(), INPUT_DIR.getParent().getParent().resolve("cocos").toString(), "-c", "intra" }; - new OD4ReportTool().run(input); + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); - assertEquals(String.format(OD4ReportTool.PARSE_SUCCESSFUL, "Examples") + String.format( - OD4ReportTool.CHECK_SUCCESSFUL, "Examples"), getOut()); - MCAssertions.assertNoFindings(); + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "Examples"), out.get(1)); } @Test - public void testOD4ReportToolPathWithSymtype() { + public void testOD4ReportToolCocosDefaultWithoutArgument() { String[] input = - { "-i", INPUT_DIR.resolve("MyFamily.od").toString(), "-path", PATH.toString(), "-symtypes", - "de.monticore.cdbasis._symboltable.CDTypeSymbol", "TypeSymbolDeSer", "-c" }; - new OD4ReportTool().run(input); + { "-i", INPUT_DIR.resolve("SimpleOD.od").toString(), "-path", PATH.toString(), "-c" }; + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); - assertEquals(String.format(OD4ReportTool.PARSE_SUCCESSFUL, "MyFamily") + String.format( - OD4ReportTool.CHECK_SUCCESSFUL, "MyFamily"), getOut()); - MCAssertions.assertNoFindings(); + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "SimpleOD"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "SimpleOD"), out.get(1)); } @Test public void testOD4ReportToolCocosIntra() { String[] input = { "-i", INPUT_DIR.resolve("SimpleOD.od").toString(), "-c", "intra" }; - assertEquals("", getOut()); - new OD4ReportTool().run(input); + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); - assertEquals(String.format(OD4ReportTool.PARSE_SUCCESSFUL, "SimpleOD") + String.format( - OD4ReportTool.CHECK_SUCCESSFUL, "SimpleOD"), getOut()); - MCAssertions.assertNoFindings(); + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "SimpleOD"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "SimpleOD"), out.get(1)); + } + + @Test + public void testOD4ReportToolCocosInter() { + String[] input = + { "-i", INPUT_DIR.resolve("SimpleOD.od").toString(), "-path", PATH.toString(), "-c", + "inter" }; + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "SimpleOD"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "SimpleOD"), out.get(1)); + } + + @Test + public void testOD4ReportToolCocosInvalidArgument() { + String[] input = { "-i", INPUT_DIR.resolve("SimpleOD.od").toString(), "-c", "foo" }; + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "SimpleOD"), out.getFirst()); + assertEquals(getAsError(OD4ReportTool.COCO_OPTION_INVALID, "foo"), out.get(1)); + } + + @Test + public void testOD4ReportToolCocosTooManyArguments() { + String[] input = + { "-i", INPUT_DIR.resolve("SimpleOD.od").toString(), "-c", "intra", "-c", "inter" }; + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "SimpleOD"), out.getFirst()); + assertEquals(getAsError(OD4ReportTool.COCO_OPTION_TOO_MANY_ARGS), out.get(1)); } @Test public void testOD4ReportToolPrettyPrint() { String[] input = { "-i", INPUT_OD.toString(), "-pp", "-c", "intra" }; - new OD4ReportTool().run(input); + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); - assertContains(getOut(), "objectdiagram Examples {"); - MCAssertions.assertNoFindings(); + assertTrue(out.stream().anyMatch(line -> line.contains("objectdiagram Examples {"))); } @Test public void testOD4ReportToolPrettyPrintToFile() { String ppOutPath = getTmpFilePath("pp.od").toString(); String[] input = { "-i", INPUT_OD.toString(), "-pp", ppOutPath, "-c", "intra" }; - new OD4ReportTool().run(input); + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "Examples"), out.get(1)); assertTrue(Paths.get(ppOutPath).toFile().exists()); - MCAssertions.assertNoFindings(); } + /** {@code -c inter} checks only inter-model CoCos, so intra-model errors are not reported. */ + @Test + public void testOD4ReportInterCoCosOnly() throws IOException { + Path model = getTmpFilePath("IntraError.od"); + Files.writeString(model, """ + import examples.cd.SimpleOD.*; + objectdiagram IntraError { + o:ObjectType2 { foobar3 -> 1; foobar3 = 2; }; + } + """); + String[] args = { "-i", model.toString(), "-path", PATH.toAbsolutePath().toString(), "-c" }; + + List inter = OD4ReportTestUtil.runToolInSeparateProcess( + ArrayUtils.add(args, "inter")); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "IntraError"), inter.getLast(), + String.join("\n", inter)); + + List intra = OD4ReportTestUtil.runToolInSeparateProcess( + ArrayUtils.add(args, "intra")); + assertTrue(intra.stream().anyMatch(line -> line.contains("0x0D004")), String.join("\n", intra)); + } + + /** Primitive types must be added only once, also if symbol types are given. */ + @Test + public void testOD4ReportSymtypesWithPrimitiveTypes() { + Path input = INPUT_DIR.resolve("PrimitiveAttributes.od"); + List out = OD4ReportTestUtil.runToolInSeparateProcess("-i", input.toString(), "-path", + PATH.toString(), "-symtypes", "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "TypeSymbolDeSer", "-c"); + + assertEquals(2, out.size(), String.join("\n", out)); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "PrimitiveAttributes"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.CHECK_SUCCESSFUL, "PrimitiveAttributes"), out.get(1)); + } + + /** The symbol table is stored next to an input file that is given without a directory. */ + @Test + public void testOD4ReportStoreSTWithoutParentPath() throws IOException { + Path workingDir = getTmpDirPath(); + Files.copy(INPUT_DIR.resolve("PrimitiveAttributes.od"), + workingDir.resolve("PrimitiveAttributes.od")); + + List out = OD4ReportTestUtil.runToolInSeparateProcess(workingDir, "-i", + "PrimitiveAttributes.od", "-path", PATH.toAbsolutePath().toString(), "-s"); + + Path symTab = workingDir.resolve("PrimitiveAttributes.odsym"); + assertEquals(2, out.size(), String.join("\n", out)); + assertEquals(getAsInfo(OD4ReportTool.STEXPORT_SUCCESSFUL, symTab.toAbsolutePath().toString()), + out.get(1)); + assertTrue(Files.isRegularFile(symTab)); + } + @Test public void testOD4ReportStoreST() { String symOutPath = getTmpFilePath("Examples.odsym").toString(); String[] input = { "-i", INPUT_OD.toString(), "-s", symOutPath, "-path", PATH.toString(), "-symtypes", "de.monticore.cdbasis._symboltable.CDTypeSymbol", "TypeSymbolDeSer" }; - new OD4ReportTool().run(input); + List out = OD4ReportTestUtil.runToolInSeparateProcess(input); + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.STEXPORT_SUCCESSFUL, + Paths.get(symOutPath).toFile().getAbsolutePath()), out.get(1)); assertTrue(Paths.get(symOutPath).toFile().exists()); - MCAssertions.assertNoFindings(); } @Test public void testStoreSymtabFile() { Path stTargetPath = getTmpFilePath("symboltable", "examples", "od", "Examples.odsym"); - new OD4ReportTool().run(new String[] { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-s", - stTargetPath.toString(), "-symtypes", "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "TypeSymbolDeSer" }); + List out = OD4ReportTestUtil.runToolInSeparateProcess( + new String[] { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-s", + stTargetPath.toString(), "-symtypes", "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "TypeSymbolDeSer" }); File symTab = stTargetPath.toFile(); assertTrue(symTab.exists() && symTab.isFile()); - MCAssertions.assertNoFindings(); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.STEXPORT_SUCCESSFUL, symTab.getAbsolutePath()), + out.get(1)); } @Test public void testStoreSymtabFile2() { Path existingTargetDirPath = getTmpFilePath("existing"); assertTrue(existingTargetDirPath.toFile().mkdir()); - new OD4ReportTool().run(new String[] { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-s", - existingTargetDirPath.toString(), "-symtypes", - "de.monticore.cdbasis._symboltable.CDTypeSymbol", "TypeSymbolDeSer" }); + List out = OD4ReportTestUtil.runToolInSeparateProcess( + new String[] { "-i", INPUT_OD.toString(), "-path", PATH.toString(), "-s", + existingTargetDirPath.toString(), "-symtypes", + "de.monticore.cdbasis._symboltable.CDTypeSymbol", "TypeSymbolDeSer" }); File symTab = existingTargetDirPath.resolve("Examples.odsym").toFile(); assertTrue(symTab.exists() && symTab.isFile()); - MCAssertions.assertNoFindings(); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.STEXPORT_SUCCESSFUL, symTab.getAbsolutePath()), + out.get(1)); } @Test public void testStoreSymtabFile3() { Path copiedInputFile = getTmpFilePath("examples", "od", "Examples.od"); assertDoesNotThrow(() -> FileUtils.copyFile(INPUT_OD.toFile(), copiedInputFile.toFile())); - new OD4ReportTool().run( + List out = OD4ReportTestUtil.runToolInSeparateProcess( new String[] { "-i", copiedInputFile.toString(), "-path", PATH.toString(), "-s", "-symtypes", "de.monticore.cdbasis._symboltable.CDTypeSymbol", "TypeSymbolDeSer" }); File symTab = copiedInputFile.getParent().resolve("Examples.odsym").toFile(); assertTrue(symTab.exists() && symTab.isFile()); - MCAssertions.assertNoFindings(); + + assertEquals(2, out.size()); + assertEquals(getAsInfo(OD4ReportTool.PARSE_SUCCESSFUL, "Examples"), out.getFirst()); + assertEquals(getAsInfo(OD4ReportTool.STEXPORT_SUCCESSFUL, symTab.getAbsolutePath()), + out.get(1)); + } + + protected String getAsInfo(String base, String... data) { + return RichConsoleLogHook.BLUE + "[INFO]" + RichConsoleLogHook.RESET + + " de.monticore.od4report.OD4ReportTool " + base.formatted(data).strip(); + } + + protected String getAsError(String base, String... data) { + return RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " " + + base.formatted(data).strip(); } } diff --git a/src/test/java/de/monticore/od4report/_cocos/OD4ReportCocoCheckerTest.java b/src/test/java/de/monticore/od4report/_cocos/OD4ReportCocoCheckerTest.java index b041eafd..257765ac 100644 --- a/src/test/java/de/monticore/od4report/_cocos/OD4ReportCocoCheckerTest.java +++ b/src/test/java/de/monticore/od4report/_cocos/OD4ReportCocoCheckerTest.java @@ -6,12 +6,12 @@ import de.monticore.ODTestBasis; import de.monticore.io.paths.MCPath; -import de.monticore.od4data.OD4DataMill; import de.monticore.od4report.OD4ReportMill; import de.monticore.od4report.OD4ReportTestUtil; import de.monticore.od4report._symboltable.IOD4ReportGlobalScope; import de.monticore.odbasis._ast.ASTODArtifact; -import de.monticore.odbasis._cocos.object.ValidObjectTypeCoco; +import de.monticore.odbasis._cocos.object.ValidObjectTypeCoCo; +import de.monticore.odbasis._symboltable.ODBasisSymbolTableCompleter; import de.monticore.runtime.junit.MCAssertions; import de.monticore.runtime.junit.TestWithMCLanguage; import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; @@ -36,7 +36,7 @@ public void checkValidObjectTypeCocoSuccess() { Path odPath = PATH.resolve(Paths.get("examples", "od", "MyFamily.od")); ASTODArtifact artifact = OD4ReportTestUtil.loadModelAndST(odPath, new MCPath(PATH)); - odCoCoChecker.addCoCo(new ValidObjectTypeCoco()); + odCoCoChecker.addCoCo(new ValidObjectTypeCoCo()); odCoCoChecker.checkAll(artifact); } @@ -44,21 +44,21 @@ public void checkValidObjectTypeCocoSuccess() { public void checkValidObjectTypeCocoFailure() { IOD4ReportGlobalScope gs = OD4ReportMill.globalScope(); TypeSymbol person = OD4ReportMill.typeSymbolBuilder().setName("Person").setEnclosingScope(gs) - .setSpannedScope(OD4DataMill.scope()).build(); + .setSpannedScope(OD4ReportMill.scope()).build(); TypeSymbol bmw = OD4ReportMill.typeSymbolBuilder().setName("BMW").setEnclosingScope(gs) - .setSpannedScope(OD4DataMill.scope()).build(); + .setSpannedScope(OD4ReportMill.scope()).build(); gs.add(person); gs.add(bmw); Path odPath = PATH.resolve(Paths.get("examples", "od", "MyFamily.od")); ASTODArtifact artifact = OD4ReportTestUtil.loadModelAndST(odPath, new MCPath()); - odCoCoChecker.addCoCo(new ValidObjectTypeCoco()); + odCoCoChecker.addCoCo(new ValidObjectTypeCoCo()); odCoCoChecker.checkAll(artifact); MCAssertions.assertHasFindingStartingWith("0xA0324 Cannot find symbol Jaguar"); MCAssertions.assertHasFindingStartingWith( - "0x0D013: The type of the return type (ASTMCQualifiedType) could not be calculated"); + ODBasisSymbolTableCompleter.ERROR_TYPE_NOT_CALCULATED.formatted("Jaguar", "tiger")); MCAssertions.assertHasFindingStartingWith("0xB0035: Type 'Jaguar' is used but not defined."); } diff --git a/src/test/java/de/monticore/od4report/_symboltable/OD4ReportDeSerTest.java b/src/test/java/de/monticore/od4report/_symboltable/OD4ReportDeSerTest.java index f85f98a4..1902051c 100644 --- a/src/test/java/de/monticore/od4report/_symboltable/OD4ReportDeSerTest.java +++ b/src/test/java/de/monticore/od4report/_symboltable/OD4ReportDeSerTest.java @@ -9,10 +9,10 @@ import de.monticore.odbasis._ast.ASTODArtifact; import de.monticore.runtime.junit.TestWithMCLanguage; import de.monticore.symbols.basicsymbols._symboltable.VariableSymbol; - import de.se_rwth.commons.Names; import org.junit.jupiter.api.Test; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; @@ -21,49 +21,35 @@ @TestWithMCLanguage(OD4ReportMill.class) public class OD4ReportDeSerTest extends ODTestBasis { - + private final Path INPUT_OD = PATH.resolve(Paths.get("examples", "od", "MyFamily.od")); - - private final Path SYMBOL_TARGET = Paths.get("target", "deser"); - + @Test public void testOD4ReportDeSer() { ASTODArtifact artifact = OD4ReportTestUtil.loadModel(INPUT_OD, new MCPath(PATH)); IOD4ReportArtifactScope artifactScope = OD4ReportTestUtil.createSymbolTableFromAST(artifact); - - // serialize - OD4ReportSymbols2Json od4ReportSymbols2Json = new OD4ReportSymbols2Json(); - String fileName = INPUT_OD.getFileName().toString() + "sym"; - String pathFromQualifiedName = Names.getPathFromQualifiedName( - artifact.getMCPackageDeclaration().getMCQualifiedName().getQName() + "." - + artifact.getObjectDiagram().getName()); - Path storedPath = SYMBOL_TARGET.resolve(pathFromQualifiedName).resolve(fileName); - od4ReportSymbols2Json.store(artifactScope, storedPath.toString()); - - assertTrue(storedPath.toFile().exists()); - - // deserialize - IOD4ReportArtifactScope loadedBasicsArtifactScope = - od4ReportSymbols2Json.load(storedPath.toString()); - + OD4ReportSymbols2Json symbols2Json = new OD4ReportSymbols2Json(); + + Path storedPath = store(symbols2Json, artifact, artifactScope); + IOD4ReportArtifactScope loadedArtifactScope = symbols2Json.load(storedPath.toString()); + // clear buffer of traverser, as elements should be traversed again - od4ReportSymbols2Json.getTraverser().clearTraversedElements(); - - assertEquals(od4ReportSymbols2Json.serialize(artifactScope), - od4ReportSymbols2Json.serialize(loadedBasicsArtifactScope)); + symbols2Json.getTraverser().clearTraversedElements(); + + assertEquals(symbols2Json.serialize(artifactScope), symbols2Json.serialize(loadedArtifactScope)); } - + @Test public void serializationTest() { ASTODArtifact ast = OD4ReportTestUtil.loadModel(INPUT_OD, new MCPath(PATH)); - + // create symbol table IOD4ReportArtifactScope artifactScope = OD4ReportTestUtil.createSymbolTableFromAST(ast); OD4ReportSymbols2Json symbols2Json = new OD4ReportSymbols2Json(); String serialized = symbols2Json.serialize(artifactScope); assertNotNull(serialized); assertNotEquals("", serialized); - + // check for contents IOD4ReportArtifactScope deserialized = symbols2Json.deserialize(serialized); assertEquals("MyFamily", deserialized.getName()); @@ -75,26 +61,44 @@ public void serializationTest() { assertEquals("examples.od.bob", bob.get().getFullName()); assertEquals("examples.cd.MyFamily.Person", alice.get().getType().printFullName()); } - + + /** + * Loads a symbol file, which is created from the current model, via the symbol path of the + * global scope and resolves its objects. + */ @Test public void deserializationTest() { + ASTODArtifact artifact = OD4ReportTestUtil.loadModel(INPUT_OD, new MCPath(PATH)); + IOD4ReportArtifactScope artifactScope = OD4ReportTestUtil.createSymbolTableFromAST(artifact); + store(new OD4ReportSymbols2Json(), artifact, artifactScope); + IOD4ReportGlobalScope gs = OD4ReportMill.globalScope(); gs.clear(); - gs.setSymbolPath(new MCPath(PATH)); + gs.setSymbolPath(new MCPath(getTmpDirPath())); assertTrue(gs.getSubScopes().isEmpty()); gs.loadFileForModelName("examples.od.MyFamily"); assertEquals(1, gs.getSubScopes().size()); - - // resolve for object alice - Optional alice = gs.resolveVariable("examples.od.MyFamily.alice"); - assertTrue(alice.isPresent()); - - // resolve for object bob - Optional bob = gs.resolveVariable("examples.od.MyFamily.bob"); - assertTrue(bob.isPresent()); - - // resolve for object tiger - Optional tiger = gs.resolveVariable("examples.od.MyFamily.tiger"); - assertTrue(tiger.isPresent()); + + for (String object : new String[] { "alice", "bob", "tiger" }) { + assertTrue(gs.resolveVariable("examples.od.MyFamily." + object).isPresent(), + "Could not resolve object " + object); + } + } + + /** + * Stores the symbol table in the temporary directory at the location of the model's qualified + * name, e.g., {@code examples/od/MyFamily.odsym}. + */ + protected Path store(OD4ReportSymbols2Json symbols2Json, ASTODArtifact artifact, + IOD4ReportArtifactScope artifactScope) { + String qualifiedName = artifact.getMCPackageDeclaration().getMCQualifiedName().getQName() + + "." + artifact.getObjectDiagram().getName(); + Path storedPath = getTmpDirPath().resolve(Names.getPathFromQualifiedName(qualifiedName)) + .resolve(artifact.getObjectDiagram().getName() + ".odsym"); + + symbols2Json.store(artifactScope, storedPath.toString()); + + assertTrue(Files.isRegularFile(storedPath), "Symbol file was not stored: " + storedPath); + return storedPath; } } diff --git a/src/test/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitorTest.java b/src/test/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitorTest.java new file mode 100644 index 00000000..cb3cf518 --- /dev/null +++ b/src/test/java/de/monticore/od4report/_symboltable/OD4ReportScopesGenitorTest.java @@ -0,0 +1,41 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package de.monticore.od4report._symboltable; + +import de.monticore.od4report.OD4ReportMill; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.TestWithMCLanguage; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; + +@TestWithMCLanguage(OD4ReportMill.class) +public class OD4ReportScopesGenitorTest { + + /** The genitor can be reused, each artifact scope is a sub scope of the global scope. */ + @Test + public void testReusedGenitor() throws IOException { + ASTODArtifact first = parse("package p; objectdiagram A { a:T {}; }"); + ASTODArtifact second = parse("objectdiagram B { b:T {}; }"); + OD4ReportScopesGenitorDelegator genitor = OD4ReportMill.scopesGenitorDelegator(); + + IOD4ReportArtifactScope firstScope = genitor.createFromAST(first); + IOD4ReportArtifactScope secondScope = genitor.createFromAST(second); + + assertSame(OD4ReportMill.globalScope(), firstScope.getEnclosingScope()); + assertSame(OD4ReportMill.globalScope(), secondScope.getEnclosingScope()); + assertSame(first, firstScope.getAstNode()); + assertSame(second, secondScope.getAstNode()); + assertEquals("p", firstScope.getPackageName()); + assertEquals("", secondScope.getPackageName()); + assertEquals("A", firstScope.getName()); + assertEquals("B", secondScope.getName()); + } + + protected ASTODArtifact parse(String model) throws IOException { + return OD4ReportMill.parser().parse_StringODArtifact(model).orElseThrow(); + } +} diff --git a/src/test/java/de/monticore/od4report/_symboltable/OD4ReportSymbolTableCreatorTest.java b/src/test/java/de/monticore/od4report/_symboltable/OD4ReportSymbolTableCreatorTest.java index 0f312de9..9040e240 100644 --- a/src/test/java/de/monticore/od4report/_symboltable/OD4ReportSymbolTableCreatorTest.java +++ b/src/test/java/de/monticore/od4report/_symboltable/OD4ReportSymbolTableCreatorTest.java @@ -7,28 +7,59 @@ import de.monticore.od4report.OD4ReportMill; import de.monticore.od4report.OD4ReportTestUtil; import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.odbasis._ast.ASTODNamedObject; import de.monticore.runtime.junit.TestWithMCLanguage; import de.monticore.symbols.basicsymbols._symboltable.VariableSymbol; import org.junit.jupiter.api.Test; import java.nio.file.Path; -import java.util.Optional; +import java.util.Map; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; @TestWithMCLanguage(OD4ReportMill.class) public class OD4ReportSymbolTableCreatorTest extends ODTestBasis { - + private final Path INPUT_DIR = PATH.resolve("symboltable"); - + + /** Each object of the diagram gets a symbol with its AST node and the type from the CD. */ @Test public void testOD4ReportSymbolTableCreator() { - Path inputOD = INPUT_DIR.resolve("AuctionParticipants.od"); - ASTODArtifact artifact = OD4ReportTestUtil.loadModel(inputOD, new MCPath(PATH)); - + ASTODArtifact artifact = + OD4ReportTestUtil.loadModel(INPUT_DIR.resolve("AuctionParticipants.od"), new MCPath(PATH)); + IOD4ReportArtifactScope symbolTable = OD4ReportTestUtil.createSymbolTableFromAST(artifact); - Optional person = - symbolTable.resolveVariable("symboltable.symbols.MyFamily.alice"); - assertTrue(person.isPresent()); + + assertEquals("AuctionParticipants", symbolTable.getName()); + assertEquals("symboltable", symbolTable.getPackageName()); + + Map expectedTypes = Map.of( + "kupfer912", "examples.cd.Auction.Auction", + "theo", "examples.cd.Auction.Person", + "otto", "examples.cd.Auction.Person", + "lisa", "examples.cd.Auction.Person", + "bp", "examples.cd.Auction.BiddingPolicy", + "tp", "examples.cd.Auction.TimingPolicy"); + assertEquals(expectedTypes.size(), symbolTable.getLocalVariableSymbols().size()); + + expectedTypes.forEach((name, type) -> { + VariableSymbol symbol = symbolTable.resolveVariable("symboltable.AuctionParticipants." + name) + .orElseGet(() -> fail("No symbol for object " + name)); + assertSame(symbolTable, symbol.getEnclosingScope(), name); + assertEquals(name, assertInstanceOf(ASTODNamedObject.class, symbol.getAstNode()).getName()); + assertEquals(type, symbol.getType().printFullName(), name); + }); + } + + /** Objects of other diagrams are resolved via the symbol path from stored symbol tables. */ + @Test + public void testResolveObjectOfOtherDiagram() { + ASTODArtifact artifact = + OD4ReportTestUtil.loadModel(INPUT_DIR.resolve("AuctionParticipants.od"), new MCPath(PATH)); + IOD4ReportArtifactScope symbolTable = OD4ReportTestUtil.createSymbolTableFromAST(artifact); + + VariableSymbol alice = symbolTable.resolveVariable("symboltable.symbols.MyFamily.alice") + .orElseGet(() -> fail("Object alice of diagram MyFamily not resolved")); + assertNotSame(symbolTable, alice.getEnclosingScope()); } } diff --git a/src/test/java/de/monticore/od4report/utils/OD4ReportCollectorTest.java b/src/test/java/de/monticore/od4report/utils/OD4ReportCollectorTest.java index 4fc97033..6550bbc9 100644 --- a/src/test/java/de/monticore/od4report/utils/OD4ReportCollectorTest.java +++ b/src/test/java/de/monticore/od4report/utils/OD4ReportCollectorTest.java @@ -9,6 +9,7 @@ import de.monticore.od4report._ast.ASTODReportObject; import de.monticore.od4report.util.OD4ReportCollector; import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.odbasis._ast.ASTObjectDiagram; import de.monticore.runtime.junit.TestWithMCLanguage; import org.junit.jupiter.api.Test; @@ -48,6 +49,23 @@ public void testCollector() { assertEquals(1, reportObjects.size()); } + /** A collector can be reused, also for different diagrams, without affecting the results. */ + @Test + public void testRepeatedQueries() { + ASTObjectDiagram examples = OD4ReportTestUtil.loadModel(EXAMPLE_DIR.resolve("Examples.od"), + new MCPath(PATH)).getObjectDiagram(); + ASTObjectDiagram simple = OD4ReportTestUtil.loadModel(EXAMPLE_DIR.resolve("SimpleOD2.od"), + new MCPath(PATH)).getObjectDiagram(); + OD4ReportCollector od4ReportCollector = new OD4ReportCollector(); + + for (int i = 0; i < 3; i++) { + assertEquals(4, od4ReportCollector.getODObjects(examples).size()); + assertEquals(5, od4ReportCollector.getODObjects(simple).size()); + assertEquals(2, od4ReportCollector.getODLinks(examples).size()); + assertEquals(1, od4ReportCollector.getODLinks(simple).size()); + } + } + @Test public void testAnonymousCollect() { Path inputOD = EXAMPLE_DIR.resolve("SimpleOD2.od"); diff --git a/src/test/java/de/monticore/odbasis/_cocos/attributes/NoAbstractAttributesCoCoTest.java b/src/test/java/de/monticore/odbasis/_cocos/attributes/NoAbstractAttributesCoCoTest.java new file mode 100644 index 00000000..829aa315 --- /dev/null +++ b/src/test/java/de/monticore/odbasis/_cocos/attributes/NoAbstractAttributesCoCoTest.java @@ -0,0 +1,72 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odbasis._cocos.attributes; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link NoAbstractAttributesCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class NoAbstractAttributesCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new NoAbstractAttributesCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts a regular object diagram attribute when the attribute does not + * use the {@code abstract} modifier. + */ + @Test + void shouldAcceptNonAbstractAttribute() { + ASTODArtifact artifact = loadArtifact("ValidNonAbstractAttribute.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports exactly the configured error message when an object diagram + * attribute is declared with the {@code abstract} modifier. + */ + @Test + void shouldReportAbstractAttribute() { + ASTODArtifact artifact = loadArtifact("InvalidAbstractAttribute.od"); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith("0x0D005"); + assertEquals( + NoAbstractAttributesCoCo.ERROR_ABSTRACT_ATTRIBUTE, + Log.getFindings().getFirst().getMsg()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/monticore/odbasis/_cocos/attributes/PartialAndCompleteAttributesCoCoTest.java b/src/test/java/de/monticore/odbasis/_cocos/attributes/PartialAndCompleteAttributesCoCoTest.java new file mode 100644 index 00000000..a09a283b --- /dev/null +++ b/src/test/java/de/monticore/odbasis/_cocos/attributes/PartialAndCompleteAttributesCoCoTest.java @@ -0,0 +1,72 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odbasis._cocos.attributes; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link PartialAndCompleteAttributesCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class PartialAndCompleteAttributesCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new PartialAndCompleteAttributesCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts an object whose attributes are not mixed between partial and + * complete declarations for the same attribute name. + */ + @Test + void shouldAcceptNonMixedAttributes() { + ASTODArtifact artifact = loadArtifact("ValidPartialAndCompleteAttributes.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports exactly the configured error message when an attribute is declared + * once as partial and once as complete within the same object. + */ + @Test + void shouldReportPartialAndCompleteAttributeMix() { + ASTODArtifact artifact = loadArtifact("InvalidPartialAndCompleteAttributes.od"); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith("0x0D004"); + assertEquals( + PartialAndCompleteAttributesCoCo.ERROR_PARTIAL_AND_COMPLETE_ATTRIBUTE_MIX.formatted("foobar"), + Log.getFindings().getFirst().getMsg()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/monticore/odbasis/_cocos/attributes/UniqueAttributeNamesCoCoTest.java b/src/test/java/de/monticore/odbasis/_cocos/attributes/UniqueAttributeNamesCoCoTest.java new file mode 100644 index 00000000..cf958bac --- /dev/null +++ b/src/test/java/de/monticore/odbasis/_cocos/attributes/UniqueAttributeNamesCoCoTest.java @@ -0,0 +1,71 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odbasis._cocos.attributes; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link UniqueAttributeNamesCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class UniqueAttributeNamesCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new UniqueAttributeNamesCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts an object if all complete attributes have unique names. + */ + @Test + void shouldAcceptUniqueCompleteAttributeNames() { + ASTODArtifact artifact = loadArtifact("ValidUniqueAttributeNames.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports exactly the configured error message when a complete attribute + * name is used more than once within the same object. + */ + @Test + void shouldReportDuplicateCompleteAttributeNames() { + ASTODArtifact artifact = loadArtifact("InvalidDuplicateAttributeNames.od"); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith("0x0D003"); + assertEquals( + UniqueAttributeNamesCoCo.ERROR_ATTRIBUTE_NAME_NOT_UNIQUE.formatted("foobar"), + Log.getFindings().getFirst().getMsg()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/monticore/odbasis/_cocos/attributes/ValidObjectAttributeCoCoTest.java b/src/test/java/de/monticore/odbasis/_cocos/attributes/ValidObjectAttributeCoCoTest.java new file mode 100644 index 00000000..531255e5 --- /dev/null +++ b/src/test/java/de/monticore/odbasis/_cocos/attributes/ValidObjectAttributeCoCoTest.java @@ -0,0 +1,87 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odbasis._cocos.attributes; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.odbasis._cocos.ODBasisCoCos; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link ValidObjectAttributesCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class ValidObjectAttributeCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new ValidObjectAttributesCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts an object when all declared attributes are defined as fields in + * the object's type. + */ + @Test + void shouldAcceptValidObjectAttributes() { + ASTODArtifact artifact = loadArtifact("ValidObjectAttributes.od"); + OD4DevelopmentTestUtil.completeSymbolTable(artifact, true); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports exactly the configured error message when an attribute is + * declared but not defined as a field in the object's type. + */ + @Test + void shouldReportUndefinedObjectAttribute() { + ASTODArtifact artifact = loadArtifact("InvalidObjectAttributes.od"); + OD4DevelopmentTestUtil.completeSymbolTable(artifact, true); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith("0x0D006"); + assertEquals( + ValidObjectAttributesCoCo.ERROR_ATTRIBUTE_NOT_DEFINED.formatted("undefinedField", "ObjectType"), + Log.getFindings().getFirst().getMsg()); + } + + /** The CoCo is an inter-model CoCo and must be part of the checker for all CoCos. */ + @Test + void shouldBeCheckedByCheckerForAllCoCos() { + ASTODArtifact artifact = loadArtifact("InvalidObjectAttributes.od"); + OD4DevelopmentTestUtil.completeSymbolTable(artifact, true); + + new ODBasisCoCos().getCheckerForAllCoCos().checkAll(artifact); + + MCAssertions.assertHasFindingStartingWith( + ValidObjectAttributesCoCo.ERROR_ATTRIBUTE_NOT_DEFINED.formatted("undefinedField", "ObjectType")); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/monticore/odbasis/_cocos/names/UniqueObjectNamesCoCoTest.java b/src/test/java/de/monticore/odbasis/_cocos/names/UniqueObjectNamesCoCoTest.java new file mode 100644 index 00000000..a3c76d9a --- /dev/null +++ b/src/test/java/de/monticore/odbasis/_cocos/names/UniqueObjectNamesCoCoTest.java @@ -0,0 +1,74 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odbasis._cocos.names; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link UniqueObjectNamesCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class UniqueObjectNamesCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new UniqueObjectNamesCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts an object diagram without duplicate named objects. + */ + @Test + void shouldAcceptUniqueObjectNames() { + ASTODArtifact artifact = loadArtifact("AnonymousObject.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports exactly the configured error message for each duplicated named + * object in the enclosing scope. + */ + @Test + void shouldReportDuplicateObjectNames() { + ASTODArtifact artifact = loadArtifact("NoUniqueNames.od"); + + odCoCoChecker.checkAll(artifact); + + assertEquals(2, Log.getFindings().size()); + MCAssertions.assertHasFindingsStartingWith("0x0D002"); + assertEquals( + UniqueObjectNamesCoCo.ERROR_OBJECT_NAME_NOT_UNIQUE.formatted("myObject"), + Log.getFindings().get(0).getMsg()); + assertEquals( + UniqueObjectNamesCoCo.ERROR_OBJECT_NAME_NOT_UNIQUE.formatted("myObject"), + Log.getFindings().get(1).getMsg()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/monticore/odbasis/_cocos/object/ValidObjectReferenceCoCoTest.java b/src/test/java/de/monticore/odbasis/_cocos/object/ValidObjectReferenceCoCoTest.java new file mode 100644 index 00000000..3dd21a27 --- /dev/null +++ b/src/test/java/de/monticore/odbasis/_cocos/object/ValidObjectReferenceCoCoTest.java @@ -0,0 +1,72 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odbasis._cocos.object; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link ValidObjectReferenceCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class ValidObjectReferenceCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new ValidObjectReferenceCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts an object diagram when all object attribute references can be + * resolved to existing objects in the enclosing scope. + */ + @Test + void shouldAcceptResolvableObjectReferences() { + ASTODArtifact artifact = loadArtifact("ValidObjectReference.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports exactly the configured error message when an attribute value + * references an object name that cannot be resolved in the enclosing scope. + */ + @Test + void shouldReportUnresolvedObjectReference() { + ASTODArtifact artifact = loadArtifact("InvalidSingleObjectReference.od"); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith("0x0D001"); + assertEquals( + ValidObjectReferenceCoCo.ERROR_UNRESOLVED_OBJECT_REFERENCE.formatted("undefinedObject"), + Log.getFindings().getFirst().getMsg()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoCoTest.java b/src/test/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoCoTest.java new file mode 100644 index 00000000..18e449d1 --- /dev/null +++ b/src/test/java/de/monticore/odbasis/_cocos/object/ValidObjectTypeCoCoTest.java @@ -0,0 +1,72 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odbasis._cocos.object; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link ValidObjectTypeCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class ValidObjectTypeCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new ValidObjectTypeCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts an object diagram when all object types can be resolved in the + * enclosing scope. + */ + @Test + void shouldAcceptValidObjectTypes() { + ASTODArtifact artifact = loadArtifact("ValidObjectType.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports exactly the configured error message when an object is declared + * with a type that cannot be resolved in the enclosing scope. + */ + @Test + void shouldReportUndefinedObjectType() { + ASTODArtifact artifact = loadArtifact("InvalidObjectType.od"); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith("0xB0035"); + assertEquals( + ValidObjectTypeCoCo.ERROR_TYPE_USED_BUT_UNDEFINED.formatted("UndefinedType"), + Log.getFindings().getFirst().getMsg()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/monticore/odbasis/_symboltable/ODBasisSymbolTableCompleterTest.java b/src/test/java/de/monticore/odbasis/_symboltable/ODBasisSymbolTableCompleterTest.java new file mode 100644 index 00000000..25eff143 --- /dev/null +++ b/src/test/java/de/monticore/odbasis/_symboltable/ODBasisSymbolTableCompleterTest.java @@ -0,0 +1,56 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package de.monticore.odbasis._symboltable; + +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests for {@link ODBasisSymbolTableCompleter}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +public class ODBasisSymbolTableCompleterTest { + + /** Several completers without type checks share a single {@code DefaultObject} type. */ + @Test + public void testSingleDefaultObjectType() throws IOException { + ASTODArtifact first = parse("objectdiagram A { a:T {}; }"); + ASTODArtifact second = parse("objectdiagram B { b:T {}; }"); + OD4DevelopmentTestUtil.createSymbolTableFromAST(first); + OD4DevelopmentTestUtil.createSymbolTableFromAST(second); + + OD4DevelopmentTestUtil.completeSymbolTable(first, false); + OD4DevelopmentTestUtil.completeSymbolTable(second, false); + + assertEquals(1, OD4DevelopmentMill.globalScope().getTypeSymbols() + .get(ODBasisSymbolTableCompleter.DEFAULT_OBJECT).size()); + } + + /** No {@code DefaultObject} type is added if the types are checked. */ + @Test + public void testNoDefaultObjectTypeIfTypesAreChecked() throws IOException { + ASTODArtifact artifact = parse("objectdiagram A { a:T {}; }"); + OD4DevelopmentTestUtil.createSymbolTableFromAST(artifact); + + OD4DevelopmentTestUtil.completeSymbolTable(artifact, true); + + MCAssertions.assertHasFindingStartingWith( + ODBasisSymbolTableCompleter.ERROR_TYPE_NOT_CALCULATED.formatted("T", "a")); + MCAssertions.assertHasFindingStartingWith("0xA0324"); + assertTrue(OD4DevelopmentMill.globalScope().getTypeSymbols() + .get(ODBasisSymbolTableCompleter.DEFAULT_OBJECT).isEmpty()); + } + + protected ASTODArtifact parse(String model) throws IOException { + return OD4DevelopmentMill.parser().parse_StringODArtifact(model).orElseThrow(); + } +} diff --git a/src/test/java/de/monticore/odlink/_cocos/link/LinkEndConsistencyCoCoTest.java b/src/test/java/de/monticore/odlink/_cocos/link/LinkEndConsistencyCoCoTest.java new file mode 100644 index 00000000..42fc2bca --- /dev/null +++ b/src/test/java/de/monticore/odlink/_cocos/link/LinkEndConsistencyCoCoTest.java @@ -0,0 +1,116 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odlink._cocos.link; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link LinkEndConsistencyCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class LinkEndConsistencyCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new LinkEndConsistencyCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts a link whose left and right side are each internally consistent, + * even if both sides resolve to different types from one another. + */ + @Test + void shouldAcceptDifferentTypesAcrossSidesWhenEachSideIsInternallyConsistent() { + ASTODArtifact artifact = loadArtifact("ValidLinkEndConsistency.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo ignores references that cannot be resolved in the enclosing scope, as + * they are reported by {@link ValidLinkReferenceCoCo}. + */ + @Test + void shouldIgnoreUnresolvedReferenceOnRightSide() { + ASTODArtifact artifact = loadArtifact("UnresolvedRightLinkEndConsistency.od"); + + odCoCoChecker.checkAll(artifact); + + MCAssertions.assertNoFindings(); + } + + /** + * Tests that an unresolved reference is reported only once if both link CoCos are checked. + */ + @Test + void shouldReportUnresolvedReferenceOnceTogetherWithValidLinkReferenceCoCo() { + ASTODArtifact artifact = loadArtifact("UnresolvedRightLinkEndConsistency.od"); + odCoCoChecker.addCoCo(new ValidLinkReferenceCoCo()); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith( + ValidLinkReferenceCoCo.ERROR_RIGHT_REFERENCE_UNRESOLVED.formatted("missingObject")); + } + + /** + * Tests that the CoCo reports error code {@code 0x0D009} when the left side of a named link + * contains references that resolve to different variable types. + */ + @Test + void shouldReportInconsistentTypesOnLeftSide() { + ASTODArtifact artifact = loadArtifact("InconsistentLeftLinkEndConsistency.od"); + + odCoCoChecker.checkAll(artifact); + + MCAssertions.assertHasFindingStartingWith("0x0D009"); + assertEquals(LinkEndConsistencyCoCo.ERROR_INCONSISTENT_REFERENCE_TYPES.formatted("left side", "fooBar", "examples.cd.SimpleOD.ObjectType2", "foo", "examples.cd.SimpleOD.ObjectType"), Log.getFindings().getFirst().getMsg()); + assertEquals(1, Log.getFindings().size()); + } + + /** + * Tests that the CoCo reports error code {@code 0x0D009} when the right side of a named link + * contains references that resolve to different variable types. + */ + @Test + void shouldReportInconsistentTypesOnRightSide() { + ASTODArtifact artifact = loadArtifact("InconsistentRightLinkEndConsistency.od"); + + odCoCoChecker.checkAll(artifact); + + MCAssertions.assertHasFindingStartingWith("0x0D009"); + assertEquals(LinkEndConsistencyCoCo.ERROR_INCONSISTENT_REFERENCE_TYPES.formatted("right side", "bar", "examples.cd.SimpleOD.ObjectType", "fooBar", "examples.cd.SimpleOD.ObjectType2"), Log.getFindings().getFirst().getMsg()); + assertEquals(1, Log.getFindings().size()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + ASTODArtifact artifact = + OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + OD4DevelopmentTestUtil.completeSymbolTable(artifact, true); + return artifact; + } +} + diff --git a/src/test/java/de/monticore/odlink/_cocos/link/NoAbstractLinkCoCoTest.java b/src/test/java/de/monticore/odlink/_cocos/link/NoAbstractLinkCoCoTest.java new file mode 100644 index 00000000..6ed79541 --- /dev/null +++ b/src/test/java/de/monticore/odlink/_cocos/link/NoAbstractLinkCoCoTest.java @@ -0,0 +1,89 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odlink._cocos.link; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link NoAbstractLinkCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class NoAbstractLinkCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new NoAbstractLinkCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts a link when neither the left side nor the right side is declared + * with the {@code abstract} modifier. + */ + @Test + void shouldAcceptNonAbstractLinkSides() { + ASTODArtifact artifact = loadArtifact("ValidNonAbstractLink.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports exactly the configured left-side error message when the left side + * of a link is declared abstract. + */ + @Test + void shouldReportAbstractLeftSide() { + ASTODArtifact artifact = loadArtifact("InvalidAbstractLeftLink.od"); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith("0x0D00A"); + assertEquals( + NoAbstractLinkCoCo.ERROR_LEFT_SIDE_ABSTRACT, + Log.getFindings().getFirst().getMsg()); + } + + /** + * Tests that the CoCo reports exactly the configured right-side error message when the right + * side of a link is declared abstract. + */ + @Test + void shouldReportAbstractRightSide() { + ASTODArtifact artifact = loadArtifact("InvalidAbstractRightLink.od"); + + odCoCoChecker.checkAll(artifact); + + assertEquals(1, Log.getFindings().size()); + MCAssertions.assertHasFindingStartingWith("0x0D00B"); + assertEquals( + NoAbstractLinkCoCo.ERROR_RIGHT_SIDE_ABSTRACT, + Log.getFindings().getFirst().getMsg()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/monticore/odlink/_cocos/link/ValidLinkReferenceCoCoTest.java b/src/test/java/de/monticore/odlink/_cocos/link/ValidLinkReferenceCoCoTest.java new file mode 100644 index 00000000..43ace0cf --- /dev/null +++ b/src/test/java/de/monticore/odlink/_cocos/link/ValidLinkReferenceCoCoTest.java @@ -0,0 +1,85 @@ +/* (c) https://github.com/MontiCore/monticore */ +package de.monticore.odlink._cocos.link; + +import de.monticore.ODOutTestBasis; +import de.monticore.io.paths.MCPath; +import de.monticore.od4development.OD4DevelopmentMill; +import de.monticore.od4development.OD4DevelopmentTestUtil; +import de.monticore.od4development._cocos.OD4DevelopmentCoCoChecker; +import de.monticore.odbasis._ast.ASTODArtifact; +import de.monticore.runtime.junit.MCAssertions; +import de.monticore.runtime.junit.TestWithMCLanguage; +import de.se_rwth.commons.logging.Log; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link ValidLinkReferenceCoCo}. + */ +@TestWithMCLanguage(OD4DevelopmentMill.class) +class ValidLinkReferenceCoCoTest extends ODOutTestBasis { + + private final Path cocoExamples = PATH.resolve("cocos"); + + private OD4DevelopmentCoCoChecker odCoCoChecker; + + @BeforeEach + void setUp() { + odCoCoChecker = new OD4DevelopmentCoCoChecker(); + odCoCoChecker.addCoCo(new ValidLinkReferenceCoCo()); + Log.getFindings().clear(); + } + + /** + * Tests that the CoCo accepts a named link when all references on the left and on the right + * side can be resolved in the enclosing scope. + */ + @Test + void shouldAcceptResolvableReferencesOnBothSides() { + ASTODArtifact artifact = loadArtifact("ValidLinkReference.od"); + + odCoCoChecker.checkAll(artifact); + + checkLogError(); + } + + /** + * Tests that the CoCo reports error code {@code 0x0D00C} when a reference on the left side of + * a named link cannot be resolved in the enclosing scope. + */ + @Test + void shouldReportUnresolvedLeftReference() { + ASTODArtifact artifact = loadArtifact("InvalidLeftLinkReference.od"); + + odCoCoChecker.checkAll(artifact); + + MCAssertions.assertHasFindingStartingWith("0x0D00C"); + assertEquals(ValidLinkReferenceCoCo.ERROR_LEFT_REFERENCE_UNRESOLVED.formatted("missingLeft"), Log.getFindings().getFirst().getMsg()); + assertEquals(1, Log.getFindings().size()); + } + + /** + * Tests that the CoCo reports error code {@code 0x0D00D} when a reference on the right side of + * a named link cannot be resolved in the enclosing scope. + */ + @Test + void shouldReportUnresolvedRightReference() { + ASTODArtifact artifact = loadArtifact("InvalidRightLinkReference.od"); + + odCoCoChecker.checkAll(artifact); + + MCAssertions.assertHasFindingStartingWith("0x0D00D"); + assertEquals(ValidLinkReferenceCoCo.ERROR_RIGHT_REFERENCE_UNRESOLVED.formatted("missingRight"), Log.getFindings().getFirst().getMsg()); + assertEquals(1, Log.getFindings().size()); + } + + protected ASTODArtifact loadArtifact(String fileName) { + return OD4DevelopmentTestUtil.loadModelAndST(cocoExamples.resolve(fileName), new MCPath(PATH)); + } +} + diff --git a/src/test/java/de/se_rwth/commons/logging/ODLogReset.java b/src/test/java/de/se_rwth/commons/logging/ODLogReset.java deleted file mode 100644 index 482659d2..00000000 --- a/src/test/java/de/se_rwth/commons/logging/ODLogReset.java +++ /dev/null @@ -1,24 +0,0 @@ -/* (c) https://github.com/MontiCore/monticore */ -package de.se_rwth.commons.logging; - -import org.junit.jupiter.api.BeforeEach; - -import java.util.ArrayList; - -/** - * Resets findings of the current MC-Log - * - */ -public class ODLogReset extends Log { - - @BeforeEach - public void setup() { - LogStub.init(); - Log.enableFailQuick(false); - } - - public static void resetFindings() { - getLog().findings = new ArrayList<>(); - } - -} diff --git a/src/test/resources/cocos/InconsistentLeftLinkEndConsistency.od b/src/test/resources/cocos/InconsistentLeftLinkEndConsistency.od new file mode 100644 index 00000000..d17d18c0 --- /dev/null +++ b/src/test/resources/cocos/InconsistentLeftLinkEndConsistency.od @@ -0,0 +1,16 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InconsistentLeftLinkEndConsistency { + + foo:ObjectType{}; + fooBar:ObjectType2{}; + barBaz:ObjectType2{}; + + link inconsistentLeft fooBar,foo -> barBaz; + +} + diff --git a/src/test/resources/cocos/InconsistentRightLinkEndConsistency.od b/src/test/resources/cocos/InconsistentRightLinkEndConsistency.od new file mode 100644 index 00000000..5a6cff00 --- /dev/null +++ b/src/test/resources/cocos/InconsistentRightLinkEndConsistency.od @@ -0,0 +1,16 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InconsistentRightLinkEndConsistency { + + foo:ObjectType{}; + bar:ObjectType{}; + fooBar:ObjectType2{}; + + link inconsistentRight foo -> bar,fooBar; + +} + diff --git a/src/test/resources/cocos/InvalidAbstractAttribute.od b/src/test/resources/cocos/InvalidAbstractAttribute.od new file mode 100644 index 00000000..c11b10ec --- /dev/null +++ b/src/test/resources/cocos/InvalidAbstractAttribute.od @@ -0,0 +1,14 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidAbstractAttribute { + + foo:ObjectType{ + abstract foobar = 1; + }; + +} + diff --git a/src/test/resources/cocos/InvalidAbstractLeftLink.od b/src/test/resources/cocos/InvalidAbstractLeftLink.od new file mode 100644 index 00000000..35b9f757 --- /dev/null +++ b/src/test/resources/cocos/InvalidAbstractLeftLink.od @@ -0,0 +1,16 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidAbstractLeftLink { + + foo:ObjectType{}; + bar:ObjectType{}; + fooBar:ObjectType2{}; + + link abstract foo -> fooBar; + +} + diff --git a/src/test/resources/cocos/InvalidAbstractRightLink.od b/src/test/resources/cocos/InvalidAbstractRightLink.od new file mode 100644 index 00000000..e0b663f3 --- /dev/null +++ b/src/test/resources/cocos/InvalidAbstractRightLink.od @@ -0,0 +1,16 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidAbstractRightLink { + + foo:ObjectType{}; + bar:ObjectType{}; + fooBar:ObjectType2{}; + + link foo -> fooBar abstract; + +} + diff --git a/src/test/resources/cocos/InvalidDuplicateAttributeNames.od b/src/test/resources/cocos/InvalidDuplicateAttributeNames.od new file mode 100644 index 00000000..d1a9e973 --- /dev/null +++ b/src/test/resources/cocos/InvalidDuplicateAttributeNames.od @@ -0,0 +1,15 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidDuplicateAttributeNames { + + foo:ObjectType{ + foobar = foo; + foobar = bar; + }; + +} + diff --git a/src/test/resources/cocos/InvalidLeftLinkReference.od b/src/test/resources/cocos/InvalidLeftLinkReference.od new file mode 100644 index 00000000..76ceb9cc --- /dev/null +++ b/src/test/resources/cocos/InvalidLeftLinkReference.od @@ -0,0 +1,15 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidLeftLinkReference { + + foo:ObjectType{}; + bar:ObjectType{}; + + link missingLeft -> bar; + +} + diff --git a/src/test/resources/cocos/InvalidObjectAttributes.od b/src/test/resources/cocos/InvalidObjectAttributes.od new file mode 100644 index 00000000..7e98a343 --- /dev/null +++ b/src/test/resources/cocos/InvalidObjectAttributes.od @@ -0,0 +1,14 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidObjectAttributes { + + foo:ObjectType{ + undefinedField = 1; + }; + +} + diff --git a/src/test/resources/cocos/InvalidObjectType.od b/src/test/resources/cocos/InvalidObjectType.od new file mode 100644 index 00000000..ac361a8c --- /dev/null +++ b/src/test/resources/cocos/InvalidObjectType.od @@ -0,0 +1,12 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidObjectType { + + foo:UndefinedType{}; + +} + diff --git a/src/test/resources/cocos/InvalidPartialAndCompleteAttributes.od b/src/test/resources/cocos/InvalidPartialAndCompleteAttributes.od new file mode 100644 index 00000000..b9a4b01b --- /dev/null +++ b/src/test/resources/cocos/InvalidPartialAndCompleteAttributes.od @@ -0,0 +1,15 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidPartialAndCompleteAttributes { + + bar:ObjectType{ + foobar -> foo; + foobar = bla; + }; + +} + diff --git a/src/test/resources/cocos/InvalidRightLinkReference.od b/src/test/resources/cocos/InvalidRightLinkReference.od new file mode 100644 index 00000000..56262433 --- /dev/null +++ b/src/test/resources/cocos/InvalidRightLinkReference.od @@ -0,0 +1,15 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidRightLinkReference { + + foo:ObjectType{}; + bar:ObjectType{}; + + link foo -> missingRight,bar; + +} + diff --git a/src/test/resources/cocos/InvalidSingleObjectReference.od b/src/test/resources/cocos/InvalidSingleObjectReference.od new file mode 100644 index 00000000..21cbbd2e --- /dev/null +++ b/src/test/resources/cocos/InvalidSingleObjectReference.od @@ -0,0 +1,16 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram InvalidObjectReference { + + foo:ObjectType{}; + + bar:ObjectType{ + foobar = undefinedObject; + }; + +} + diff --git a/src/test/resources/cocos/UnresolvedRightLinkEndConsistency.od b/src/test/resources/cocos/UnresolvedRightLinkEndConsistency.od new file mode 100644 index 00000000..88ba31a6 --- /dev/null +++ b/src/test/resources/cocos/UnresolvedRightLinkEndConsistency.od @@ -0,0 +1,15 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram UnresolvedRightLinkEndConsistency { + + foo:ObjectType{}; + bar:ObjectType{}; + + link brokenLink foo -> missingObject,bar; + +} + diff --git a/src/test/resources/cocos/ValidLinkEndConsistency.od b/src/test/resources/cocos/ValidLinkEndConsistency.od new file mode 100644 index 00000000..e206c72d --- /dev/null +++ b/src/test/resources/cocos/ValidLinkEndConsistency.od @@ -0,0 +1,17 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidLinkEndConsistency { + + foo:ObjectType{}; + bar:ObjectType{}; + fooBar:ObjectType2{}; + barBaz:ObjectType2{}; + + link firstLink foo,bar -> fooBar,barBaz; + +} + diff --git a/src/test/resources/cocos/ValidLinkReference.od b/src/test/resources/cocos/ValidLinkReference.od new file mode 100644 index 00000000..84a4d54c --- /dev/null +++ b/src/test/resources/cocos/ValidLinkReference.od @@ -0,0 +1,16 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidLinkReference { + + foo:ObjectType{}; + bar:ObjectType{}; + fooBar:ObjectType2{}; + + link foo,bar -> fooBar; + +} + diff --git a/src/test/resources/cocos/ValidNonAbstractAttribute.od b/src/test/resources/cocos/ValidNonAbstractAttribute.od new file mode 100644 index 00000000..d2f80e41 --- /dev/null +++ b/src/test/resources/cocos/ValidNonAbstractAttribute.od @@ -0,0 +1,14 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidNonAbstractAttribute { + + foo:ObjectType{ + foobar = 1; + }; + +} + diff --git a/src/test/resources/cocos/ValidNonAbstractLink.od b/src/test/resources/cocos/ValidNonAbstractLink.od new file mode 100644 index 00000000..a4795307 --- /dev/null +++ b/src/test/resources/cocos/ValidNonAbstractLink.od @@ -0,0 +1,16 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidNonAbstractLink { + + foo:ObjectType{}; + bar:ObjectType{}; + fooBar:ObjectType2{}; + + link foo -> fooBar; + +} + diff --git a/src/test/resources/cocos/ValidObjectAttributes.od b/src/test/resources/cocos/ValidObjectAttributes.od new file mode 100644 index 00000000..c36ed44e --- /dev/null +++ b/src/test/resources/cocos/ValidObjectAttributes.od @@ -0,0 +1,14 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidObjectAttributes { + + foo:ObjectType{ + foobar = 1; + }; + +} + diff --git a/src/test/resources/cocos/ValidObjectReference.od b/src/test/resources/cocos/ValidObjectReference.od new file mode 100644 index 00000000..a4daeff3 --- /dev/null +++ b/src/test/resources/cocos/ValidObjectReference.od @@ -0,0 +1,16 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidObjectReference { + + foo:ObjectType{}; + + bar:ObjectType{ + foobar = foo; + }; + +} + diff --git a/src/test/resources/cocos/ValidObjectType.od b/src/test/resources/cocos/ValidObjectType.od new file mode 100644 index 00000000..98a0b19e --- /dev/null +++ b/src/test/resources/cocos/ValidObjectType.od @@ -0,0 +1,13 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidObjectType { + + foo:ObjectType{}; + bar:ObjectType{}; + +} + diff --git a/src/test/resources/cocos/ValidPartialAndCompleteAttributes.od b/src/test/resources/cocos/ValidPartialAndCompleteAttributes.od new file mode 100644 index 00000000..fad954f0 --- /dev/null +++ b/src/test/resources/cocos/ValidPartialAndCompleteAttributes.od @@ -0,0 +1,15 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidPartialAndCompleteAttributes { + + bar:ObjectType{ + foobar -> foo; + foobar -> bla; + }; + +} + diff --git a/src/test/resources/cocos/ValidUniqueAttributeNames.od b/src/test/resources/cocos/ValidUniqueAttributeNames.od new file mode 100644 index 00000000..ea5d2b6e --- /dev/null +++ b/src/test/resources/cocos/ValidUniqueAttributeNames.od @@ -0,0 +1,15 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package cocos; + +import examples.cd.SimpleOD.*; + +objectdiagram ValidUniqueAttributeNames { + + foo:ObjectType{ + foobar = foo; + foobaz -> bar; + }; + +} + diff --git a/src/test/resources/examples/cd/ArtifactKindModel.cdsym b/src/test/resources/examples/cd/ArtifactKindModel.cdsym index d9d063b0..9dc997b1 100644 --- a/src/test/resources/examples/cd/ArtifactKindModel.cdsym +++ b/src/test/resources/examples/cd/ArtifactKindModel.cdsym @@ -1,849 +1,857 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "ArtifactKindModel", - "symbols": [ - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "belongsTo", - "association": 643587433 - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "subPackage", - "association": 2065886345 - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "contain", - "association": 573102881 - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "ArtifactKindModel", + "symbols": [ + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "belongsTo", + "association": 1296928719 + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "subPackage", + "association": 1290614253 + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "contain", + "association": 2077662850 + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Artifact", + "fullName": "ArtifactKindModel.Artifact", + "packageName": "ArtifactKindModel", + "isClass": true, + "isAbstract": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Artifact", - "fullName": "ArtifactKindModel.Artifact", - "packageName": "ArtifactKindModel", - "isClass": true, - "isAbstract": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Artifact", - "fullName": "Artifact", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Artifact" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "artifact", - "fullName": "ArtifactKindModel.Artifact.artifact", - "packageName": "ArtifactKindModel", - "cardinality": "[*]", - "association": 1710228600, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Artifact" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "refersTo", - "fullName": "ArtifactKindModel.Artifact.refersTo", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1710228600, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Artifact" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "parent", - "fullName": "ArtifactKindModel.Artifact.parent", - "packageName": "ArtifactKindModel", - "cardinality": "[0..1]", - "association": 606365803, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.ArtifactContainer" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "simpleName", - "fullName": "ArtifactKindModel.Artifact.simpleName", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "nameExtension", - "fullName": "ArtifactKindModel.Artifact.nameExtension", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "name", - "fullName": "ArtifactKindModel.Artifact.name", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "fullName", - "fullName": "ArtifactKindModel.Artifact.fullName", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "modified", - "fullName": "ArtifactKindModel.Artifact.modified", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.util.Date" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "isRoot", - "fullName": "ArtifactKindModel.Artifact.isRoot", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - } - } - ] - } - }, + "fullName": "Artifact", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Artifact" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "artifact", + "fullName": "ArtifactKindModel.Artifact.artifact", + "packageName": "ArtifactKindModel", + "cardinality": "[*]", + "association": 1090695601, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Artifact" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "refersTo", + "fullName": "ArtifactKindModel.Artifact.refersTo", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1090695601, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Artifact" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "parent", + "fullName": "ArtifactKindModel.Artifact.parent", + "packageName": "ArtifactKindModel", + "cardinality": "[0..1]", + "association": 1638249646, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.ArtifactContainer" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "simpleName", + "fullName": "ArtifactKindModel.Artifact.simpleName", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "nameExtension", + "fullName": "ArtifactKindModel.Artifact.nameExtension", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "name", + "fullName": "ArtifactKindModel.Artifact.name", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "fullName", + "fullName": "ArtifactKindModel.Artifact.fullName", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "modified", + "fullName": "ArtifactKindModel.Artifact.modified", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.util.Date" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "isRoot", + "fullName": "ArtifactKindModel.Artifact.isRoot", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ArtifactContainer", + "fullName": "ArtifactKindModel.ArtifactContainer", + "packageName": "ArtifactKindModel", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Artifact" + } + ], + "isClass": true, + "isAbstract": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "ArtifactContainer", - "fullName": "ArtifactKindModel.ArtifactContainer", + "fullName": "ArtifactContainer", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.ArtifactContainer" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "contains", + "fullName": "ArtifactKindModel.ArtifactContainer.contains", "packageName": "ArtifactKindModel", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Artifact" - } - ], - "isClass": true, - "isAbstract": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ArtifactContainer", - "fullName": "ArtifactContainer", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.ArtifactContainer" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "contains", - "fullName": "ArtifactKindModel.ArtifactContainer.contains", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 606365803, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Artifact" - } - } - ] - } - }, + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1638249646, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Artifact" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Directory", + "fullName": "ArtifactKindModel.Directory", + "packageName": "ArtifactKindModel", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.ArtifactContainer" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Directory", - "fullName": "ArtifactKindModel.Directory", - "packageName": "ArtifactKindModel", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.ArtifactContainer" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Directory", - "fullName": "Directory", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Directory" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] - } - }, + "fullName": "Directory", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Directory" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "JavaArchive", + "fullName": "ArtifactKindModel.JavaArchive", + "packageName": "ArtifactKindModel", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.ArtifactContainer" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "JavaArchive", - "fullName": "ArtifactKindModel.JavaArchive", - "packageName": "ArtifactKindModel", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.ArtifactContainer" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "JavaArchive", - "fullName": "JavaArchive", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArchive" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] - } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "fullName": "JavaArchive", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArchive" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "JavaArtifact", + "fullName": "ArtifactKindModel.JavaArtifact", + "packageName": "ArtifactKindModel", + "isClass": true, + "isAbstract": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "JavaArtifact", - "fullName": "ArtifactKindModel.JavaArtifact", - "packageName": "ArtifactKindModel", - "isClass": true, - "isAbstract": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "JavaArtifact", - "fullName": "JavaArtifact", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "javaArtifact", - "fullName": "ArtifactKindModel.JavaArtifact.javaArtifact", - "packageName": "ArtifactKindModel", - "cardinality": "[*]", - "association": 8197402, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "refersTo", - "fullName": "ArtifactKindModel.JavaArtifact.refersTo", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 8197402, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "reliesOnJavaArtifact", - "fullName": "ArtifactKindModel.JavaArtifact.reliesOnJavaArtifact", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 692838068, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "javaSourceFile", - "fullName": "ArtifactKindModel.JavaArtifact.javaSourceFile", - "packageName": "ArtifactKindModel", - "cardinality": "[*]", - "association": 1392570698, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaSourceFile" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "definedType", - "fullName": "ArtifactKindModel.JavaArtifact.definedType", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 528877978, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaType" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "simpleName", - "fullName": "ArtifactKindModel.JavaArtifact.simpleName", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "nameExtension", - "fullName": "ArtifactKindModel.JavaArtifact.nameExtension", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "name", - "fullName": "ArtifactKindModel.JavaArtifact.name", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "fullName", - "fullName": "ArtifactKindModel.JavaArtifact.fullName", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "modified", - "fullName": "ArtifactKindModel.JavaArtifact.modified", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.util.Date" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "isRoot", - "fullName": "ArtifactKindModel.JavaArtifact.isRoot", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - } - } - ] - } - }, + "fullName": "JavaArtifact", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "javaArtifact", + "fullName": "ArtifactKindModel.JavaArtifact.javaArtifact", + "packageName": "ArtifactKindModel", + "cardinality": "[*]", + "association": 2123269713, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "refersTo", + "fullName": "ArtifactKindModel.JavaArtifact.refersTo", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 2123269713, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "reliesOnJavaArtifact", + "fullName": "ArtifactKindModel.JavaArtifact.reliesOnJavaArtifact", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1240412896, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "javaSourceFile", + "fullName": "ArtifactKindModel.JavaArtifact.javaSourceFile", + "packageName": "ArtifactKindModel", + "cardinality": "[*]", + "association": 656349395, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaSourceFile" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "definedType", + "fullName": "ArtifactKindModel.JavaArtifact.definedType", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1809129176, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaType" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "simpleName", + "fullName": "ArtifactKindModel.JavaArtifact.simpleName", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "nameExtension", + "fullName": "ArtifactKindModel.JavaArtifact.nameExtension", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "name", + "fullName": "ArtifactKindModel.JavaArtifact.name", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "fullName", + "fullName": "ArtifactKindModel.JavaArtifact.fullName", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "modified", + "fullName": "ArtifactKindModel.JavaArtifact.modified", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.util.Date" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "isRoot", + "fullName": "ArtifactKindModel.JavaArtifact.isRoot", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "JavaSourceFile", + "fullName": "ArtifactKindModel.JavaSourceFile", + "packageName": "ArtifactKindModel", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "JavaSourceFile", - "fullName": "ArtifactKindModel.JavaSourceFile", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "compile", + "fullName": "ArtifactKindModel.JavaSourceFile.compile", "packageName": "ArtifactKindModel", - "superTypes": [ + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "Set", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaClassFile" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "compile", - "fullName": "ArtifactKindModel.JavaSourceFile.compile", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "Set", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaClassFile" - } - ] - }, - "isMethod": true - }, - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "JavaSourceFile", - "fullName": "JavaSourceFile", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaSourceFile" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "imports", - "fullName": "ArtifactKindModel.JavaSourceFile.imports", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1392570698, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "compiledTo", - "fullName": "ArtifactKindModel.JavaSourceFile.compiledTo", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 15910024, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaClassFile" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "produces", - "fullName": "ArtifactKindModel.JavaSourceFile.produces", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1420623741, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "belongsTo", - "fullName": "ArtifactKindModel.JavaSourceFile.belongsTo", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[1]", - "association": 643587433, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Package" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "isPresentSyntaxError", - "fullName": "ArtifactKindModel.JavaSourceFile.isPresentSyntaxError", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - } - } - ] - } - }, + ] + }, + "isMethod": true + }, + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "JavaSourceFile", + "fullName": "JavaSourceFile", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaSourceFile" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "imports", + "fullName": "ArtifactKindModel.JavaSourceFile.imports", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 656349395, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "compiledTo", + "fullName": "ArtifactKindModel.JavaSourceFile.compiledTo", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1370224403, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaClassFile" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "produces", + "fullName": "ArtifactKindModel.JavaSourceFile.produces", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 246264949, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "belongsTo", + "fullName": "ArtifactKindModel.JavaSourceFile.belongsTo", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[1]", + "association": 1296928719, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Package" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "isPresentSyntaxError", + "fullName": "ArtifactKindModel.JavaSourceFile.isPresentSyntaxError", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "JavaClassFile", + "fullName": "ArtifactKindModel.JavaClassFile", + "packageName": "ArtifactKindModel", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "JavaClassFile", - "fullName": "ArtifactKindModel.JavaClassFile", + "fullName": "JavaClassFile", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaClassFile" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "javaSourceFile", + "fullName": "ArtifactKindModel.JavaClassFile.javaSourceFile", "packageName": "ArtifactKindModel", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "JavaClassFile", - "fullName": "JavaClassFile", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaClassFile" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "javaSourceFile", - "fullName": "ArtifactKindModel.JavaClassFile.javaSourceFile", - "packageName": "ArtifactKindModel", - "cardinality": "[1]", - "association": 15910024, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaSourceFile" - } - } - ] - } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "cardinality": "[1]", + "association": 1370224403, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaSourceFile" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Package", + "fullName": "ArtifactKindModel.Package", + "packageName": "ArtifactKindModel", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Package", - "fullName": "ArtifactKindModel.Package", - "packageName": "ArtifactKindModel", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Package", - "fullName": "Package", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Package" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "javaSourceFile", - "fullName": "ArtifactKindModel.Package.javaSourceFile", - "packageName": "ArtifactKindModel", - "cardinality": "[*]", - "association": 643587433, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaSourceFile" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "parent", - "fullName": "ArtifactKindModel.Package.parent", - "packageName": "ArtifactKindModel", - "cardinality": "[0..1]", - "association": 2065886345, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Package" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "child", - "fullName": "ArtifactKindModel.Package.child", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 2065886345, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Package" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "javaType", - "fullName": "ArtifactKindModel.Package.javaType", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 573102881, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaType" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "name", - "fullName": "ArtifactKindModel.Package.name", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "fullName", - "fullName": "ArtifactKindModel.Package.fullName", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "isRoot", - "fullName": "ArtifactKindModel.Package.isRoot", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - } - } - ] - } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "fullName": "Package", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Package" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "javaSourceFile", + "fullName": "ArtifactKindModel.Package.javaSourceFile", + "packageName": "ArtifactKindModel", + "cardinality": "[*]", + "association": 1296928719, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaSourceFile" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "parent", + "fullName": "ArtifactKindModel.Package.parent", + "packageName": "ArtifactKindModel", + "cardinality": "[0..1]", + "association": 1290614253, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Package" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "child", + "fullName": "ArtifactKindModel.Package.child", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1290614253, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Package" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "javaType", + "fullName": "ArtifactKindModel.Package.javaType", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 2077662850, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaType" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "name", + "fullName": "ArtifactKindModel.Package.name", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "fullName", + "fullName": "ArtifactKindModel.Package.fullName", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "isRoot", + "fullName": "ArtifactKindModel.Package.isRoot", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "JavaType", + "fullName": "ArtifactKindModel.JavaType", + "packageName": "ArtifactKindModel", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "JavaType", - "fullName": "ArtifactKindModel.JavaType", - "packageName": "ArtifactKindModel", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "JavaType", - "fullName": "JavaType", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaType" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "javaArtifact", - "fullName": "ArtifactKindModel.JavaType.javaArtifact", - "packageName": "ArtifactKindModel", - "cardinality": "[1..*]", - "association": 528877978, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaArtifact" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "typePackage", - "fullName": "ArtifactKindModel.JavaType.typePackage", - "packageName": "ArtifactKindModel", - "cardinality": "[1]", - "association": 573102881, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.Package" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "containingType", - "fullName": "ArtifactKindModel.JavaType.containingType", - "packageName": "ArtifactKindModel", - "cardinality": "[0..1]", - "association": 1898751355, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaType" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "innerType", - "fullName": "ArtifactKindModel.JavaType.innerType", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1898751355, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaType" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "javaType", - "fullName": "ArtifactKindModel.JavaType.javaType", - "packageName": "ArtifactKindModel", - "cardinality": "[*]", - "association": 1164241227, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaType" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "reliesOn", - "fullName": "ArtifactKindModel.JavaType.reliesOn", - "packageName": "ArtifactKindModel", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1164241227, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "ArtifactKindModel.JavaType" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "simpleName", - "fullName": "ArtifactKindModel.JavaType.simpleName", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "name", - "fullName": "ArtifactKindModel.JavaType.name", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "fullName", - "fullName": "ArtifactKindModel.JavaType.fullName", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "isInnerType", - "fullName": "ArtifactKindModel.JavaType.isInnerType", - "packageName": "ArtifactKindModel", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - } - } - ] - } - }, - { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "ArtifactKindModel", - "fullName": "ArtifactKindModel" - } - ], - "furtherObjects": { - "8197402": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "1710228600": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "573102881": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - }, - "1392570698": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "2065886345": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - }, - "606365803": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - }, - "1164241227": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "1420623741": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "643587433": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "1898751355": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - }, - "15910024": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "528877978": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "692838068": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - } + "fullName": "JavaType", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaType" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "javaArtifact", + "fullName": "ArtifactKindModel.JavaType.javaArtifact", + "packageName": "ArtifactKindModel", + "cardinality": "[1..*]", + "association": 1809129176, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaArtifact" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "typePackage", + "fullName": "ArtifactKindModel.JavaType.typePackage", + "packageName": "ArtifactKindModel", + "cardinality": "[1]", + "association": 2077662850, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.Package" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "containingType", + "fullName": "ArtifactKindModel.JavaType.containingType", + "packageName": "ArtifactKindModel", + "cardinality": "[0..1]", + "association": 1554877309, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaType" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "innerType", + "fullName": "ArtifactKindModel.JavaType.innerType", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1554877309, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaType" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "javaType", + "fullName": "ArtifactKindModel.JavaType.javaType", + "packageName": "ArtifactKindModel", + "cardinality": "[*]", + "association": 2063786038, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaType" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "reliesOn", + "fullName": "ArtifactKindModel.JavaType.reliesOn", + "packageName": "ArtifactKindModel", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 2063786038, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "ArtifactKindModel.JavaType" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "simpleName", + "fullName": "ArtifactKindModel.JavaType.simpleName", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "name", + "fullName": "ArtifactKindModel.JavaType.name", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "fullName", + "fullName": "ArtifactKindModel.JavaType.fullName", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "isInnerType", + "fullName": "ArtifactKindModel.JavaType.isInnerType", + "packageName": "ArtifactKindModel", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + } + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "ArtifactKindModel", + "fullName": "ArtifactKindModel" + } + ], + "furtherObjects": { + "1296928719": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "1290614253": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true + }, + "2077662850": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true + }, + "1090695601": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "1638249646": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true + }, + "2123269713": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "1240412896": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "656349395": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "1809129176": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "1370224403": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "246264949": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "1554877309": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true + }, + "2063786038": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/Associations.cdsym b/src/test/resources/examples/cd/Associations.cdsym index e7d1ad7f..2d9f882d 100644 --- a/src/test/resources/examples/cd/Associations.cdsym +++ b/src/test/resources/examples/cd/Associations.cdsym @@ -1,515 +1,523 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "Associations", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "Associations", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "OuterType", + "fullName": "examples.cd.Associations.OuterType", + "packageName": "examples.cd.Associations", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "OuterType", - "fullName": "examples.cd.Associations.OuterType", + "fullName": "OuterType", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.OuterType" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "linkToAnObject", + "fullName": "examples.cd.Associations.OuterType.linkToAnObject", "packageName": "examples.cd.Associations", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "OuterType", - "fullName": "OuterType", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.OuterType" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "linkToAnObject", - "fullName": "examples.cd.Associations.OuterType.linkToAnObject", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.ObjectType" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "linkList", - "fullName": "examples.cd.Associations.OuterType.linkList", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.Type" - } - ] - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.ObjectType" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "ObjectType", - "fullName": "examples.cd.Associations.ObjectType", - "packageName": "examples.cd.Associations", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType", - "fullName": "ObjectType", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.ObjectType" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] - } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "OtherObjectType", - "fullName": "examples.cd.Associations.OtherObjectType", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "linkList", + "fullName": "examples.cd.Associations.OuterType.linkList", "packageName": "examples.cd.Associations", - "superTypes": [ + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.ObjectType" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.Type" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "OtherObjectType", - "fullName": "OtherObjectType", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.OtherObjectType" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + ] } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType", + "fullName": "examples.cd.Associations.ObjectType", + "packageName": "examples.cd.Associations", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "ObjectType", + "fullName": "ObjectType", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.ObjectType" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "OtherObjectType", + "fullName": "examples.cd.Associations.OtherObjectType", + "packageName": "examples.cd.Associations", + "superTypes": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.ObjectType" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "OtherObjectType", + "fullName": "OtherObjectType", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.OtherObjectType" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "InnerObjectType", + "fullName": "examples.cd.Associations.InnerObjectType", + "packageName": "examples.cd.Associations", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.ObjectType" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "InnerObjectType", - "fullName": "examples.cd.Associations.InnerObjectType", + "fullName": "InnerObjectType", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.InnerObjectType" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "someInt", + "fullName": "examples.cd.Associations.InnerObjectType.someInt", "packageName": "examples.cd.Associations", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.ObjectType" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "InnerObjectType", - "fullName": "InnerObjectType", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.InnerObjectType" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "someInt", - "fullName": "examples.cd.Associations.InnerObjectType.someInt", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "someBool", - "fullName": "examples.cd.Associations.InnerObjectType.someBool", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "someString", - "fullName": "examples.cd.Associations.InnerObjectType.someString", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "TypeOfObject", - "fullName": "examples.cd.Associations.TypeOfObject", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "someBool", + "fullName": "examples.cd.Associations.InnerObjectType.someBool", "packageName": "examples.cd.Associations", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "TypeOfObject", - "fullName": "TypeOfObject", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.TypeOfObject" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "innerLink", - "fullName": "examples.cd.Associations.TypeOfObject.innerLink", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.ObjectType" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "innerLink2", - "fullName": "examples.cd.Associations.TypeOfObject.innerLink2", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.TypeOfAnonymousObject" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "linkList1", - "fullName": "examples.cd.Associations.TypeOfObject.linkList1", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T" - } - ] - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "TypeOfAnonymousObject", - "fullName": "examples.cd.Associations.TypeOfAnonymousObject", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "someString", + "fullName": "examples.cd.Associations.InnerObjectType.someString", "packageName": "examples.cd.Associations", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "TypeOfAnonymousObject", - "fullName": "TypeOfAnonymousObject", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.TypeOfAnonymousObject" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "name", - "fullName": "examples.cd.Associations.TypeOfAnonymousObject.name", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "Type", - "fullName": "examples.cd.Associations.Type", + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "TypeOfObject", + "fullName": "examples.cd.Associations.TypeOfObject", + "packageName": "examples.cd.Associations", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "TypeOfObject", + "fullName": "TypeOfObject", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.TypeOfObject" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "innerLink", + "fullName": "examples.cd.Associations.TypeOfObject.innerLink", "packageName": "examples.cd.Associations", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Type", - "fullName": "Type", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.Type" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.ObjectType" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "TypeOne", - "fullName": "examples.cd.Associations.TypeOne", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "innerLink2", + "fullName": "examples.cd.Associations.TypeOfObject.innerLink2", "packageName": "examples.cd.Associations", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.Type" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "TypeOne", - "fullName": "TypeOne", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.TypeOne" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.TypeOfAnonymousObject" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "TypeTwo", - "fullName": "examples.cd.Associations.TypeTwo", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "linkList1", + "fullName": "examples.cd.Associations.TypeOfObject.linkList1", "packageName": "examples.cd.Associations", - "superTypes": [ + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.Type" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "TypeTwo", - "fullName": "TypeTwo", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.TypeTwo" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + ] } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "TypeThree", - "fullName": "examples.cd.Associations.TypeThree", + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "TypeOfAnonymousObject", + "fullName": "examples.cd.Associations.TypeOfAnonymousObject", + "packageName": "examples.cd.Associations", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "TypeOfAnonymousObject", + "fullName": "TypeOfAnonymousObject", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.TypeOfAnonymousObject" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "name", + "fullName": "examples.cd.Associations.TypeOfAnonymousObject.name", "packageName": "examples.cd.Associations", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.Type" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "TypeThree", - "fullName": "TypeThree", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.TypeThree" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "content", - "fullName": "examples.cd.Associations.TypeThree.content", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Type", + "fullName": "examples.cd.Associations.Type", + "packageName": "examples.cd.Associations", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "Type", + "fullName": "Type", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.Type" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "TypeOne", + "fullName": "examples.cd.Associations.TypeOne", + "packageName": "examples.cd.Associations", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "T", - "fullName": "examples.cd.Associations.T", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.Type" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "TypeOne", + "fullName": "TypeOne", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.TypeOne" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "TypeTwo", + "fullName": "examples.cd.Associations.TypeTwo", + "packageName": "examples.cd.Associations", + "superTypes": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.Type" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "TypeTwo", + "fullName": "TypeTwo", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.TypeTwo" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "TypeThree", + "fullName": "examples.cd.Associations.TypeThree", + "packageName": "examples.cd.Associations", + "superTypes": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.Type" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "TypeThree", + "fullName": "TypeThree", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.TypeThree" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "content", + "fullName": "examples.cd.Associations.TypeThree.content", "packageName": "examples.cd.Associations", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T", - "fullName": "T", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T", + "fullName": "examples.cd.Associations.T", + "packageName": "examples.cd.Associations", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "T", + "fullName": "T", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T1", + "fullName": "examples.cd.Associations.T1", + "packageName": "examples.cd.Associations", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "T1", - "fullName": "examples.cd.Associations.T1", - "packageName": "examples.cd.Associations", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T1", - "fullName": "T1", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T1" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] - } - }, + "fullName": "T1", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T1" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T2", + "fullName": "examples.cd.Associations.T2", + "packageName": "examples.cd.Associations", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "T2", - "fullName": "examples.cd.Associations.T2", + "fullName": "T2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T2" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "foo", + "fullName": "examples.cd.Associations.T2.foo", "packageName": "examples.cd.Associations", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T2", - "fullName": "T2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T2" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "foo", - "fullName": "examples.cd.Associations.T2.foo", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T3" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T3" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T3", + "fullName": "examples.cd.Associations.T3", + "packageName": "examples.cd.Associations", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "T3", - "fullName": "examples.cd.Associations.T3", + "fullName": "T3", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Associations.T3" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "content", + "fullName": "examples.cd.Associations.T3.content", "packageName": "examples.cd.Associations", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T3", - "fullName": "T3", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Associations.T3" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "content", - "fullName": "examples.cd.Associations.T3.content", - "packageName": "examples.cd.Associations", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" } - }, - { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "Associations", - "fullName": "examples.cd.Associations", - "packageName": "examples.cd" - } - ] + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "Associations", + "fullName": "examples.cd.Associations", + "packageName": "examples.cd" + } + ], + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/Auction.cdsym b/src/test/resources/examples/cd/Auction.cdsym index a2ab3c2f..3887e88e 100644 --- a/src/test/resources/examples/cd/Auction.cdsym +++ b/src/test/resources/examples/cd/Auction.cdsym @@ -1,366 +1,374 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "Auction", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "participants", - "association": 1894698434 - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "Auction", - "fullName": "examples.cd.Auction.Auction", + "generated-using": "www.MontiCore.de technology", + "name": "Auction", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "participants", + "association": 100445376 + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Auction", + "fullName": "examples.cd.Auction.Auction", + "packageName": "examples.cd.Auction", + "isClass": true, + "isAbstract": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "getNumberOfBids", + "fullName": "examples.cd.Auction.Auction.getNumberOfBids", + "packageName": "examples.cd.Auction", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + }, + "isMethod": true, + "isPublic": true + }, + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "bid", + "fullName": "examples.cd.Auction.Auction.bid", "packageName": "examples.cd.Auction", - "isClass": true, - "isAbstract": true, + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + }, + "isMethod": true, + "isPublic": true, "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "getNumberOfBids", - "fullName": "examples.cd.Auction.Auction.getNumberOfBids", - "packageName": "examples.cd.Auction", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - }, - "isMethod": true, - "isPublic": true - }, - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "bid", - "fullName": "examples.cd.Auction.Auction.bid", - "packageName": "examples.cd.Auction", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - }, - "isMethod": true, - "isPublic": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "p", - "fullName": "examples.cd.Auction.Auction.bid.p", - "packageName": "examples.cd.Auction", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Person" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "t", - "fullName": "examples.cd.Auction.Auction.bid.t", - "packageName": "examples.cd.Auction", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.util.Date" - } - } - ] - } - }, - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Auction", - "fullName": "Auction", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Auction" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "biddingPolicy", - "fullName": "examples.cd.Auction.Auction.biddingPolicy", - "packageName": "examples.cd.Auction", - "isDefinitiveNavigable": true, - "cardinality": "[1]", - "association": 1288052401, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.BiddingPolicy" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "timingPolicy", - "fullName": "examples.cd.Auction.Auction.timingPolicy", - "packageName": "examples.cd.Auction", - "isDefinitiveNavigable": true, - "cardinality": "[1]", - "association": 764358458, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.TimingPolicy" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "bidder", - "fullName": "examples.cd.Auction.Auction.bidder", - "packageName": "examples.cd.Auction", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1894698434, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Person" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "message", - "fullName": "examples.cd.Auction.Auction.message", - "packageName": "examples.cd.Auction", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 539240764, - "isOrdered": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Message" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "auctionIdent", - "fullName": "examples.cd.Auction.Auction.auctionIdent", - "packageName": "examples.cd.Auction", - "isPublic": true, - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "long" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "title", - "fullName": "examples.cd.Auction.Auction.title", - "packageName": "examples.cd.Auction", - "isProtected": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + "symbols": [ + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "p", + "fullName": "examples.cd.Auction.Auction.bid.p", + "packageName": "examples.cd.Auction", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Person" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "t", + "fullName": "examples.cd.Auction.Auction.bid.t", + "packageName": "examples.cd.Auction", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.util.Date" + } + } + ] } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "BiddingPolicy", - "fullName": "examples.cd.Auction.BiddingPolicy", + }, + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "Auction", + "fullName": "Auction", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Auction" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "biddingPolicy", + "fullName": "examples.cd.Auction.Auction.biddingPolicy", "packageName": "examples.cd.Auction", - "isInterface": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "auction", - "fullName": "examples.cd.Auction.BiddingPolicy.auction", - "packageName": "examples.cd.Auction", - "isDefinitiveNavigable": true, - "association": 1288052401, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Auction" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[1]", + "association": 1562764987, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.BiddingPolicy" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "TimingPolicy", - "fullName": "examples.cd.Auction.TimingPolicy", + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "timingPolicy", + "fullName": "examples.cd.Auction.Auction.timingPolicy", "packageName": "examples.cd.Auction", - "isInterface": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "auction", - "fullName": "examples.cd.Auction.TimingPolicy.auction", - "packageName": "examples.cd.Auction", - "association": 764358458, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Auction" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[1]", + "association": 216376974, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.TimingPolicy" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "bidder", + "fullName": "examples.cd.Auction.Auction.bidder", + "packageName": "examples.cd.Auction", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 100445376, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Person" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "message", + "fullName": "examples.cd.Auction.Auction.message", + "packageName": "examples.cd.Auction", + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 164714495, + "isOrdered": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Message" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "auctionIdent", + "fullName": "examples.cd.Auction.Auction.auctionIdent", + "packageName": "examples.cd.Auction", + "isPublic": true, + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "long" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "title", + "fullName": "examples.cd.Auction.Auction.title", + "packageName": "examples.cd.Auction", + "isProtected": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "BiddingPolicy", + "fullName": "examples.cd.Auction.BiddingPolicy", + "packageName": "examples.cd.Auction", + "isInterface": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "auction", + "fullName": "examples.cd.Auction.BiddingPolicy.auction", + "packageName": "examples.cd.Auction", + "isDefinitiveNavigable": true, + "association": 1562764987, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Auction" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "TimingPolicy", + "fullName": "examples.cd.Auction.TimingPolicy", + "packageName": "examples.cd.Auction", + "isInterface": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "auction", + "fullName": "examples.cd.Auction.TimingPolicy.auction", + "packageName": "examples.cd.Auction", + "association": 216376974, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Auction" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Person", + "fullName": "examples.cd.Auction.Person", + "packageName": "examples.cd.Auction", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Person", - "fullName": "examples.cd.Auction.Person", + "fullName": "Person", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Person" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "auctions", + "fullName": "examples.cd.Auction.Person.auctions", "packageName": "examples.cd.Auction", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Person", - "fullName": "Person", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Person" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "auctions", - "fullName": "examples.cd.Auction.Person.auctions", - "packageName": "examples.cd.Auction", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1894698434, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Auction" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "message", - "fullName": "examples.cd.Auction.Person.message", - "packageName": "examples.cd.Auction", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1487230025, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Message" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "name", - "fullName": "examples.cd.Auction.Person.name", - "packageName": "examples.cd.Auction", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 100445376, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Auction" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "Message", - "fullName": "examples.cd.Auction.Message", + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "message", + "fullName": "examples.cd.Auction.Person.message", "packageName": "examples.cd.Auction", - "isClass": true, + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 2080643905, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Message" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "name", + "fullName": "examples.cd.Auction.Person.name", + "packageName": "examples.cd.Auction", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Message", + "fullName": "examples.cd.Auction.Message", + "packageName": "examples.cd.Auction", + "isClass": true, + "isPublic": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "Message", + "fullName": "Message", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Message" + }, + "isConstructor": true, "isPublic": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Message", - "fullName": "Message", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Message" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "auction", - "fullName": "examples.cd.Auction.Message.auction", - "packageName": "examples.cd.Auction", - "association": 539240764, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Auction" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "person", - "fullName": "examples.cd.Auction.Message.person", - "packageName": "examples.cd.Auction", - "cardinality": "[1]", - "association": 1487230025, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.Person" - } - } - ] + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "auction", + "fullName": "examples.cd.Auction.Message.auction", + "packageName": "examples.cd.Auction", + "association": 164714495, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Auction" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "AllData", - "fullName": "examples.cd.Auction.AllData", + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "person", + "fullName": "examples.cd.Auction.Message.person", "packageName": "examples.cd.Auction", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "AllData", - "fullName": "AllData", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Auction.AllData" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "cardinality": "[1]", + "association": 2080643905, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.Person" } - }, - { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "Auction", - "fullName": "examples.cd.Auction", - "packageName": "examples.cd" - } - ], - "furtherObjects": { - "764358458": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - }, - "1288052401": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - }, - "539240764": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "1894698434": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "1487230025": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "AllData", + "fullName": "examples.cd.Auction.AllData", + "packageName": "examples.cd.Auction", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "AllData", + "fullName": "AllData", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Auction.AllData" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "Auction", + "fullName": "examples.cd.Auction", + "packageName": "examples.cd" + } + ], + "furtherObjects": { + "100445376": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "1562764987": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true + }, + "216376974": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true + }, + "164714495": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "2080643905": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/Calendar.cdsym b/src/test/resources/examples/cd/Calendar.cdsym index ca53ba21..701939bf 100644 --- a/src/test/resources/examples/cd/Calendar.cdsym +++ b/src/test/resources/examples/cd/Calendar.cdsym @@ -1,173 +1,181 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "Calendar", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "Calendar", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Calendar", + "fullName": "examples.cd.Calendar.Calendar", + "packageName": "examples.cd.Calendar", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Calendar", - "fullName": "examples.cd.Calendar.Calendar", + "fullName": "Calendar", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Calendar.Calendar" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "event", + "fullName": "examples.cd.Calendar.Calendar.event", "packageName": "examples.cd.Calendar", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Calendar", - "fullName": "Calendar", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Calendar.Calendar" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "event", - "fullName": "examples.cd.Calendar.Calendar.event", - "packageName": "examples.cd.Calendar", - "cardinality": "[*]", - "association": 639105046, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Calendar.Event" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "year", - "fullName": "examples.cd.Calendar.Calendar.year", - "packageName": "examples.cd.Calendar", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "isPublic", - "fullName": "examples.cd.Calendar.Calendar.isPublic", - "packageName": "examples.cd.Calendar", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "events", - "fullName": "examples.cd.Calendar.Calendar.events", - "packageName": "examples.cd.Calendar", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Calendar.Event" - } - ] - } - } - ] + "cardinality": "[*]", + "association": 361571676, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Calendar.Event" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "year", + "fullName": "examples.cd.Calendar.Calendar.year", + "packageName": "examples.cd.Calendar", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "isPublic", + "fullName": "examples.cd.Calendar.Calendar.isPublic", + "packageName": "examples.cd.Calendar", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "events", + "fullName": "examples.cd.Calendar.Calendar.events", + "packageName": "examples.cd.Calendar", + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Calendar.Event" + } + ] + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Event", + "fullName": "examples.cd.Calendar.Event", + "packageName": "examples.cd.Calendar", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Event", - "fullName": "examples.cd.Calendar.Event", + "fullName": "Event", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Calendar.Event" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "calendar", + "fullName": "examples.cd.Calendar.Event.calendar", "packageName": "examples.cd.Calendar", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Event", - "fullName": "Event", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Calendar.Event" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "calendar", - "fullName": "examples.cd.Calendar.Event.calendar", - "packageName": "examples.cd.Calendar", - "isDefinitiveNavigable": true, - "cardinality": "[1]", - "association": 639105046, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Calendar.Calendar" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "title", - "fullName": "examples.cd.Calendar.Event.title", - "packageName": "examples.cd.Calendar", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "description", - "fullName": "examples.cd.Calendar.Event.description", - "packageName": "examples.cd.Calendar", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "data", - "fullName": "examples.cd.Calendar.Event.data", - "packageName": "examples.cd.Calendar", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.util.Date" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "subEvents", - "fullName": "examples.cd.Calendar.Event.subEvents", - "packageName": "examples.cd.Calendar", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Calendar.Event" - } - ] - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[1]", + "association": 361571676, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Calendar.Calendar" } - }, - { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "Calendar", - "fullName": "examples.cd.Calendar", - "packageName": "examples.cd" - } - ], - "furtherObjects": { - "639105046": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "title", + "fullName": "examples.cd.Calendar.Event.title", + "packageName": "examples.cd.Calendar", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "description", + "fullName": "examples.cd.Calendar.Event.description", + "packageName": "examples.cd.Calendar", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "data", + "fullName": "examples.cd.Calendar.Event.data", + "packageName": "examples.cd.Calendar", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.util.Date" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "subEvents", + "fullName": "examples.cd.Calendar.Event.subEvents", + "packageName": "examples.cd.Calendar", + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Calendar.Event" + } + ] + } + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "Calendar", + "fullName": "examples.cd.Calendar", + "packageName": "examples.cd" + } + ], + "furtherObjects": { + "361571676": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/Examples.cdsym b/src/test/resources/examples/cd/Examples.cdsym index 3e5d6d22..3de9fbf5 100644 --- a/src/test/resources/examples/cd/Examples.cdsym +++ b/src/test/resources/examples/cd/Examples.cdsym @@ -1,196 +1,204 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "Examples", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "Examples", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Rule", + "fullName": "examples.cd.Examples.Rule", + "packageName": "examples.cd.Examples", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Rule", - "fullName": "examples.cd.Examples.Rule", + "fullName": "Rule", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Rule" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "action", + "fullName": "examples.cd.Examples.Rule.action", "packageName": "examples.cd.Examples", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Rule", - "fullName": "Rule", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Rule" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "action", - "fullName": "examples.cd.Examples.Rule.action", - "packageName": "examples.cd.Examples", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 1934692470, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Action" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "content", - "fullName": "examples.cd.Examples.Rule.content", - "packageName": "examples.cd.Examples", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1357686726, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Action" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "content", + "fullName": "examples.cd.Examples.Rule.content", + "packageName": "examples.cd.Examples", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Action", + "fullName": "examples.cd.Examples.Action", + "packageName": "examples.cd.Examples", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Action", - "fullName": "examples.cd.Examples.Action", + "fullName": "Action", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Action" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "action", + "fullName": "examples.cd.Examples.Action.action", + "packageName": "examples.cd.Examples", + "cardinality": "[1]", + "association": 42820240, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Action" + } + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "rule", + "fullName": "examples.cd.Examples.Action.rule", "packageName": "examples.cd.Examples", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Action", - "fullName": "Action", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Action" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "action", - "fullName": "examples.cd.Examples.Action.action", - "packageName": "examples.cd.Examples", - "cardinality": "[1]", - "association": 68195659, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Action" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "rule", - "fullName": "examples.cd.Examples.Action.rule", - "packageName": "examples.cd.Examples", - "cardinality": "[1]", - "association": 1934692470, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Rule" - } - } - ] + "cardinality": "[1]", + "association": 1357686726, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Rule" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ActionA", + "fullName": "examples.cd.Examples.ActionA", + "packageName": "examples.cd.Examples", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Action" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "ActionA", - "fullName": "examples.cd.Examples.ActionA", + "fullName": "ActionA", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.ActionA" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "rule1", + "fullName": "examples.cd.Examples.ActionA.rule1", "packageName": "examples.cd.Examples", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Action" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ActionA", - "fullName": "ActionA", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.ActionA" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "rule1", - "fullName": "examples.cd.Examples.ActionA.rule1", - "packageName": "examples.cd.Examples", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Rule" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "rule2", - "fullName": "examples.cd.Examples.ActionA.rule2", - "packageName": "examples.cd.Examples", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Rule" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Rule" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "ActionB", - "fullName": "examples.cd.Examples.ActionB", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "rule2", + "fullName": "examples.cd.Examples.ActionA.rule2", "packageName": "examples.cd.Examples", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.Action" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ActionB", - "fullName": "ActionB", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.Examples.ActionB" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Rule" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ActionB", + "fullName": "examples.cd.Examples.ActionB", + "packageName": "examples.cd.Examples", + "superTypes": [ { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "Examples", - "fullName": "examples.cd.Examples", - "packageName": "examples.cd" - } - ], - "furtherObjects": { - "1934692470": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "68195659": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.Action" } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "ActionB", + "fullName": "ActionB", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.Examples.ActionB" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "Examples", + "fullName": "examples.cd.Examples", + "packageName": "examples.cd" + } + ], + "furtherObjects": { + "1357686726": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "42820240": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/MyFamily.cdsym b/src/test/resources/examples/cd/MyFamily.cdsym index fabc4c4f..244b30ca 100644 --- a/src/test/resources/examples/cd/MyFamily.cdsym +++ b/src/test/resources/examples/cd/MyFamily.cdsym @@ -1,308 +1,316 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "MyFamily", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "married", - "association": 841166421 - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "cars", - "association": 115945887 - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "MyFamily", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "married", + "association": 2029780820 + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "cars", + "association": 94830685 + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Person", + "fullName": "examples.cd.MyFamily.Person", + "packageName": "examples.cd.MyFamily", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Person", - "fullName": "examples.cd.MyFamily.Person", + "fullName": "Person", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Person" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "person", + "fullName": "examples.cd.MyFamily.Person.person", "packageName": "examples.cd.MyFamily", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Person", - "fullName": "Person", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Person" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "person", - "fullName": "examples.cd.MyFamily.Person.person", - "packageName": "examples.cd.MyFamily", - "isDefinitiveNavigable": true, - "cardinality": "[1]", - "association": 841166421, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Person" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "car", - "fullName": "examples.cd.MyFamily.Person.car", - "packageName": "examples.cd.MyFamily", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 115945887, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Car" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "age", - "fullName": "examples.cd.MyFamily.Person.age", - "packageName": "examples.cd.MyFamily", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[1]", + "association": 2029780820, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Person" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "Car", - "fullName": "examples.cd.MyFamily.Car", + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "car", + "fullName": "examples.cd.MyFamily.Person.car", "packageName": "examples.cd.MyFamily", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Car", - "fullName": "Car", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Car" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "person", - "fullName": "examples.cd.MyFamily.Car.person", - "packageName": "examples.cd.MyFamily", - "isDefinitiveNavigable": true, - "cardinality": "[1]", - "association": 115945887, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Person" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "bought", - "fullName": "examples.cd.MyFamily.Car.bought", - "packageName": "examples.cd.MyFamily", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Date" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "color", - "fullName": "examples.cd.MyFamily.Car.color", - "packageName": "examples.cd.MyFamily", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Color" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 94830685, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Car" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "BMW", - "fullName": "examples.cd.MyFamily.BMW", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "age", + "fullName": "examples.cd.MyFamily.Person.age", "packageName": "examples.cd.MyFamily", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Car" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "BMW", - "fullName": "BMW", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.BMW" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "Jaguar", - "fullName": "examples.cd.MyFamily.Jaguar", + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Car", + "fullName": "examples.cd.MyFamily.Car", + "packageName": "examples.cd.MyFamily", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "Car", + "fullName": "Car", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Car" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "person", + "fullName": "examples.cd.MyFamily.Car.person", "packageName": "examples.cd.MyFamily", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Car" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Jaguar", - "fullName": "Jaguar", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Jaguar" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "length", - "fullName": "examples.cd.MyFamily.Jaguar.length", - "packageName": "examples.cd.MyFamily", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "double" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[1]", + "association": 94830685, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Person" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "Color", - "fullName": "examples.cd.MyFamily.Color", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "bought", + "fullName": "examples.cd.MyFamily.Car.bought", "packageName": "examples.cd.MyFamily", - "isEnum": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "BLUE", - "fullName": "examples.cd.MyFamily.Color.BLUE", - "packageName": "examples.cd.MyFamily", - "isPublic": true, - "isStatic": true, - "isFinal": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Color" - }, - "isReadOnly": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "RED", - "fullName": "examples.cd.MyFamily.Color.RED", - "packageName": "examples.cd.MyFamily", - "isPublic": true, - "isStatic": true, - "isFinal": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Color" - }, - "isReadOnly": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "WHITE", - "fullName": "examples.cd.MyFamily.Color.WHITE", - "packageName": "examples.cd.MyFamily", - "isPublic": true, - "isStatic": true, - "isFinal": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Color" - }, - "isReadOnly": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "BLACK", - "fullName": "examples.cd.MyFamily.Color.BLACK", - "packageName": "examples.cd.MyFamily", - "isPublic": true, - "isStatic": true, - "isFinal": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Color" - }, - "isReadOnly": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Date" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "Date", - "fullName": "examples.cd.MyFamily.Date", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "color", + "fullName": "examples.cd.MyFamily.Car.color", "packageName": "examples.cd.MyFamily", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Date", - "fullName": "Date", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.MyFamily.Date" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Color" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "BMW", + "fullName": "examples.cd.MyFamily.BMW", + "packageName": "examples.cd.MyFamily", + "superTypes": [ { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "MyFamily", - "fullName": "examples.cd.MyFamily", - "packageName": "examples.cd" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Car" } - ], - "furtherObjects": { - "841166421": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "115945887": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "BMW", + "fullName": "BMW", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.BMW" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Jaguar", + "fullName": "examples.cd.MyFamily.Jaguar", + "packageName": "examples.cd.MyFamily", + "superTypes": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Car" } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "Jaguar", + "fullName": "Jaguar", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Jaguar" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "length", + "fullName": "examples.cd.MyFamily.Jaguar.length", + "packageName": "examples.cd.MyFamily", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "double" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Color", + "fullName": "examples.cd.MyFamily.Color", + "packageName": "examples.cd.MyFamily", + "isEnum": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "BLUE", + "fullName": "examples.cd.MyFamily.Color.BLUE", + "packageName": "examples.cd.MyFamily", + "isPublic": true, + "isStatic": true, + "isFinal": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Color" + }, + "isReadOnly": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "RED", + "fullName": "examples.cd.MyFamily.Color.RED", + "packageName": "examples.cd.MyFamily", + "isPublic": true, + "isStatic": true, + "isFinal": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Color" + }, + "isReadOnly": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "WHITE", + "fullName": "examples.cd.MyFamily.Color.WHITE", + "packageName": "examples.cd.MyFamily", + "isPublic": true, + "isStatic": true, + "isFinal": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Color" + }, + "isReadOnly": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "BLACK", + "fullName": "examples.cd.MyFamily.Color.BLACK", + "packageName": "examples.cd.MyFamily", + "isPublic": true, + "isStatic": true, + "isFinal": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Color" + }, + "isReadOnly": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Date", + "fullName": "examples.cd.MyFamily.Date", + "packageName": "examples.cd.MyFamily", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "Date", + "fullName": "Date", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.MyFamily.Date" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "MyFamily", + "fullName": "examples.cd.MyFamily", + "packageName": "examples.cd" + } + ], + "furtherObjects": { + "2029780820": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "94830685": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/Project.cdsym b/src/test/resources/examples/cd/Project.cdsym index 292703f7..84385c2b 100644 --- a/src/test/resources/examples/cd/Project.cdsym +++ b/src/test/resources/examples/cd/Project.cdsym @@ -6,7 +6,7 @@ { "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", "name": "test", - "association": 1764291958 + "association": 1262237002 }, { "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", @@ -35,7 +35,7 @@ "packageName": "examples.cd.Project", "isDefinitiveNavigable": true, "cardinality": "[*]", - "association": 1764291958, + "association": 1262237002, "type": { "kind": "de.monticore.types.check.SymTypeOfObject", "objName": "examples.cd.Project.Test" @@ -70,7 +70,7 @@ "fullName": "examples.cd.Project.Test.gitLab", "packageName": "examples.cd.Project", "cardinality": "[1]", - "association": 1764291958, + "association": 1262237002, "isLeft": true, "type": { "kind": "de.monticore.types.check.SymTypeOfObject", @@ -158,9 +158,17 @@ } ], "furtherObjects": { - "1764291958": { + "1262237002": { "kind": "de.monticore.cdassociation._symboltable.SymAssociation", "isAssociation": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/SimpleOD.cd b/src/test/resources/examples/cd/SimpleOD.cd index d5564b08..95b87914 100644 --- a/src/test/resources/examples/cd/SimpleOD.cd +++ b/src/test/resources/examples/cd/SimpleOD.cd @@ -16,6 +16,7 @@ classdiagram SimpleOD { class ObjectType2 extends ObjectType { int foobar3; String foobar4; + String myDate; } class ObjectType3 extends ObjectType { diff --git a/src/test/resources/examples/cd/SimpleOD.cdsym b/src/test/resources/examples/cd/SimpleOD.cdsym index 8f80c5f2..f7420d97 100644 --- a/src/test/resources/examples/cd/SimpleOD.cdsym +++ b/src/test/resources/examples/cd/SimpleOD.cdsym @@ -1,291 +1,309 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "SimpleOD", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "firstLink", - "association": 1392570698 - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "secondLink", - "association": 1418245573 - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "SimpleOD", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "firstLink", + "association": 1370224403 + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "secondLink", + "association": 2063786038 + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType", + "fullName": "examples.cd.SimpleOD.ObjectType", + "packageName": "examples.cd.SimpleOD", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "ObjectType", - "fullName": "examples.cd.SimpleOD.ObjectType", + "fullName": "ObjectType", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "objectType", + "fullName": "examples.cd.SimpleOD.ObjectType.objectType", "packageName": "examples.cd.SimpleOD", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType", - "fullName": "ObjectType", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "objectType", - "fullName": "examples.cd.SimpleOD.ObjectType.objectType", - "packageName": "examples.cd.SimpleOD", - "isDefinitiveNavigable": true, - "cardinality": "[1]", - "association": 1392570698, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "foobar", - "fullName": "examples.cd.SimpleOD.ObjectType.foobar", - "packageName": "examples.cd.SimpleOD", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "foobar2", - "fullName": "examples.cd.SimpleOD.ObjectType.foobar2", - "packageName": "examples.cd.SimpleOD", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[1]", + "association": 1370224403, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "ObjectType1", - "fullName": "examples.cd.SimpleOD.ObjectType1", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "foobar", + "fullName": "examples.cd.SimpleOD.ObjectType.foobar", "packageName": "examples.cd.SimpleOD", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType1", - "fullName": "ObjectType1", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType1" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "foobar2", + "fullName": "examples.cd.SimpleOD.ObjectType.foobar2", + "packageName": "examples.cd.SimpleOD", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType1", + "fullName": "examples.cd.SimpleOD.ObjectType1", + "packageName": "examples.cd.SimpleOD", + "superTypes": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "ObjectType1", + "fullName": "ObjectType1", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType1" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType2", + "fullName": "examples.cd.SimpleOD.ObjectType2", + "packageName": "examples.cd.SimpleOD", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "ObjectType2", - "fullName": "examples.cd.SimpleOD.ObjectType2", + "fullName": "ObjectType2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType2" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "foobar3", + "fullName": "examples.cd.SimpleOD.ObjectType2.foobar3", "packageName": "examples.cd.SimpleOD", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType2", - "fullName": "ObjectType2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType2" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "foobar3", - "fullName": "examples.cd.SimpleOD.ObjectType2.foobar3", - "packageName": "examples.cd.SimpleOD", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "foobar4", - "fullName": "examples.cd.SimpleOD.ObjectType2.foobar4", - "packageName": "examples.cd.SimpleOD", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "ObjectType3", - "fullName": "examples.cd.SimpleOD.ObjectType3", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "foobar4", + "fullName": "examples.cd.SimpleOD.ObjectType2.foobar4", "packageName": "examples.cd.SimpleOD", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType3", - "fullName": "ObjectType3", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType3" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "myDate", + "fullName": "examples.cd.SimpleOD.ObjectType2.myDate", + "packageName": "examples.cd.SimpleOD", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType3", + "fullName": "examples.cd.SimpleOD.ObjectType3", + "packageName": "examples.cd.SimpleOD", + "superTypes": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "ObjectType3", + "fullName": "ObjectType3", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType3" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType4", + "fullName": "examples.cd.SimpleOD.ObjectType4", + "packageName": "examples.cd.SimpleOD", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "ObjectType4", - "fullName": "examples.cd.SimpleOD.ObjectType4", + "fullName": "ObjectType4", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType4" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "foobar", + "fullName": "examples.cd.SimpleOD.ObjectType4.foobar", "packageName": "examples.cd.SimpleOD", - "superTypes": [ + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType4", - "fullName": "ObjectType4", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType4" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "foobar", - "fullName": "examples.cd.SimpleOD.ObjectType4.foobar", - "packageName": "examples.cd.SimpleOD", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - } - ] - } - } - ] + ] } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType5", + "fullName": "examples.cd.SimpleOD.ObjectType5", + "packageName": "examples.cd.SimpleOD", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "ObjectType5", - "fullName": "examples.cd.SimpleOD.ObjectType5", + "fullName": "ObjectType5", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType5" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "foobar", + "fullName": "examples.cd.SimpleOD.ObjectType5.foobar", "packageName": "examples.cd.SimpleOD", - "superTypes": [ + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "Map", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + }, + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD.ObjectType" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType5", - "fullName": "ObjectType5", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType5" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "foobar", - "fullName": "examples.cd.SimpleOD.ObjectType5.foobar", - "packageName": "examples.cd.SimpleOD", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "Map", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - }, - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD.ObjectType" - } - ] - } - } - ] + ] } - }, - { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "SimpleOD", - "fullName": "examples.cd.SimpleOD", - "packageName": "examples.cd" - } - ], - "furtherObjects": { - "1392570698": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "1418245573": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - } + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "SimpleOD", + "fullName": "examples.cd.SimpleOD", + "packageName": "examples.cd" + } + ], + "furtherObjects": { + "1370224403": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "2063786038": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/SimpleOD2.cdsym b/src/test/resources/examples/cd/SimpleOD2.cdsym index f3c48a48..9de44656 100644 --- a/src/test/resources/examples/cd/SimpleOD2.cdsym +++ b/src/test/resources/examples/cd/SimpleOD2.cdsym @@ -1,253 +1,293 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "SimpleOD2", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", - "name": "related", - "association": 530410619 - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "SimpleOD2", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdassociation._symboltable.CDAssociationSymbol", + "name": "related", + "association": 1337835760 + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType", + "fullName": "examples.cd.SimpleOD2.ObjectType", + "packageName": "examples.cd.SimpleOD2", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "ObjectType", - "fullName": "examples.cd.SimpleOD2.ObjectType", + "fullName": "ObjectType", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.ObjectType" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "objectType2", + "fullName": "examples.cd.SimpleOD2.ObjectType.objectType2", "packageName": "examples.cd.SimpleOD2", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType", - "fullName": "ObjectType", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.ObjectType" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "objectType2", - "fullName": "examples.cd.SimpleOD2.ObjectType.objectType2", - "packageName": "examples.cd.SimpleOD2", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 530410619, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.ObjectType2" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "innerLink", - "fullName": "examples.cd.SimpleOD2.ObjectType.innerLink", - "packageName": "examples.cd.SimpleOD2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T3" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "linkList1", - "fullName": "examples.cd.SimpleOD2.ObjectType.linkList1", - "packageName": "examples.cd.SimpleOD2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T" - } - ] - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1337835760, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.ObjectType2" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "ObjectType2", - "fullName": "examples.cd.SimpleOD2.ObjectType2", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "innerLink", + "fullName": "examples.cd.SimpleOD2.ObjectType.innerLink", "packageName": "examples.cd.SimpleOD2", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType2", - "fullName": "ObjectType2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.ObjectType2" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "objectType", - "fullName": "examples.cd.SimpleOD2.ObjectType2.objectType", - "packageName": "examples.cd.SimpleOD2", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 530410619, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.ObjectType" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T3" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "T", - "fullName": "examples.cd.SimpleOD2.T", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "linkList1", + "fullName": "examples.cd.SimpleOD2.ObjectType.linkList1", "packageName": "examples.cd.SimpleOD2", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T", - "fullName": "T", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] - } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "T1", - "fullName": "examples.cd.SimpleOD2.T1", - "packageName": "examples.cd.SimpleOD2", - "superTypes": [ + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T1", - "fullName": "T1", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T1" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + ] } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "T2", - "fullName": "examples.cd.SimpleOD2.T2", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "objectType2", + "fullName": "examples.cd.SimpleOD2.ObjectType.objectType2", "packageName": "examples.cd.SimpleOD2", - "superTypes": [ + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "java.util.Set", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.ObjectType2" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T2", - "fullName": "T2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T2" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "foo", - "fullName": "examples.cd.SimpleOD2.T2.foo", - "packageName": "examples.cd.SimpleOD2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T3" - } - } - ] + ] } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "T3", - "fullName": "examples.cd.SimpleOD2.T3", + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType2", + "fullName": "examples.cd.SimpleOD2.ObjectType2", + "packageName": "examples.cd.SimpleOD2", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "ObjectType2", + "fullName": "ObjectType2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.ObjectType2" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "objectType", + "fullName": "examples.cd.SimpleOD2.ObjectType2.objectType", "packageName": "examples.cd.SimpleOD2", - "superTypes": [ + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1337835760, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.ObjectType" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "objectType", + "fullName": "examples.cd.SimpleOD2.ObjectType2.objectType", + "packageName": "examples.cd.SimpleOD2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "java.util.Set", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.ObjectType" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T3", - "fullName": "T3", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleOD2.T3" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "content", - "fullName": "examples.cd.SimpleOD2.T3.content", - "packageName": "examples.cd.SimpleOD2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + ] } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T", + "fullName": "examples.cd.SimpleOD2.T", + "packageName": "examples.cd.SimpleOD2", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "T", + "fullName": "T", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T1", + "fullName": "examples.cd.SimpleOD2.T1", + "packageName": "examples.cd.SimpleOD2", + "superTypes": [ { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "SimpleOD2", - "fullName": "examples.cd.SimpleOD2", - "packageName": "examples.cd" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T" } - ], - "furtherObjects": { - "530410619": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "T1", + "fullName": "T1", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T1" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T2", + "fullName": "examples.cd.SimpleOD2.T2", + "packageName": "examples.cd.SimpleOD2", + "superTypes": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "T2", + "fullName": "T2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T2" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "foo", + "fullName": "examples.cd.SimpleOD2.T2.foo", + "packageName": "examples.cd.SimpleOD2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T3" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T3", + "fullName": "examples.cd.SimpleOD2.T3", + "packageName": "examples.cd.SimpleOD2", + "superTypes": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T" } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "T3", + "fullName": "T3", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleOD2.T3" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "content", + "fullName": "examples.cd.SimpleOD2.T3.content", + "packageName": "examples.cd.SimpleOD2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "SimpleOD2", + "fullName": "examples.cd.SimpleOD2", + "packageName": "examples.cd" + } + ], + "furtherObjects": { + "1337835760": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/SimpleTypes.cdsym b/src/test/resources/examples/cd/SimpleTypes.cdsym index 7d921d81..da900317 100644 --- a/src/test/resources/examples/cd/SimpleTypes.cdsym +++ b/src/test/resources/examples/cd/SimpleTypes.cdsym @@ -1,368 +1,376 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "SimpleTypes", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "SimpleTypes", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Type1", + "fullName": "examples.cd.SimpleTypes.Type1", + "packageName": "examples.cd.SimpleTypes", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Type1", - "fullName": "examples.cd.SimpleTypes.Type1", + "fullName": "Type1", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.Type1" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "type3", + "fullName": "examples.cd.SimpleTypes.Type1.type3", "packageName": "examples.cd.SimpleTypes", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Type1", - "fullName": "Type1", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.Type1" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "type3", - "fullName": "examples.cd.SimpleTypes.Type1.type3", - "packageName": "examples.cd.SimpleTypes", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 141015648, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.Type3" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "myString", - "fullName": "examples.cd.SimpleTypes.Type1.myString", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "myList", - "fullName": "examples.cd.SimpleTypes.Type1.myList", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - ] - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "myEmpty", - "fullName": "examples.cd.SimpleTypes.Type1.myEmpty", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "negative", - "fullName": "examples.cd.SimpleTypes.Type1.negative", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "longValue", - "fullName": "examples.cd.SimpleTypes.Type1.longValue", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "long" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "bool", - "fullName": "examples.cd.SimpleTypes.Type1.bool", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "boolean" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "doubleValue", - "fullName": "examples.cd.SimpleTypes.Type1.doubleValue", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "double" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "negDoubleValue", - "fullName": "examples.cd.SimpleTypes.Type1.negDoubleValue", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "double" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 889422145, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.Type3" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "myString", + "fullName": "examples.cd.SimpleTypes.Type1.myString", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "myList", + "fullName": "examples.cd.SimpleTypes.Type1.myList", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + ] + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "myEmpty", + "fullName": "examples.cd.SimpleTypes.Type1.myEmpty", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "negative", + "fullName": "examples.cd.SimpleTypes.Type1.negative", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "longValue", + "fullName": "examples.cd.SimpleTypes.Type1.longValue", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "long" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "bool", + "fullName": "examples.cd.SimpleTypes.Type1.bool", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "doubleValue", + "fullName": "examples.cd.SimpleTypes.Type1.doubleValue", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "double" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "negDoubleValue", + "fullName": "examples.cd.SimpleTypes.Type1.negDoubleValue", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "double" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Type2", + "fullName": "examples.cd.SimpleTypes.Type2", + "packageName": "examples.cd.SimpleTypes", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Type2", - "fullName": "examples.cd.SimpleTypes.Type2", + "fullName": "Type2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.Type2" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr1", + "fullName": "examples.cd.SimpleTypes.Type2.attr1", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr2", + "fullName": "examples.cd.SimpleTypes.Type2.attr2", "packageName": "examples.cd.SimpleTypes", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Type2", - "fullName": "Type2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.Type2" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr1", - "fullName": "examples.cd.SimpleTypes.Type2.attr1", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr2", - "fullName": "examples.cd.SimpleTypes.Type2.attr2", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.Type1" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr3", - "fullName": "examples.cd.SimpleTypes.Type2.attr3", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr4", - "fullName": "examples.cd.SimpleTypes.Type2.attr4", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr5", - "fullName": "examples.cd.SimpleTypes.Type2.attr5", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr6", - "fullName": "examples.cd.SimpleTypes.Type2.attr6", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr7", - "fullName": "examples.cd.SimpleTypes.Type2.attr7", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr8", - "fullName": "examples.cd.SimpleTypes.Type2.attr8", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "attr9", - "fullName": "examples.cd.SimpleTypes.Type2.attr9", - "packageName": "examples.cd.SimpleTypes", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.Type1" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr3", + "fullName": "examples.cd.SimpleTypes.Type2.attr3", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr4", + "fullName": "examples.cd.SimpleTypes.Type2.attr4", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr5", + "fullName": "examples.cd.SimpleTypes.Type2.attr5", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr6", + "fullName": "examples.cd.SimpleTypes.Type2.attr6", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr7", + "fullName": "examples.cd.SimpleTypes.Type2.attr7", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr8", + "fullName": "examples.cd.SimpleTypes.Type2.attr8", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "attr9", + "fullName": "examples.cd.SimpleTypes.Type2.attr9", + "packageName": "examples.cd.SimpleTypes", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Type3", + "fullName": "examples.cd.SimpleTypes.Type3", + "packageName": "examples.cd.SimpleTypes", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "Type3", - "fullName": "examples.cd.SimpleTypes.Type3", + "fullName": "Type3", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.Type3" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "type1", + "fullName": "examples.cd.SimpleTypes.Type3.type1", "packageName": "examples.cd.SimpleTypes", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Type3", - "fullName": "Type3", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.Type3" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "type1", - "fullName": "examples.cd.SimpleTypes.Type3.type1", - "packageName": "examples.cd.SimpleTypes", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 141015648, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.Type1" - } - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "myObject", - "fullName": "examples.cd.SimpleTypes.Type3.myObject", - "packageName": "examples.cd.SimpleTypes", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 23053378, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.MyObject" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 889422145, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.Type1" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "Type6", - "fullName": "examples.cd.SimpleTypes.Type6", + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "myObject", + "fullName": "examples.cd.SimpleTypes.Type3.myObject", "packageName": "examples.cd.SimpleTypes", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "Type6", - "fullName": "Type6", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.Type6" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1928312257, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.MyObject" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "Type6", + "fullName": "examples.cd.SimpleTypes.Type6", + "packageName": "examples.cd.SimpleTypes", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "Type6", + "fullName": "Type6", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.Type6" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "MyObject", + "fullName": "examples.cd.SimpleTypes.MyObject", + "packageName": "examples.cd.SimpleTypes", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "MyObject", - "fullName": "examples.cd.SimpleTypes.MyObject", + "fullName": "MyObject", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.MyObject" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", + "name": "type3", + "fullName": "examples.cd.SimpleTypes.MyObject.type3", "packageName": "examples.cd.SimpleTypes", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "MyObject", - "fullName": "MyObject", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.MyObject" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.cdassociation._symboltable.CDRoleSymbol", - "name": "type3", - "fullName": "examples.cd.SimpleTypes.MyObject.type3", - "packageName": "examples.cd.SimpleTypes", - "isDefinitiveNavigable": true, - "cardinality": "[*]", - "association": 23053378, - "isLeft": true, - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.SimpleTypes.Type3" - } - } - ] + "isDefinitiveNavigable": true, + "cardinality": "[*]", + "association": 1928312257, + "isLeft": true, + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.SimpleTypes.Type3" } - }, - { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "SimpleTypes", - "fullName": "examples.cd.SimpleTypes", - "packageName": "examples.cd" - } - ], - "furtherObjects": { - "141015648": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isAssociation": true - }, - "23053378": { - "kind": "de.monticore.cdassociation._symboltable.SymAssociation", - "isComposition": true - } + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "SimpleTypes", + "fullName": "examples.cd.SimpleTypes", + "packageName": "examples.cd" + } + ], + "furtherObjects": { + "889422145": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isAssociation": true + }, + "1928312257": { + "kind": "de.monticore.cdassociation._symboltable.SymAssociation", + "isComposition": true } + }, + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/cd/TObjects.cdsym b/src/test/resources/examples/cd/TObjects.cdsym index 7665d655..5a6ab221 100644 --- a/src/test/resources/examples/cd/TObjects.cdsym +++ b/src/test/resources/examples/cd/TObjects.cdsym @@ -1,241 +1,249 @@ { - "generated-using": "www.MontiCore.de technology", - "name": "TObjects", - "package": "examples.cd", - "symbols": [ - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "generated-using": "www.MontiCore.de technology", + "name": "TObjects", + "package": "examples.cd", + "symbols": [ + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType", + "fullName": "examples.cd.TObjects.ObjectType", + "packageName": "examples.cd.TObjects", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "ObjectType", - "fullName": "examples.cd.TObjects.ObjectType", + "fullName": "ObjectType", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.ObjectType" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "linkToAnObject", + "fullName": "examples.cd.TObjects.ObjectType.linkToAnObject", "packageName": "examples.cd.TObjects", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType", - "fullName": "ObjectType", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.ObjectType" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "linkToAnObject", - "fullName": "examples.cd.TObjects.ObjectType.linkToAnObject", - "packageName": "examples.cd.TObjects", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.ObjectType2" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "linkList1", - "fullName": "examples.cd.TObjects.ObjectType.linkList1", - "packageName": "examples.cd.TObjects", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.ObjectType2" - } - ] - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.ObjectType2" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "ObjectType2", - "fullName": "examples.cd.TObjects.ObjectType2", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "linkList1", + "fullName": "examples.cd.TObjects.ObjectType.linkList1", "packageName": "examples.cd.TObjects", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "ObjectType2", - "fullName": "ObjectType2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.ObjectType2" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ + { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.ObjectType2" + } + ] } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "ObjectType2", + "fullName": "examples.cd.TObjects.ObjectType2", + "packageName": "examples.cd.TObjects", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "ObjectType2", + "fullName": "ObjectType2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.ObjectType2" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T", + "fullName": "examples.cd.TObjects.T", + "packageName": "examples.cd.TObjects", + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "T", - "fullName": "examples.cd.TObjects.T", - "packageName": "examples.cd.TObjects", - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T", - "fullName": "T", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - } - ] - } - }, + "fullName": "T", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T1", + "fullName": "examples.cd.TObjects.T1", + "packageName": "examples.cd.TObjects", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "T1", - "fullName": "examples.cd.TObjects.T1", + "fullName": "T1", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T1" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "cNumber", + "fullName": "examples.cd.TObjects.T1.cNumber", "packageName": "examples.cd.TObjects", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T1", - "fullName": "T1", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T1" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "cNumber", - "fullName": "examples.cd.TObjects.T1.cNumber", - "packageName": "examples.cd.TObjects", - "type": { - "kind": "de.monticore.types.check.SymTypePrimitive", - "primitiveName": "int" - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T2", + "fullName": "examples.cd.TObjects.T2", + "packageName": "examples.cd.TObjects", + "superTypes": [ { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T" + } + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", "name": "T2", - "fullName": "examples.cd.TObjects.T2", + "fullName": "T2", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T2" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "obj1", + "fullName": "examples.cd.TObjects.T2.obj1", "packageName": "examples.cd.TObjects", - "superTypes": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T" - } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T2", - "fullName": "T2", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T2" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "obj1", - "fullName": "examples.cd.TObjects.T2.obj1", - "packageName": "examples.cd.TObjects", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T" - } - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "qualLinkList1", - "fullName": "examples.cd.TObjects.T2.qualLinkList1", - "packageName": "examples.cd.TObjects", - "type": { - "kind": "de.monticore.types.check.SymTypeOfGenerics", - "typeConstructorFullName": "List", - "arguments": [ - { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T1" - } - ] - } - } - ] + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T" } - }, - { - "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", - "name": "T3", - "fullName": "examples.cd.TObjects.T3", + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "qualLinkList1", + "fullName": "examples.cd.TObjects.T2.qualLinkList1", "packageName": "examples.cd.TObjects", - "superTypes": [ + "type": { + "kind": "de.monticore.types.check.SymTypeOfGenerics", + "typeConstructorFullName": "List", + "arguments": [ { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T1" } - ], - "isClass": true, - "spannedScope": { - "symbols": [ - { - "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", - "name": "T3", - "fullName": "T3", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "examples.cd.TObjects.T3" - }, - "isConstructor": true, - "isPublic": true, - "isStatic": true - }, - { - "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", - "name": "content", - "fullName": "examples.cd.TObjects.T3.content", - "packageName": "examples.cd.TObjects", - "type": { - "kind": "de.monticore.types.check.SymTypeOfObject", - "objName": "java.lang.String" - } - } - ] + ] } - }, + } + ] + } + }, + { + "kind": "de.monticore.cdbasis._symboltable.CDTypeSymbol", + "name": "T3", + "fullName": "examples.cd.TObjects.T3", + "packageName": "examples.cd.TObjects", + "superTypes": [ { - "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", - "name": "TObjects", - "fullName": "examples.cd.TObjects", - "packageName": "examples.cd" + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T" } - ] + ], + "isClass": true, + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol", + "name": "T3", + "fullName": "T3", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "examples.cd.TObjects.T3" + }, + "isConstructor": true, + "isPublic": true, + "isStatic": true + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "content", + "fullName": "examples.cd.TObjects.T3.content", + "packageName": "examples.cd.TObjects", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + } + ] + } + }, + { + "kind": "de.monticore.symbols.basicsymbols._symboltable.DiagramSymbol", + "name": "TObjects", + "fullName": "examples.cd.TObjects", + "packageName": "examples.cd" + } + ], + "symbolHierarchy": { + "de.monticore.cdbasis._symboltable.CDTypeSymbol": "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.MethodSymbol": "de.monticore.symbols.basicsymbols._symboltable.FunctionSymbol", + "de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.cd4codebasis._symboltable.CDMethodSignatureSymbol": "de.monticore.symbols.oosymbols._symboltable.MethodSymbol", + "de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", + "de.monticore.symbols.oosymbols._symboltable.FieldSymbol": "de.monticore.symbols.basicsymbols._symboltable.VariableSymbol" + } } \ No newline at end of file diff --git a/src/test/resources/examples/od/PrimitiveAttributes.od b/src/test/resources/examples/od/PrimitiveAttributes.od new file mode 100644 index 00000000..5ffe3b76 --- /dev/null +++ b/src/test/resources/examples/od/PrimitiveAttributes.od @@ -0,0 +1,14 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package examples.od; + +import examples.cd.SimpleOD.*; + +objectdiagram PrimitiveAttributes { + + o:ObjectType2 { + int foobar3 = 1; + String foobar4 = "x"; + }; + +} diff --git a/src/test/resources/examples/od/SimpleOD.od b/src/test/resources/examples/od/SimpleOD.od index 4f35dc3d..b45943e3 100644 --- a/src/test/resources/examples/od/SimpleOD.od +++ b/src/test/resources/examples/od/SimpleOD.od @@ -4,7 +4,7 @@ package examples.od; import examples.cd.SimpleOD.*; -objectdiagram SimpleOD{ +objectdiagram SimpleOD { myObject1:ObjectType{}; diff --git a/src/test/resources/examples/od2cd/InnerObject.od b/src/test/resources/examples/od2cd/InnerObject.od index 5e8f278e..df78b1d3 100644 --- a/src/test/resources/examples/od2cd/InnerObject.od +++ b/src/test/resources/examples/od2cd/InnerObject.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.Associations.*; diff --git a/src/test/resources/examples/od2cd/MyFamily.od b/src/test/resources/examples/od2cd/MyFamily.od index 16e8356c..69a03a11 100644 --- a/src/test/resources/examples/od2cd/MyFamily.od +++ b/src/test/resources/examples/od2cd/MyFamily.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.MyFamily.*; diff --git a/src/test/resources/examples/od2cd/MyFamily.puml b/src/test/resources/examples/od2cd/MyFamily.puml index 84fab2c3..1618e2d9 100644 --- a/src/test/resources/examples/od2cd/MyFamily.puml +++ b/src/test/resources/examples/od2cd/MyFamily.puml @@ -4,7 +4,7 @@ object "__alice:Person__" as alice { age = 29 } object "__bob:Person__" as bob { - nicknames = "Bob""Bobby""Robert" + nicknames = ["Bob", "Bobby", "Robert"] } alice <--> bob : married object "__:BMW__" as __bmw_anonymous_1 { diff --git a/src/test/resources/examples/od2cd/PlantUMLConstructs.od b/src/test/resources/examples/od2cd/PlantUMLConstructs.od new file mode 100644 index 00000000..b98abdad --- /dev/null +++ b/src/test/resources/examples/od2cd/PlantUMLConstructs.od @@ -0,0 +1,27 @@ +/* (c) https://github.com/MontiCore/monticore */ + +package examples.od2cd; + +import examples.cd.SimpleOD.*; + +objectdiagram PlantUMLConstructs { + + a:ObjectType1 { + e = Color.RED; + q = x.y; + sum = 1 + 2; + l = [1, 2, 3]; + m = [1 -> 2, 3 -> 4]; + o = ...; + }; + + b:ObjectType2 {}; + + c:ObjectType3 {}; + + composition a -- (part) b; + aggregation a -- c; + link a [[key]] (src) -> (tgt) [[other]] b; + link a ["k"] -> c; + +} diff --git a/src/test/resources/examples/od2cd/PlantUMLConstructs.puml b/src/test/resources/examples/od2cd/PlantUMLConstructs.puml new file mode 100644 index 00000000..303b147c --- /dev/null +++ b/src/test/resources/examples/od2cd/PlantUMLConstructs.puml @@ -0,0 +1,19 @@ +@startuml +note "OD" as tag #white +object "__a:ObjectType1__" as a { + e = Color.RED + q = x.y + sum = 1 + 2 + l = [1, 2, 3] + m = [1 -> 2, 3 -> 4] + o = ... +} +object "__b:ObjectType2__" as b { +} +object "__c:ObjectType3__" as c { +} +a *-- "part" b +a o-- c +a [key] "src" --> "tgt" [other] b +a ["k"] --> c +@enduml diff --git a/src/test/resources/examples/od2cd/ProjectListOD.od b/src/test/resources/examples/od2cd/ProjectListOD.od index 2e40cf29..ae0089be 100644 --- a/src/test/resources/examples/od2cd/ProjectListOD.od +++ b/src/test/resources/examples/od2cd/ProjectListOD.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.Project.*; diff --git a/src/test/resources/examples/od2cd/QualifiedInnerLinks.od b/src/test/resources/examples/od2cd/QualifiedInnerLinks.od index 670bd65f..a33f411c 100644 --- a/src/test/resources/examples/od2cd/QualifiedInnerLinks.od +++ b/src/test/resources/examples/od2cd/QualifiedInnerLinks.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.TObjects.*; diff --git a/src/test/resources/examples/od2cd/QualifiedInnerLinks.puml b/src/test/resources/examples/od2cd/QualifiedInnerLinks.puml index f8947f17..3a49fdcd 100644 --- a/src/test/resources/examples/od2cd/QualifiedInnerLinks.puml +++ b/src/test/resources/examples/od2cd/QualifiedInnerLinks.puml @@ -7,6 +7,6 @@ object "__objectName2:T1__" as objectName2 { cNumber = 2 } object "__objectName3:T2__" as objectName3 { - qualLinkList1 = 1 objectName12 objectName2 + qualLinkList1 = [1 -> objectName1, 2 -> objectName2] } @enduml \ No newline at end of file diff --git a/src/test/resources/examples/od2cd/QualifiedLinks.od b/src/test/resources/examples/od2cd/QualifiedLinks.od index 61783de9..2c28fbfa 100644 --- a/src/test/resources/examples/od2cd/QualifiedLinks.od +++ b/src/test/resources/examples/od2cd/QualifiedLinks.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.Auction.*; diff --git a/src/test/resources/examples/od2cd/QualifiedLinks.puml b/src/test/resources/examples/od2cd/QualifiedLinks.puml index af502232..2fef492f 100644 --- a/src/test/resources/examples/od2cd/QualifiedLinks.puml +++ b/src/test/resources/examples/od2cd/QualifiedLinks.puml @@ -18,8 +18,8 @@ object "__p1:Person__" as p1 { name = "Theobald Schmidt" isActive = false } -o1-->a1 -o1-->a1 -o1-->a2 -o1-->p1 +o1 --> a1 +o1 [auctionIdent] --> a1 +o1 [auctionIdent] --> a2 +o1 ["xyz"] --> p1 @enduml \ No newline at end of file diff --git a/src/test/resources/examples/od2cd/SimpleOD.od b/src/test/resources/examples/od2cd/SimpleOD.od index 064ac23a..9ace3e30 100644 --- a/src/test/resources/examples/od2cd/SimpleOD.od +++ b/src/test/resources/examples/od2cd/SimpleOD.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.SimpleOD.*; diff --git a/src/test/resources/examples/od2cd/SimpleOD2.od b/src/test/resources/examples/od2cd/SimpleOD2.od index 4f580b91..8a94cb65 100644 --- a/src/test/resources/examples/od2cd/SimpleOD2.od +++ b/src/test/resources/examples/od2cd/SimpleOD2.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.SimpleOD2.*; diff --git a/src/test/resources/examples/od2cd/SpecialValues.od b/src/test/resources/examples/od2cd/SpecialValues.od index 450df675..29ef7209 100644 --- a/src/test/resources/examples/od2cd/SpecialValues.od +++ b/src/test/resources/examples/od2cd/SpecialValues.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.SimpleTypes.*; diff --git a/src/test/resources/examples/od2cd/SpecialValues.puml b/src/test/resources/examples/od2cd/SpecialValues.puml index 064800d0..81e1a0bb 100644 --- a/src/test/resources/examples/od2cd/SpecialValues.puml +++ b/src/test/resources/examples/od2cd/SpecialValues.puml @@ -2,8 +2,8 @@ note "OD" as tag #white object "__o1:Type1__" as o1 { myString = "abc\\def" - myList = "a""b" - myEmpty = + myList = ["a", "b"] + myEmpty = ... negativ =-111 longValue = 20l bool = true diff --git a/src/test/resources/examples/od2cd/StereoWithKeyword.od b/src/test/resources/examples/od2cd/StereoWithKeyword.od index b1ccb16a..22c8e3a8 100644 --- a/src/test/resources/examples/od2cd/StereoWithKeyword.od +++ b/src/test/resources/examples/od2cd/StereoWithKeyword.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.ArtifactKindModel.*; diff --git a/src/test/resources/examples/od2cd/Variants.od b/src/test/resources/examples/od2cd/Variants.od index 6dad8316..e6951b71 100644 --- a/src/test/resources/examples/od2cd/Variants.od +++ b/src/test/resources/examples/od2cd/Variants.od @@ -1,6 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ -package examples.od; +package examples.od2cd; import examples.cd.SimpleTypes.*; diff --git a/src/test/resources/examples/od2cd/Variants.puml b/src/test/resources/examples/od2cd/Variants.puml index 8f459c3e..8a85e323 100644 --- a/src/test/resources/examples/od2cd/Variants.puml +++ b/src/test/resources/examples/od2cd/Variants.puml @@ -18,8 +18,8 @@ object "__o4:MyObject__" as o4 { object "__:Type6__" as __type6_anonymous_1 { } o1 --> o2 -o2 "leftRole" -- "rightRole" o1 : association1 -o2 "leftRole" -- "rightRole" o1 : association1 +o2 [ID] "leftRole" -- "rightRole" o1 : association1 +o2 ["ID"] "leftRole" -- "rightRole" o1 : association1 o2 "myO3" -- "myO2" o3 : association1 o1 --> o3 o3 *--* o4 diff --git a/src/test/resources/symboltable/aggregation/basicgame_cd/BasicGameCD.cdsym b/src/test/resources/symboltable/aggregation/basicgame_cd/BasicGameCD.cdsym index 5da3aae5..981581e8 100644 --- a/src/test/resources/symboltable/aggregation/basicgame_cd/BasicGameCD.cdsym +++ b/src/test/resources/symboltable/aggregation/basicgame_cd/BasicGameCD.cdsym @@ -155,6 +155,15 @@ "objName": "java.lang.String" } }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "value", + "isPrivate": true, + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, { "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", "name": "classes", diff --git a/src/test/resources/symboltable/tooltest/examples/A.cdsym b/src/test/resources/symboltable/tooltest/examples/A.cdsym index cfc554ed..71ff9144 100644 --- a/src/test/resources/symboltable/tooltest/examples/A.cdsym +++ b/src/test/resources/symboltable/tooltest/examples/A.cdsym @@ -5,11 +5,43 @@ "symbols": [ { "kind": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", - "name": "A" + "name": "A", + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "x", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "int" + } + }, + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "s", + "type": { + "kind": "de.monticore.types.check.SymTypeOfObject", + "objName": "java.lang.String" + } + } + ] + } }, { "kind": "de.monticore.symbols.basicsymbols._symboltable.TypeSymbol", - "name": "B" + "name": "B", + "spannedScope": { + "symbols": [ + { + "kind": "de.monticore.symbols.oosymbols._symboltable.FieldSymbol", + "name": "b", + "type": { + "kind": "de.monticore.types.check.SymTypePrimitive", + "primitiveName": "boolean" + } + } + ] + } } ] -} \ No newline at end of file +}