use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSurfaceTransformer method transform.
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = surfaceTransformer.createSurfaceNamer(productConfig);
List<ServiceDocView> serviceDocs = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
if (!productConfig.hasInterfaceConfig(apiInterface)) {
continue;
}
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable);
StaticLangFileView<StaticLangApiView> apiFile = generateApiFile(context, productConfig);
surfaceDocs.add(apiFile);
serviceDocs.add(apiFile.classView().doc());
StaticLangApiMethodView exampleApiMethod = getExampleApiMethod(apiFile.classView().apiMethods());
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangStubSettingsView> stubSettingsFile = generateStubSettingsFile(context, productConfig, exampleApiMethod);
context = context.withNewTypeTable(namer.getRootPackageName());
StaticLangFileView<StaticLangSettingsView> settingsFile = generateSettingsFile(context, productConfig, exampleApiMethod, stubSettingsFile.classView());
surfaceDocs.add(settingsFile);
surfaceDocs.add(stubSettingsFile);
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangStubInterfaceView> stubInterfaceFile = generateStubInterfaceFile(context, productConfig);
surfaceDocs.add(stubInterfaceFile);
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangRpcStubView> grpcStubFile = generateRpcStubClassFile(context, productConfig);
surfaceDocs.add(grpcStubFile);
surfaceDocs.add(generateCallableFactoryClassFile(context, productConfig));
}
PackageInfoView packageInfo = generatePackageInfo(model, productConfig, namer, serviceDocs);
surfaceDocs.add(packageInfo);
return surfaceDocs;
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class CSharpSurfaceNamer method getAndSaveCallerAsyncPagedResponseTypeName.
@Override
public String getAndSaveCallerAsyncPagedResponseTypeName(MethodContext methodContext, FieldConfig resourceFieldConfig) {
ImportTypeTable typeTable = methodContext.getTypeTable();
String outputTypeName = methodContext.getMethodModel().getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer());
String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig);
return typeTable.getAndSaveNicknameForContainer("Google.Api.Gax.PagedAsyncEnumerable", outputTypeName, resourceTypeName);
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class CSharpSurfaceNamer method getAndSaveCallerPagedResponseTypeName.
@Override
public String getAndSaveCallerPagedResponseTypeName(MethodContext methodContext, FieldConfig resourceFieldConfig) {
ImportTypeTable typeTable = methodContext.getTypeTable();
String outputTypeName = methodContext.getMethodModel().getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer());
String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig);
return typeTable.getAndSaveNicknameForContainer("Google.Api.Gax.PagedEnumerable", outputTypeName, resourceTypeName);
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class GoGapicSurfaceTransformer method addXApiImports.
@VisibleForTesting
void addXApiImports(InterfaceContext context, Collection<MethodModel> methods) {
ImportTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("context;;;");
typeTable.saveNicknameFor("math;;;");
typeTable.saveNicknameFor("google.golang.org/grpc;;;");
typeTable.saveNicknameFor("github.com/googleapis/gax-go/v2;gax;;");
typeTable.saveNicknameFor("google.golang.org/api/option;;;");
typeTable.saveNicknameFor("google.golang.org/api/transport;;;");
typeTable.saveNicknameFor("google.golang.org/grpc/metadata;;;");
typeTable.getImports().remove(EMPTY_PROTO_PKG);
addContextImports(context, ImportContext.CLIENT, methods);
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSampleImportTransformer method addOutputImports.
@Override
protected void addOutputImports(MethodContext context, OutputContext outputContext) {
ImportTypeTable typeTable = context.getTypeTable();
OutputTransformer.ScopeTable scopeTable = outputContext.scopeTable();
for (TypeModel type : scopeTable.allTypes()) {
if (type == null) {
saveResourceTypeName(context);
} else {
typeTable.getAndSaveNicknameFor(type);
}
}
if (outputContext.hasMaps()) {
typeTable.getAndSaveNicknameFor("java.util.Map");
}
if (outputContext.hasBytesFileOutput()) {
typeTable.getAndSaveNicknameFor("java.io.FileOutputStream");
typeTable.getAndSaveNicknameFor("java.io.OutputStream");
}
if (outputContext.hasStringFileOutput()) {
typeTable.getAndSaveNicknameFor("java.io.FileWriter");
}
}
Aggregations