コード例 #1
0
 private void UpdateChainResolverActual(System.Object context)
 {
     isCreatingChainResolver = true;
     try {
         try {
             //Debug.Log("UpdateChainResolverActual");
             if (chainResolver != null && chainResolver.reflectionDB != null && !chainResolver.reflectionDB.needsToBeKilled)
             {
                 chainResolver.Refresh(editor, editor.cursor.GetVectorPosition());
             }
             else
             {
                 //Debug.Log("UpdateChainResolverActual");
                 chainResolver = new ChainResolver(editor, editor.cursor.GetVectorPosition());
             }
         }
         catch (System.Exception ex) {
             Debug.LogError(ex.Message);
         }
     }
     finally {
         //UIDEThreadPool.UnregisterThread("SRCSUS_UpdateChainResolver");
     }
     isCreatingChainResolver = false;
 }
コード例 #2
0
        protected override IReadOnlyCollection <ResourceFieldAttribute> OnResolveFieldChain(string path, FieldChainRequirements chainRequirements)
        {
            var field = ChainResolver.GetField(path, _resourceContext, path);

            _validateSingleFieldCallback?.Invoke(field, _resourceContext, path);

            return(new[] { field });
        }
コード例 #3
0
        protected override IReadOnlyCollection <ResourceFieldAttribute> OnResolveFieldChain(string path, FieldChainRequirements chainRequirements)
        {
            var attribute = ChainResolver.GetAttribute(path, _resourceContextInScope, path);

            _validateSingleAttributeCallback?.Invoke(attribute, _resourceContextInScope, path);

            return(new[] { attribute });
        }
コード例 #4
0
        public override void Start()
        {
            UIDEThreadPool.timeout = 5.0f;
            lastReparseTime        = editor.editorWindow.time;
            useUnityscript         = editor.extension == ".js";

            conservativeParsing  = Application.platform == RuntimePlatform.OSXEditor;
            conservativeParsing |= true;

            chainResolver = null;
            Reparse();
            UpdateChainResolver();
        }
コード例 #5
0
        protected override IReadOnlyCollection <ResourceFieldAttribute> OnResolveFieldChain(string path, FieldChainRequirements chainRequirements)
        {
            if (chainRequirements == FieldChainRequirements.EndsInToMany)
            {
                return(ChainResolver.ResolveToOneChainEndingInToMany(_resourceContextInScope, path));
            }

            if (chainRequirements == FieldChainRequirements.EndsInAttribute)
            {
                return(ChainResolver.ResolveToOneChainEndingInAttribute(_resourceContextInScope, path, _validateSingleFieldCallback));
            }

            throw new InvalidOperationException($"Unexpected combination of chain requirement flags '{chainRequirements}'.");
        }
コード例 #6
0
        public void SetUp()
        {
            graph = new FubuRegistry(x =>
            {
                x.Actions.IncludeType <ChainResolverController>();
            }).BuildGraph();

            graph.Behaviors.Each(x => Debug.WriteLine(x.FirstCallDescription()));

            typeResolver = new TypeResolver();
            typeResolver.AddStrategy <ProxyDetector>();

            resolver = new ChainResolver(typeResolver, graph);
        }
コード例 #7
0
        protected override IReadOnlyCollection <ResourceFieldAttribute> OnResolveFieldChain(string path, FieldChainRequirements chainRequirements)
        {
            if (chainRequirements == FieldChainRequirements.EndsInToMany)
            {
                // The mismatch here (ends-in-to-many being interpreted as entire-chain-must-be-to-many) is intentional.
                return(ChainResolver.ResolveToManyChain(_resourceContextInScope, path, _validateSingleFieldCallback));
            }

            if (chainRequirements == FieldChainRequirements.IsRelationship)
            {
                return(ChainResolver.ResolveRelationshipChain(_resourceContextInScope, path, _validateSingleFieldCallback));
            }

            throw new InvalidOperationException($"Unexpected combination of chain requirement flags '{chainRequirements}'.");
        }
