Ejemplo n.º 1
0
        /// <summary>
        /// Removes all occurrences of transparent identifiers
        /// </summary>
        void RemoveTransparentIdentifierReferences(AstNode node, Dictionary <string, object> fromOrLetIdentifiers)
        {
            foreach (AstNode child in node.Children)
            {
                RemoveTransparentIdentifierReferences(child, fromOrLetIdentifiers);
            }
            MemberReferenceExpression mre = node as MemberReferenceExpression;

            if (mre != null)
            {
                IdentifierExpression ident = mre.Target as IdentifierExpression;
                if (ident != null && IsTransparentIdentifier(ident.Identifier))
                {
                    IdentifierExpression newIdent = new IdentifierExpression(mre.MemberName);
                    mre.TypeArguments.MoveTo(newIdent.TypeArguments);
                    newIdent.CopyAnnotationsFrom(mre);
                    newIdent.RemoveAnnotations <Semantics.MemberResolveResult>();                    // remove the reference to the property of the anonymous type
                    if (fromOrLetIdentifiers.TryGetValue(mre.MemberName, out var annotation))
                    {
                        newIdent.AddAnnotation(annotation);
                    }
                    mre.ReplaceWith(newIdent);
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes all occurrences of transparent identifiers
        /// </summary>
        void RemoveTransparentIdentifierReferences(AstNode node)
        {
            foreach (AstNode child in node.Children)
            {
                RemoveTransparentIdentifierReferences(child);
            }
            MemberReferenceExpression mre = node as MemberReferenceExpression;

            if (mre != null)
            {
                IdentifierExpression ident = mre.Target as IdentifierExpression;
                if (ident != null && IsTransparentIdentifier(ident.Identifier))
                {
                    IdentifierExpression newIdent = new IdentifierExpression(mre.MemberName);
                    mre.TypeArguments.MoveTo(newIdent.TypeArguments);
                    newIdent.CopyAnnotationsFrom(mre);
                    newIdent.RemoveAnnotations <PropertyDeclaration>();                    // remove the reference to the property of the anonymous type
                    mre.ReplaceWith(newIdent);
                    return;
                }
            }
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Removes all occurrences of transparent identifiers
		/// </summary>
		void RemoveTransparentIdentifierReferences(AstNode node, string transparentIdentifier)
		{
			foreach (AstNode child in node.Children) {
				RemoveTransparentIdentifierReferences(child, transparentIdentifier);
			}
			MemberReferenceExpression mre = node as MemberReferenceExpression;
			if (mre != null) {
				IdentifierExpression ident = mre.Target as IdentifierExpression;
				if (ident != null && ident.Identifier == transparentIdentifier) {
					IdentifierExpression newIdent = new IdentifierExpression(mre.MemberName);
					mre.TypeArguments.MoveTo(newIdent.TypeArguments);
					newIdent.CopyAnnotationsFrom(mre);
					newIdent.RemoveAnnotations<PropertyDeclaration>(); // remove the reference to the property of the anonymous type
					mre.ReplaceWith(newIdent);
					return;
				} else if (mre.MemberName == transparentIdentifier) {
					var newVar = mre.Target.Detach();
					newVar.CopyAnnotationsFrom(mre);
					newVar.RemoveAnnotations<PropertyDeclaration>(); // remove the reference to the property of the anonymous type
					mre.ReplaceWith(newVar);
					return;
				}
			}
		}