Exemple #1
0
        private void ProcessDirective([NotNull] IT4Directive directive)
        {
            IT4Token nameToken = directive.GetNameToken();

            if (nameToken == null)
            {
                return;
            }

            DirectiveInfo directiveInfo = _directiveInfoManager.GetDirectiveByName(nameToken.GetText());

            if (directiveInfo == null)
            {
                return;
            }

            // Notify of missing required attributes.
            IEnumerable <string> attributeNames = directive.GetAttributes().SelectNotNull(attr => attr.GetName());
            var hashSet = new JetHashSet <string>(attributeNames, StringComparer.OrdinalIgnoreCase);

            foreach (DirectiveAttributeInfo attributeInfo in directiveInfo.SupportedAttributes)
            {
                if (attributeInfo.IsRequired && !hashSet.Contains(attributeInfo.Name))
                {
                    AddHighlighting(new HighlightingInfo(nameToken.GetHighlightingRange(),
                                                         new MissingRequiredAttributeHighlighting(nameToken, attributeInfo.Name)));
                }
            }

            // Assembly attributes in preprocessed templates are useless.
            if (directiveInfo == _directiveInfoManager.Assembly && DaemonProcess.SourceFile.ToProjectFile().IsPreprocessedT4Template())
            {
                AddHighlighting(new HighlightingInfo(directive.GetHighlightingRange(), new IgnoredAssemblyDirectiveHighlighting(directive)));
            }
        }
Exemple #2
0
        private void ProcessDirective([NotNull] IT4Directive directive)
        {
            IT4Token nameToken = directive.GetNameToken();

            if (nameToken == null)
            {
                return;
            }

            DirectiveInfo directiveInfo = _directiveInfoManager.GetDirectiveByName(nameToken.GetText());

            if (directiveInfo == null)
            {
                return;
            }

            IEnumerable <string> attributeNames = directive.GetAttributes().SelectNotNull(attr => attr.GetName());
            var hashSet = new JetHashSet <string>(attributeNames, StringComparer.OrdinalIgnoreCase);

            foreach (DirectiveAttributeInfo attributeInfo in directiveInfo.SupportedAttributes)
            {
                if (attributeInfo.IsRequired && !hashSet.Contains(attributeInfo.Name))
                {
                    AddHighlighting(new HighlightingInfo(nameToken.GetHighlightingRange(),
                                                         new MissingRequiredAttributeHighlighting(nameToken, attributeInfo.Name)));
                }
            }
        }