use of io.crnk.gen.typescript.model.TSModule in project crnk-framework by crnk-project.
the class TypescriptUtilsTest method getNestedInterfacesReturnsNullIfDoesNotExistsAndNonCreateRequested.
@Test
public void getNestedInterfacesReturnsNullIfDoesNotExistsAndNonCreateRequested() {
TSModule module = new TSModule();
module.setName("TestModule");
TSClassType classType = new TSClassType();
classType.setParent(module);
classType.setName("TestClass");
module.getElements().add(classType);
TSInterfaceType testInterface = TypescriptUtils.getNestedInterface(classType, "TestInterface", false);
Assert.assertNull(testInterface);
}
use of io.crnk.gen.typescript.model.TSModule in project crnk-framework by crnk-project.
the class TSWriter method visitReference.
public void visitReference(TSType type) {
if (type instanceof TSParameterizedType) {
TSParameterizedType paramType = (TSParameterizedType) type;
visitReference(paramType.getBaseType());
builder.append("<");
List<TSType> parameters = paramType.getParameters();
for (int i = 0; i < parameters.size(); i++) {
if (i > 0) {
builder.append(", ");
}
visitReference(parameters.get(i));
}
builder.append(">");
} else {
if (type.getParent() instanceof TSModule) {
visitReference((TSModule) type.getParent());
builder.append(".");
}
builder.append(type.getName());
}
}
use of io.crnk.gen.typescript.model.TSModule in project crnk-framework by crnk-project.
the class TSImportProcessor method processType.
private static void processType(TSSource source, TSNamedElement type) {
TSSource refSource = getSource(type);
// no need for inclusions of primitive types and within same file
if (!(type instanceof TSPrimitiveType || source == refSource)) {
TSNamedElement importedType = type;
if (type.getParent() instanceof TSModule) {
importedType = (TSNamedElement) type.getParent();
}
addImport(refSource, source, importedType);
}
}
Aggregations