object GetCurrentLocalDefinition(Identifier id) { AstNode node = nodeStack.Peek(); if (node is Identifier && node.Parent != null) { node = node.Parent; } if (node is ParameterDeclaration || node is VariableInitializer || node is CatchClause || node is VariableDesignation) { var variable = node.Annotation <ILVariableResolveResult>()?.Variable; if (variable != null) { return(variable); } } if (id.Role == QueryJoinClause.IntoIdentifierRole || id.Role == QueryJoinClause.JoinIdentifierRole) { var variable = id.Annotation <ILVariableResolveResult>()?.Variable; if (variable != null) { return(variable); } } if (node is QueryLetClause) { var variable = node.Annotation <CSharp.Transforms.LetIdentifierAnnotation>(); if (variable != null) { return(variable); } } if (node is LabelStatement label) { var method = nodeStack.Select(nd => nd.GetSymbol() as IMethod).FirstOrDefault(mr => mr != null); if (method != null) { return(method + label.Label); } } if (node is MethodDeclaration && node.Parent is LocalFunctionDeclarationStatement) { var localFunction = node.Parent.GetResolveResult() as MemberResolveResult; if (localFunction != null) { return(localFunction.Member); } } return(null); }
public override void WriteIdentifier(Identifier identifier, TextTokenType tokenType) { if (tokenType == TextTokenType.Text) { tokenType = TextTokenHelper.GetTextTokenType(identifier.AnnotationVT <TextTokenType>() ?? identifier.Annotation <object>()); } if (tokenType != TextTokenType.Keyword && (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier))) { output.Write('@', TextTokenType.Operator); } var definition = GetCurrentDefinition(identifier); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenType, false); return; } object memberRef = GetCurrentMemberReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenType); return; } definition = GetCurrentLocalDefinition(); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenType); return; } memberRef = GetCurrentLocalReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenType, true); return; } if (firstUsingDeclaration) { output.MarkFoldStart(defaultCollapsed: true); firstUsingDeclaration = false; } var s = identifier.Name; if (identifier.Annotation <IdentifierFormatted>() == null) { s = IdentifierEscaper.Escape(s); } output.Write(s, tokenType); }
public override void WriteIdentifier(Identifier identifier, TextTokenKind tokenKind) { if (tokenKind == TextTokenKind.Text) { tokenKind = TextTokenKindUtils.GetTextTokenType(identifier.AnnotationVT <TextTokenKind>() ?? identifier.Annotation <object>()); } if (tokenKind != TextTokenKind.Keyword && (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier))) { output.Write("@", TextTokenKind.Operator); } var definition = GetCurrentDefinition(identifier); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenKind, false); return; } object memberRef = GetCurrentMemberReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenKind); return; } definition = GetCurrentLocalDefinition(); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenKind); return; } memberRef = GetCurrentLocalReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenKind, true); return; } if (firstUsingDeclaration) { firstUsingDeclaration = false; } var s = identifier.Name; if (identifier.Annotation <IdentifierFormatted>() == null) { s = IdentifierEscaper.Escape(s); } output.Write(s, tokenKind); }
public override void WriteIdentifier(Identifier identifier, TextTokenType tokenType) { if (tokenType == TextTokenType.Text) tokenType = TextTokenHelper.GetTextTokenType(identifier.AnnotationVT<TextTokenType>() ?? identifier.Annotation<object>()); if (tokenType != TextTokenType.Keyword && (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier))) { output.Write('@', TextTokenType.Operator); } var definition = GetCurrentDefinition(identifier); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenType, false); return; } object memberRef = GetCurrentMemberReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenType); return; } definition = GetCurrentLocalDefinition(); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenType); return; } memberRef = GetCurrentLocalReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenType, true); return; } if (firstUsingDeclaration) { output.MarkFoldStart(defaultCollapsed: true); firstUsingDeclaration = false; } var s = identifier.Name; if (identifier.Annotation<IdentifierFormatted>() == null) s = IdentifierEscaper.Escape(s); output.Write(s, tokenType); }
public override void WriteIdentifier(Identifier identifier, TextTokenKind tokenKind) { if (tokenKind == TextTokenKind.Text) tokenKind = TextTokenKindUtils.GetTextTokenType(identifier.AnnotationVT<TextTokenKind>() ?? identifier.Annotation<object>()); if (tokenKind != TextTokenKind.Keyword && (identifier.IsVerbatim || CSharpOutputVisitor.IsKeyword(identifier.Name, identifier))) { output.Write("@", TextTokenKind.Operator); } var definition = GetCurrentDefinition(identifier); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenKind, false); return; } object memberRef = GetCurrentMemberReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenKind); return; } definition = GetCurrentLocalDefinition(); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenKind); return; } memberRef = GetCurrentLocalReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenKind, true); return; } if (firstUsingDeclaration) { firstUsingDeclaration = false; } var s = identifier.Name; if (identifier.Annotation<IdentifierFormatted>() == null) s = IdentifierEscaper.Escape(s); output.Write(s, tokenKind); }
public override void WriteIdentifier(Identifier identifier, TextTokenType tokenType) { if (tokenType == TextTokenType.Text) tokenType = TextTokenHelper.GetTextTokenType(identifier.AnnotationVT<TextTokenType>() ?? identifier.Annotation<object>()); var definition = GetCurrentDefinition(identifier); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenType, false); return; } object memberRef = GetCurrentMemberReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenType); return; } definition = GetCurrentLocalDefinition(); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenType); return; } memberRef = GetCurrentLocalReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenType, true); return; } if (firstUsingDeclaration) { output.MarkFoldStart(defaultCollapsed: true); firstUsingDeclaration = false; } output.Write(IdentifierEscaper.Escape(identifier.Name), tokenType); }
public override void WriteIdentifier(Identifier identifier, TextTokenType tokenType) { if (tokenType == TextTokenType.Text) { tokenType = TextTokenHelper.GetTextTokenType(identifier.AnnotationVT <TextTokenType>() ?? identifier.Annotation <object>()); } var definition = GetCurrentDefinition(identifier); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenType, false); return; } object memberRef = GetCurrentMemberReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenType); return; } definition = GetCurrentLocalDefinition(); if (definition != null) { output.WriteDefinition(IdentifierEscaper.Escape(identifier.Name), definition, tokenType); return; } memberRef = GetCurrentLocalReference(); if (memberRef != null) { output.WriteReference(IdentifierEscaper.Escape(identifier.Name), memberRef, tokenType, true); return; } if (firstUsingDeclaration) { output.MarkFoldStart(defaultCollapsed: true); firstUsingDeclaration = false; } output.Write(IdentifierEscaper.Escape(identifier.Name), tokenType); }
public virtual void VisitIdentifier(Identifier identifier) { // Do not call StartNode and EndNode for Identifier, because they are handled by the ITokenWriter. // ITokenWriter assumes that each node processed between a // StartNode(parentNode)-EndNode(parentNode)-pair is a child of parentNode. WriteIdentifier(identifier, CSharpMetadataTextColorProvider.Instance.GetColor(identifier.Annotation<object>())); }
public virtual void VisitIdentifier(Identifier identifier) { // Do not call StartNode and EndNode for Identifier, because they are handled by the ITokenWriter. // ITokenWriter assumes that each node processed between a // StartNode(parentNode)-EndNode(parentNode)-pair is a child of parentNode. WriteIdentifier(identifier, TextTokenHelper.GetTextTokenType(identifier.Annotation<object>())); }