Пример #1
0
		protected override Expression DoResolve (ResolveContext rc)
		{
			var sn = expr as SimpleName;
			const ResolveFlags flags = ResolveFlags.VariableOrValue | ResolveFlags.Type;

			if (sn != null) {
				expr = sn.LookupNameExpression (rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity);

				//
				// Resolve expression which does have type set as we need expression type
				// with disable flow analysis as we don't know whether left side expression
				// is used as variable or type
				//
				if (expr is VariableReference || expr is ConstantExpr || expr is Linq.TransparentMemberAccess) {
					expr = expr.Resolve (rc);
				} else if (expr is TypeParameterExpr) {
					expr.Error_UnexpectedKind (rc, flags, sn.Location);
					expr = null;
				}
			} else {
				expr = expr.Resolve (rc, flags);
			}

			if (expr == null)
				return null;

			TypeSpec expr_type = expr.Type;
			if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod) {
				expr.Error_OperatorCannotBeApplied (rc, loc, ".", expr_type);
				return null;
			}

			if (targs != null) {
				if (!targs.Resolve (rc))
					return null;
			}

			var results = new List<string> ();
			var nexpr = expr as NamespaceExpression;
			if (nexpr != null) {
				string namespaced_partial;

				if (partial_name == null)
					namespaced_partial = nexpr.Namespace.Name;
				else
					namespaced_partial = nexpr.Namespace.Name + "." + partial_name;

				rc.CurrentMemberDefinition.GetCompletionStartingWith (namespaced_partial, results);
				if (partial_name != null)
					results = results.Select (l => l.Substring (partial_name.Length)).ToList ();
			} else {
				var r = MemberCache.GetCompletitionMembers (rc, expr_type, partial_name).Select (l => l.Name);
				AppendResults (results, partial_name, r);
			}

			throw new CompletionResult (partial_name == null ? "" : partial_name, results.Distinct ().ToArray ());
		}
Пример #2
0
        protected override Expression DoResolve(ResolveContext ec)
        {
            Expression expr_resolved = expr.Resolve(ec,
                                                    ResolveFlags.VariableOrValue | ResolveFlags.Type);

            if (expr_resolved == null)
            {
                return(null);
            }

            TypeSpec expr_type = expr_resolved.Type;

            if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod)
            {
                expr_resolved.Error_OperatorCannotBeApplied(ec, loc, ".", expr_type);
                return(null);
            }

            if (targs != null)
            {
                if (!targs.Resolve(ec))
                {
                    return(null);
                }
            }

            var results = new List <string> ();

            if (expr_resolved is Namespace)
            {
                Namespace nexpr = expr_resolved as Namespace;
                string    namespaced_partial;

                if (partial_name == null)
                {
                    namespaced_partial = nexpr.Name;
                }
                else
                {
                    namespaced_partial = nexpr.Name + "." + partial_name;
                }

                ec.CurrentMemberDefinition.GetCompletionStartingWith(namespaced_partial, results);
                if (partial_name != null)
                {
                    results = results.Select(l => l.Substring(partial_name.Length)).ToList();
                }
            }
            else
            {
                var r = MemberCache.GetCompletitionMembers(ec, expr_type, partial_name).Select(l => l.Name);
                AppendResults(results, partial_name, r);
            }

            throw new CompletionResult(partial_name == null ? "" : partial_name, results.Distinct().ToArray());
        }
Пример #3
0
		protected override Expression DoResolve (ResolveContext ec)
		{
			var members = MemberCache.GetCompletitionMembers (ec, ec.CurrentInitializerVariable.Type, partial_name);

// TODO: Does this mean exact match only ?
//			if (partial_name != null && results.Count > 0 && result [0] == "")
//				throw new CompletionResult ("", new string [] { "=" });

			var results = members.Where (l => (l.Kind & (MemberKind.Field | MemberKind.Property)) != 0).Select (l => l.Name).ToList ();
			if (partial_name != null) {
				var temp = new List<string> ();
				AppendResults (temp, partial_name, results);
				results = temp;
			}

			throw new CompletionResult (partial_name == null ? "" : partial_name, results.Distinct ().ToArray ());
		}
