Exemple #1
0
        bool ResolveIdentifier(string identifier)
        {
            IField local;

            ClearResult();
            if (resolver.CallingMember != null)
            {
                local = resolver.FindLocalVariable(identifier, false);
                if (local != null)
                {
                    MakeResult(local);
                    return(true);
                }

                IMethodOrProperty method = resolver.CallingMember;
                if (method != null)
                {
                    foreach (IParameter p in method.Parameters)
                    {
                        if (IsSameName(p.Name, identifier))
                        {
                            MakeResult(new DefaultField.ParameterField(p.ReturnType, p.Name, p.Region, callingClass));
                            return(true);
                        }
                    }
                    if (method is IProperty && IsSameName(identifier, "value"))
                    {
                        if (((IProperty)method).SetterRegion.IsInside(resolver.CaretLine, resolver.CaretColumn))
                        {
                            MakeResult(new DefaultField.ParameterField(method.ReturnType, "value", method.Region, callingClass));
                            return(true);
                        }
                    }
                }
            }

            {             // Find members of this class or enclosing classes
                IClass tmp = callingClass;
                while (tmp != null)
                {
                    if (ResolveMember(tmp.DefaultReturnType, identifier))
                    {
                        return(true);
                    }
                    tmp = tmp.DeclaringType;
                }
            }

            SearchTypeResult searchTypeResult = projectContent.SearchType(new SearchTypeRequest(identifier, 0, callingClass, cu, resolver.CaretLine, resolver.CaretColumn));

            if (!string.IsNullOrEmpty(searchTypeResult.NamespaceResult))
            {
                MakeNamespaceResult(searchTypeResult.NamespaceResult);
                return(true);
            }

            // Boo can import classes+modules:
            foreach (object o in resolver.GetImportedNamespaceContents())
            {
                IClass c = o as IClass;
                if (c != null && IsSameName(identifier, c.Name))
                {
                    MakeTypeResult(c);
                    return(true);
                }
                IMember member = o as IMember;
                if (member != null && IsSameName(identifier, member.Name))
                {
                    if (member is IMethod)
                    {
                        MakeMethodResult(member.DeclaringType.DefaultReturnType, member.Name);
                    }
                    else
                    {
                        MakeResult(member);
                    }
                    return(true);
                }
            }

            local = resolver.FindLocalVariable(identifier, true);
            if (local != null)
            {
                MakeResult(local);
                return(true);
            }

            return(false);
        }