Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ProB Rodin Plugin
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
ProB Rodin Plugin
Commits
eaf30ff0
Commit
eaf30ff0
authored
12 years ago
by
Sebastian Krings
Browse files
Options
Downloads
Patches
Plain Diff
insert results of unit analysis in the inferredUnitPragma text fields
parent
69181ee0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
de.prob.ui/src/de/prob/ui/eventb/StartUnitAnalysisHandler.java
+74
-6
74 additions, 6 deletions
...ob.ui/src/de/prob/ui/eventb/StartUnitAnalysisHandler.java
with
74 additions
and
6 deletions
de.prob.ui/src/de/prob/ui/eventb/StartUnitAnalysisHandler.java
+
74
−
6
View file @
eaf30ff0
...
@@ -7,7 +7,9 @@
...
@@ -7,7 +7,9 @@
package
de.prob.ui.eventb
;
package
de.prob.ui.eventb
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.eclipse.core.commands.AbstractHandler
;
import
org.eclipse.core.commands.AbstractHandler
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionEvent
;
...
@@ -23,20 +25,25 @@ import org.eclipse.core.resources.IResourceDelta;
...
@@ -23,20 +25,25 @@ import org.eclipse.core.resources.IResourceDelta;
import
org.eclipse.core.resources.ResourcesPlugin
;
import
org.eclipse.core.resources.ResourcesPlugin
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.IPath
;
import
org.eclipse.core.runtime.IPath
;
import
org.eclipse.core.runtime.NullProgressMonitor
;
import
org.eclipse.jface.action.IAction
;
import
org.eclipse.jface.action.IAction
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.eventb.core.IConstant
;
import
org.eventb.core.IContextRoot
;
import
org.eventb.core.IContextRoot
;
import
org.eventb.core.IEventBRoot
;
import
org.eventb.core.IEventBRoot
;
import
org.eventb.core.IMachineRoot
;
import
org.eventb.core.IMachineRoot
;
import
org.eventb.core.IVariable
;
import
org.rodinp.core.IRodinFile
;
import
org.rodinp.core.IRodinFile
;
import
org.rodinp.core.RodinCore
;
import
org.rodinp.core.RodinCore
;
import
org.rodinp.core.RodinDBException
;
import
de.prob.core.Animator
;
import
de.prob.core.Animator
;
import
de.prob.core.LimitedLogger
;
import
de.prob.core.LimitedLogger
;
import
de.prob.core.command.ActivateUnitPluginCommand
;
import
de.prob.core.command.ActivateUnitPluginCommand
;
import
de.prob.core.command.ClearMachineCommand
;
import
de.prob.core.command.ClearMachineCommand
;
import
de.prob.core.command.CommandException
;
import
de.prob.core.command.ComposedCommand
;
import
de.prob.core.command.ComposedCommand
;
import
de.prob.core.command.GetPluginResultCommand
;
import
de.prob.core.command.GetPluginResultCommand
;
import
de.prob.core.command.SetPreferencesCommand
;
import
de.prob.core.command.SetPreferencesCommand
;
...
@@ -44,7 +51,12 @@ import de.prob.core.command.StartAnimationCommand;
...
@@ -44,7 +51,12 @@ import de.prob.core.command.StartAnimationCommand;
import
de.prob.core.command.internal.InternalLoadCommand
;
import
de.prob.core.command.internal.InternalLoadCommand
;
import
de.prob.exceptions.ProBException
;
import
de.prob.exceptions.ProBException
;
import
de.prob.logging.Logger
;
import
de.prob.logging.Logger
;
import
de.prob.parser.BindingGenerator
;
import
de.prob.parser.ResultParserException
;
import
de.prob.prolog.term.CompoundPrologTerm
;
import
de.prob.prolog.term.ListPrologTerm
;
import
de.prob.prolog.term.ListPrologTerm
;
import
de.prob.prolog.term.PrologTerm
;
import
de.prob.ui.pragmas.InferredUnitPragma
;
public
class
StartUnitAnalysisHandler
extends
AbstractHandler
implements
public
class
StartUnitAnalysisHandler
extends
AbstractHandler
implements
IHandler
{
IHandler
{
...
@@ -130,20 +142,76 @@ public class StartUnitAnalysisHandler extends AbstractHandler implements
...
@@ -130,20 +142,76 @@ public class StartUnitAnalysisHandler extends AbstractHandler implements
animator
.
execute
(
composed
);
animator
.
execute
(
composed
);
// TODO: get resulting state and fill attributes
// TODO: get resulting state and fill attributes
GetPluginResultCommand
stateValues
Command
=
new
GetPluginResultCommand
(
GetPluginResultCommand
pluginResult
Command
=
new
GetPluginResultCommand
(
"Grounded Result State"
);
"Grounded Result State"
);
animator
.
execute
(
stateValues
Command
);
animator
.
execute
(
pluginResult
Command
);
ListPrologTerm
output
=
stateValuesCommand
.
getResult
();
ListPrologTerm
output
=
pluginResultCommand
.
getResult
();
System
.
out
.
println
(
"Resulting state: "
+
output
);
System
.
out
.
println
(
output
);
// preprocess the list into a map
Map
<
String
,
String
>
variables
=
new
HashMap
<
String
,
String
>();
for
(
PrologTerm
term
:
output
)
{
CompoundPrologTerm
compoundTerm
;
try
{
compoundTerm
=
BindingGenerator
.
getCompoundTerm
(
term
,
"bind"
,
2
);
}
catch
(
ResultParserException
e
)
{
CommandException
commandException
=
new
CommandException
(
e
.
getLocalizedMessage
(),
e
);
commandException
.
notifyUserOnce
();
throw
commandException
;
}
variables
.
put
(
compoundTerm
.
getArgument
(
1
).
toString
(),
compoundTerm
.
getArgument
(
2
).
toString
());
}
// look up the variables / constants of the selected machine in
// the state
// and set the inferredUnitPragma attribute
if
(
rootElement
instanceof
IMachineRoot
)
{
// find and update variables
IVariable
[]
allVariables
=
rootElement
.
getMachineRoot
()
.
getVariables
();
for
(
IVariable
var
:
allVariables
)
{
String
variableName
=
var
.
getIdentifierString
();
if
(
variables
.
containsKey
(
variableName
))
{
var
.
setAttributeValue
(
InferredUnitPragma
.
ATTRIBUTE
,
variables
.
get
(
variableName
),
new
NullProgressMonitor
());
}
}
}
else
if
(
rootElement
instanceof
IContextRoot
)
{
// find and update constants
IConstant
[]
allConstants
=
rootElement
.
getContextRoot
()
.
getConstants
();
for
(
IConstant
var
:
allConstants
)
{
String
constantName
=
var
.
getIdentifierString
();
if
(
variables
.
containsKey
(
constantName
))
{
var
.
setAttributeValue
(
InferredUnitPragma
.
ATTRIBUTE
,
variables
.
get
(
constantName
),
new
NullProgressMonitor
());
}
}
}
else
{
throw
new
ExecutionException
(
"Cannot translate anything else than IMachineRoot or IContextRoot. Type of "
+
rootElement
.
getComponentName
()
+
" was: "
+
rootElement
.
getClass
());
}
// shutdown animator
// shutdown animator
animator
.
shutdown
();
animator
.
shutdown
();
}
catch
(
ProBException
e
)
{
}
catch
(
ProBException
e
)
{
e
.
notifyUserOnce
();
e
.
notifyUserOnce
();
throw
new
ExecutionException
(
"Loading the machine failed"
,
e
);
throw
new
ExecutionException
(
"Unit Analysis Failed"
,
e
);
}
catch
(
RodinDBException
e
)
{
throw
new
ExecutionException
(
"Unit Analysis Failed with a RodinDBException"
,
e
);
}
}
}
}
return
null
;
return
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment