Skip to content

Commit

Permalink
Merge pull request #237 from anneetien/230-Add-transientvolatilesynch…
Browse files Browse the repository at this point in the history
…ronized-to-FamixJava-copied-from-compatibility-MM

Add Transient, volatile and synchronized by copying Compatibility MM …
  • Loading branch information
anneetien authored Feb 26, 2021
2 parents ede6af3 + 1514fa7 commit 00e7477
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Famix-Java-Entities/FamixJavaAttribute.class.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Class {
#name : #FamixJavaAttribute,
#superclass : #FamixJavaNamedEntity,
#traits : 'FamixTAttribute + FamixTCanBeFinal + FamixTHasVisibility + FamixTInvocationsReceiver + FamixTWithClassScope',
#classTraits : 'FamixTAttribute classTrait + FamixTCanBeFinal classTrait + FamixTHasVisibility classTrait + FamixTInvocationsReceiver classTrait + FamixTWithClassScope classTrait',
#traits : 'FamixJavaTCanBeTransient + FamixJavaTCanBeVolatile + FamixTAttribute + FamixTCanBeFinal + FamixTHasVisibility + FamixTWithClassScope + FamixTInvocationsReceiver',
#classTraits : 'FamixJavaTCanBeTransient classTrait + FamixJavaTCanBeVolatile classTrait + FamixTAttribute classTrait + FamixTCanBeFinal classTrait + FamixTInvocationsReceiver classTrait + FamixTHasVisibility classTrait + FamixTWithClassScope classTrait',
#category : #'Famix-Java-Entities-Entities'
}

Expand Down
4 changes: 2 additions & 2 deletions src/Famix-Java-Entities/FamixJavaMethod.class.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Class {
#name : #FamixJavaMethod,
#superclass : #FamixJavaContainerEntity,
#traits : 'FamixTCanBeAbstract + FamixTCanBeFinal + FamixTHasVisibility + FamixTMethod + FamixTWithCaughtExceptions + FamixTWithDeclaredExceptions + FamixTWithThrownExceptions',
#classTraits : 'FamixTCanBeAbstract classTrait + FamixTCanBeFinal classTrait + FamixTHasVisibility classTrait + FamixTMethod classTrait + FamixTWithCaughtExceptions classTrait + FamixTWithDeclaredExceptions classTrait + FamixTWithThrownExceptions classTrait',
#traits : 'FamixJavaTCanBeSynchronized + FamixTCanBeAbstract + FamixTCanBeFinal + FamixTHasVisibility + FamixTMethod + FamixTWithCaughtExceptions + FamixTWithDeclaredExceptions + FamixTWithThrownExceptions',
#classTraits : 'FamixJavaTCanBeSynchronized classTrait + FamixTCanBeAbstract classTrait + FamixTCanBeFinal classTrait + FamixTHasVisibility classTrait + FamixTMethod classTrait + FamixTWithCaughtExceptions classTrait + FamixTWithDeclaredExceptions classTrait + FamixTWithThrownExceptions classTrait',
#category : #'Famix-Java-Entities-Entities'
}

Expand Down
45 changes: 45 additions & 0 deletions src/Famix-Java-Entities/FamixJavaTCanBeSynchronized.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"
I allow an entity to be synchronized
ex:
```java
public class SynchronizedCounter {
private int c = 0;
public synchronized void increment() {
c++;
}
}
```
"
Trait {
#name : #FamixJavaTCanBeSynchronized,
#instVars : [
'#isSynchronized => FMProperty'
],
#category : #'Famix-Java-Entities-Traits'
}

