Skip to content

Commit

Permalink
Implemented Java to UML Class transformation
Browse files Browse the repository at this point in the history
  added IncQuery nature to transformation project
  • Loading branch information
Daniel Segesdi committed Dec 11, 2015
1 parent 800e382 commit f281a87
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 47 deletions.
1 change: 1 addition & 0 deletions com.incquerylabs.evm.jdt.uml.transformation/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="src" path="src-gen/"/>
<classpathentry kind="output" path="bin"/>
</classpath>
6 changes: 6 additions & 0 deletions com.incquerylabs.evm.jdt.uml.transformation/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.incquery.tooling.core.projectbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
Expand All @@ -30,5 +35,6 @@
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.incquery.projectnature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: Uml
Bundle-SymbolicName: com.incquerylabs.evm.jdt.uml.transformation;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: INCQUERYLABS
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.incquerylabs.evm.jdt.uml.transformation
Require-Bundle: org.eclipse.incquery.runtime.evm;bundle-version="1.0.1",
org.eclipse.jdt.core;bundle-version="3.11.1",
org.eclipse.xtend.lib,
Expand All @@ -17,6 +17,7 @@ Require-Bundle: org.eclipse.incquery.runtime.evm;bundle-version="1.0.1",
org.eclipse.emf.common;bundle-version="2.11.0",
org.eclipse.core.runtime;bundle-version="3.11.1",
org.eclipse.emf.transaction;bundle-version="1.9.0",
org.eclipse.papyrus.infra.core;bundle-version="1.1.0"
Export-Package: com.incquerylabs.evm.jdt.uml.transformation
org.eclipse.papyrus.infra.core;bundle-version="1.1.0",
org.eclipse.incquery.runtime;bundle-version="1.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.apache.log4j;version="1.2.15"
7 changes: 4 additions & 3 deletions com.incquerylabs.evm.jdt.uml.transformation/build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source.. = src/,\
xtend-gen/
output.. = bin/
bin.includes = META-INF/,\
.
source.. = src/,\
xtend-gen/,\
src-gen/
output.. = bin/
1 change: 1 addition & 0 deletions com.incquerylabs.evm.jdt.uml.transformation/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><plugin/>
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
package com.incquerylabs.evm.jdt.uml.transformation.rules

import com.incquerylabs.evm.jdt.JDTActivationState
import com.incquerylabs.evm.jdt.JDTEventAtom
import com.incquerylabs.evm.jdt.JDTEventSourceSpecification
import com.incquerylabs.evm.jdt.JDTRule
import com.incquerylabs.evm.jdt.fqnutil.JDTQualifiedName
import com.incquerylabs.evm.jdt.fqnutil.UMLQualifiedName
import com.incquerylabs.evm.jdt.job.JDTJobFactory
import com.incquerylabs.evm.jdt.uml.transformation.rules.filters.CompilationUnitFilter
import com.incquerylabs.evm.jdt.uml.transformation.rules.visitors.TypeVisitor
import com.incquerylabs.evm.jdt.umlmanipulator.IUMLManipulator
import org.apache.log4j.Level
import org.apache.log4j.Logger
import org.eclipse.incquery.runtime.evm.api.ActivationLifeCycle
import org.eclipse.jdt.core.ICompilationUnit
import org.eclipse.jdt.core.IJavaElementDelta
import org.eclipse.jdt.core.IJavaProject
import com.incquerylabs.evm.jdt.job.JDTJobFactory
import com.incquerylabs.evm.jdt.JDTActivationState
import com.incquerylabs.evm.jdt.uml.transformation.rules.filters.CompilationUnitFilter
import org.apache.log4j.Level
import com.incquerylabs.evm.jdt.JDTEventAtom
import javax.management.RuntimeErrorException
import com.incquerylabs.evm.jdt.uml.transformation.rules.visitors.TypeVisitor
import org.eclipse.jdt.core.IPackageFragment

class CompilationUnitRule extends JDTRule {
extension Logger logger = Logger.getLogger(this.class)
extension val IUMLManipulator umlManipulator


new(JDTEventSourceSpecification eventSourceSpecification, ActivationLifeCycle activationLifeCycle, IJavaProject project, IUMLManipulator umlManipulator) {
super(eventSourceSpecification, activationLifeCycle, project)
this.umlManipulator = umlManipulator
Expand All @@ -29,32 +34,54 @@ class CompilationUnitRule extends JDTRule {
jobs.add(JDTJobFactory.createJob(JDTActivationState.APPEARED)[activation, context |
val atom = activation.atom
debug('''Compilation unit appeared: «atom.element»''')
atom.transform
])

jobs.add(JDTJobFactory.createJob(JDTActivationState.DISAPPEARED)[activation, context |
debug('''Compilation unit disappeared: «activation.atom.element»''')

try {
val compilationUnit = activation.atom.element as ICompilationUnit
compilationUnit.deleteCorrespondingClass
} catch (IllegalArgumentException e) {
error('''Error during updating compilation unit''', e)
}
])

jobs.add(JDTJobFactory.createJob(JDTActivationState.UPDATED)[activation, context |
val atom = activation.atom
debug('''Compilation unit updated: «activation.atom.element»''')

try{
atom.transform
} catch (IllegalArgumentException e) {
error('''Error during updating compilation unit''', e)
}
])
}

def transform(JDTEventAtom atom) {
val element = atom.element
val delta = atom.delta
val ast = delta.compilationUnitAST
if(ast == null) {
error('''AST was null, compilation unit is not transformed: «element»''')
return
val element = atom.element as ICompilationUnit
var delta = atom.delta
var ast = delta.compilationUnitAST
if(delta.flags.bitwiseAnd(IJavaElementDelta.F_AST_AFFECTED) != 0) {
element.deleteCorrespondingClass
if(ast == null) {
throw new IllegalArgumentException('''AST was null, compilation unit is not transformed: «element»''')
}
val typeVisitor = new TypeVisitor(umlManipulator)
ast.accept(typeVisitor)
}
val typeVisitor = new TypeVisitor(umlManipulator)
ast.accept(typeVisitor)

return
}

def deleteCorrespondingClass(ICompilationUnit element) {
val packageFragment = element.parent
if(!(packageFragment instanceof IPackageFragment)) {
throw new IllegalArgumentException('''Compilation unit is not in a package: «element»''')
}
val javaQualifiedName = JDTQualifiedName::create('''«packageFragment.elementName».«element.elementName»''').parent.get
val umlQualifiedName = UMLQualifiedName::create(javaQualifiedName)

deleteClass(umlQualifiedName)
}

}

This file was deleted.

3 changes: 2 additions & 1 deletion com.incquerylabs.evm.jdt/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Bundle-SymbolicName: com.incquerylabs.evm.jdt
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.incquerylabs.evm.jdt,
com.incquerylabs.evm.jdt.job
com.incquerylabs.evm.jdt.job,
com.incquerylabs.evm.jdt.util
Require-Bundle: org.eclipse.incquery.runtime.evm;bundle-version="1.0.1",
org.eclipse.jdt.core;bundle-version="3.11.1",
com.google.guava;bundle-version="15.0.0",
Expand Down

0 comments on commit f281a87

Please sign in to comment.