Ejemplo n.º 1
0
        public void Apply(CodeCompletionContext 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(CodeCompletionContext 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);
            }
        }
Ejemplo n.º 3
0
 private IParameterDescriptorProvider GetParameterDescriptorProvider(CodeCompletionContext context)
 {
     return context.GetAttributeTag() as IParameterDescriptorProvider;
 }
 private IDeclaredParameter GetDeclaredParameter(CodeCompletionContext context)
 {
     return context.GetAttributeTag() as IDeclaredParameter;
 }
Ejemplo n.º 5
0
 private ILogger GetLogger(CodeCompletionContext context)
 {
     return context.GetAttributeTag() as ILogger;
 }