Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
languages
EmbeddedMontiArc
Commits
b501d3f2
Commit
b501d3f2
authored
Oct 09, 2017
by
Yannick Deuster
Browse files
added "getEnclosingScope" to ElementInstance
parent
57df8680
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/ComponentInstanceSymbol.java
View file @
b501d3f2
...
...
@@ -36,7 +36,7 @@ import java.util.Optional;
*
* @author Robert Heim
*/
public
class
ComponentInstanceSymbol
extends
TaggingScopeSpanningSymbol
{
public
class
ComponentInstanceSymbol
extends
TaggingScopeSpanningSymbol
implements
ElementInstance
{
public
static
final
EMAComponentInstanceKind
KIND
=
EMAComponentInstanceKind
.
INSTANCE
;
...
...
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/ElementInstance.java
View file @
b501d3f2
...
...
@@ -2,6 +2,7 @@ package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import
de.monticore.lang.montiarc.tagging._symboltable.TagKind
;
import
de.monticore.lang.montiarc.tagging._symboltable.TagSymbol
;
import
de.monticore.symboltable.Scope
;
import
java.util.Collection
;
...
...
@@ -13,4 +14,5 @@ public interface ElementInstance {
public
Collection
<
TagSymbol
>
getTags
();
public
<
T
extends
TagSymbol
>
Collection
<
T
>
getTags
(
final
TagKind
tagKind
);
public
String
getName
();
public
Scope
getEnclosingScope
()
;
}
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/PortSymbol.java
View file @
b501d3f2
...
...
@@ -262,4 +262,48 @@ public class PortSymbol extends TaggingSymbol implements ElementInstance {
public
boolean
isPartOfPortArray
()
{
return
getName
().
contains
(
"["
)
&&
getName
().
contains
(
"]"
);
}
/**
* if model input is;
* component X {
* port ...;
*
* component A {
* port in Integer p1,
* out Integer p2;
* }
*
* component A a1, a2, a3;
*
* connect a1.p2 -> a2.p1, a3.p1;
* }
*
* if I have the port symbol a1.p2 than this method returns the list of port symbols {a2.p1, a3.p1}
* @return
*/
public
List
<
PortSymbol
>
getTargetConnectedPorts
(
ExpandedComponentInstanceSymbol
topComponent
)
{
//It does not works for components, when one of them is top component and another not.
List
<
PortSymbol
>
targetPorts
=
new
ArrayList
<>();
if
(!
topComponent
.
getConnectors
().
equals
(
null
))
{
//If the port is Outgoing then return incoming ports of connected components
if
(
this
.
isOutgoing
())
{
topComponent
.
getConnectors
().
stream
()
.
filter
(
s
->
s
.
getSourcePort
().
equals
(
this
))
.
forEach
(
s
->
targetPorts
.
add
(
s
.
getTargetPort
()));
}
else
if
(
this
.
isIncoming
())
{
//If the port is incoming then return outgoing ports of connected components
topComponent
.
getConnectors
().
stream
()
.
filter
(
s
->
s
.
getTargetPort
().
equals
(
this
))
.
forEach
(
s
->
targetPorts
.
add
(
s
.
getSourcePort
()));
}
}
return
targetPorts
;
//TODO: Find the way to get connections from the top element
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment