Skip to content

Commit

Permalink
fix some {: .img-fluid }
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Oct 16, 2023
1 parent 27da348 commit eefeb1e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions _posts/2021-05-15-connecting-meta-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ My model is not able to represent this situation.
So, there are two possibilities: I can fix my meta-model, or I can extend it with a new concept.
Here, we will see how I can extend it.

![Extended Coaster meta-model](/img/posts/2021-05-15-connecting-meta-models/extended-coaster-model.drawio.svg){: .img-fill }
![Extended Coaster meta-model](/img/posts/2021-05-15-connecting-meta-models/extended-coaster-model.drawio.svg){: .img-fluid }

As presented in the above figure, we add the Events concept as a kind of Creator.

Expand Down Expand Up @@ -151,14 +151,14 @@ We will not detail how to implement the world meta-model.
But the generator is available in my [GitHub repository](https://github.com/badetitou/CoastersCollector).
The figure below illustrates the meta-model.

![World meta-model](/img/posts/2021-05-15-connecting-meta-models/world-meta-model.drawio.svg){: .img-fill }
![World meta-model](/img/posts/2021-05-15-connecting-meta-models/world-meta-model.drawio.svg){: .img-fluid }

### Connecting world meta-model with Coaster meta-model

Our goal is to connect the coaster meta-model with the world meta-model.
To do so, we will connect the *country* concepts of each meta-model.

![Connected meta-model](/img/posts/2021-05-15-connecting-meta-models/connected-meta-model.drawio.svg){: .img-fill }
![Connected meta-model](/img/posts/2021-05-15-connecting-meta-models/connected-meta-model.drawio.svg){: .img-fluid }

As a first step, you should install both the coaster meta-model and the world meta-model.
Again, both are available in my [GitHub repository](https://github.com/badetitou/CoastersCollector).
Expand Down
2 changes: 1 addition & 1 deletion _posts/2021-10-01-migrating-internationalization.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ For example, in the introduction example, the namespace of all entries is *"Edit

I designed a meta-model to represent all those concepts:

![meta-model](/img/posts/2021-10-01-Migrating-internationalization/I18N-metamodel.png)
![meta-model](/img/posts/2021-10-01-Migrating-internationalization/I18N-metamodel.png){: .img-fluid }

Once the meta-model is designed, we must create an importer that takes `.properties` files as input and produces a model.

Expand Down
24 changes: 12 additions & 12 deletions _posts/2022-06-22-load-fast.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ comments: true
tags: fast
---

# Introduction
## Introduction

When we are interested in the migration/modernization of projects we are using models of the project and their meta-models. Moose revolves around a powerful Famix meta-model that allows us to do several operations. For instance, previous posts present how to [analyze and query a model](https://modularmoose.org/2021/03/30/modularmoose-usecase.html), [visualize a model with plantUML](https://modularmoose.org/2021/06/04/plantUML-for-metamodel.html), or [create a model](https://modularmoose.org/2021/02/15/Coasters.html), etc.

FAST is a meta-model that helps us understand source code in a less abstract way. Indeed, FAST is based on AST (Abstract Syntax Tree) which is close to the source code. And as the devil is in the details, FAST contains interesting elements when analyzing programs (for example some specific expression or statement), and effectively this is what makes the difference between FAST and Famix.
(Consult this [overview](https://modularmoose.org/moose-wiki/Developers/Parsers/FAST) about the FAST model).

![Abstraction Level](/img/posts/2022-03-14-load-fast/abstraction.png)
![Abstraction Level](/img/posts/2022-03-14-load-fast/abstraction.png){: .img-fluid }

In this blog post we will explain how to load FAST Java and generate a FAST model of Java code. For this we will take [ArgoUML](https://en.wikipedia.org/wiki/ArgoUML), an open-source Java project, as an example.

# Overview & Prerequisites
## Overview & Prerequisites

First of all, we have to understand from where we are going to start and where we are going to end up. As already mentioned, we will take the AgroUML’s java code and the goal is to generate the corresponding AST and do analyses on it. To do this, 3 steps are necessary to have the AST as illustrated in the figure below:

Expand All @@ -33,13 +33,13 @@ First of all, we have to understand from where we are going to start and where w

Before starting, we must download [the source code](/assets/files/ArgoUML-0.34.zip) and [the Famix model](/assets/files/ArgoUML-0-34.json) of the ArgoUML project, step 1 of the diagram above (follow this [blog](https://fuhrmanator.github.io/2019/07/29/AnalyzingJavaWithMoose.html) for more details).

# Configuration
## Configuration

Now, we will import the Famix model from the `ArgoUML-0-34.json` file in the Models Browser. Then, we should know that the FAST meta-model is specific to a gien programming language, i.e for Pharo code we need FAST for Pharo, for X language code we need the FAST meta-model for the X language. Right now, there are two FAST meta-models: FAST Java and FAST Pharo.

In the following, we will generate the AST of a class (or method) for Pharo/Java code in three different ways: directly from some source code, from a method in Pharo, or from a Famix entity.

## FAST Installation
### FAST Installation

To install FAST Java you can run the following script on Moose Playground:

Expand All @@ -59,7 +59,7 @@ repository: 'github://moosetechnology/FAST-Pharo:v2/src';
load: 'importer'.
```

## Java code as string
### Java code as string

In this case, we will use a specialized importer "FAST-Java importer" to import the AST from a method source code. The complete code of the method to import is between single quote (_i.e._ a Pharo string) in the following code:

Expand All @@ -74,7 +74,7 @@ JavaSmaCCProgramNodeImporterVisitor new
}'
```

## Pharo class or method
### Pharo class or method

The following script imports the method #collect: of Collection :

Expand All @@ -83,13 +83,13 @@ FASTSmalltalkImporterVisitor new
runWithSource: (Collection >> #collect:) sourceCode
```

## Generate FastJava model
### Generate FastJava model

In this section, we will not proceed as above. Instead, we start from a class/method of the Famix Java model and we will load its FAST representation.

We will add the model to the Playground

![Add Model on Playground](/img/posts/2022-03-14-load-fast/AddModelPlayground.png)
![Add Model on Playground](/img/posts/2022-03-14-load-fast/AddModelPlayground.png){: .img-fluid }

We got this:

Expand All @@ -109,14 +109,14 @@ And finally we generate the AST using generateFastJava:
class generateFastJava
```

# Navigating Through AST
## Navigating Through AST

One nice way to explore a FAST model is to use the source code and the tree extensions of the inspector. It allows one to navigate in a FAST model and see the code corresponding to each node.

To use it, we start from the Java model loaded above. Then, we select a model method entity. On the right-hand pane of the inspector, select the Tree tab, on the left-hand pane, select the source code extension. The source code is highlighted and the area selected corresponds to the entity selected in the right-hand panel. ( from [FAST-Pharo article](https://modularmoose.org/moose-wiki/Developers/Parsers/FAST-Pharo) )

![Navigating Through AST](/img/posts/2022-03-14-load-fast/NavigatingThrowAST.gif)
![Navigating Through AST](/img/posts/2022-03-14-load-fast/NavigatingThrowAST.gif){: .img-fluid }

# Conclusion
## Conclusion

In this post, we saw how to load the AST of a Pharo/Java model using FAST. The FAST model is useful when we need to understand more details about our model (for example identifiers, expression statements .. etc) which are not provided by Famix.

0 comments on commit eefeb1e

Please sign in to comment.