示例#1
0
        public void Release(ChainItem item)
        {
            ItemPack _pack = null;

            if (item.GetType() == typeof(CaptionText))//ClickableText是CaptionText的子类,不能用is判断
            {
                _pack = FindPackage(item, m_CaptionTextBuffer);
            }
            else if (item is ClickableText)
            {
                _pack = FindPackage(item, m_ClickableTextBuffer);
            }
            else if (item is StarItem)
            {
                _pack = FindPackage(item, m_StarItemBuffer);
            }

            if (_pack == null)
            {
                Debug.Log("正在释放未知的CaptionText");
            }
            else
            {
                RecyclePackage(_pack);
            }
        }
示例#2
0
        public List <ChainItem> GetChainItems(int user_id)
        {
            List <ChainItem> chains = new List <ChainItem>();

            try
            {
                MySqlConnection conn = new MySqlConnection(connString);
                //Console.WriteLine("Connecting to MySQL...");
                conn.Open();

                // Perform database operations
                String          query   = "SELECT c.* FROM chains AS c INNER JOIN block_chain_user AS bcu ON bcu.chain_id=c.id WHERE user_id=" + user_id.ToString() + ";";
                MySqlCommand    command = new MySqlCommand(query, conn);
                MySqlDataReader reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    ChainItem chain = new ChainItem();
                    //ulong temp = (ulong)reader[0];
                    chain.id   = Convert.ToInt32(reader[0]);
                    chain.name = (string)reader[1];
                    //temp = (ulong)reader[2];
                    chain.created_by = Convert.ToInt32(reader[2]);
                    chains.Add(chain);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(chains);
        }
示例#3
0
        public ChainItem GetChainItem(int id)
        {
            ChainItem chain = new ChainItem();

            try
            {
                MySqlConnection conn = new MySqlConnection(connString);
                //Console.WriteLine("Connecting to MySQL...");
                conn.Open();

                // Perform database operations
                String          query   = "SELECT id, name, created_by FROM chains WHERE id=" + id.ToString() + ";";
                MySqlCommand    command = new MySqlCommand(query, conn);
                MySqlDataReader reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    ulong temp = (ulong)reader[0];
                    chain.id         = Convert.ToInt32(temp);
                    chain.name       = (string)reader[1];
                    temp             = (ulong)reader[2];
                    chain.created_by = Convert.ToInt32(temp);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(chain);
        }
示例#4
0
        public List <string> GetAllFilesNamesInChainFromSite(ChainItem ChainToDownload)
        {
            List <string> filesnames = new List <string>();
            FtpWebRequest request    = (FtpWebRequest)WebRequest.Create(ChainToDownload.ChainWebSiteLink);

            request.Method      = WebRequestMethods.Ftp.ListDirectory;
            request.Credentials = new NetworkCredential(ChainToDownload.ChainUserName, ChainToDownload.ChainPassword);
            request.KeepAlive   = true;
            request.UsePassive  = false;

            FtpWebResponse response = (FtpWebResponse)request.GetResponse();

            Stream       responseStream = response.GetResponseStream();
            StreamReader reader         = new StreamReader(responseStream);

            while (!reader.EndOfStream)
            {
                String filename = reader.ReadLine();
                filesnames.Add(filename);
                Console.WriteLine(filename);
            }
            List <string> fullpriceList = new List <string>();

            foreach (var item in filesnames)
            {
                if (item.Contains("PriceFull"))
                {
                    fullpriceList.Add(item);
                }
            }

            return(fullpriceList);
        }
示例#5
0
    private static bool TraverseRecursively(Shape shape, List <ChainItem> chain)
    {
        _traversedShapes.Add(shape);
        bool chainItemHasConnector = false;

        ChainItem chainItem = new ChainItem();

        chainItem.Shape           = shape;
        chainItem.TargetDirection = shape.CurrentDirection;
        chain.Add(chainItem);

        var connector = FindConnectorWithConnection(shape);

        if (connector != null && shape.HasConnection(connector.CurrentDirection))
        {
            //Debug.LogWarning(connector.name);
            chainItemHasConnector = true;
            _unTraversedConnectors.Remove(connector);
        }

        var neighbors = NodesGrid.FindConnectedNeighborShapes(shape);

        bool hasFirstChain = false;

        foreach (var neighbor in neighbors)
        {
            if (!_traversedShapes.Contains(neighbor))
            {
                List <ChainItem> targetChain = chain;
                if (hasFirstChain)
                {
                    targetChain = chainItem.childChain;
                }

                bool nextChainItemHasConnector = TraverseRecursively(neighbor, targetChain);
                chainItemHasConnector |= nextChainItemHasConnector;
                hasFirstChain          = true;
            }
        }

        //если текущая нода не соединена с коннектором и дочерние ответвления тоже не соединены с коннектором, то удалить данный узел.
        if (!chainItemHasConnector)
        {
            //chainItem.Shape.name += "_RemovedChainItem";
            chain.Remove(chainItem);
        }

        return(chainItemHasConnector);
    }
示例#6
0
        private ItemPack FindPackage(ChainItem item, List <ItemPack> list)
        {
            ItemPack _pack = null;

            for (int i = 0; i < list.Count; i++)
            {
                ItemPack _temp = list[i];
                if (_temp.m_Item.Equals(item))
                {
                    _pack = _temp;
                    break;
                }
            }
            return(_pack);
        }
示例#7
0
    private static bool TraverseRecursively(Shape shape, List<ChainItem> chain)
    {        
        _traversedShapes.Add(shape);
        bool chainItemHasConnector = false;

        ChainItem chainItem = new ChainItem();
        chainItem.Shape = shape;
        chainItem.TargetDirection = shape.CurrentDirection;
        chain.Add(chainItem);

        var connector = FindConnectorWithConnection(shape);
        if (connector != null && shape.HasConnection(connector.CurrentDirection))
        {
            //Debug.LogWarning(connector.name);
            chainItemHasConnector = true;
            _unTraversedConnectors.Remove(connector);
        }

        var neighbors = NodesGrid.FindConnectedNeighborShapes(shape);

        bool hasFirstChain = false;
        foreach (var neighbor in neighbors)
        {            
            if (!_traversedShapes.Contains(neighbor))
            {
                List<ChainItem> targetChain = chain;
                if (hasFirstChain)
                    targetChain = chainItem.childChain;

                bool nextChainItemHasConnector = TraverseRecursively(neighbor, targetChain);
                chainItemHasConnector |= nextChainItemHasConnector;
                hasFirstChain = true;
            }
        }

        //если текущая нода не соединена с коннектором и дочерние ответвления тоже не соединены с коннектором, то удалить данный узел.
        if (!chainItemHasConnector)
        {
            //chainItem.Shape.name += "_RemovedChainItem";
            chain.Remove(chainItem);
        }

        return chainItemHasConnector;
    }
示例#8
0
        //正向最长匹配
        public string ForwardSplitting(RowFirstDynamicArray <ChainContent> m_segGraph)
        {
            string abc = "";
            // =GetSegGraph();
            int currcol = 0;
            ChainItem <ChainContent> dfg = m_segGraph.GetElement(0, 1);
            ChainItem <ChainContent> aa  = dfg.next;

            while (null != aa.next)
            {
                if (aa.next.row == aa.row)
                {
                    currcol = aa.next.col;
                    aa      = aa.next;
                }
                else
                {
                    abc    += aa.Content.sWord;
                    currcol = aa.col;
                    aa      = m_segGraph.GetFirstElementOfRow(currcol);
                    break;
                }
            }

            while (null != aa.next)
            {
                if (aa.next.row == aa.row)
                {
                    currcol = aa.next.col;
                    aa      = aa.next;
                }
                else
                {
                    abc    += "/" + aa.Content.sWord;
                    currcol = aa.col;
                    aa      = m_segGraph.GetFirstElementOfRow(currcol);
                }
            }
            return(abc);
        }
示例#9
0
        public void DownloadFileFromSite(string FilePathOnSite, ChainItem ChainToDownload)
        {
            string path = @"c:\temp";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            var           destinationDirectory = path + @"\" + FilePathOnSite;
            var           RemoteFtpPath        = ChainToDownload.ChainWebSiteLink + @"/" + FilePathOnSite;
            FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(RemoteFtpPath);

            Request.Method      = WebRequestMethods.Ftp.DownloadFile;
            Request.Credentials = new NetworkCredential(ChainToDownload.ChainUserName, ChainToDownload.ChainPassword);
            Request.KeepAlive   = true;
            Request.UsePassive  = false;
            Request.UseBinary   = true;

            FtpWebResponse Response = (FtpWebResponse)Request.GetResponse();

            Stream       ResponseStream = Response.GetResponseStream();
            StreamReader Reader         = new StreamReader(ResponseStream);

            using (FileStream writer = new FileStream(destinationDirectory, FileMode.Create))
            {
                long   length     = Response.ContentLength;
                int    bufferSize = 2048;
                int    readCount;
                byte[] buffer = new byte[2048];

                readCount = ResponseStream.Read(buffer, 0, bufferSize);
                while (readCount > 0)
                {
                    writer.Write(buffer, 0, readCount);
                    readCount = ResponseStream.Read(buffer, 0, bufferSize);
                }
            }
        }
示例#10
0
        private void DownloadFilesFromWebsite(ChainItem item)
        {
            var listOfFilesNames = this._downloadAccessor.GetAllFilesNamesInChainFromSite(item);

            this._downloadAccessor.DownloadFileFromSite(listOfFilesNames.First(), item);
        }
示例#11
0
        public int PostChain(ChainItem chain)
        {
            Console.WriteLine(chain.groups);
            try
            {
                MySqlConnection conn = new MySqlConnection(connString);
                //Console.WriteLine("Connecting to MySQL...");
                conn.Open();

                // Perform database operations
                String query = "INSERT INTO `chains` (name, created_by) " +
                               "VALUES ('" + chain.name + "', " + chain.created_by.ToString() + ");" +
                               "SELECT LAST_INSERT_ID();";
                MySqlCommand    command = new MySqlCommand(query, conn);
                MySqlDataReader reader  = command.ExecuteReader();

                int chain_id = 0;
                while (reader.Read())
                {
                    chain_id = Convert.ToInt32(reader[0]);
                }
                reader.Close();

                if (chain_id == 0)
                {
                    Console.WriteLine("failed to insert chain into db.");
                    return(0);
                }

                int rowsAffected;
                query = "INSERT INTO `groups_chains` (group_id, chain_id) VALUES ";
                for (int i = 0; i < chain.groups.Count; i++)
                {
                    command      = new MySqlCommand(query + "(" + chain.groups[i] + ", " + chain_id.ToString() + ");", conn);
                    rowsAffected = command.ExecuteNonQuery();
                    if (rowsAffected != 1)
                    {
                        Console.WriteLine("failed to properly insert chain into db.");
                        return(0);
                    }
                }

                if (!chain.users.Contains(chain.created_by))
                {
                    query = "INSERT INTO `block_chain_user` (chain_id, user_id, block)" +
                            "VALUES (" + chain_id.ToString() + ", " + chain.created_by.ToString() + ", 0);";
                    command      = new MySqlCommand(query, conn);
                    rowsAffected = command.ExecuteNonQuery();
                    if (rowsAffected != 1)
                    {
                        Console.WriteLine("failed to properly insert chain into db.");
                        return(0);
                    }
                }
                for (int i = 0; i < chain.users.Count; i++)
                {
                    query = "INSERT INTO `block_chain_user` (chain_id, user_id, block)" +
                            "VALUES (" + chain_id.ToString() + ", " + chain.users[i].ToString() + ", 0);";
                    command      = new MySqlCommand(query, conn);
                    rowsAffected = command.ExecuteNonQuery();
                    if (rowsAffected != 1)
                    {
                        Console.WriteLine("failed to properly insert chain into db.");
                        return(0);
                    }
                }

                return(chain_id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(0);
            }
        }
示例#12
0
 protected override bool IsApplicable(ChainItem nextChainItem)
 {
     return(false);
 }
        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);
        }
        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);
        }