{ #category : #meta }
FamixJavaTCanBeSynchronized classSide >> annotation [

<FMClass: #TCanBeSynchronized super: #Object>
<package: #'Famix-Java-Entities'>
<generated>
^self
]

{ #category : #accessing }
FamixJavaTCanBeSynchronized >> isSynchronized [

<FMProperty: #isSynchronized type: #Boolean>
<generated>
<FMComment: 'Entity can be declared synchronized'>
^ isSynchronized
]

{ #category : #accessing }
FamixJavaTCanBeSynchronized >> isSynchronized: anObject [
<generated>
isSynchronized := anObject
]
41 changes: 41 additions & 0 deletions src/Famix-Java-Entities/FamixJavaTCanBeTransient.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"
I allow an entity to be transient
ex:
```java
public class Student implements Serializable{
transient int age; //Now it will not be serialized
}
```
"
Trait {
#name : #FamixJavaTCanBeTransient,
#instVars : [
'#isTransient => FMProperty'
],
#category : #'Famix-Java-Entities-Traits'
}

{ #category : #meta }
FamixJavaTCanBeTransient classSide >> annotation [

<FMClass: #TCanBeTransient super: #Object>
<package: #'Famix-Java-Entities'>
<generated>
^self
]

{ #category : #accessing }
FamixJavaTCanBeTransient >> isTransient [

<FMProperty: #isTransient type: #Boolean>
<generated>
<FMComment: 'Entity can be declared transient'>
^ isTransient
]

{ #category : #accessing }
FamixJavaTCanBeTransient >> isTransient: anObject [
<generated>
isTransient := anObject
]
41 changes: 41 additions & 0 deletions src/Famix-Java-Entities/FamixJavaTCanBeVolatile.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"
I allow an entity to be volatible
ex:
```java
public class SharedObject {
public volatile int counter = 0;
}
```
"
Trait {
#name : #FamixJavaTCanBeVolatile,
#instVars : [
'#isVolatile => FMProperty'
],
#category : #'Famix-Java-Entities-Traits'
}

{ #category : #meta }
FamixJavaTCanBeVolatile classSide >> annotation [

<FMClass: #TCanBeVolatile super: #Object>
<package: #'Famix-Java-Entities'>
<generated>
^self
]

{ #category : #accessing }
FamixJavaTCanBeVolatile >> isVolatile [

<FMProperty: #isVolatile type: #Boolean>
<generated>
<FMComment: 'Entity can be declared volatile'>
^ isVolatile
]

{ #category : #accessing }
FamixJavaTCanBeVolatile >> isVolatile: anObject [
<generated>
isVolatile := anObject
]
65 changes: 63 additions & 2 deletions src/Famix-Java-Generator/FamixJavaGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ Class {
'parameterizedType',
'file',
'folder',
'indexedFileAnchor'
'indexedFileAnchor',
'tCanBeVolatile',
'tCanBeTransient',
'tCanBeSynchronized'
],
#category : #'Famix-Java-Generator'
}
Expand All @@ -51,6 +54,46 @@ FamixJavaGenerator class >> prefix [
^ #'FamixJava'
]

{ #category : #definition }
FamixJavaGenerator >> commentForTCanBeSynchronized [
^ 'I allow an entity to be synchronized
ex:
```java
public class SynchronizedCounter {
private int c = 0;
public synchronized void increment() {
c++;
}
}
```'
]

{ #category : #definition }
FamixJavaGenerator >> commentForTCanBeTransient [
^ 'I allow an entity to be transient
ex:
```java
public class Student implements Serializable{
transient int age; //Now it will not be serialized
}
```'
]

{ #category : #definition }
FamixJavaGenerator >> commentForTCanBeVolatile [
^ 'I allow an entity to be volatible
ex:
```java
public class SharedObject {
public volatile int counter = 0;
}
```'
]

{ #category : #definition }
FamixJavaGenerator >> defineClasses [
super defineClasses.
Expand Down Expand Up @@ -143,6 +186,8 @@ FamixJavaGenerator >> defineHierarchy [
attribute --|> #TWithClassScope.
attribute --|> #TCanBeFinal.
attribute --|> #THasVisibility.
attribute --|> tCanBeVolatile.
attribute --|> tCanBeTransient.
attribute --|> #TInvocationsReceiver.

file --|> namedEntity.
Expand All @@ -162,6 +207,7 @@ FamixJavaGenerator >> defineHierarchy [
method --|> #TCanBeAbstract.
method --|> #TCanBeFinal.
method --|> #THasVisibility.
method --|> tCanBeSynchronized.

caughtException --|> exception.
caughtException --|> #TCaughtException.
Expand Down Expand Up @@ -271,7 +317,22 @@ FamixJavaGenerator >> defineProperties [
super defineProperties.
((namespace property: #parentNamespace)
comment: 'Parent namespace embedding this namespace, if any.';
container) *- ((namespace property: #childNamespaces) comment: 'Namespaces embedded in this namespace, if any.')
container) *- ((namespace property: #childNamespaces) comment: 'Namespaces embedded in this namespace, if any.').

((tCanBeVolatile property: #isVolatile type: #Boolean)
comment: 'Entity can be declared volatile').
((tCanBeTransient property: #isTransient type: #Boolean)
comment: 'Entity can be declared transient').
((tCanBeSynchronized property: #isSynchronized type: #Boolean)
comment: 'Entity can be declared synchronized').
]

{ #category : #definition }
FamixJavaGenerator >> defineTraits [
super defineTraits.
tCanBeVolatile := builder newTraitNamed: #TCanBeVolatile comment: self commentForTCanBeVolatile.
tCanBeTransient := builder newTraitNamed: #TCanBeTransient comment: self commentForTCanBeTransient.
tCanBeSynchronized := builder newTraitNamed: #TCanBeSynchronized comment: self commentForTCanBeSynchronized
]

{ #category : #definition }
Expand Down

0 comments on commit 00e7477

Please sign in to comment.