コード例 #8
0
        public override TooltipItem GetTooltipItem(Vector2 pos)
        {
            Vector2 originalPos = pos;
            if (parserInterface.lastSourceFile == null) {
                Reparse();
            }

            pos = editor.doc.GoToEndOfWord(pos,1);
            Vector2 endWordPos = editor.doc.IncrementPosition(pos,-1);
            pos = editor.doc.GoToEndOfWhitespace(pos,1);

            ExpressionInfo result = new ExpressionInfo();
            result.startPosition = pos;
            result.endPosition = pos;
            result.initialized = true;

            char nextChar = editor.doc.GetCharAt(pos);
            bool isBeginGeneric = nextChar == '<';
            if (useUnityscript) {
                Vector2 charAfterPos = editor.doc.GoToEndOfWhitespace(editor.doc.IncrementPosition(pos,1),1);
                char charAfter = editor.doc.GetCharAt(charAfterPos);
                if (nextChar == '.' && charAfter == '<') {
                    pos = charAfterPos;
                    nextChar = editor.doc.GetCharAt(pos);
                    isBeginGeneric = true;
                }
            }
            //GameObject go;

            //go.GetComponent<Vector3>();
            if (isBeginGeneric) {
                result.startPosition = pos;
                result.endPosition = pos;
                ExpressionResolver.editor = editor;
                result = ExpressionResolver.CountToExpressionEnd(result,1,ExpressionBracketType.Generic);

                pos = result.endPosition;
                pos = editor.doc.IncrementPosition(pos,1);
                pos = editor.doc.GoToEndOfWhitespace(pos,1);

                result.startPosition = pos;
                result.endPosition = pos;
                nextChar = editor.doc.GetCharAt(pos);
            }

            bool isFunction = false;
            if (nextChar == '(') {
                ExpressionResolver.editor = editor;
                result = ExpressionResolver.CountToExpressionEnd(result,1,ExpressionBracketType.Expression);
                pos = result.endPosition;
                nextChar = editor.doc.GetCharAt(pos);
                isFunction = true;
            }

            if (!isFunction) {
                pos = endWordPos;
            }

            //Debug.Log(nextChar+" "+editor.doc.GetCharAt(endWordPos));

            string str = editor.syntaxRule.ResolveExpressionAt(pos,-1);
            if (useUnityscript) {
                str = str.Replace(".<","<");
            }
            //Debug.Log(str);

            ChainResolver sigChainResolver = new ChainResolver(editor,originalPos);
            ChainItem item = null;
            item = sigChainResolver.ResolveChain(str,false);

            TooltipItem tooltipItem = null;
            if (item != null) {
                if (item.finalLinkType != null) {
                    tooltipItem = new TooltipItem(item.finalLinkType.Name+" "+item.finalLink.name);
                    tooltipItem.clrType = item.finalLinkType;
                }

                if (item.finalLink.completionItem != null) {
                    tooltipItem = new TooltipItem(item.finalLink.completionItem);
                }

            }

            return tooltipItem;
        }
