コード例 #1
0
ファイル: DocGenerator.cs プロジェクト: thild/monodevelop
 public DocGenerator(TextEditorData data)
 {
     this.data = data;
     if (data != null)
     {
         provider = RefactoringService.GetASTProvider(data.Document.MimeType);
     }
 }
コード例 #2
0
        public override bool IsValid(RefactoringOptions options)
        {
            INRefactoryASTProvider provider = options.GetASTProvider();
            IResolver resolver = options.GetResolver();

            if (provider == null || resolver == null)
            {
                return(false);
            }
            if (invoke == null)
            {
                invoke = GetInvocationExpression(options);
            }
            if (invoke == null)
            {
                return(false);
            }
            returnType      = DomReturnType.Void;
            modifiers       = ICSharpCode.NRefactory.Ast.Modifiers.None;
            resolvePosition = new DomLocation(options.Document.TextEditor.CursorLine, options.Document.TextEditor.CursorColumn);
            ResolveResult resolveResult = resolver.Resolve(new ExpressionResult(provider.OutputNode(options.Dom, invoke)), resolvePosition);

            if (resolveResult is MethodResolveResult)
            {
                MethodResolveResult mrr = (MethodResolveResult)resolveResult;
                if (mrr.ExactMethodMatch)
                {
                    return(false);
                }
                returnType = mrr.MostLikelyMethod.ReturnType;
                modifiers  = (ICSharpCode.NRefactory.Ast.Modifiers)mrr.MostLikelyMethod.Modifiers;
            }

            if (invoke.TargetObject is MemberReferenceExpression)
            {
                string callingObject = provider.OutputNode(options.Dom, ((MemberReferenceExpression)invoke.TargetObject).TargetObject);
                resolveResult = resolver.Resolve(new ExpressionResult(callingObject), resolvePosition);
                if (resolveResult == null || resolveResult.ResolvedType == null || resolveResult.CallingType == null)
                {
                    return(false);
                }
                IType type = options.Dom.GetType(resolveResult.ResolvedType);
                return(type != null && type.CompilationUnit != null && File.Exists(type.CompilationUnit.FileName) && RefactoringService.GetASTProvider(DesktopService.GetMimeTypeForUri(type.CompilationUnit.FileName)) != null);
            }
            return(invoke.TargetObject is IdentifierExpression);
        }
コード例 #3
0
 public INRefactoryASTProvider GetASTProvider()
 {
     return(RefactoringService.GetASTProvider(MimeType));
 }