protected override CompletionDataList GetAttributeValueCompletions(S.IAttributedXObject ob, S.XAttribute att)
        {
            var list = base.GetAttributeValueCompletions(ob, att) ?? new CompletionDataList();

            if (ob is S.XElement)
            {
                if (ob.Name.HasPrefix)
                {
                    string id = ob.GetId();
                    if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(id.Trim()))
                    {
                        id = null;
                    }
                    AddAspAttributeValueCompletionData(list, ob.Name, att.Name, id);
                }
            }
            else if (ob is AspNetDirective)
            {
                return(DirectiveCompletion.GetAttributeValues(project, Document.FileName, ob.Name.FullName, att.Name.FullName));
            }
            return(list.Count > 0? list : null);
        }
示例#2
0
        protected override CompletionDataList GetAttributeCompletions(S.IAttributedXObject attributedOb,
                                                                      Dictionary <string, string> existingAtts)
        {
            var list = base.GetAttributeCompletions(attributedOb, existingAtts) ?? new CompletionDataList();

            if (attributedOb is S.XElement)
            {
                if (!existingAtts.ContainsKey("runat"))
                {
                    list.Add("runat=\"server\"", "md-literal",
                             GettextCatalog.GetString("Required for ASP.NET controls.\n") +
                             GettextCatalog.GetString(
                                 "Indicates that this tag should be able to be\n" +
                                 "manipulated programmatically on the web server."));
                }

                if (!existingAtts.ContainsKey("id"))
                {
                    list.Add("id", "md-literal",
                             GettextCatalog.GetString("Unique identifier.\n") +
                             GettextCatalog.GetString(
                                 "An identifier that is unique within the document.\n" +
                                 "If the tag is a server control, this will be used \n" +
                                 "for the corresponding variable name in the CodeBehind."));
                }

                existingAtts["ID"] = "";
                if (attributedOb.Name.HasPrefix)
                {
                    AddAspAttributeCompletionData(list, attributedOb.Name, existingAtts);
                }
            }
            else if (attributedOb is AspNetDirective)
            {
                return(DirectiveCompletion.GetAttributes(project, attributedOb.Name.FullName, existingAtts));
            }
            return(list.Count > 0? list : null);
        }
示例#3
0
        protected override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext,
                                                                    bool forced, ref int triggerWordLength)
        {
            ITextBuffer buf = this.Buffer;
            // completionChar may be a space even if the current char isn't, when ctrl-space is fired t
            char currentChar = completionContext.TriggerOffset < 1? ' ' : buf.GetCharAt(completionContext.TriggerOffset - 1);

            //char previousChar = completionContext.TriggerOffset < 2? ' ' : buf.GetCharAt (completionContext.TriggerOffset - 2);


            //directive names
            if (Tracker.Engine.CurrentState is AspNetDirectiveState)
            {
                var directive = Tracker.Engine.Nodes.Peek() as AspNetDirective;
                if (HasDoc && directive != null && directive.Region.BeginLine == completionContext.TriggerLine &&
                    directive.Region.BeginColumn + 3 == completionContext.TriggerLineOffset)
                {
                    return(DirectiveCompletion.GetDirectives(aspDoc.Type));
                }
                return(null);
            }
            else if (Tracker.Engine.CurrentState is S.XmlNameState && Tracker.Engine.CurrentState.Parent is AspNetDirectiveState)
            {
                var directive = Tracker.Engine.Nodes.Peek() as AspNetDirective;
                if (HasDoc && directive != null && directive.Region.BeginLine == completionContext.TriggerLine &&
                    directive.Region.BeginColumn + 4 == completionContext.TriggerLineOffset && char.IsLetter(currentChar))
                {
                    triggerWordLength = 1;
                    return(DirectiveCompletion.GetDirectives(aspDoc.Type));
                }
                return(null);
            }

            bool isAspExprState = Tracker.Engine.CurrentState is AspNetExpressionState;

            //non-xml tag completion
            if (currentChar == '<' && !(isAspExprState || Tracker.Engine.CurrentState is S.XmlFreeState))
            {
                var list = new CompletionDataList();
                AddAspBeginExpressions(list);
                return(list);
            }

            if (!HasDoc || aspDoc.Info.DocType == null)
            {
                //FIXME: get doctype from master page
                DocType = null;
            }
            else
            {
                DocType = new MonoDevelop.Xml.StateEngine.XDocType(TextLocation.Empty);
                var matches = DocTypeRegex.Match(aspDoc.Info.DocType);
                DocType.PublicFpi = matches.Groups["fpi"].Value;
                DocType.Uri       = matches.Groups["uri"].Value;
            }

            if (Tracker.Engine.CurrentState is HtmlScriptBodyState)
            {
                var el = Tracker.Engine.Nodes.Peek() as S.XElement;
                if (el != null)
                {
                    var att = GetHtmlAtt(el, "runat");
                    if (att != null && "server".Equals(att.Value, StringComparison.OrdinalIgnoreCase))
                    {
                        if (documentBuilder != null)
                        {
                            // TODO: C# completion
                        }
                    }

                    /*
                     * else {
                     *      att = GetHtmlAtt (el, "language");
                     *      if (att == null || "javascript".Equals (att.Value, StringComparison.OrdinalIgnoreCase)) {
                     *          att = GetHtmlAtt (el, "type");
                     *              if (att == null || "text/javascript".Equals (att.Value, StringComparison.OrdinalIgnoreCase)) {
                     *                      // TODO: JS completion
                     *              }
                     *      }
                     * }*/
                }
            }

            return(base.HandleCodeCompletion(completionContext, forced, ref triggerWordLength));
        }