Search in sources :

Example 6 with TypeAlias

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();
}
Also used : ImportFileView(com.google.api.codegen.viewmodel.ImportFileView) ImmutableList(com.google.common.collect.ImmutableList) ImportTypeView(com.google.api.codegen.viewmodel.ImportTypeView) TypeAlias(com.google.api.codegen.util.TypeAlias)

Example 7 with TypeAlias

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();
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) StaticLangStubInterfaceView(com.google.api.codegen.viewmodel.StaticLangStubInterfaceView) TypeAlias(com.google.api.codegen.util.TypeAlias) InterfaceContext(com.google.api.codegen.config.InterfaceContext)

Example 8 with TypeAlias

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();
}
Also used : TypeAlias(com.google.api.codegen.util.TypeAlias) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

TypeAlias (com.google.api.codegen.util.TypeAlias)8 ImportFileView (com.google.api.codegen.viewmodel.ImportFileView)4 ImportTypeView (com.google.api.codegen.viewmodel.ImportTypeView)4 ImmutableList (com.google.common.collect.ImmutableList)4 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)2 InterfaceContext (com.google.api.codegen.config.InterfaceContext)2 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 com.google.api.codegen.config (com.google.api.codegen.config)1 InitCodeLineType (com.google.api.codegen.metacode.InitCodeLineType)1 InitCodeNode (com.google.api.codegen.metacode.InitCodeNode)1 com.google.api.codegen.transformer (com.google.api.codegen.transformer)1 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)1 PythonTypeTable (com.google.api.codegen.util.py.PythonTypeTable)1 ImportSectionView (com.google.api.codegen.viewmodel.ImportSectionView)1 StaticLangRpcStubView (com.google.api.codegen.viewmodel.StaticLangRpcStubView)1 StaticLangStubInterfaceView (com.google.api.codegen.viewmodel.StaticLangStubInterfaceView)1 Interface (com.google.api.tools.framework.model.Interface)1 MessageType (com.google.api.tools.framework.model.MessageType)1