Skip to content
Snippets Groups Projects
Commit d492f921 authored by Jesper's avatar Jesper
Browse files

[cleanup] Replace string concatenation with format strings

parent 8f1e4709
No related branches found
No related tags found
No related merge requests found
...@@ -540,13 +540,15 @@ public aspect Attributes { ...@@ -540,13 +540,15 @@ public aspect Attributes {
public void TypeDecl.refineWith(SynEq equ, SynEq refinedEqu) { public void TypeDecl.refineWith(SynEq equ, SynEq refinedEqu) {
StringBuffer s = new StringBuffer(); StringBuffer s = new StringBuffer();
String newMethodName = "refined_" + equ.aspectName() + "_" + name() + "_" + equ.signature(); String newMethodName
= String.format("refined_%s_%s_%s", equ.aspectName(), name(), equ.signature());
if (equ.decl() == null) { if (equ.decl() == null) {
throw new Error("Error: could not find declaration of refined synthesized equation " throw new Error(String.format(
+ equ.name() + " (" + equ.getFileName() + ":" + equ.getStartLine() + ")"); "Error: could not find declaration of refined synthesized equation %s (%s:%d)",
equ.name(), equ.getFileName(), equ.getStartLine()));
} }
s.append("private " + equ.decl().getType() + " " + newMethodName + "(" s.append(String.format("private %s %s(%s)\n",
+ equ.parametersDecl() + ")\n"); equ.decl().getType(), newMethodName, equ.parametersDecl()));
if (equ.getRHS() instanceof ASTBlock) { if (equ.getRHS() instanceof ASTBlock) {
s.append(Unparser.unparse(equ.getRHS())); s.append(Unparser.unparse(equ.getRHS()));
} else { } else {
...@@ -689,8 +691,8 @@ public aspect Attributes { ...@@ -689,8 +691,8 @@ public aspect Attributes {
} }
} }
s.append("private " + equ.decl().getType() + " " + newMethodName + "(" + s.append(String.format("private %s %s(%s%s)\n",
indexDecl + equ.parametersDecl() + ")\n"); equ.decl().getType(), newMethodName, indexDecl, equ.parametersDecl()));
if (equ.getRHS() instanceof ASTBlock) { if (equ.getRHS() instanceof ASTBlock) {
s.append(Unparser.unparse(equ.getRHS())); s.append(Unparser.unparse(equ.getRHS()));
} else { } else {
...@@ -785,8 +787,9 @@ public aspect Attributes { ...@@ -785,8 +787,9 @@ public aspect Attributes {
if (refinedDecl == null) { if (refinedDecl == null) {
refinedDecl = refinedCandidate; refinedDecl = refinedCandidate;
} else { } else {
grammar().error("refinement previously defined at " grammar().error(
+ refinedCandidate.getFileName() + ":" + refinedCandidate.getStartLine(), String.format("refinement previously defined at %s:%s",
refinedCandidate.getFileName(), refinedCandidate.getStartLine()),
refinedDecl.getFileName(), refinedDecl.getStartLine()); refinedDecl.getFileName(), refinedDecl.getStartLine());
} }
outerIter.remove(); outerIter.remove();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment