@travetto/transformer
Advanced tools
Comparing version 3.1.0 to 3.1.2
{ | ||
"name": "@travetto/transformer", | ||
"version": "3.1.0", | ||
"version": "3.1.2", | ||
"description": "Functionality for AST transformations, with transformer registration, and general utils", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -298,13 +298,17 @@ import ts from 'typescript'; | ||
generateUniqueIdentifier(node: ts.Node, type: AnyType): string { | ||
let unique: string; | ||
let unique: string | undefined; | ||
try { | ||
// Tie to source location if possible | ||
const tgt = DeclarationUtil.getPrimaryDeclarationNode(type.original!); | ||
unique = `${ts.getLineAndCharacterOfPosition(tgt.getSourceFile(), tgt.getStart()).line}_${tgt.getEnd() - tgt.getStart()}`; | ||
if (tgt.getSourceFile().fileName !== this.source.fileName) { // if in same file | ||
unique = `${SystemUtil.naiveHash(tgt.getSourceFile().fileName)}_${unique}`; | ||
const fileName = tgt.getSourceFile().fileName; | ||
if (fileName === this.source.fileName) { // if in same file suffix with location | ||
unique = `${ts.getLineAndCharacterOfPosition(tgt.getSourceFile(), tgt.getStart()).line}_${tgt.getEnd() - tgt.getStart()}`; | ||
} else { | ||
// Otherwise treat it as external and add nothing to it | ||
} | ||
} catch { | ||
// Determine type unique ident | ||
unique = SystemUtil.uuid(type.name ? 5 : 10); | ||
const imp = this.#resolver.getFileImportName(this.source.fileName); | ||
unique = `${SystemUtil.naiveHash(`${imp}${type.name ?? 'unknown'}`)}`; | ||
} | ||
@@ -316,3 +320,4 @@ // Otherwise read name with uuid | ||
} | ||
return `${name}_${unique}`; | ||
name ||= 'Shape'; | ||
return unique ? `${name}_${unique}` : name; | ||
} | ||
@@ -319,0 +324,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90328
2274