コード例 #9
0
        public override CompletionMethod[] GetMethodOverloads(Vector2 pos)
        {
            //Vector2 originalPos = pos;
            if (parserInterface.lastSourceFile == null) {
                Reparse();
            }

            pos = editor.doc.IncrementPosition(pos,-1);
            pos = editor.doc.IncrementPosition(pos,-1);
            pos = editor.doc.GoToEndOfWhitespace(pos,-1);

            //char nextChar = editor.doc.GetCharAt(pos);
            if (editor.doc.GetCharAt(pos) == '>') {
                ExpressionResolver.editor = editor;
                pos = ExpressionResolver.SimpleMoveToEndOfScope(pos,-1,ExpressionBracketType.Generic);
                pos = editor.doc.GoToEndOfWhitespace(pos,-1);
                if (useUnityscript) {
                    if (editor.doc.GetCharAt(pos) == '.') {
                        pos = editor.doc.IncrementPosition(pos,-1);
                    }
                }
                pos = editor.doc.GoToEndOfWhitespace(pos,-1);
                //GameObject go;
                //go.GetComponent<Vector3>();
            }
            Vector2 endWordPos = pos;

            pos = editor.doc.GoToEndOfWord(pos,-1);
            Vector2 startWordPos = editor.doc.IncrementPosition(pos,1);
            pos = editor.doc.GoToEndOfWhitespace(pos,-1);
            //

            //Debug.Log(editor.doc.GetCharAt(pos));
            bool hasDot = false;
            if (editor.doc.GetCharAt(pos) == '.') {
                if (useUnityscript) {
                    if (editor.doc.GetCharAt(editor.doc.IncrementPosition(pos,1)) != '<') {
                        hasDot = true;
                    }
                }
                else {
                    hasDot = true;
                }
            }

            UIDELine startLine = editor.doc.RealLineAt((int)startWordPos.y);
            string functionName = startLine.rawText.Substring((int)startWordPos.x,((int)endWordPos.x-(int)startWordPos.x)+1);

            pos = editor.doc.IncrementPosition(pos,-1);
            pos = editor.doc.GoToEndOfWhitespace(pos,-1);

            string str = editor.syntaxRule.ResolveExpressionAt(pos,-1);
            if (useUnityscript) {
                str = str.Replace(".<","<");
            }
            //Debug.Log(str);

            CompletionMethod[] methods = new CompletionMethod[0];
            ChainResolver sigChainResolver = new ChainResolver(editor,pos);

            //Handle constructors
            bool isDirectConstructor = str == "new|";
            bool isIndirectConstructor = !isDirectConstructor && str.StartsWith("new|");
            if (isIndirectConstructor && hasDot) {
                isIndirectConstructor = false;
            }
            if (isIndirectConstructor) {
                ChainItem item = null;
                item = sigChainResolver.ResolveChain(str+"."+functionName);
                if (item == null || item.finalLinkType == null) {
                    return methods;
                }
                methods = sigChainResolver.GetConstructors(item.finalLinkType);
                return methods;
            }
            else if (isDirectConstructor) {
                ChainItem item = null;
                item = sigChainResolver.ResolveChain(functionName);
                if (item == null || item.finalLinkType == null) {
                    return methods;
                }
                methods = sigChainResolver.GetConstructors(item.finalLinkType);
                return methods;
            }

            System.Type type = sigChainResolver.reflectionDB.currentType;
            bool isStatic = false;
            if (hasDot) {
                ChainItem item = null;
                item = sigChainResolver.ResolveChain(str,false);
                if (item == null || item.finalLinkType == null) {
                    return methods;
                }
                isStatic = item.finalLink.isStatic;
                type = item.finalLinkType;
            }

            methods = sigChainResolver.GetMethodOverloads(type,functionName,isStatic);

            return methods;
        }
