public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node) { var aliasable = node.GetAnnotations(AliasableType).FirstOrDefault(); if (aliasable != null && _importedClassNames.Contains(node.Identifier.ValueText)) { // Type name needs fully aliasing; there is a name collision with another type. var ns = aliasable.Data; if (!_namespaceAliases.TryGetValue(ns, out var alias)) { // Create alias using the first character of each namespace part. // TODO: Ensure single-character aliased are not generated; they cause a compilation error. alias = ns .Split('.', StringSplitOptions.RemoveEmptyEntries) .Select(x => char.ToLowerInvariant(x[0])) .Aggregate("", (a, c) => a + c); _namespaceAliases.Add(ns, alias); } // Move any comments to the new node, and return it. var aliasedName = AliasQualifiedName(alias, node.WithoutTrivia()); return(aliasedName.WithTriviaFrom(node)); } return(base.VisitIdentifierName(node)); }