示例#1
0
        public override void WriteIdentifier(Identifier identifier)
        {
            if (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier))
            {
                output.Write('@');
            }

            var    definition = GetCurrentDefinition();
            string name       = TextWriterTokenWriter.EscapeIdentifier(identifier.Name);

            switch (definition)
            {
            case IType t:
                output.WriteReference(t, name, true);
                return;

            case IMember m:
                output.WriteReference(m, name, true);
                return;
            }

            var member = GetCurrentMemberReference();

            switch (member)
            {
            case IType t:
                output.WriteReference(t, name, false);
                return;

            case IMember m:
                output.WriteReference(m, name, false);
                return;
            }

            var localDefinition = GetCurrentLocalDefinition();

            if (localDefinition != null)
            {
                output.WriteLocalReference(name, localDefinition, isDefinition: true);
                return;
            }

            var localRef = GetCurrentLocalReference();

            if (localRef != null)
            {
                output.WriteLocalReference(name, localRef);
                return;
            }

            if (firstUsingDeclaration && !lastUsingDeclaration)
            {
                output.MarkFoldStart(defaultCollapsed: !settings.ExpandUsingDeclarations);
                firstUsingDeclaration = false;
            }

            output.Write(name);
        }