public void Apply(BaseCodeCompletionContext context, IList<ILookupItem> result)
        {
            IParameterDescriptorProvider provider = GetParameterDescriptorProvider(context);

            ICollection<IParameterDescriptor> descriptors = provider.GetParameterDescriptors();

            // it's parameters conception hak, TODO fix conception
            IXmlTag tag = context.GetAttributeTag();
            Assert.CheckNotNull(tag);

            foreach (IParameterDescriptor descriptor in descriptors)
            {
                if (!descriptor.IsAttribute)
                    continue;

                // scipr declared attribjutes
                // it's parameters conception hak, TODO fix conception
                if(tag.GetAttribute(descriptor.Name) != null)
                    continue;

                LookupItemBase item = CreateItem(descriptor, context);
                item.InsertRange = new TextRange(0);
                item.ReplaceRange = new TextRange(0, context.GetPrefix().Length);
                result.Add(item);
            }
        }
        public void Apply(BaseCodeCompletionContext context, IList<ILookupItem> result)
        {
            IXmlTag tag = context.GetAttributeTag();
            Assert.CheckNotNull(tag);
            IXmlAttribute attribute = context.Token.GetContainingElement<IXmlAttribute>(false);
            Assert.CheckNotNull(attribute);

            IParameterDescriptor descriptor = null;
            IDeclaredParameter declaredParameter = tag as IDeclaredParameter;
            if (declaredParameter != null && attribute.AttributeName == L4NConstants.VALUE)
            {
                descriptor = declaredParameter.ParameterDescriptorProvider.GetParameterDescriptor(declaredParameter.Name);
            }
            else
            {
                IParameterDescriptorProvider parameterDescriptorProvider = tag as IParameterDescriptorProvider;
                if (parameterDescriptorProvider == null)
                    return;
                descriptor = parameterDescriptorProvider.GetParameterDescriptor(attribute.AttributeName);
            }

            if(descriptor == null)
                return;

            if(!descriptor.IsEnumerable)
                return;

            string[] values = descriptor.PossibleValues;
            if(values == null)
                return;

            foreach (string v in values)
            {
                TextLookupItem item = new TextLookupItem(v);
                item.InsertRange = new TextRange(0);
                item.ReplaceRange = new TextRange(0, context.GetPrefix().Length);
                result.Add(item);
            }
        }
Beispiel #3
0
 private ILogger GetLogger(BaseCodeCompletionContext context)
 {
     return context.GetAttributeTag() as ILogger;
 }
 private IDeclaredParameter GetDeclaredParameter(BaseCodeCompletionContext context)
 {
     return context.GetAttributeTag() as IDeclaredParameter;
 }
 private IParameterDescriptorProvider GetParameterDescriptorProvider(BaseCodeCompletionContext context)
 {
     return context.GetAttributeTag() as IParameterDescriptorProvider;
 }