private TextLookupRanges EvaluateRanges(ISpecificCodeCompletionContext context)
        {
            var file = context.BasicContext.File as INTriplesFile;

            DocumentRange selectionRange = context.BasicContext.SelectedRange;

            if (file != null)
            {
                var token = file.FindNodeAt(selectionRange) as ITokenNode;

                if (token != null)
                {
                    DocumentRange tokenRange = token.GetNavigationRange();

                    var insertRange  = new TextRange(tokenRange.TextRange.StartOffset, selectionRange.TextRange.EndOffset);
                    var replaceRange = new TextRange(
                        tokenRange.TextRange.StartOffset,
                        Math.Max(tokenRange.TextRange.EndOffset, selectionRange.TextRange.EndOffset));

                    return(new TextLookupRanges(insertRange, replaceRange));
                }
            }

            return(new TextLookupRanges(TextRange.InvalidRange, TextRange.InvalidRange));
        }
Exemplo n.º 2
0
        private IRangeMarker CreateRangeMarker(ISpecificCodeCompletionContext context)
        {
            var rangeMarker =
                new TextRange(context.BasicContext.CaretDocumentOffset.Offset).CreateRangeMarker(
                    context.BasicContext.Document);

            return(rangeMarker);
        }
        public static bool IsInsideAccessorType(this ISpecificCodeCompletionContext context, string accessorType)
        {
            var nodeAt = context.BasicContext.File.FindNodeAt(context.BasicContext.CaretDocumentOffset);

            var accessorClrType = nodeAt.GetAccessorSuperTypes();

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

            return(accessorClrType.Any(t => t.ToString().Equals(accessorType, StringComparison.OrdinalIgnoreCase)));
        }
        public static bool IsInsideMethodPath(this ISpecificCodeCompletionContext context, string path)
        {
            var nodeAt = context.BasicContext.File.FindNodeAt(context.BasicContext.CaretDocumentOffset);

            var accessorPath = nodeAt.GetMethodPath();

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

            return(accessorPath.Equals(path));
        }
Exemplo n.º 5
0
        private LinkedList <KeyValueSettingLookupItem> CreateLookupItems(
            ISpecificCodeCompletionContext context,
            IEnumerable <KeyValueSetting> settings,
            IProjectModelElement project,
            IRangeMarker rangeMarker,
            LinkedList <KeyValueSettingLookupItem> lookupItems)
        {
            foreach (var setting in settings)
            {
                var iconId     = _presentationService.GetIcon(project);
                var lookupItem = new KeyValueSettingLookupItem(setting, iconId, rangeMarker);
                lookupItem.InitializeRanges(context.EvaluateRanges(), context.BasicContext);

                lookupItems.AddLast(lookupItem);
            }

            return(lookupItems);
        }
Exemplo n.º 6
0
        public LinkedList <KeyValueSettingLookupItem> GetJsonSettingsLookupItems(
            ISpecificCodeCompletionContext context,
            JsonSettingType settingType,
            string jsonPath = null)
        {
            var lookupItems = new LinkedList <KeyValueSettingLookupItem>();

            var project = context.BasicContext.File.GetProject();

            if (project == null)
            {
                return(lookupItems);
            }

            var rangeMarker = CreateRangeMarker(context);
            var settings    = project.GetJsonProjectSettings(settingType, jsonPath);

            return(CreateLookupItems(context, settings, project, rangeMarker, lookupItems));
        }
        public static TextLookupRanges EvaluateRanges(this ISpecificCodeCompletionContext context)
        {
            var basicContext = context.BasicContext;

            var startOffset = basicContext.CaretDocumentOffset;
            var endOffset   = basicContext.SelectedRange.EndOffset;

            var caretTreeOffset = basicContext.CaretTreeOffset;

            if (basicContext.File.FindTokenAt(caretTreeOffset) is ITokenNode tokenNode && tokenNode.IsAnyStringLiteral())
            {
                startOffset = tokenNode.GetDocumentStartOffset();
                endOffset   = tokenNode.GetDocumentEndOffset();
            }

            var replaceRange = new DocumentRange(startOffset, endOffset);

            return(new TextLookupRanges(replaceRange, replaceRange));
        }
Exemplo n.º 8
0
        public LinkedList <KeyValueSettingLookupItem> GetXmlSettingsLookupItems(
            ISpecificCodeCompletionContext context,
            string settingsTagName,
            string settingsKeyAttribute,
            string settingsValueAttributes)
        {
            var lookupItems = new LinkedList <KeyValueSettingLookupItem>();

            var project = context.BasicContext.File.GetProject();

            if (project == null)
            {
                return(lookupItems);
            }

            var rangeMarker = CreateRangeMarker(context);
            var settings    = project.GetXmlProjectSettings(settingsTagName, settingsKeyAttribute, settingsValueAttributes);

            return(CreateLookupItems(context, settings, project, rangeMarker, lookupItems));
        }
Exemplo n.º 9
0
 private static bool IsDoubleCompletion(ISpecificCodeCompletionContext context)
 {
     return(context.BasicContext.Parameters.Multiplier == 2);
 }
Exemplo n.º 10
0
 public void TransformItems(ISpecificCodeCompletionContext context, IItemsCollector collector, object data)
 {
     PriorityAdjuster.PutMoqCompleteAtTop(collector);
 }
Exemplo n.º 11
0
 public bool AddLookupItems(ISpecificCodeCompletionContext context, IItemsCollector collector, object data)
 => true;
Exemplo n.º 12
0
 public object IsAvailable(ISpecificCodeCompletionContext context)
 => true;