コード例 #10
0
        public void UpdateAutoComplete(string text, bool isBackspace)
        {
            if (!isEnabled) return;
            if (text == "\n" || text == "\b" || (text == "" && !isBackspace)) {
                return;
            }

            if (text.Length > 1) {
                HideBox();
                return;
            }

            UIDELine line = editor.doc.LineAt(editor.cursor.posY);
            UIDEElement element = GetCursorElement();

            if (!genericMode) {
                if (text == "(") {
                    StartShowTooltip(editor.cursor.GetVectorPosition(),true);
                    dontShowToolTipAgain = true;
                    cancelTooltip = false;
                }
                if (text == ")" || isBackspace) {
                    if (isShowingMethodOverloadTooltip) {
                        HideToolTip();
                    }
                    if (!isBackspace) {
                        cancelTooltip = true;
                    }
                }
                if (text == " " && (editor.extension == ".cs" || editor.extension == ".js")) {
                    Vector2 lastWordPos = editor.doc.IncrementPosition(editor.cursor.GetVectorPosition(),-1);
                    lastWordPos = editor.doc.IncrementPosition(lastWordPos,-1);
                    //lastWordPos = editor.doc.GoToEndOfWhitespace(lastWordPos,-1);
                    UIDEElement newElement = editor.doc.GetElementAt(lastWordPos);
                    if (newElement != null && newElement.rawText == "new") {
                        Vector2 newWordStart = lastWordPos;
                        newWordStart.x = line.GetElementStartPos(newElement);
                        Vector2 leadingCharPos = editor.doc.IncrementPosition(newWordStart,-1);
                        leadingCharPos = editor.doc.GoToEndOfWhitespace(leadingCharPos,-1);
                        char leadingChar = editor.doc.GetCharAt(leadingCharPos);
                        if (leadingChar == '=') {
                            Vector2 wordStartPos = editor.doc.IncrementPosition(leadingCharPos,-1);
                            wordStartPos = editor.doc.GoToEndOfWhitespace(wordStartPos,-1);
                            string str = "";
                            UIDEElement firstNonWhitespaceElement = line.GetFirstNonWhitespaceElement();
                            if (editor.extension == ".js" && firstNonWhitespaceElement != null && firstNonWhitespaceElement.rawText == "var") {
                                Vector2 typeStart = editor.doc.GoToNextRealChar(wordStartPos,':',-1);
                                if (typeStart.y == wordStartPos.y) {
                                    typeStart = editor.doc.IncrementPosition(typeStart,1);
                                    typeStart = editor.doc.GoToEndOfWhitespace(typeStart,1);

                                    if (typeStart.x < wordStartPos.x) {
                                        str = line.rawText.Substring((int)typeStart.x,(int)wordStartPos.x-(int)typeStart.x+1);
                                        str = str.Replace(" ","");
                                        str = str.Replace("\t","");
                                        str = str.Replace(".<","<");
                                    }
                                }
                            }
                            else {
                                str = editor.syntaxRule.ResolveExpressionAt(wordStartPos,-1);
                            }
                            ChainResolver sigChainResolver = new ChainResolver(editor,editor.cursor.GetVectorPosition());

                            ChainItem item = null;
                            item = sigChainResolver.ResolveChain(str,false);

                            if (item != null && item.finalLinkType != null) {
                                CompletionItem cItem = new CompletionItem(item.finalLinkType);
                                if (cItem != null) {
                                    string[] usingNamespaces = editor.syntaxRule.GetNamespacesVisibleInCurrentScope(editor.cursor.GetVectorPosition());
                                    string[] chainNamespaces = editor.syntaxRule.GetNamespaceChain(editor.cursor.GetVectorPosition());
                                    cItem.name = cItem.PrettyFormatType(false,usingNamespaces,chainNamespaces);
                                    //Debug.Log(cItem.genericArguments[0].resultingType);
                                    itemList = new List<CompletionItem>();
                                    itemList.Add(cItem);
                                    selectedIndex = 0;
                                    ShowBox();
                                }
                            }

                            return;
                        }

                    }
                }
            }

            if (element != null) {
                isDot = element.tokenDef.HasType("Dot");
                isWord = element.tokenDef.HasType("Word");
                isWhiteSpace = element.tokenDef.HasType("WhiteSpace");
                bool isDotOrWord = isDot||isWord;

                autoCompleteKey = element.rawText;
                int elementPos = line.GetElementStartPos(element);
                bool isChain = false;

                if (isDot) {
                    isChain = true;
                }
                else {
                    if (elementPos > 0 && isWord) {
                        UIDEElement previousElement = line.GetElementAt(elementPos-1);
                        if (previousElement != null) {
                            if (previousElement.tokenDef.HasType("Dot")) {
                                isChain = true;
                            }
                        }
                    }
                }

                if (genericMode) {
                    isChain = false;
                }

                //bool newCharIsWhitespace = text == " "||text == "\t";

                if (visible && isWord) {
                    //continue an existing autocomplete
                }
                if (!visible && isDotOrWord && !isBackspace) {
                    TryStartUpdateAutoCompleteList(isChain);
                }
                if (visible && !isDotOrWord) {
                    HideBox();
                }
                if (visible && isBackspace && !isDotOrWord) {
                    HideBox();
                }
                //For performance on OSX.
                if (Application.platform == RuntimePlatform.OSXEditor) {
                    if (visible && isBackspace) {
                        HideBox();
                        visible = false;
                    }
                }
                if (visible && autoCompleteKey != "") {
                    TryStartUpdateAutoCompleteList(isChain);
                }
                if (visible && isDot) {
                    UpdateRect();
                }
                //TryStartUpdateAutoCompleteList();
            }
            else {
                if (visible) {
                    HideBox();
                }
            }

            editor.editorWindow.Repaint();
        }
