コード例 #1
1
        public FromImportCompletionAnalysis(IList<ClassificationSpan> tokens, ITrackingSpan span, ITextBuffer textBuffer, CompletionOptions options)
            : base(span, textBuffer, options)
        {
            Debug.Assert(tokens[0].Span.GetText() == "from");

            int beforeImportToken = tokens
                .TakeWhile(tok => !(tok.ClassificationType.IsOfType(PredefinedClassificationTypeNames.Keyword) && tok.Span.GetText() == "import"))
                .Count();

            bool lastIsDot = tokens.Last().ClassificationType.IsOfType(JPredefinedClassificationTypeNames.Dot);
            _modulesOnly = beforeImportToken == tokens.Count;
            _noCompletions = !_modulesOnly && lastIsDot;
            _includeStar = beforeImportToken == tokens.Count - 1;

            if (beforeImportToken >= 2) {
                // If there are at least two tokens ('from' <name>) before the
                // 'import' token, use completions from that package.
                if (beforeImportToken < tokens.Count || lastIsDot) {
                    _namespace = tokens
                        .Take(beforeImportToken)
                        .Where(tok => tok.ClassificationType.IsOfType(PredefinedClassificationTypeNames.Identifier))
                        .Select(tok => tok.Span.GetText())
                        .ToArray();
                } else {
                    _importKeywordOnly = true;
                }
            }
        }
コード例 #2
0
ファイル: CompletionSource.cs プロジェクト: borota/JTVS
        public static CompletionOptions GetOptions(this ICompletionSession session)
        {
            var options = new CompletionOptions {
                ConvertTabsToSpaces = session.TextView.Options.IsConvertTabsToSpacesEnabled(),
                IndentSize = session.TextView.Options.GetIndentSize(),
                TabSize = session.TextView.Options.GetTabSize()
            };

            if (JToolsPackage.Instance != null) {
                options.IntersectMembers = JToolsPackage.Instance.AdvancedEditorOptionsPage.IntersectMembers;
                options.HideAdvancedMembers = JToolsPackage.Instance.LangPrefs.HideAdvancedMembers;
                options.FilterCompletions = JToolsPackage.Instance.AdvancedEditorOptionsPage.FilterCompletions;
                options.SearchMode = JToolsPackage.Instance.AdvancedEditorOptionsPage.SearchMode;
            }
            return options;
        }
コード例 #3
0
        internal ImportCompletionAnalysis(IList<ClassificationSpan> tokens, ITrackingSpan span, ITextBuffer textBuffer, CompletionOptions options)
            : base(span, textBuffer, options)
        {
            Debug.Assert(tokens[0].Span.GetText() == "import");

            int beforeLastComma = tokens
                .Reverse()
                .SkipWhile(tok => !tok.ClassificationType.IsOfType(JPredefinedClassificationTypeNames.Comma))
                .Count();

            if (tokens.Count >= 2 && beforeLastComma < tokens.Count) {
                int spanEnd = Span.GetEndPoint(textBuffer.CurrentSnapshot).Position;
                var nameParts = new List<string>();
                bool removeLastPart = false, lastWasError = false;
                foreach(var tok in tokens.Skip(beforeLastComma > 0 ? beforeLastComma : 1)) {
                    if (tok.ClassificationType.IsOfType(PredefinedClassificationTypeNames.Identifier)) {
                        nameParts.Add(tok.Span.GetText());
                        // Only remove the last part if the trigger point is
                        // not right at the end of it.
                        removeLastPart = (tok.Span.End.Position != spanEnd);
                    } else if (tok.ClassificationType.IsOfType(JPredefinedClassificationTypeNames.Dot)) {
                        removeLastPart = false;
                    } else {
                        lastWasError = true;
                        break;
                    }
                }

                if (!lastWasError) {
                    if (removeLastPart && nameParts.Count > 0) {
                        nameParts.RemoveAt(nameParts.Count - 1);
                    }
                    _namespace = nameParts.ToArray();
                }
            }
        }
コード例 #4
0
 internal NormalCompletionAnalysis(VsProjectAnalyzer analyzer, ITextSnapshot snapshot, ITrackingSpan span, ITextBuffer textBuffer, CompletionOptions options)
     : base(span, textBuffer, options)
 {
     _snapshot = snapshot;
     _analyzer = analyzer;
 }
コード例 #5
0
ファイル: CompletionAnalysis.cs プロジェクト: borota/JTVS
 internal CompletionAnalysis(ITrackingSpan span, ITextBuffer textBuffer, CompletionOptions options)
 {
     _span = span;
     _textBuffer = textBuffer;
     _options = (options == null) ? new CompletionOptions() : options.Clone();
 }
コード例 #6
0
 internal DecoratorCompletionAnalysis(ITrackingSpan span, ITextBuffer textBuffer, CompletionOptions options)
     : base(span, textBuffer, options)
 {
 }
コード例 #7
0
 internal StringLiteralCompletionList(ITrackingSpan span, ITextBuffer textBuffer, CompletionOptions options)
     : base(span, textBuffer, options)
 {
 }
コード例 #8
0
ファイル: JAnalysisExtensions.cs プロジェクト: borota/JTVS
 /// <summary>
 /// Gets a CompletionAnalysis providing a list of possible members the user can dot through.
 /// </summary>
 public static CompletionAnalysis GetCompletions(this ITextSnapshot snapshot, ITrackingSpan span, ITrackingPoint point, CompletionOptions options)
 {
     return VsProjectAnalyzer.GetCompletions(snapshot, span, point, options);
 }
コード例 #9
0
 internal OverrideCompletionAnalysis(ITrackingSpan span, ITextBuffer textBuffer, CompletionOptions options)
     : base(span, textBuffer, options) {
 }
コード例 #10
0
ファイル: FuzzyCompletionSet.cs プロジェクト: borota/JTVS
        /// <summary>
        /// Initializes a new instance with the specified properties.
        /// </summary>
        /// <param name="moniker">The unique, non-localized identifier for the
        /// completion set.</param>
        /// <param name="displayName">The localized name of the completion set.
        /// </param>
        /// <param name="applicableTo">The tracking span to which the
        /// completions apply.</param>
        /// <param name="completions">The list of completions.</param>
        /// <param name="options">The options to use for filtering and
        /// selecting items.</param>
        /// <param name="comparer">The comparer to use to order the provided
        /// completions.</param>
        public FuzzyCompletionSet(string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable<DynamicallyVisibleCompletion> completions, CompletionOptions options, IComparer<Completion> comparer)
            : base(moniker, displayName, applicableTo, null, null)
        {
            _completions = new BulkObservableCollection<Completion>();
            _completions.AddRange(completions.OrderBy(c => c, comparer));
            _comparer = new FuzzyStringMatcher(options.SearchMode);

            _shouldFilter = options.FilterCompletions;
            _shouldHideAdvanced = options.HideAdvancedMembers;

            if (_shouldFilter | _shouldHideAdvanced) {
                _filteredCompletions = new FilteredObservableCollection<Completion>(_completions);

                foreach (var c in _completions.Cast<DynamicallyVisibleCompletion>()) {
                    c.Visible = !_shouldHideAdvanced || !IsAdvanced(c);
                }
                _filteredCompletions.Filter(IsVisible);
            }
        }