use of com.sonar.sslr.api.AstNode in project magik-tools by StevenLooman.
the class NewDocParserTest method testParameterEmpty.
@Test
void testParameterEmpty() throws IOException {
final String code = "" + "_method a.b(param1, param2) << param3\n" + " ## @param \n" + " ## @param param1\n" + " ## @param {integer} param2\n" + " ## @param {integer} param3 \n" + " ## @param {integer|float} param4\n" + "_endmethod";
final AstNode topNode = this.parseMagik(code);
final AstNode methodNode = topNode.getFirstChild(MagikGrammar.METHOD_DEFINITION);
final NewDocParser docParser = new NewDocParser(methodNode);
final Map<String, String> parameterTypes = docParser.getParameterTypes();
assertThat(parameterTypes).containsOnly(Map.entry("param1", ""), Map.entry("param2", "integer"), Map.entry("param3", "integer"), Map.entry("param4", "integer|float"));
}
use of com.sonar.sslr.api.AstNode in project magik-tools by StevenLooman.
the class NewDocParserTest method testReturnEmpty.
@Test
void testReturnEmpty() throws IOException {
final String code = "" + "_method a.b\n" + " ## @return \n" + " ## @return {sw:integer}\n" + " ## @return {sw:integer} \n" + " ## @return {sw:integer|sw:float}\n" + "_endmethod";
final AstNode topNode = this.parseMagik(code);
final AstNode methodNode = topNode.getFirstChild(MagikGrammar.METHOD_DEFINITION);
final NewDocParser docParser = new NewDocParser(methodNode);
final List<String> returnTypes = docParser.getReturnTypes();
assertThat(returnTypes).containsExactly("", "sw:integer", "sw:integer", "sw:integer|sw:float");
}
use of com.sonar.sslr.api.AstNode in project magik-tools by StevenLooman.
the class NewDocParserTest method testReturnSelf.
@Test
void testReturnSelf() throws IOException {
final String code = "" + "_method a.b\n" + " ## @return {_self}\n" + "_endmethod";
final AstNode topNode = this.parseMagik(code);
final AstNode methodNode = topNode.getFirstChild(MagikGrammar.METHOD_DEFINITION);
final NewDocParser docParser = new NewDocParser(methodNode);
final List<String> returnTypes = docParser.getReturnTypes();
assertThat(returnTypes).containsExactly("_self");
}
use of com.sonar.sslr.api.AstNode in project magik-tools by StevenLooman.
the class NewDocParserTest method testReturn.
@Test
void testReturn() throws IOException {
final String code = "" + "_method a.b\n" + " ## @return {sw:integer} An Integer.\n" + "_endmethod";
final AstNode topNode = this.parseMagik(code);
final AstNode methodNode = topNode.getFirstChild(MagikGrammar.METHOD_DEFINITION);
final NewDocParser docParser = new NewDocParser(methodNode);
final List<String> returnTypes = docParser.getReturnTypes();
assertThat(returnTypes).containsExactly("sw:integer");
}
use of com.sonar.sslr.api.AstNode in project magik-tools by StevenLooman.
the class NewDocParserTest method testSlotTypes.
@Test
void testSlotTypes() throws IOException {
final String code = "" + "## @slot slot1 Slot 1.\n" + "## @slot {integer} slot2 Slot 2.\n" + "def_slotted_exemplar(:example,\n" + " {\n" + " {:slot1, _unset}\n" + " })\n";
final AstNode topNode = this.parseMagik(code);
final AstNode definitionNode = topNode.getFirstChild(MagikGrammar.STATEMENT);
final NewDocParser docParser = new NewDocParser(definitionNode);
final Map<String, String> slotTypes = docParser.getSlotTypes();
assertThat(slotTypes).containsOnly(Map.entry("slot1", ""), Map.entry("slot2", "integer"));
}
Aggregations