Skip to content

Commit

Permalink
Limit @doclink to string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Jan 13, 2024
1 parent 03124da commit 3adc3b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@
import com.fujitsu.vdmj.in.annotations.INAnnotation;
import com.fujitsu.vdmj.in.expressions.INExpression;
import com.fujitsu.vdmj.in.expressions.INExpressionList;
import com.fujitsu.vdmj.in.expressions.INStringLiteralExpression;
import com.fujitsu.vdmj.tc.lex.TCIdentifierToken;

public class INDocLinkAnnotation extends INAnnotation
{
private static final long serialVersionUID = 1L;

public INDocLinkAnnotation(TCIdentifierToken name, INExpressionList args)
{
super(name, args);
}

@Override
public String toString()
{
StringBuilder sb = new StringBuilder();

for (INExpression arg: args)
{
sb.append(arg.toString());
INStringLiteralExpression s = (INStringLiteralExpression) arg;
sb.append(s.value.value);
sb.append("\n");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.fujitsu.vdmj.tc.definitions.TCDefinition;
import com.fujitsu.vdmj.tc.expressions.TCExpression;
import com.fujitsu.vdmj.tc.expressions.TCExpressionList;
import com.fujitsu.vdmj.tc.expressions.TCStringLiteralExpression;
import com.fujitsu.vdmj.tc.lex.TCIdentifierToken;
import com.fujitsu.vdmj.tc.modules.TCModule;
import com.fujitsu.vdmj.tc.statements.TCStatement;
Expand Down Expand Up @@ -122,7 +123,17 @@ public void check()
{
if (args.isEmpty())
{
name.report(6008, "@DocLink(Expression...)");
name.report(6008, "@DocLink(\"arg\"...)");
}
else
{
for (TCExpression arg: args)
{
if (!(arg instanceof TCStringLiteralExpression))
{
arg.report(6008, "@DocLink args must be string literals");
}
}
}
}

Expand Down

0 comments on commit 3adc3b0

Please sign in to comment.