コード例 #11
0
 private void UpdateChainResolverActual(System.Object context)
 {
     isCreatingChainResolver = true;
     try {
         try {
             chainResolver = new ChainResolver(editor,editor.cursor.GetVectorPosition());
         }
         catch (System.Exception ex) {
             Debug.LogError(ex.Message);
         }
     }
     finally {
         //UIDEThreadPool.UnregisterThread("SRCSUS_UpdateChainResolver");
     }
     isCreatingChainResolver = false;
 }
コード例 #12
0
        public override CompletionMethod[] GetMethodOverloads(Vector2 pos)
        {
            //Vector2 originalPos = pos;
            if (parserInterface.lastSourceFile == null)
            {
                Reparse();
            }

            pos = editor.doc.IncrementPosition(pos, -1);
            pos = editor.doc.IncrementPosition(pos, -1);
            pos = editor.doc.GoToEndOfWhitespace(pos, -1);

            //char nextChar = editor.doc.GetCharAt(pos);
            if (editor.doc.GetCharAt(pos) == '>')
            {
                ExpressionResolver.editor = editor;
                pos = ExpressionResolver.SimpleMoveToEndOfScope(pos, -1, ExpressionBracketType.Generic);
                pos = editor.doc.GoToEndOfWhitespace(pos, -1);
                if (useUnityscript)
                {
                    if (editor.doc.GetCharAt(pos) == '.')
                    {
                        pos = editor.doc.IncrementPosition(pos, -1);
                    }
                }
                pos = editor.doc.GoToEndOfWhitespace(pos, -1);
                //GameObject go;
                //go.GetComponent<Vector3>();
            }
            Vector2 endWordPos = pos;

            pos = editor.doc.GoToEndOfWord(pos, -1);
            Vector2 startWordPos = editor.doc.IncrementPosition(pos, 1);

            pos = editor.doc.GoToEndOfWhitespace(pos, -1);
            //

            //Debug.Log(editor.doc.GetCharAt(pos));
            bool hasDot = false;

            if (editor.doc.GetCharAt(pos) == '.')
            {
                if (useUnityscript)
                {
                    if (editor.doc.GetCharAt(editor.doc.IncrementPosition(pos, 1)) != '<')
                    {
                        hasDot = true;
                    }
                }
                else
                {
                    hasDot = true;
                }
            }

            UIDELine startLine    = editor.doc.RealLineAt((int)startWordPos.y);
            string   functionName = startLine.rawText.Substring((int)startWordPos.x, ((int)endWordPos.x - (int)startWordPos.x) + 1);

            pos = editor.doc.IncrementPosition(pos, -1);
            pos = editor.doc.GoToEndOfWhitespace(pos, -1);

            string str = editor.syntaxRule.ResolveExpressionAt(pos, -1);

            if (useUnityscript)
            {
                str = str.Replace(".<", "<");
            }
            //Debug.Log(str);

            CompletionMethod[] methods          = new CompletionMethod[0];
            ChainResolver      sigChainResolver = new ChainResolver(editor, pos);

            //Handle constructors
            bool isDirectConstructor   = str == "new|";
            bool isIndirectConstructor = !isDirectConstructor && str.StartsWith("new|");

            if (isIndirectConstructor && hasDot)
            {
                isIndirectConstructor = false;
            }
            if (isIndirectConstructor)
            {
                ChainItem item = null;
                item = sigChainResolver.ResolveChain(str + "." + functionName);
                if (item == null || item.finalLinkType == null)
                {
                    return(methods);
                }
                methods = sigChainResolver.GetConstructors(item.finalLinkType);
                return(methods);
            }
            else if (isDirectConstructor)
            {
                ChainItem item = null;
                item = sigChainResolver.ResolveChain(functionName);
                if (item == null || item.finalLinkType == null)
                {
                    return(methods);
                }
                methods = sigChainResolver.GetConstructors(item.finalLinkType);
                return(methods);
            }

            System.Type type     = sigChainResolver.reflectionDB.currentType;
            bool        isStatic = false;

            if (hasDot)
            {
                ChainItem item = null;
                item = sigChainResolver.ResolveChain(str, false);
                if (item == null || item.finalLinkType == null)
                {
                    return(methods);
                }
                isStatic = item.finalLink.isStatic;
                type     = item.finalLinkType;
            }

            methods = sigChainResolver.GetMethodOverloads(type, functionName, isStatic);

            return(methods);
        }
