Skip to content

Commit

Permalink
JmlClauseIfClause and JmlCallableClause
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon committed May 2, 2024
1 parent ba3385f commit f2ef7f2
Show file tree
Hide file tree
Showing 58 changed files with 1,050 additions and 200 deletions.
12 changes: 9 additions & 3 deletions JmlMetaModel.plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,16 @@ enum JmlClauseKind {
DIVERGES_REDUNDANTLY
DURATION
DURATION_REDUNDANTLY
WHEN
WHEN_REDUNDANTLY
NONE

}

class JmlClauseIf extends JmlClause
class JmlClauseIf extends JmlClause {
then : Java.Expression
cond : Java.Expression
}
class JmlMultiExprClause extends JmlClause {
heaps : NodeList<SimpleName>
}
Expand All @@ -174,12 +180,12 @@ class JmlOldClause extends JmlClause {
declarations : Java.VariableDeclarationExpr
}
class JmlCallableClause extends JmlClause {

pre : Java.Expression
methodCalls : List<Java.MethodCallExpr>
}
class JmlForallClause extends JmlClause {
boundedVariables : NodeList<Parameter>
}
class JmlCapturesClause extends JmlClause
class JmlSignalsClause extends JmlClause {
parameter: Java.Parameter
expression: Java.Expression
Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-generators/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.10-SNAPSHOT</version>
<version>3.25.10-b2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-metamodel-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.10-SNAPSHOT</version>
<version>3.25.10-b2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public class MetaModelGenerator extends AbstractGenerator {
add(JmlForallClause.class);
add(JmlOldClause.class);
add(JmlCallableClause.class);
add(JmlClauseIf.class);
add(JmlMethodSignature.class);
add(com.github.javaparser.ast.jml.clauses.JmlContract.class);

//add(com.github.javaparser.ast.JmlBoundVariable.class);
Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-serialization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.10-SNAPSHOT</version>
<version>3.25.10-b2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-testing-bdd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.10-SNAPSHOT</version>
<version>3.25.10-b2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion javaparser-core-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.10-SNAPSHOT</version>
<version>3.25.10-b2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion javaparser-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>jmlparser-parent</artifactId>
<groupId>io.github.jmltoolkit</groupId>
<version>3.25.10-SNAPSHOT</version>
<version>3.25.10-b2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,10 @@ public boolean remove(Node node) {
if (node == null) {
return false;
}
if (contracts != null) {
for (int i = 0; i < contracts.size(); i++) {
if (contracts.get(i) == node) {
contracts.remove(i);
return true;
}
for (int i = 0; i < contracts.size(); i++) {
if (contracts.get(i) == node) {
contracts.remove(i);
return true;
}
}
for (int i = 0; i < modifiers.size(); i++) {
Expand Down Expand Up @@ -355,12 +353,10 @@ public boolean replace(Node node, Node replacementNode) {
if (node == null) {
return false;
}
if (contracts != null) {
for (int i = 0; i < contracts.size(); i++) {
if (contracts.get(i) == node) {
contracts.set(i, (JmlContract) replacementNode);
return true;
}
for (int i = 0; i < contracts.size(); i++) {
if (contracts.get(i) == node) {
contracts.set(i, (JmlContract) replacementNode);
return true;
}
}
for (int i = 0; i < modifiers.size(); i++) {
Expand Down Expand Up @@ -456,6 +452,7 @@ public NodeList<JmlContract> getContracts() {
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
@SuppressWarnings("unchecked")
public T setContracts(final NodeList<JmlContract> contracts) {
assertNotNull(contracts);
if (contracts == this.contracts) {
return (T) this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ public boolean remove(Node node) {
if (node == null) {
return false;
}
for (int i = 0; i < contracts.size(); i++) {
if (contracts.get(i) == node) {
contracts.remove(i);
return true;
}
}
for (int i = 0; i < parameters.size(); i++) {
if (parameters.get(i) == node) {
parameters.remove(i);
Expand Down Expand Up @@ -236,6 +242,12 @@ public boolean replace(Node node, Node replacementNode) {
setBody((Statement) replacementNode);
return true;
}
for (int i = 0; i < contracts.size(); i++) {
if (contracts.get(i) == node) {
contracts.set(i, (JmlContract) replacementNode);
return true;
}
}
for (int i = 0; i < parameters.size(); i++) {
if (parameters.get(i) == node) {
parameters.set(i, (Parameter) replacementNode);
Expand Down Expand Up @@ -284,14 +296,22 @@ public boolean isExplicitlyTyped() {
return getParameters().stream().allMatch(p -> !(p.getType().isUnknownType()));
}

@Override
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
public NodeList<JmlContract> getContracts() {
return contracts;
}

@Override
public LambdaExpr setContracts(NodeList<JmlContract> contracts) {
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
public LambdaExpr setContracts(final NodeList<JmlContract> contracts) {
assertNotNull(contracts);
if (contracts == this.contracts) {
return this;
}
notifyPropertyChange(ObservableProperty.CONTRACTS, this.contracts, contracts);
if (this.contracts != null)
this.contracts.setParentNode(null);
this.contracts = contracts;
setAsParentNodeOf(contracts);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,32 @@
import com.github.javaparser.TokenRange;
import com.github.javaparser.ast.AllFieldsConstructor;
import com.github.javaparser.ast.Generated;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.expr.SimpleName;
import com.github.javaparser.ast.visitor.CloneVisitor;
import com.github.javaparser.ast.visitor.GenericVisitor;
import com.github.javaparser.ast.visitor.VoidVisitor;
import com.github.javaparser.metamodel.JavaParserMetaModel;
import com.github.javaparser.metamodel.JmlCallableClauseMetaModel;
import com.github.javaparser.ast.Node;

import java.util.Optional;
import java.util.function.Consumer;

import com.github.javaparser.ast.observer.ObservableProperty;

import static com.github.javaparser.utils.Utils.assertNotNull;

/**
* @author Alexander Weigl
* @version 1 (2/22/21)
*/
public class JmlCallableClause extends JmlClause {

private NodeList<JmlMethodSignature> methodSignatures = new NodeList<JmlMethodSignature>();

@AllFieldsConstructor
public JmlCallableClause() {
this(null);
public JmlCallableClause(SimpleName name, NodeList<JmlMethodSignature> methodSignatures) {
super(name);
}

/**
Expand Down Expand Up @@ -63,21 +70,85 @@ public JmlClauseKind getKind() {
}

@Override
@Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
public boolean isJmlCallableClause() {
return true;
}

@Override
@Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
public JmlCallableClause asJmlCallableClause() {
return this;
}

@Override
@Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
public Optional<JmlCallableClause> toJmlCallableClause() {
return Optional.of(this);
}

@Override
@Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
public void ifJmlCallableClause(Consumer<JmlCallableClause> action) {
action.accept(this);
}

@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
public NodeList<JmlMethodSignature> getMethodSignatures() {
return methodSignatures;
}

@Generated("com.github.javaparser.generator.core.node.PropertyGenerator")
public JmlCallableClause setMethodSignatures(final NodeList<JmlMethodSignature> methodSignatures) {
assertNotNull(methodSignatures);
if (methodSignatures == this.methodSignatures) {
return this;
}
notifyPropertyChange(ObservableProperty.METHOD_SIGNATURES, this.methodSignatures, methodSignatures);
if (this.methodSignatures != null)
this.methodSignatures.setParentNode(null);
this.methodSignatures = methodSignatures;
setAsParentNodeOf(methodSignatures);
return this;
}

@Override
@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
public boolean remove(Node node) {
if (node == null) {
return false;
}
for (int i = 0; i < methodSignatures.size(); i++) {
if (methodSignatures.get(i) == node) {
methodSignatures.remove(i);
return true;
}
}
return super.remove(node);
}

@Override
@Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator")
public boolean replace(Node node, Node replacementNode) {
if (node == null) {
return false;
}
for (int i = 0; i < methodSignatures.size(); i++) {
if (methodSignatures.get(i) == node) {
methodSignatures.set(i, (JmlMethodSignature) replacementNode);
return true;
}
}
return super.replace(node, replacementNode);
}

/**
* This constructor is used by the parser and is considered private.
*/
@Generated("com.github.javaparser.generator.core.node.MainConstructorGenerator")
public JmlCallableClause(TokenRange tokenRange, SimpleName name, NodeList<JmlMethodSignature> methodSignatures) {
super(tokenRange, name);
setMethodSignatures(methodSignatures);
customInitialization();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* @author Alexander Weigl
* @version 1 (2/22/21)
*/
// in favour of JmlMultiExprClause
@Deprecated()
public class JmlCapturesClause extends JmlClause {

@AllFieldsConstructor
Expand Down
Loading

0 comments on commit f2ef7f2

Please sign in to comment.