示例#15
0
 public int PostChainItem(ChainItem item)
 {
     return(_service.PostChain(item));
 }
示例#16
0
 public ChainItem(ChainItem previousItem, TPayload payload)
     : base(previousItem, Serializer.Serialize(payload))
 {
 }
示例#17
0
 public ItemPack(ChainItem item)
 {
     m_Item   = item;
     isUseing = false;
 }
        public override CompletionItem[] GetChainCompletionItems()
        {
            if (parserInterface.lastSourceFile == null)
            {
                Reparse();
            }

            if (conservativeParsing && isCreatingChainResolver)
            {
                int i = 0;
                while (isCreatingChainResolver && i < 100)
                {
                    Thread.Sleep(10);
                    i++;
                }
            }

            if (conservativeParsing)
            {
                UpdateChainResolverActual(null);
            }

            List <CompletionItem> items = new List <CompletionItem>();

            Vector2 previousCharPos = editor.cursor.GetVectorPosition();

            previousCharPos = editor.doc.IncrementPosition(previousCharPos, -1);

            UIDELine    line    = editor.doc.RealLineAt((int)previousCharPos.y);
            UIDEElement element = line.GetElementAt((int)previousCharPos.x);

            Vector2 expressionStartPos = previousCharPos;

            bool lastCharIsDot = element.tokenDef.HasType("Dot");

            if (lastCharIsDot)
            {
                expressionStartPos = editor.doc.IncrementPosition(expressionStartPos, -1);
            }
            else
            {
                int elementPos = line.GetElementStartPos(element);
                if (elementPos >= 2)
                {
                    element = line.GetElementAt(elementPos - 1);
                    if (element.tokenDef.HasType("Dot"))
                    {
                        expressionStartPos.x = elementPos - 2;
                    }
                }
            }

            ChainItem item = null;
            string    str  = ResolveExpressionAt(expressionStartPos, -1);

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

            VerifyChainResolver();

            item = chainResolver.ResolveChain(str);

            if (item != null)
            {
                items = item.autoCompleteItems;
            }

            return(items.ToArray());
        }
 protected override bool IsApplicable(ChainItem nextChainItem)
 {
     return(nextChainItem is ContractSigningChainItem ||
            nextChainItem is ContractSubjectDefinitionChainItem ||
            nextChainItem is ContractObjectDefinitionChainItem);
 }
 public ContractObjectDefinitionChainItem(ChainItem previousItem, ContractObjectDefinition payload)
     : base(previousItem, payload)
 {
 }
        public override CompletionItem[] GetGlobalCompletionItems()
        {
            if (editor.editorWindow.generalSettings.GetForceGenericAutoComplete())
            {
                return(GetGenericCompletionItems());
            }

            if (parserInterface.lastSourceFile == null)
            {
                Reparse();
            }
            if (conservativeParsing && parserInterface != null && parserInterface.isParsing)
            {
                int i = 0;
                while (parserInterface.isParsing && i < 100)
                {
                    Thread.Sleep(10);
                    i++;
                }
            }

            //float startTime = Time.realtimeSinceStartup;
            List <CompletionItem> items = new List <CompletionItem>();

            //items = parserInterface.GetCurrentVisibleItems(editor.cursor.GetVectorPosition(), this).ToList();
            //Debug.Log(Time.realtimeSinceStartup-startTime);
            string[] keywords       = UIDE.SyntaxRules.CSharp.Keywords.keywords;
            string[] modifiers      = UIDE.SyntaxRules.CSharp.Keywords.modifiers;
            string[] primitiveTypes = UIDE.SyntaxRules.CSharp.Keywords.primitiveTypes;
            if (useUnityscript)
            {
                keywords       = UIDE.SyntaxRules.Unityscript.Keywords.keywords;
                modifiers      = UIDE.SyntaxRules.Unityscript.Keywords.modifiers;
                primitiveTypes = UIDE.SyntaxRules.Unityscript.Keywords.primitiveTypes;
            }
            for (int i = 0; i < keywords.Length; i++)
            {
                CompletionItem item = CompletionItem.CreateFromKeyword(keywords[i]);
                items.Add(item);
            }
            for (int i = 0; i < modifiers.Length; i++)
            {
                CompletionItem item = CompletionItem.CreateFromModifier(modifiers[i]);
                items.Add(item);
            }
            for (int i = 0; i < primitiveTypes.Length; i++)
            {
                CompletionItem item = CompletionItem.CreateFromPrimitiveType(primitiveTypes[i]);
                items.Add(item);
            }

            //Add members of the current type
            string    typeName = "new|" + GetCurrentTypeFullName(editor.cursor.GetVectorPosition()) + "()";
            ChainItem typeItem = null;

            VerifyChainResolver();

            CompletionItem[] globalItems = chainResolver.GetCurrentlyVisibleGlobalItems();
            items.AddRange(globalItems);

            items.AddRange(parserInterface.GetCurrentVisibleItems(editor.cursor.GetVectorPosition(), this));

            typeItem = chainResolver.ResolveChain(typeName);
            if (typeItem != null)
            {
                items.AddRange(typeItem.autoCompleteItems);
            }

            string[] interfaces = GetCurrentTypeInterfaceNames(editor.cursor.GetVectorPosition());

            for (int i = 0; i < interfaces.Length; i++)
            {
                typeItem = null;
                typeItem = chainResolver.ResolveChain(interfaces[i]);
                if (typeItem != null)
                {
                    items.AddRange(typeItem.autoCompleteItems);
                }
            }

            return(items.ToArray());
        }
示例#22
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();
        }
示例#23
0
 public ContractSigningChainItem(ChainItem previousItem, ContractSigning payload)
     : base(previousItem, payload)
 {
 }