Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a12029e
Ada language support (generic generator)
stcarrez Sep 3, 2017
05a4a28
Ada language support (main generator)
stcarrez Sep 3, 2017
62d1687
Ada language support: register the AdaCodegen generator class
stcarrez Sep 3, 2017
6c7d039
Ada language license template
stcarrez Sep 3, 2017
372ce0d
Ada language model templates (spec and body)
stcarrez Sep 3, 2017
658d04c
Ada language client spec and body templates
stcarrez Sep 3, 2017
458865a
Ada language server spec and body templates
stcarrez Sep 3, 2017
0f91872
Fix escaping Ada keywords for parameter name
stcarrez Sep 9, 2017
dcd99e9
Generate GNAT project and update type mappings
stcarrez Sep 9, 2017
9718d23
Fix generation of operations with no parameters
stcarrez Sep 9, 2017
0b48e3c
Fix instantiation of Ada.Containers.Vectors package in generated mode…
stcarrez Sep 9, 2017
30d287b
New template for the GNAT project file generation
stcarrez Sep 9, 2017
880bb0e
Fix datatype generation for Ada language
stcarrez Sep 10, 2017
44adbe4
Add a Serialize procedure declaration for the Ada model generation
stcarrez Sep 10, 2017
a9b343b
Add a Serialize procedure for the Ada template model generation
stcarrez Sep 10, 2017
9150416
Fix operation name and parameter name for Ada
stcarrez Sep 16, 2017
89914a1
Media type support for Ada code generator
stcarrez Sep 16, 2017
ac65aa3
Use x-has-notes extension to avoid emitting notes when they are empty
stcarrez Sep 16, 2017
01a85a9
First generation for Ada client operation body
stcarrez Sep 16, 2017
f714074
Add a x-has-uniq-produces and x-has-uniq-consumes to media types
stcarrez Sep 16, 2017
6bf87bb
Add a postProcessParameter for Ada code generator to emit a x-is-mode…
stcarrez Sep 17, 2017
839fcfe
Update Ada client body template for the serialization of data
stcarrez Sep 17, 2017
4fc030c
Fix postProcessParameter in Ada code generator to take into account f…
stcarrez Sep 17, 2017
12adeeb
Update the Ada client body to support form parameters
stcarrez Sep 17, 2017
5c9165a
Fix type name used for mapped types in the Ada generator
stcarrez Sep 17, 2017
04dc3f2
Declare a Deserialize procedure for the Ada generated model
stcarrez Sep 17, 2017
4ba4838
Override the fromOperation for Ada client code generator
stcarrez Sep 17, 2017
4a04690
Update the Ada client package spec template to declare the result type
stcarrez Sep 17, 2017
35615fb
Add support to extract response and return result in Ada client code
stcarrez Sep 17, 2017
b7ba0e1
Fix Ada postProcessModels to handle container properties and emit a c…
stcarrez Sep 17, 2017
5a436a6
Add support for Deserialize procedure in the Ada model generator
stcarrez Sep 17, 2017
cd57585
Fix indentation of generated Ada client body package
stcarrez Sep 17, 2017
c2fc0b9
Add projectName option to configure the GNAT project name
stcarrez Sep 17, 2017
39c0a30
Update the GNAT project name for the Ada code generator
stcarrez Sep 17, 2017
74ea12b
Cleanup implementation and remove unused code
stcarrez Oct 1, 2017
e4228fc
Cleanup implementation and remove unused code
stcarrez Oct 1, 2017
6b85484
Merge remote-tracking branch 'upstream/master'
stcarrez Oct 1, 2017
fd750c2
Fix javadoc errors
stcarrez Oct 2, 2017
cae43aa
Use 'ada' for the language name to follow swagger-codegen convention
stcarrez Oct 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
package io.swagger.codegen.languages;

import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.models.properties.Property;

import java.util.Arrays;

abstract public class AbstractAdaCodegen extends DefaultCodegen implements CodegenConfig {

public AbstractAdaCodegen() {
super();

/*
* Reserved words. Override this with reserved words specific to your language
*/
setReservedWordsLowerCase(
Arrays.asList(
"abort",
"abs",
"abstract",
"accept",
"access",
"aliased",
"all",
"and",
"array",
"at",
"begin",
"body",
"case",
"constant",
"declare",
"delay",
"digits",
"do",
"else",
"elsif",
"end",
"entry",
"exception",
"exit",
"for",
"function",
"generic",
"goto",
"if",
"in",
"interface",
"is",
"limited",
"loop",
"mod",
"new",
"not",
"null",
"of",
"or",
"others",
"out",
"overriding",
"package",
"pragma",
"private",
"procedure",
"protected",
"raise",
"range",
"record",
"rem",
"renames",
"requeue",
"return",
"reverse",
"select",
"separate",
"some",
"subtype",
"synchronized",
"tagged",
"task",
"terminate",
"then",
"type",
"until",
"use",
"when",
"while",
"with",
"xor")
);
}

/**
* Turn a parameter name, operation name into an Ada identifier.
*
* Ada programming standard avoid the camelcase syntax and prefer the underscore
* notation. We also have to make sure the identifier is not a reserved keyword.
* When this happens, we add the configurable prefix. The function translates:
*
* body - P_Body
* petId - Pet_Id
* updatePetWithForm - Update_Pet_With_Form
*
* @param name the parameter name.
* @param prefix the optional prefix in case the parameter name is a reserved keyword.
* @return the Ada identifier to be used.
*/
protected String toAdaIdentifier(String name, String prefix) {
// We cannot use reserved keywords for identifiers
if (isReservedWord(name)) {
LOGGER.warn("Identifier '" + name + "' is a reserved word, renamed to " + prefix + name);
name = prefix + name;
}
StringBuilder result = new StringBuilder();
boolean needUpperCase = true;
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (needUpperCase) {
needUpperCase = false;
result.append(Character.toUpperCase(c));

} else if (Character.isUpperCase((c))) {
if (!needUpperCase) {
result.append('_');
}
result.append(c);
needUpperCase = false;
} else {
result.append(c);
if (c == '_') {
needUpperCase = true;
}
}
}
return result.toString();
}

@Override
public String toOperationId(String operationId) {
return toAdaIdentifier(sanitizeName(operationId), "Call_");
}

@Override
public String toVarName(String name) {
return toAdaIdentifier(sanitizeName(name), "P_");
}

@Override
public String toParamName(String name) {
return toAdaIdentifier(super.toParamName(name), "P_");
}

@Override
public CodegenProperty fromProperty(String name, Property p) {
CodegenProperty property = super.fromProperty(name, p);
String nameInCamelCase = property.nameInCamelCase;
nameInCamelCase = sanitizeName(nameInCamelCase);
property.nameInCamelCase = nameInCamelCase;
return property;
}
}
Loading