private string GetEnterCompleteItemText()
        {
            var boundSettingsStore = settingsStore.BindToContextTransient(ContextRange.ApplicationWide);
            var insertType         = boundSettingsStore.GetValue((CodeCompletionSettingsKey s) => s.EnterKeyInsertType);

            return(GetCompleteItemText(insertType));
        }
 public UnityDeclarationHighlightingProviderBase(ISolution solution, SolutionAnalysisService swa, CallGraphSwaExtensionProvider callGraphSwaExtensionProvider,
                                                 SettingsStore settingsStore, PerformanceCriticalCodeCallGraphAnalyzer analyzer)
 {
     Solution = solution;
     Swa      = swa;
     CallGraphSwaExtensionProvider = callGraphSwaExtensionProvider;
     Analyzer = analyzer;
     Settings = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext()));
 }
コード例 #3
0
 public UnityDeclarationHighlightingProviderBase(ISolution solution, CallGraphSwaExtensionProvider callGraphSwaExtensionProvider,
                                                 SettingsStore settingsStore, PerformanceCriticalCodeCallGraphMarksProvider marksProvider, IElementIdProvider provider)
 {
     Solution = solution;
     CallGraphSwaExtensionProvider = callGraphSwaExtensionProvider;
     MarksProvider = marksProvider;
     Settings      = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext()));
     myProvider    = provider;
 }
コード例 #4
0
 public UnityCommonIconProvider(ISolution solution, SolutionAnalysisService swa, CallGraphSwaExtensionProvider callGraphSwaExtensionProvider,
                                SettingsStore settingsStore, PerformanceCriticalCodeCallGraphAnalyzer analyzer, UnityApi unityApi)
 {
     Solution = solution;
     Swa      = swa;
     CallGraphSwaExtensionProvider = callGraphSwaExtensionProvider;
     Analyzer = analyzer;
     UnityApi = unityApi;
     Settings = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext()));
 }
コード例 #5
0
 public UnityCommonIconProvider(ISolution solution,
                                CallGraphSwaExtensionProvider callGraphSwaExtensionProvider,
                                SettingsStore settingsStore, PerformanceCriticalCodeCallGraphMarksProvider marksProvider, UnityApi unityApi,
                                IElementIdProvider provider)
 {
     Solution = solution;
     CallGraphSwaExtensionProvider = callGraphSwaExtensionProvider;
     MarksProvider = marksProvider;
     UnityApi      = unityApi;
     Settings      = settingsStore.BindToContextTransient(ContextRange.Smart(solution.ToDataContext()));
     myProvider    = provider;
 }
コード例 #6
0
        private bool ReformatForSmartEnter(string dummyText, ITextControl textControl, IFile file, TreeTextRange reparseTreeOffset, TreeOffset lBraceTreePos, TreeOffset rBraceTreePos, bool insertEnterAfter = false)
        {
            // insert dummy text and reformat
            TreeOffset newCaretPos;
            var        codeFormatter = GetCodeFormatter(file);

            using (PsiTransactionCookie.CreateAutoCommitCookieWithCachesUpdate(PsiServices, "Typing assist"))
            {
                string newLine      = Environment.NewLine;
                string textToInsert = newLine + dummyText;
                if (insertEnterAfter)
                {
                    textToInsert = textToInsert + newLine;
                }
                file = file.ReParse(reparseTreeOffset, textToInsert);
                if (file == null)
                {
                    return(false);
                }

                ITreeNode lBraceNode = file.FindTokenAt(lBraceTreePos);
                if (lBraceNode == null)
                {
                    return(false);
                }

                var dummyNode = file.FindTokenAt(reparseTreeOffset.StartOffset + newLine.Length) as ITokenNode;

                var languageService = file.Language.LanguageService();
                if (languageService == null)
                {
                    return(false);
                }

                while (dummyNode != null && languageService.IsFilteredNode(dummyNode))
                {
                    dummyNode = dummyNode.GetNextToken();
                }

                if (dummyNode == null)
                {
                    return(false);
                }

                var rBraceNode = file.FindTokenAt(rBraceTreePos + newLine.Length + dummyText.Length + (insertEnterAfter ? newLine.Length : 0));

                var boundSettingsStore = SettingsStore.BindToContextTransient(textControl.ToContextRange());

                codeFormatter.Format(lBraceNode, CodeFormatProfile.DEFAULT, null, boundSettingsStore);
                codeFormatter.Format(
                    rBraceNode.FindFormattingRangeToLeft(),
                    rBraceNode,
                    CodeFormatProfile.DEFAULT,
                    null,
                    boundSettingsStore);
                codeFormatter.Format(lBraceNode.Parent, CodeFormatProfile.INDENT, null);

                newCaretPos = dummyNode.GetTreeStartOffset();
                file        = file.ReParse(new TreeTextRange(newCaretPos, newCaretPos + dummyText.Length), "");
                Assertion.Assert(file != null, "file != null");
            }

            // dposition cursor
            DocumentRange newCaretPosition = file.GetDocumentRange(newCaretPos);

            if (newCaretPosition.IsValid())
            {
                textControl.Caret.MoveTo(newCaretPosition.TextRange.StartOffset, CaretVisualPlacement.DontScrollIfVisible);
            }

            return(true);
        }