diff --git a/src/main/render/apache/service/client.ts b/src/main/render/apache/service/client.ts index 4eb776e0..4d01d924 100644 --- a/src/main/render/apache/service/client.ts +++ b/src/main/render/apache/service/client.ts @@ -40,6 +40,7 @@ import { typeNodeForFieldType, } from '../types' +import { resolveIdentifierName } from '../../../resolver/utils' import { IRenderState } from '../../../types' export function renderClient( @@ -153,7 +154,14 @@ export function renderClient( ts.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [ ts.createExpressionWithTypeArguments( [], - ts.createIdentifier(`${node.extends.value}.Client`), + ts.createIdentifier( + `${ + resolveIdentifierName( + node.extends.value, + state, + ).fullName + }.Client`, + ), ), ]), ] diff --git a/src/main/render/apache/service/processor.ts b/src/main/render/apache/service/processor.ts index f5429d3c..559b159c 100644 --- a/src/main/render/apache/service/processor.ts +++ b/src/main/render/apache/service/processor.ts @@ -120,7 +120,12 @@ export function renderHandlerInterface( ), ts.createTypeReferenceNode( ts.createIdentifier( - `${service.extends.value}.IHandler`, + `${ + resolveIdentifierName( + service.extends.value, + state, + ).fullName + }.IHandler`, ), undefined, ), @@ -243,7 +248,12 @@ export function renderProcessor( ts.createExpressionWithTypeArguments( [], ts.createIdentifier( - `${node.extends.value}.Processor`, + `${ + resolveIdentifierName( + node.extends.value, + state, + ).fullName + }.Processor`, ), ), ]), diff --git a/src/main/render/shared/service/index.ts b/src/main/render/shared/service/index.ts index 84db7579..f1ad27f9 100644 --- a/src/main/render/shared/service/index.ts +++ b/src/main/render/shared/service/index.ts @@ -10,6 +10,7 @@ import { COMMON_IDENTIFIERS } from '../identifiers' import { createAnyType, TypeMapping } from '../types' +import { resolveIdentifierName } from '../../../resolver/utils' import { IRenderState } from '../../../types' import { createFunctionParameter } from '../utils' @@ -108,7 +109,12 @@ export function renderHandlerInterface( ), ts.createTypeReferenceNode( ts.createIdentifier( - `${service.extends.value}.IHandler`, + `${ + resolveIdentifierName( + service.extends.value, + state, + ).fullName + }.IHandler`, ), [ts.createTypeReferenceNode('Context', undefined)], ), diff --git a/src/main/render/thrift-server/service/client.ts b/src/main/render/thrift-server/service/client.ts index f3b22891..e28bb384 100644 --- a/src/main/render/thrift-server/service/client.ts +++ b/src/main/render/thrift-server/service/client.ts @@ -47,6 +47,7 @@ import { renderServiceAnnotationsStaticProperty, } from '../annotations' +import { resolveIdentifierName } from '../../../resolver/utils' import { createClassConstructor } from '../../shared/utils' import { looseName, strictName, toolkitName } from '../struct/utils' @@ -59,11 +60,18 @@ function extendsAbstract(): ts.HeritageClause { ]) } -function extendsService(service: Identifier): ts.HeritageClause { +function extendsService( + service: Identifier, + state: IRenderState, +): ts.HeritageClause { return ts.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [ ts.createExpressionWithTypeArguments( [ts.createTypeReferenceNode(COMMON_IDENTIFIERS.Context, undefined)], - ts.createIdentifier(`${service.value}.Client`), + ts.createIdentifier( + `${ + resolveIdentifierName(service.value, state).fullName + }.Client`, + ), ), ]) } @@ -90,7 +98,7 @@ export function renderClient( const heritage: Array = service.extends !== null - ? [extendsService(service.extends)] + ? [extendsService(service.extends, state)] : [extendsAbstract()] // export class { ... } diff --git a/src/main/render/thrift-server/service/processor.ts b/src/main/render/thrift-server/service/processor.ts index 1d59923e..2f832e19 100644 --- a/src/main/render/thrift-server/service/processor.ts +++ b/src/main/render/thrift-server/service/processor.ts @@ -60,7 +60,10 @@ import { renderServiceAnnotationsStaticProperty, } from '../annotations' -import { resolveIdentifierDefinition } from '../../../resolver/utils' +import { + resolveIdentifierDefinition, + resolveIdentifierName, +} from '../../../resolver/utils' import { className, looseName, strictName, toolkitName } from '../struct/utils' function objectLiteralForServiceFunctions( @@ -95,11 +98,18 @@ function createHandlerType(node: ServiceDefinition): ts.TypeNode { ]) } -export function extendsService(service: Identifier): ts.HeritageClause { +export function extendsService( + service: Identifier, + state: IRenderState, +): ts.HeritageClause { return ts.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [ ts.createExpressionWithTypeArguments( [ts.createTypeReferenceNode(COMMON_IDENTIFIERS.Context, undefined)], - ts.createIdentifier(`${service.value}.Processor`), + ts.createIdentifier( + `${ + resolveIdentifierName(service.value, state).fullName + }.Processor`, + ), ), ]) } @@ -164,7 +174,7 @@ export function renderProcessor( const heritage: Array = service.extends !== null - ? [extendsService(service.extends)] + ? [extendsService(service.extends, state)] : [extendsAbstract()] // export class { ... } diff --git a/src/tests/integration/apache/add-service.ts b/src/tests/integration/apache/add-service.ts index f21a80a6..c60f6497 100644 --- a/src/tests/integration/apache/add-service.ts +++ b/src/tests/integration/apache/add-service.ts @@ -5,7 +5,7 @@ import { TBufferedTransport, } from 'thrift' -import { AddService } from './codegen/add-service' +import { AddService } from './codegen/com/test/add-service' import { Server } from 'net' diff --git a/src/tests/integration/apache/calculator-service.ts b/src/tests/integration/apache/calculator-service.ts index 0fe06dd2..5fee376f 100644 --- a/src/tests/integration/apache/calculator-service.ts +++ b/src/tests/integration/apache/calculator-service.ts @@ -16,11 +16,11 @@ import { ExceptionTwo, Operation, Work, -} from './codegen/calculator' +} from './codegen/com/test/calculator' -import { AddService } from './codegen/add-service' +import { AddService } from './codegen/com/test/add-service' -import { SharedStruct, SharedUnion } from './codegen/shared' +import { SharedStruct, SharedUnion } from './codegen/com/test/shared' import { Server } from 'net' diff --git a/src/tests/integration/apache/index.spec.ts b/src/tests/integration/apache/index.spec.ts index d0916252..15d85ef8 100644 --- a/src/tests/integration/apache/index.spec.ts +++ b/src/tests/integration/apache/index.spec.ts @@ -17,9 +17,9 @@ import { LastName, Operation, Work, -} from './codegen/calculator' +} from './codegen/com/test/calculator' -import { SharedStruct, SharedUnion } from './codegen/shared' +import { SharedStruct, SharedUnion } from './codegen/com/test/shared' import { createAddServer } from './add-service' import { createCalculatorServer } from './calculator-service' diff --git a/src/tests/integration/thrift/add-service.thrift b/src/tests/integration/thrift/add-service.thrift index 0ca979ef..af0cca1f 100644 --- a/src/tests/integration/thrift/add-service.thrift +++ b/src/tests/integration/thrift/add-service.thrift @@ -1,5 +1,5 @@ -namespace java add-service -namespace js add-service +namespace java com.test.add-service +namespace js com.test.add-service service AddService { diff --git a/src/tests/integration/thrift/calculator.thrift b/src/tests/integration/thrift/calculator.thrift index 08cdc5d2..d66e9d57 100644 --- a/src/tests/integration/thrift/calculator.thrift +++ b/src/tests/integration/thrift/calculator.thrift @@ -2,8 +2,8 @@ include "shared.thrift" include "common/common.thrift" include "operation.thrift" -namespace java calculator -namespace js calculator +namespace java com.test.calculator +namespace js com.test.calculator typedef i32 MyInteger typedef operation.Operation Operation diff --git a/src/tests/integration/thrift/common/common.thrift b/src/tests/integration/thrift/common/common.thrift index e85fe949..80919c1b 100644 --- a/src/tests/integration/thrift/common/common.thrift +++ b/src/tests/integration/thrift/common/common.thrift @@ -1,5 +1,5 @@ -namespace java common -namespace js common +namespace java com.core.common +namespace js com.core.common include "shared.thrift" diff --git a/src/tests/integration/thrift/exceptions.thrift b/src/tests/integration/thrift/exceptions.thrift index c2205e56..7bbed4ce 100644 --- a/src/tests/integration/thrift/exceptions.thrift +++ b/src/tests/integration/thrift/exceptions.thrift @@ -1,5 +1,5 @@ -namespace java exceptions -namespace js exceptions +namespace java com.test.exceptions +namespace js com.test.exceptions include "shared.thrift" diff --git a/src/tests/integration/thrift/operation.thrift b/src/tests/integration/thrift/operation.thrift index 6928c0aa..8cd79152 100644 --- a/src/tests/integration/thrift/operation.thrift +++ b/src/tests/integration/thrift/operation.thrift @@ -1,5 +1,5 @@ -namespace java operation -namespace js operation +namespace java com.test.operation +namespace js com.test.operation include "exceptions.thrift" diff --git a/src/tests/integration/thrift/shared.thrift b/src/tests/integration/thrift/shared.thrift index 2f283e37..22f2b29b 100644 --- a/src/tests/integration/thrift/shared.thrift +++ b/src/tests/integration/thrift/shared.thrift @@ -1,5 +1,5 @@ -namespace java shared -namespace js shared +namespace java com.test.shared +namespace js com.test.shared const i32 SHARED_INT = 45 diff --git a/src/tests/integration/thrift/user.thrift b/src/tests/integration/thrift/user.thrift index fc277bd8..48f99324 100644 --- a/src/tests/integration/thrift/user.thrift +++ b/src/tests/integration/thrift/user.thrift @@ -1,5 +1,5 @@ -namespace java user -namespace js user +namespace java com.test.user +namespace js com.test.user struct User { 1: string name