Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
languages
EmbeddedMontiArc
Commits
0cd5855b
Commit
0cd5855b
authored
Oct 12, 2017
by
Sascha Niklas Schneiders
Browse files
updated cocos
parent
c5b75073
Changes
3
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
0cd5855b
...
...
@@ -376,14 +376,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
</configuration>
</plugin>
</plugins>
</build>
...
...
src/main/java/de/monticore/lang/embeddedmontiarc/cocos/ConnectorEndPointCorrectlyQualified.java
View file @
0cd5855b
...
...
@@ -29,47 +29,48 @@ import java.util.function.Predicate;
/**
* @author Crispin Kirchner
*
*
* Implementation of CO1 and CO2
*/
public
class
ConnectorEndPointCorrectlyQualified
implements
EmbeddedMontiArcASTConnectorCoCo
{
private
void
checkEndpointCorrectlyQualified
(
ASTQualifiedNameWithArray
name
,
Predicate
<
Integer
>
predicate
,
String
errorMessage
)
{
int
i
=
0
;
if
(
name
.
getCompName
()
!=
null
)
++
i
;
if
(
name
.
getPortName
()
!=
null
)
++
i
;
//if (!predicate.test(name.getParts().size())) {
if
(!
predicate
.
test
(
i
)){
Log
.
error
(
String
.
format
(
errorMessage
,
name
.
toString
()),
name
.
get_SourcePositionStart
());
implements
EmbeddedMontiArcASTConnectorCoCo
{
private
void
checkEndpointCorrectlyQualified
(
ASTQualifiedNameWithArray
name
,
Predicate
<
Integer
>
predicate
,
String
errorMessage
)
{
int
i
=
0
;
if
(
name
.
getCompName
()
!=
null
)
++
i
;
if
(
name
.
getPortName
()
!=
null
)
++
i
;
//if (!predicate.test(name.getParts().size())) {
if
(!
predicate
.
test
(
i
))
{
Log
.
error
(
String
.
format
(
errorMessage
,
name
.
toString
()),
name
.
get_SourcePositionStart
());
}
}
}
/**
* Ensure that the connector endpoint is of the form `rootComponentPort' or `subComponent.port'
*/
private
void
checkEndPointMaximallyTwiceQualified
(
ASTQualifiedNameWithArray
name
)
{
checkEndpointCorrectlyQualified
(
name
,
i
->
i
<=
2
&&
i
>
0
,
"0xDB61C Connector endVal point \"%s\" must only consist of an optional component name and a port name"
);
}
/**
* @see EmbeddedMontiArcASTConnectorCoCo#check(ASTConnector)
*/
@Override
public
void
check
(
ASTConnector
node
)
{
if
(
node
.
getSource
().
isPresent
())
{
checkEndPointMaximallyTwiceQualified
(
node
.
getSource
().
get
());
}
else
{
Log
.
error
(
"Error Connector has no valid source or constant"
);
/**
* Ensure that the connector endpoint is of the form `rootComponentPort' or `subComponent.port'
*/
private
void
checkEndPointMaximallyTwiceQualified
(
ASTQualifiedNameWithArray
name
)
{
checkEndpointCorrectlyQualified
(
name
,
i
->
i
<=
2
&&
i
>
0
,
"0xDB61C Connector endVal point \"%s\" must only consist of an optional component name and a port name"
);
}
for
(
ASTQualifiedNameWithArray
name
:
node
.
getTargets
())
{
checkEndPointMaximallyTwiceQualified
(
name
);
/**
* @see EmbeddedMontiArcASTConnectorCoCo#check(ASTConnector)
*/
@Override
public
void
check
(
ASTConnector
node
)
{
if
(
node
.
getSource
().
isPresent
())
{
checkEndPointMaximallyTwiceQualified
(
node
.
getSource
().
get
());
}
else
{
if
(!
node
.
getUnitNumberResolution
().
isPresent
()
&&
!
node
.
getBoolLiteral
().
isPresent
())
Log
.
error
(
"Error Connector has no valid source or constant "
+
node
.
toString
());
}
for
(
ASTQualifiedNameWithArray
name
:
node
.
getTargets
())
{
checkEndPointMaximallyTwiceQualified
(
name
);
}
}
}
}
src/main/java/de/monticore/lang/embeddedmontiarc/cocos/TypeParameterNamesUnique.java
View file @
0cd5855b
...
...
@@ -36,29 +36,27 @@ import java.util.List;
*/
public
class
TypeParameterNamesUnique
implements
EmbeddedMontiArcASTComponentHeadCoCo
{
/**
* @see de.monticore.lang.embeddedmontiarc.embeddedmontiarc._cocos.EmbeddedMontiArcASTComponentCoCo#check(de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent)
*/
@Override
public
void
check
(
ASTComponentHead
node
)
{
ASTTypeParameters
typeParameters
=
node
.
getGenericTypeParameters
().
orElse
(
null
);
if
(
typeParameters
==
null
)
{
return
;
/**
* @see de.monticore.lang.embeddedmontiarc.embeddedmontiarc._cocos.EmbeddedMontiArcASTComponentCoCo#check(de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent)
*/
@Override
public
void
check
(
ASTComponentHead
node
)
{
ASTTypeParameters
typeParameters
=
node
.
getGenericTypeParameters
().
orElse
(
null
);
if
(
typeParameters
==
null
)
{
return
;
}
List
<
String
>
typeParameterNames
=
new
ArrayList
<>();
for
(
ASTTypeVariableDeclaration
typeParameter
:
typeParameters
.
getTypeVariableDeclarations
())
{
if
(
typeParameter
.
getNamingResolution
().
isPresent
()
&&
typeParameterNames
.
contains
(
typeParameter
.
getNamingResolution
().
get
().
getName
()))
{
Log
.
error
(
String
.
format
(
"0x35F1A The formal type parameter name \"%s\" is not unique"
,
typeParameter
.
getNamingResolution
().
get
().
getName
()),
typeParameter
.
get_SourcePositionStart
());
}
else
{
//typeParameterNames.add(typeParameter.getNamingResolution().get().getName());
}
}
}
List
<
String
>
typeParameterNames
=
new
ArrayList
<>();
for
(
ASTTypeVariableDeclaration
typeParameter
:
typeParameters
.
getTypeVariableDeclarations
())
{
if
(
typeParameterNames
.
contains
(
typeParameter
.
getNamingResolution
().
get
().
getName
()))
{
Log
.
error
(
String
.
format
(
"0x35F1A The formal type parameter name \"%s\" is not unique"
,
typeParameter
.
getNamingResolution
().
get
().
getName
()),
typeParameter
.
get_SourcePositionStart
());
}
else
{
typeParameterNames
.
add
(
typeParameter
.
getNamingResolution
().
get
().
getName
());
}
}
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment