Example #1
0
        public static AbstractType[] ResolveTypeLoosely(IEditorData editor, out NodeResolutionAttempt resolutionAttempt, ResolutionContext ctxt = null)
        {
            if (ctxt == null)
            {
                ctxt = ResolutionContext.Create(editor);
            }

            var o = GetScopedCodeObject(editor, ctxt: ctxt);

            var optionBackup = ctxt.CurrentContext.ContextDependentOptions;

            ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.ReturnMethodReferencesOnly;
            resolutionAttempt = NodeResolutionAttempt.Normal;

            AbstractType[] ret;

            if (o is IExpression)
            {
                ret = Evaluation.EvaluateTypes((IExpression)o, ctxt);
            }
            else if (o is ITypeDeclaration)
            {
                ret = TypeDeclarationResolver.Resolve((ITypeDeclaration)o, ctxt);
            }
            else
            {
                ret = null;
            }

            if (ret == null)
            {
                resolutionAttempt = NodeResolutionAttempt.NoParameterOrTemplateDeduction;

                if (o is PostfixExpression_MethodCall)
                {
                    o = (o as PostfixExpression_MethodCall).PostfixForeExpression;
                }

                if (o is IdentifierExpression)
                {
                    ret = Evaluation.GetOverloads(o as IdentifierExpression, ctxt, false);
                }
                else if (o is ITypeDeclaration)
                {
                    ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.NoTemplateParameterDeduction;
                    ret = TypeDeclarationResolver.Resolve(o as ITypeDeclaration, ctxt);
                }
            }

            if (ret == null)
            {
                resolutionAttempt = NodeResolutionAttempt.RawSymbolLookup;
                ret = TypeDeclarationResolver.HandleNodeMatches(LookupIdRawly(editor, o as ISyntaxRegion), ctxt);
            }

            ctxt.CurrentContext.ContextDependentOptions = optionBackup;
            return(ret);
        }
Example #2
0
		public static AbstractType ResolveTypeLoosely(IEditorData editor, out NodeResolutionAttempt resolutionAttempt, out ISyntaxRegion sr, bool editorFriendly = false)
		{
			return ResolveTypeLoosely (editor, sr = DResolver.GetScopedCodeObject(editor), out resolutionAttempt, editorFriendly);
		}
Example #3
0
		public static AbstractType ResolveTypeLoosely(IEditorData editor, ISyntaxRegion o, out NodeResolutionAttempt resolutionAttempt, bool editorFriendly)
		{
			resolutionAttempt = NodeResolutionAttempt.Normal;

			if (o == null)
				return null;

			if (editorFriendly) {
				if (o is PostfixExpression_MethodCall)
					o = (o as PostfixExpression_MethodCall).PostfixForeExpression;
			}
			
			var ctxt = ResolutionContext.Create(editor, false);

			AbstractType ret = null;
			NodeResolutionAttempt resAttempt = NodeResolutionAttempt.Normal;
			CodeCompletion.DoTimeoutableCompletionTask(null, ctxt, () =>
				{
					ctxt.Push(editor);

					ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.ReturnMethodReferencesOnly | ResolutionOptions.DontResolveAliases;

					if (o is IExpression)
						ret = ExpressionTypeEvaluation.EvaluateType((IExpression)o, ctxt, false);
					else if (o is ITypeDeclaration)
						ret = TypeDeclarationResolver.ResolveSingle((ITypeDeclaration)o, ctxt);
					else if (o is INode)
						ret = TypeDeclarationResolver.HandleNodeMatch(o as INode, ctxt, null, o);

					if(ret != null && !(ret is UnknownType))
						return;


					ctxt.ClearCaches();

					resAttempt = NodeResolutionAttempt.NoParameterOrTemplateDeduction;

					ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.ReturnMethodReferencesOnly | ResolutionOptions.DontResolveAliases;

					if (o is IdentifierExpression)
						ret = AmbiguousType.Get(ExpressionTypeEvaluation.GetOverloads(o as IdentifierExpression, ctxt, deduceParameters: false));
					else if (o is ITypeDeclaration)
						ret = TypeDeclarationResolver.ResolveSingle(o as ITypeDeclaration, ctxt);
					else if (o is IExpression)
						ret = ExpressionTypeEvaluation.EvaluateType(o as IExpression, ctxt, false);

					if(ret != null && !(ret is UnknownType))
						return;



					ctxt.ClearCaches();

					resAttempt = NodeResolutionAttempt.RawSymbolLookup;
					ret = LookupIdRawly(editor.ParseCache, o, editor.SyntaxTree);
				});

			resolutionAttempt = resAttempt;

			return ret;
		}
Example #4
0
        public static AbstractType ResolveTypeLoosely(IEditorData editor, out NodeResolutionAttempt resolutionAttempt, ResolutionContext ctxt = null)
        {
            var o = GetScopedCodeObject(editor);

            if (ctxt == null)
            {
                ctxt = ResolutionContext.Create(editor, false);
            }

            AbstractType          ret        = null;
            NodeResolutionAttempt resAttempt = NodeResolutionAttempt.Normal;

            CodeCompletion.DoTimeoutableCompletionTask(null, ctxt, () =>
            {
                ctxt.Push(editor);

                var optionBackup = ctxt.CurrentContext.ContextDependentOptions;
                ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.ReturnMethodReferencesOnly | ResolutionOptions.DontResolveAliases;

                if (o is IExpression)
                {
                    ret = ExpressionTypeEvaluation.EvaluateType((IExpression)o, ctxt, false);
                }
                else if (o is ITypeDeclaration)
                {
                    ret = TypeDeclarationResolver.ResolveSingle((ITypeDeclaration)o, ctxt);
                }
                else if (o is INode)
                {
                    ret = TypeDeclarationResolver.HandleNodeMatch(o as INode, ctxt, null, o);
                }
                else
                {
                    ret = null;
                }

                if (ret == null)
                {
                    resAttempt = NodeResolutionAttempt.NoParameterOrTemplateDeduction;

                    if (o is PostfixExpression_MethodCall)
                    {
                        o = (o as PostfixExpression_MethodCall).PostfixForeExpression;
                    }

                    ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.NoTemplateParameterDeduction | ResolutionOptions.DontResolveAliases;

                    if (o is IdentifierExpression)
                    {
                        ret = AmbiguousType.Get(ExpressionTypeEvaluation.GetOverloads(o as IdentifierExpression, ctxt, deduceParameters: false), o);
                    }
                    else if (o is ITypeDeclaration)
                    {
                        ret = TypeDeclarationResolver.ResolveSingle(o as ITypeDeclaration, ctxt);
                    }
                    else if (o is IExpression)
                    {
                        ret = ExpressionTypeEvaluation.EvaluateType(o as IExpression, ctxt, false);
                    }
                }

                if (ret == null)
                {
                    resAttempt    = NodeResolutionAttempt.RawSymbolLookup;
                    var overloads = TypeDeclarationResolver.HandleNodeMatches(LookupIdRawly(editor, o as ISyntaxRegion), ctxt, null, o);
                    ret           = AmbiguousType.Get(overloads, o);
                }

                ctxt.CurrentContext.ContextDependentOptions = optionBackup;
            });

            resolutionAttempt = resAttempt;

            if (ret != null)
            {
                ret.DeclarationOrExpressionBase = o;
            }

            return(ret);
        }