コード例 #13
0
ファイル: AutoComplete.cs プロジェクト: bradparks/tni-unity
        public void UpdateAutoComplete(string text, bool isBackspace)
        {
            if (!isEnabled)
            {
                return;
            }
            if (text == "\n" || text == "\b" || (text == "" && !isBackspace))
            {
                return;
            }

            if (text.Length > 1)
            {
                HideBox();
                return;
            }

            UIDELine    line    = editor.doc.LineAt(editor.cursor.posY);
            UIDEElement element = GetCursorElement();

            if (!genericMode)
            {
                if (text == "(")
                {
                    StartShowTooltip(editor.cursor.GetVectorPosition(), true);
                    dontShowToolTipAgain = true;
                    cancelTooltip        = false;
                }
                if (text == ")" || isBackspace)
                {
                    if (isShowingMethodOverloadTooltip)
                    {
                        HideToolTip();
                    }
                    if (!isBackspace)
                    {
                        cancelTooltip = true;
                    }
                }
                if (text == " " && (editor.extension == ".cs" || editor.extension == ".js"))
                {
                    Vector2 lastWordPos = editor.doc.IncrementPosition(editor.cursor.GetVectorPosition(), -1);
                    lastWordPos = editor.doc.IncrementPosition(lastWordPos, -1);
                    //lastWordPos = editor.doc.GoToEndOfWhitespace(lastWordPos,-1);
                    UIDEElement newElement = editor.doc.GetElementAt(lastWordPos);
                    if (newElement != null && newElement.rawText == "new")
                    {
                        Vector2 newWordStart = lastWordPos;
                        newWordStart.x = line.GetElementStartPos(newElement);
                        Vector2 leadingCharPos = editor.doc.IncrementPosition(newWordStart, -1);
                        leadingCharPos = editor.doc.GoToEndOfWhitespace(leadingCharPos, -1);
                        char leadingChar = editor.doc.GetCharAt(leadingCharPos);
                        if (leadingChar == '=')
                        {
                            Vector2 wordStartPos = editor.doc.IncrementPosition(leadingCharPos, -1);
                            wordStartPos = editor.doc.GoToEndOfWhitespace(wordStartPos, -1);
                            string      str = "";
                            UIDEElement firstNonWhitespaceElement = line.GetFirstNonWhitespaceElement();
                            if (editor.extension == ".js" && firstNonWhitespaceElement != null && firstNonWhitespaceElement.rawText == "var")
                            {
                                Vector2 typeStart = editor.doc.GoToNextRealChar(wordStartPos, ':', -1);
                                if (typeStart.y == wordStartPos.y)
                                {
                                    typeStart = editor.doc.IncrementPosition(typeStart, 1);
                                    typeStart = editor.doc.GoToEndOfWhitespace(typeStart, 1);

                                    if (typeStart.x < wordStartPos.x)
                                    {
                                        str = line.rawText.Substring((int)typeStart.x, (int)wordStartPos.x - (int)typeStart.x + 1);
                                        str = str.Replace(" ", "");
                                        str = str.Replace("\t", "");
                                        str = str.Replace(".<", "<");
                                    }
                                }
                            }
                            else
                            {
                                str = editor.syntaxRule.ResolveExpressionAt(wordStartPos, -1);
                            }
                            ChainResolver sigChainResolver = new ChainResolver(editor, editor.cursor.GetVectorPosition());

                            ChainItem item = null;
                            item = sigChainResolver.ResolveChain(str, false);

                            if (item != null && item.finalLinkType != null)
                            {
                                CompletionItem cItem = new CompletionItem(item.finalLinkType);
                                if (cItem != null)
                                {
                                    string[] usingNamespaces = editor.syntaxRule.GetNamespacesVisibleInCurrentScope(editor.cursor.GetVectorPosition());
                                    string[] chainNamespaces = editor.syntaxRule.GetNamespaceChain(editor.cursor.GetVectorPosition());
                                    cItem.name = cItem.PrettyFormatType(false, usingNamespaces, chainNamespaces);
                                    //Debug.Log(cItem.genericArguments[0].resultingType);
                                    itemList = new List <CompletionItem>();
                                    itemList.Add(cItem);
                                    selectedIndex = 0;
                                    ShowBox();
                                }
                            }

                            return;
                        }
                    }
                }
            }

            if (element != null)
            {
                isDot        = element.tokenDef.HasType("Dot");
                isWord       = element.tokenDef.HasType("Word");
                isWhiteSpace = element.tokenDef.HasType("WhiteSpace");
                bool isDotOrWord = isDot || isWord;

                autoCompleteKey = element.rawText;
                int  elementPos = line.GetElementStartPos(element);
                bool isChain    = false;

                if (isDot)
                {
                    isChain = true;
                }
                else
                {
                    if (elementPos > 0 && isWord)
                    {
                        UIDEElement previousElement = line.GetElementAt(elementPos - 1);
                        if (previousElement != null)
                        {
                            if (previousElement.tokenDef.HasType("Dot"))
                            {
                                isChain = true;
                            }
                        }
                    }
                }

                if (genericMode)
                {
                    isChain = false;
                }

                //bool newCharIsWhitespace = text == " "||text == "\t";

                if (visible && isWord)
                {
                    //continue an existing autocomplete
                }
                if (!visible && isDotOrWord && !isBackspace)
                {
                    TryStartUpdateAutoCompleteList(isChain);
                }
                if (visible && !isDotOrWord)
                {
                    HideBox();
                }
                if (visible && isBackspace && !isDotOrWord)
                {
                    HideBox();
                }
                //For performance on OSX.
                if (Application.platform == RuntimePlatform.OSXEditor)
                {
                    if (visible && isBackspace)
                    {
                        HideBox();
                        visible = false;
                    }
                }
                if (visible && autoCompleteKey != "")
                {
                    TryStartUpdateAutoCompleteList(isChain);
                }
                if (visible && isDot)
                {
                    UpdateRect();
                }
                //TryStartUpdateAutoCompleteList();
            }
            else
            {
                if (visible)
                {
                    HideBox();
                }
            }

            editor.editorWindow.Repaint();
        }
