Fully separate AIDL and Java type namespaces
For android::aidl::ValidatableType, rename:
- QualifiedName() -> CanonicalName()
- Name() -> ShortName()
For android::aidl::java::Type, add a new JavaType() method.
Use that method exclusively when generating Java.
Bug: 26875320
Test: unit and integration tests pass
Change-Id: Ib1d09f4f84d3270634e611f0911f60a2e685cefc
diff --git a/ast_java.cpp b/ast_java.cpp
index fae38ca..44e298d 100644
--- a/ast_java.cpp
+++ b/ast_java.cpp
@@ -71,7 +71,7 @@
to->Write("%s\n", this->comment.c_str());
}
WriteModifiers(to, this->modifiers, SCOPE_MASK | STATIC | FINAL | OVERRIDE);
- to->Write("%s %s", this->variable->type->QualifiedName().c_str(),
+ to->Write("%s %s", this->variable->type->JavaType().c_str(),
this->variable->name.c_str());
if (this->value.length() != 0) {
to->Write(" = %s", this->value.c_str());
@@ -102,7 +102,7 @@
for (int i = 0; i < this->dimension; i++) {
dim += "[]";
}
- to->Write("%s%s %s", this->type->QualifiedName().c_str(), dim.c_str(),
+ to->Write("%s%s %s", this->type->JavaType().c_str(), dim.c_str(),
this->name.c_str());
}
@@ -118,7 +118,7 @@
if (this->object != NULL) {
this->object->Write(to);
} else if (this->clazz != NULL) {
- to->Write("%s", this->clazz->QualifiedName().c_str());
+ to->Write("%s", this->clazz->JavaType().c_str());
}
to->Write(".%s", name.c_str());
}
@@ -157,7 +157,7 @@
this->lvalue->Write(to);
to->Write(" = ");
if (this->cast != NULL) {
- to->Write("(%s)", this->cast->QualifiedName().c_str());
+ to->Write("(%s)", this->cast->JavaType().c_str());
}
this->rvalue->Write(to);
}
@@ -203,7 +203,7 @@
this->obj->Write(to);
to->Write(".");
} else if (this->clazz != NULL) {
- to->Write("%s.", this->clazz->QualifiedName().c_str());
+ to->Write("%s.", this->clazz->JavaType().c_str());
}
to->Write("%s(", this->name.c_str());
WriteArgumentList(to, this->arguments);
@@ -247,7 +247,7 @@
: type(t), size(s) {}
void NewArrayExpression::Write(CodeWriter* to) const {
- to->Write("new %s[", this->type->QualifiedName().c_str());
+ to->Write("new %s[", this->type->JavaType().c_str());
size->Write(to);
to->Write("]");
}
@@ -268,7 +268,7 @@
Cast::Cast(const Type* t, Expression* e) : type(t), expression(e) {}
void Cast::Write(CodeWriter* to) const {
- to->Write("((%s)", this->type->QualifiedName().c_str());
+ to->Write("((%s)", this->type->JavaType().c_str());
expression->Write(to);
to->Write(")");
}
@@ -284,7 +284,7 @@
if (this->rvalue != NULL) {
to->Write(" = ");
if (this->cast != NULL) {
- to->Write("(%s)", this->cast->QualifiedName().c_str());
+ to->Write("(%s)", this->cast->JavaType().c_str());
}
this->rvalue->Write(to);
}
@@ -384,7 +384,7 @@
for (i = 0; i < this->returnTypeDimension; i++) {
dim += "[]";
}
- to->Write("%s%s ", this->returnType->QualifiedName().c_str(), dim.c_str());
+ to->Write("%s%s ", this->returnType->JavaType().c_str(), dim.c_str());
}
to->Write("%s(", this->name.c_str());
@@ -406,7 +406,7 @@
} else {
to->Write(", ");
}
- to->Write("%s", this->exceptions[i]->QualifiedName().c_str());
+ to->Write("%s", this->exceptions[i]->JavaType().c_str());
}
if (this->statements == NULL) {
@@ -437,7 +437,7 @@
to->Write("interface ");
}
- string name = this->type->Name();
+ string name = this->type->JavaType();
size_t pos = name.rfind('.');
if (pos != string::npos) {
name = name.c_str() + pos + 1;
@@ -446,7 +446,7 @@
to->Write("%s", name.c_str());
if (this->extends != NULL) {
- to->Write(" extends %s", this->extends->QualifiedName().c_str());
+ to->Write(" extends %s", this->extends->JavaType().c_str());
}
N = this->interfaces.size();
@@ -457,7 +457,7 @@
to->Write(" extends");
}
for (i = 0; i < N; i++) {
- to->Write(" %s", this->interfaces[i]->QualifiedName().c_str());
+ to->Write(" %s", this->interfaces[i]->JavaType().c_str());
}
}