private bool DoCaseCompletion(CodeEditorControl editor)
        {
            Caret caret          = editor.ActiveViewControl.Caret;
            NRefactoryResolver r = new NRefactoryResolver(ScriptControl.Parser.ProjectParser.CurrentProjectContent, LanguageProperties.CSharp);

            if (r.Initialize(editor.ActiveViewControl.FileName, caret.Position.Y + 1, caret.Position.X + 1))
            {
                AST.INode currentMember = r.ParseCurrentMember(ScriptControl.Parser.ProjectParser.GetFileContents(editor.FileName));
                if (currentMember != null)
                {
                    CaseCompletionSwitchFinder ccsf = new CaseCompletionSwitchFinder(caret.Position.Y + 1, caret.Position.X + 1);
                    currentMember.AcceptVisitor(ccsf, null);
                    if (ccsf.bestStatement != null)
                    {
                        r.RunLookupTableVisitor(currentMember);
                        ResolveResult rr = r.ResolveInternal(ccsf.bestStatement.SwitchExpression, ExpressionContext.Default);
                        if (rr != null && rr.ResolvedType != null)
                        {
                            return(ProvideContextCompletion(editor, rr.ResolvedType, ' '));
                        }
                    }
                }
            }
            return(false);
        }
示例#2
0
        bool DoCaseCompletion(ITextEditor editor)
        {
            ITextEditorCaret caret = editor.Caret;
            var r = new NRefactoryResolver(LanguageProperties.CSharp);

            if (r.Initialize(ParserService.GetParseInformation(editor.Document.Text, ProjectContent), caret.Line, caret.Column))
            {
                NRefactory.Ast.INode currentMember = r.ParseCurrentMember(editor.Document.Text);
                if (currentMember != null)
                {
                    var ccsf = new CaseCompletionSwitchFinder(caret.Line, caret.Column);
                    currentMember.AcceptVisitor(ccsf, null);
                    if (ccsf.BestStatement != null)
                    {
                        r.RunLookupTableVisitor(currentMember);
                        ResolveResult rr = r.ResolveInternal(ccsf.BestStatement.SwitchExpression, ExpressionContext.Default);
                        if (rr != null && rr.ResolvedType != null)
                        {
                            return(ProvideContextCompletion(editor, rr.ResolvedType, ' '));
                        }
                    }
                }
            }
            return(false);
        }
        bool DoCaseCompletion(SharpDevelopTextAreaControl editor)
        {
            ICSharpCode.TextEditor.Caret caret = editor.ActiveTextAreaControl.Caret;
            NRefactoryResolver           r     = new NRefactoryResolver(LanguageProperties.CSharp);

            if (r.Initialize(ParserService.GetParseInformation(editor.FileName), caret.Line + 1, caret.Column + 1))
            {
                AST.INode currentMember = r.ParseCurrentMember(editor.Text);
                if (currentMember != null)
                {
                    CaseCompletionSwitchFinder ccsf = new CaseCompletionSwitchFinder(caret.Line + 1, caret.Column + 1);
                    currentMember.AcceptVisitor(ccsf, null);
                    if (ccsf.bestStatement != null)
                    {
                        r.RunLookupTableVisitor(currentMember);
                        ResolveResult rr = r.ResolveInternal(ccsf.bestStatement.SwitchExpression, ExpressionContext.Default);
                        if (rr != null && rr.ResolvedType != null)
                        {
                            return(ProvideContextCompletion(editor, rr.ResolvedType, ' '));
                        }
                    }
                }
            }
            return(false);
        }
		bool DoCaseCompletion(SharpDevelopTextAreaControl editor)
		{
			ICSharpCode.TextEditor.Caret caret = editor.ActiveTextAreaControl.Caret;
			NRefactoryResolver r = new NRefactoryResolver(ParserService.CurrentProjectContent, LanguageProperties.CSharp);
			if (r.Initialize(editor.FileName, caret.Line + 1, caret.Column + 1)) {
				AST.INode currentMember = r.ParseCurrentMember(editor.Text);
				if (currentMember != null) {
					CaseCompletionSwitchFinder ccsf = new CaseCompletionSwitchFinder(caret.Line + 1, caret.Column + 1);
					currentMember.AcceptVisitor(ccsf, null);
					if (ccsf.bestStatement != null) {
						r.RunLookupTableVisitor(currentMember);
						ResolveResult rr = r.ResolveInternal(ccsf.bestStatement.SwitchExpression, ExpressionContext.Default);
						if (rr != null && rr.ResolvedType != null) {
							return ProvideContextCompletion(editor, rr.ResolvedType, ' ');
						}
					}
				}
			}
			return false;
		}
		bool DoCaseCompletion(ITextEditor editor)
		{
			ITextEditorCaret caret = editor.Caret;
			NRefactoryResolver r = new NRefactoryResolver(LanguageProperties.CSharp);
			if (r.Initialize(ParserService.GetParseInformation(editor.FileName), caret.Line, caret.Column)) {
				AST.INode currentMember = r.ParseCurrentMember(editor.Document.Text);
				if (currentMember != null) {
					CaseCompletionSwitchFinder ccsf = new CaseCompletionSwitchFinder(caret.Line, caret.Column);
					currentMember.AcceptVisitor(ccsf, null);
					if (ccsf.bestStatement != null) {
						r.RunLookupTableVisitor(currentMember);
						ResolveResult rr = r.ResolveInternal(ccsf.bestStatement.SwitchExpression, ExpressionContext.Default);
						if (rr != null && rr.ResolvedType != null) {
							return ProvideContextCompletion(editor, rr.ResolvedType, ' ');
						}
					}
				}
			}
			return false;
		}