コード例 #14
0
        public override TooltipItem GetTooltipItem(Vector2 pos)
        {
            Vector2 originalPos = pos;

            if (parserInterface.lastSourceFile == null)
            {
                Reparse();
            }


            pos = editor.doc.GoToEndOfWord(pos, 1);
            Vector2 endWordPos = editor.doc.IncrementPosition(pos, -1);

            pos = editor.doc.GoToEndOfWhitespace(pos, 1);

            ExpressionInfo result = new ExpressionInfo();

            result.startPosition = pos;
            result.endPosition   = pos;
            result.initialized   = true;

            char nextChar       = editor.doc.GetCharAt(pos);
            bool isBeginGeneric = nextChar == '<';

            if (useUnityscript)
            {
                Vector2 charAfterPos = editor.doc.GoToEndOfWhitespace(editor.doc.IncrementPosition(pos, 1), 1);
                char    charAfter    = editor.doc.GetCharAt(charAfterPos);
                if (nextChar == '.' && charAfter == '<')
                {
                    pos            = charAfterPos;
                    nextChar       = editor.doc.GetCharAt(pos);
                    isBeginGeneric = true;
                }
            }
            //GameObject go;

            //go.GetComponent<Vector3>();
            if (isBeginGeneric)
            {
                result.startPosition      = pos;
                result.endPosition        = pos;
                ExpressionResolver.editor = editor;
                result = ExpressionResolver.CountToExpressionEnd(result, 1, ExpressionBracketType.Generic);

                pos = result.endPosition;
                pos = editor.doc.IncrementPosition(pos, 1);
                pos = editor.doc.GoToEndOfWhitespace(pos, 1);

                result.startPosition = pos;
                result.endPosition   = pos;
                nextChar             = editor.doc.GetCharAt(pos);
            }

            bool isFunction = false;

            if (nextChar == '(')
            {
                ExpressionResolver.editor = editor;
                result     = ExpressionResolver.CountToExpressionEnd(result, 1, ExpressionBracketType.Expression);
                pos        = result.endPosition;
                nextChar   = editor.doc.GetCharAt(pos);
                isFunction = true;
            }

            if (!isFunction)
            {
                pos = endWordPos;
            }

            //Debug.Log(nextChar+" "+editor.doc.GetCharAt(endWordPos));

            string str = editor.syntaxRule.ResolveExpressionAt(pos, -1);

            if (useUnityscript)
            {
                str = str.Replace(".<", "<");
            }
            //Debug.Log(str);

            ChainResolver sigChainResolver = new ChainResolver(editor, originalPos);
            ChainItem     item             = null;

            item = sigChainResolver.ResolveChain(str, false);

            TooltipItem tooltipItem = null;

            if (item != null)
            {
                if (item.finalLinkType != null)
                {
                    tooltipItem         = new TooltipItem(item.finalLinkType.Name + " " + item.finalLink.name);
                    tooltipItem.clrType = item.finalLinkType;
                }

                if (item.finalLink.completionItem != null)
                {
                    tooltipItem = new TooltipItem(item.finalLink.completionItem);
                }
            }

            return(tooltipItem);
        }