Пример #4
0
        protected override Expression DoResolve(ResolveContext ec)
        {
            Expression expr_resolved = expr.Resolve(ec,
                                                    ResolveFlags.VariableOrValue | ResolveFlags.Type);

            if (expr_resolved == null)
            {
                return(null);
            }

            TypeSpec expr_type = expr_resolved.Type;

            if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod)
            {
                Unary.Error_OperatorCannotBeApplied(ec, loc, ".", expr_type);
                return(null);
            }

            if (targs != null)
            {
                if (!targs.Resolve(ec))
                {
                    return(null);
                }
            }

            var results = new List <string> ();

            if (expr_resolved is Namespace)
            {
                Namespace nexpr = expr_resolved as Namespace;
                string    namespaced_partial;

                if (partial_name == null)
                {
                    namespaced_partial = nexpr.Name;
                }
                else
                {
                    namespaced_partial = nexpr.Name + "." + partial_name;
                }

#if false
                Console.WriteLine("Workign with: namespaced partial {0}", namespaced_partial);
                foreach (var x in ec.TypeContainer.NamespaceEntry.CompletionGetTypesStartingWith(ec.TypeContainer, namespaced_partial))
                {
                    Console.WriteLine("    {0}", x);
                }
#endif

                CompletionSimpleName.AppendResults(
                    results,
                    partial_name,
                    ec.CurrentMemberDefinition.Parent.NamespaceEntry.CompletionGetTypesStartingWith(namespaced_partial));
            }
            else
            {
                var r = MemberCache.GetCompletitionMembers(ec, expr_type, partial_name).Select(l => l.Name);
                AppendResults(results, partial_name, r);
            }

            throw new CompletionResult(partial_name == null ? "" : partial_name, results.Distinct().ToArray());
        }
Пример #5
0
        protected override Expression DoResolve(ResolveContext rc)
        {
            var sn = expr as SimpleName;
            const ResolveFlags flags = ResolveFlags.VariableOrValue | ResolveFlags.Type;

            //
            // Resolve the expression with flow analysis turned off, we'll do the definite
            // assignment checks later.  This is because we don't know yet what the expression
            // will resolve to - it may resolve to a FieldExpr and in this case we must do the
            // definite assignment check on the actual field and not on the whole struct.
            //
            using (rc.Set(ResolveContext.Options.OmitStructFlowAnalysis)) {
                if (sn != null)
                {
                    expr = sn.LookupNameExpression(rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity);

                    //
                    // Resolve expression which does have type set as we need expression type
                    // with disable flow analysis as we don't know whether left side expression
                    // is used as variable or type
                    //
                    if (expr is VariableReference || expr is ConstantExpr || expr is Linq.TransparentMemberAccess)
                    {
                        using (rc.With(ResolveContext.Options.DoFlowAnalysis, false)) {
                            expr = expr.Resolve(rc);
                        }
                    }
                    else if (expr is TypeParameterExpr)
                    {
                        expr.Error_UnexpectedKind(rc, flags, sn.Location);
                        expr = null;
                    }
                }
                else
                {
                    expr = expr.Resolve(rc, flags);
                }
            }

            if (expr == null)
            {
                return(null);
            }

            TypeSpec expr_type = expr.Type;

            if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod)
            {
                expr.Error_OperatorCannotBeApplied(rc, loc, ".", expr_type);
                return(null);
            }

            if (targs != null)
            {
                if (!targs.Resolve(rc))
                {
                    return(null);
                }
            }

            var results = new List <string> ();

            if (expr is Namespace)
            {
                Namespace nexpr = expr as Namespace;
                string    namespaced_partial;

                if (partial_name == null)
                {
                    namespaced_partial = nexpr.Name;
                }
                else
                {
                    namespaced_partial = nexpr.Name + "." + partial_name;
                }

                rc.CurrentMemberDefinition.GetCompletionStartingWith(namespaced_partial, results);
                if (partial_name != null)
                {
                    results = results.Select(l => l.Substring(partial_name.Length)).ToList();
                }
            }
            else
            {
                var r = MemberCache.GetCompletitionMembers(rc, expr_type, partial_name).Select(l => l.Name);
                AppendResults(results, partial_name, r);
            }

            throw new CompletionResult(partial_name == null ? "" : partial_name, results.Distinct().ToArray());
        }