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
2ce9aa21
Verified
Commit
2ce9aa21
authored
Jan 20, 2018
by
Stefan Brunecker
Browse files
Improve performance
parent
c93f27a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/embeddedmontiarc/embeddedmontiarc/_symboltable/ExpandedComponentInstanceSymbol.java
View file @
2ce9aa21
...
...
@@ -289,41 +289,47 @@ public class ExpandedComponentInstanceSymbol
* @return
*/
public
List
<
ConnectorSymbol
>
getSubComponentConnectors
()
{
List
<
ConnectorSymbol
>
list
=
new
ArrayList
<>();
for
(
ConnectorSymbol
connectorSymbol
:
getConnectors
())
{
for
(
ExpandedComponentInstanceSymbol
symbol
:
getSubComponents
())
{
for
(
ExpandedComponentInstanceSymbol
symbol2
:
getSubComponents
())
{
if
(
symbol
.
containsPort
(
connectorSymbol
.
getSourcePort
())
&&
symbol2
.
containsPort
(
connectorSymbol
.
getTargetPort
()))
{
if
(!
list
.
contains
(
connectorSymbol
))
list
.
add
(
connectorSymbol
);
}
Set
<
ConnectorSymbol
>
set
=
new
LinkedHashSet
<>();
Collection
<
ConnectorSymbol
>
connectors
=
getConnectors
();
Collection
<
ExpandedComponentInstanceSymbol
>
subComponents
=
getSubComponents
();
for
(
ConnectorSymbol
connector
:
connectors
)
{
PortSymbol
sourcePort
=
connector
.
getSourcePort
();
PortSymbol
targetPort
=
connector
.
getTargetPort
();
Optional
<
ExpandedComponentInstanceSymbol
>
sourceCmpOpt
=
sourcePort
.
getComponentInstance
();
Optional
<
ExpandedComponentInstanceSymbol
>
targetCmpOpt
=
targetPort
.
getComponentInstance
();
if
(
sourceCmpOpt
.
isPresent
()
&&
targetCmpOpt
.
isPresent
())
{
ExpandedComponentInstanceSymbol
sourceCmp
=
sourceCmpOpt
.
get
();
ExpandedComponentInstanceSymbol
targetCmp
=
targetCmpOpt
.
get
();
if
(
subComponents
.
contains
(
sourceCmp
)
&&
subComponents
.
contains
(
targetCmp
))
{
set
.
add
(
connector
);
}
}
}
return
list
;
return
new
ArrayList
<>(
set
);
}
public
List
<
ExpandedComponentInstanceSymbol
>
getIndependentSubComponents
()
{
List
<
ExpandedComponentInstanceSymbol
>
instances
=
new
ArrayList
<>();
for
(
ExpandedComponentInstanceSymbol
symbol
:
getSubComponents
())
{
boolean
noInputDependency
=
true
;
for
(
PortSymbol
portSymbol
:
symbol
.
getOutgoingPorts
())
{
for
(
ConnectorSymbol
connectorSymbol
:
getSubComponentConnectors
())
{
if
(
portSymbol
.
equals
(
connectorSymbol
.
getSourcePort
())
||
portSymbol
.
equals
(
connectorSymbol
.
getTargetPort
()))
{
noInputDependency
=
false
;
}
}
Collection
<
ExpandedComponentInstanceSymbol
>
subComponents
=
getSubComponents
();
List
<
ConnectorSymbol
>
subComponentConnectors
=
getSubComponentConnectors
();
Set
<
ExpandedComponentInstanceSymbol
>
nonIndependentSubComponents
=
new
HashSet
<>();
for
(
ConnectorSymbol
connector
:
subComponentConnectors
)
{
PortSymbol
sourcePort
=
connector
.
getSourcePort
();
Optional
<
ExpandedComponentInstanceSymbol
>
sourceCmpOpt
=
sourcePort
.
getComponentInstance
();
if
(
sourceCmpOpt
.
isPresent
())
{
ExpandedComponentInstanceSymbol
sourceCmp
=
sourceCmpOpt
.
get
();
nonIndependentSubComponents
.
add
(
sourceCmp
);
}
if
(
noInputDependency
)
{
instances
.
add
(
symbol
);
}
}
return
instances
;
List
<
ExpandedComponentInstanceSymbol
>
independentSubComponents
=
new
ArrayList
<>(
subComponents
);
independentSubComponents
.
removeAll
(
nonIndependentSubComponents
);
return
new
ArrayList
<>(
independentSubComponents
);
}
public
boolean
isTemplateComponent
()
{
...
...
Write
Preview
Markdown
is supported
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