コード例 #15
0
        public override void Start()
        {
            lastReparseTime = editor.editorWindow.time;
            useUnityscript = editor.extension == ".js";

            conservativeParsing = Application.platform == RuntimePlatform.OSXEditor;
            conservativeParsing |= true;

            chainResolver = null;
            Reparse();
            UpdateChainResolver();
        }
コード例 #16
0
 private void UpdateChainResolverActual(System.Object context)
 {
     isCreatingChainResolver = true;
     try {
         try {
             //Debug.Log("UpdateChainResolverActual");
             if (chainResolver != null && chainResolver.reflectionDB != null && !chainResolver.reflectionDB.needsToBeKilled) {
                 chainResolver.Refresh(editor,editor.cursor.GetVectorPosition());
             }
             else {
                 //Debug.Log("UpdateChainResolverActual");
                 chainResolver = new ChainResolver(editor,editor.cursor.GetVectorPosition());
             }
         }
         catch (System.Exception ex) {
             Debug.LogError(ex.Message);
         }
     }
     finally {
         //UIDEThreadPool.UnregisterThread("SRCSUS_UpdateChainResolver");
     }
     isCreatingChainResolver = false;
 }
コード例 #17
0
 protected override IReadOnlyCollection <ResourceFieldAttribute> OnResolveFieldChain(string path, FieldChainRequirements chainRequirements)
 {
     return(ChainResolver.ResolveToManyChain(_resourceContextInScope, path, _validateSingleFieldCallback));
 }