コード例 #1
0
        private static bool GetContext(object data)
        {
            if (mxmlContext == null || mxmlContext.model == null)
            {
                return(false);
            }

            ScintillaControl sci = PluginBase.MainForm.CurrentDocument.SciControl;

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

            // XmlComplete context
            try
            {
                if (data is XMLContextTag)
                {
                    tagContext = (XMLContextTag)data;
                }
                else
                {
                    object[] o = (object[])data;
                    tagContext   = (XMLContextTag)o[0];
                    tokenContext = (string)o[1];
                }
            }
            catch
            {
                return(false);
            }

            // more context
            parentTag = XMLComplete.GetParentTag(sci, tagContext);

            // rebuild tags cache?
            string sum = "" + context.GetAllProjectClasses().Count;

            foreach (string uri in mxmlContext.namespaces.Values)
            {
                sum += uri;
            }
            if (IsDirty || sum != checksum)
            {
                checksum = sum;
                GetAllTags();
            }
            return(true);
        }
コード例 #2
0
ファイル: MxmlComplete.cs プロジェクト: Gr33z00/flashdevelop
        public static bool GotoDeclaration()
        {
            ScintillaNet.ScintillaControl sci = PluginBase.MainForm.CurrentDocument.SciControl;
            if (sci == null)
            {
                return(false);
            }
            if (sci.ConfigurationLanguage != "xml")
            {
                return(false);
            }

            int pos = sci.CurrentPos;
            int len = sci.TextLength;

            while (pos < len)
            {
                char c = (char)sci.CharAt(pos);
                if (c <= 32 || c == '/' || c == '>')
                {
                    break;
                }
                pos++;
            }
            XMLContextTag ctag = XMLComplete.GetXMLContextTag(sci, pos);

            if (ctag.Name == null)
            {
                return(true);
            }
            string word = sci.GetWordFromPosition(sci.CurrentPos);

            string     type  = ResolveType(mxmlContext, ctag.Name);
            ClassModel model = context.ResolveType(type, mxmlContext.model);

            if (model.IsVoid()) // try resolving tag as member of parent tag
            {
                parentTag = XMLComplete.GetParentTag(sci, ctag);
                if (parentTag.Name != null)
                {
                    ctag  = parentTag;
                    type  = ResolveType(mxmlContext, ctag.Name);
                    model = context.ResolveType(type, mxmlContext.model);
                    if (model.IsVoid())
                    {
                        return(true);
                    }
                }
                else
                {
                    return(true);
                }
            }

            if (!ctag.Name.EndsWith(word))
            {
                ASResult found = ResolveAttribute(model, word);
                ASComplete.OpenDocumentToDeclaration(sci, found);
            }
            else
            {
                ASResult found = new ASResult();
                found.InFile = model.InFile;
                found.Type   = model;
                ASComplete.OpenDocumentToDeclaration(sci, found);
            }
            return(true);
        }