use of com.google.api.codegen.util.TypeAlias in project toolkit by googleapis.
the class GoImportSectionTransformer method generateImportSection.
public ImportSectionView generateImportSection(Map<String, TypeAlias> typeImports) {
ImmutableList.Builder<ImportFileView> standardImports = ImmutableList.builder();
ImmutableList.Builder<ImportFileView> externalImports = ImmutableList.builder();
for (TypeAlias alias : typeImports.values()) {
String importPath = alias.getFullName();
ImportTypeView.Builder imp = ImportTypeView.newBuilder();
imp.fullName('"' + importPath + '"');
imp.nickname(alias.getNickname());
imp.type(alias.getImportType());
ImmutableList.Builder<ImportFileView> target = isStandardImport(importPath) ? standardImports : externalImports;
target.add(ImportFileView.newBuilder().types(ImmutableList.of(imp.build())).build());
}
return ImportSectionView.newBuilder().standardImports(standardImports.build()).externalImports(externalImports.build()).build();
}
use of com.google.api.codegen.util.TypeAlias in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateStubInterface.
private StaticLangStubInterfaceView generateStubInterface(InterfaceContext context, GapicProductConfig productConfig) {
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
addStubInterfaceImports(context);
// Stub class has different default package name from methods classes.
InterfaceContext apiMethodsContext = context.withNewTypeTable(context.getNamer().getRootPackageName());
List<StaticLangApiMethodView> methods = javaApiMethodTransformer.generateApiMethods(apiMethodsContext);
for (TypeAlias alias : apiMethodsContext.getImportTypeTable().getTypeTable().getAllImports().values()) {
context.getImportTypeTable().getAndSaveNicknameFor(alias);
}
StaticLangStubInterfaceView.Builder stubInterface = StaticLangStubInterfaceView.newBuilder();
stubInterface.doc(serviceTransformer.generateServiceDoc(context, null, productConfig));
String name = context.getNamer().getApiStubInterfaceName(context.getInterfaceConfig());
stubInterface.releaseLevelAnnotation(context.getNamer().getReleaseAnnotation(productConfig.getReleaseLevel()));
stubInterface.name(name);
stubInterface.callableMethods(filterIncludeCallableMethods(methods));
stubInterface.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
return stubInterface.build();
}
use of com.google.api.codegen.util.TypeAlias in project toolkit by googleapis.
the class PythonTypeTable method getImports.
@Override
public Map<String, TypeAlias> getImports() {
ImmutableMap.Builder<String, TypeAlias> imports = ImmutableMap.builder();
for (Collection<TypeAlias> aliases : moduleImports.asMap().values()) {
TypeAlias alias = aliases.iterator().next();
imports.put(alias.getFullName(), alias);
}
return imports.build();
}
Aggregations