use of com.google.api.codegen.util.php.PhpTypeTable in project toolkit by googleapis.
the class PhpGapicSurfaceTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces()) {
ModelTypeTable modelTypeTable = new ModelTypeTable(new PhpTypeTable(productConfig.getPackageName()), new PhpModelTypeNameConverter(productConfig.getPackageName()));
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, modelTypeTable, new PhpSurfaceNamer(productConfig.getPackageName()), new PhpFeatureConfig());
surfaceDocs.addAll(transform(context));
}
return surfaceDocs;
}
use of com.google.api.codegen.util.php.PhpTypeTable in project toolkit by googleapis.
the class PhpModelTypeNameConverterTest method testNestedMessageFullName.
@Test
public void testNestedMessageFullName() {
String packageName = "Google\\Example\\Library\\V1";
TypeRef type = ModelTypeNameConverterTestUtil.getTestType(tempDir, "SomeMessage2", "SomeMessage3");
PhpModelTypeNameConverter converter = new PhpModelTypeNameConverter(packageName);
PhpTypeTable typeTable = new PhpTypeTable(packageName);
TypeName typeName = converter.getTypeName(type);
assertThat(typeName.getFullName()).isEqualTo("\\Google\\Example\\Library\\V1\\SomeMessage2\\SomeMessage3");
typeTable.getAndSaveNicknameFor(typeName);
assertThat(typeTable.getImports()).containsKey("\\Google\\Example\\Library\\V1\\SomeMessage2\\SomeMessage3");
}
use of com.google.api.codegen.util.php.PhpTypeTable in project toolkit by googleapis.
the class PhpModelTypeNameConverterTest method testGetEnumValue.
@Test
public void testGetEnumValue() {
String packageName = "Google\\Example\\Library\\V1";
TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
EnumValue value = type.getEnumType().getValues().get(0);
PhpModelTypeNameConverter converter = new PhpModelTypeNameConverter(packageName);
PhpTypeTable typeTable = new PhpTypeTable(packageName);
assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(typeTable)).isEqualTo("Rating::GOOD");
assertThat(typeTable.getImports()).containsKey("\\Google\\Example\\Library\\V1\\Book\\Rating");
}
use of com.google.api.codegen.util.php.PhpTypeTable in project toolkit by googleapis.
the class PhpGapicSurfaceTransformer method transform.
@Override
public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
if (!productConfig.hasInterfaceConfig(apiInterface)) {
continue;
}
ModelTypeTable modelTypeTable = new ModelTypeTable(new PhpTypeTable(productConfig.getPackageName()), new PhpModelTypeNameConverter(productConfig.getPackageName()));
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, modelTypeTable, new PhpSurfaceNamer(productConfig.getPackageName()), new PhpFeatureConfig(productConfig));
surfaceDocs.addAll(transform(context));
}
return surfaceDocs;
}
use of com.google.api.codegen.util.php.PhpTypeTable in project toolkit by googleapis.
the class PhpGapicSurfaceTestTransformer method createContext.
private GapicInterfaceContext createContext(InterfaceModel apiInterface, GapicProductConfig productConfig, PhpSurfaceNamer.TestKind testKind) {
PhpSurfaceNamer surfacePackageNamer = new PhpSurfaceNamer(productConfig.getPackageName());
String testPackageName = surfacePackageNamer.getTestPackageName(testKind);
ModelTypeTable typeTable = new ModelTypeTable(new PhpTypeTable(testPackageName), new PhpModelTypeNameConverter(testPackageName));
return GapicInterfaceContext.create(apiInterface, productConfig, typeTable, surfacePackageNamer, new PhpFeatureConfig(productConfig));
}
Aggregations