Пример #1
0
        public CTL_TodoObject(string lineContent, int lineNb, CTL_TodoFile file, CTL_KeywordObject keyworkRef)
        {
            sNeedRefreshDisplayedElementsList = true;
            mLinkedKeyword = keyworkRef;
            mFile          = file;
            mLineContent   = lineContent;
            mLineNumber    = lineNb;
            if (!CTL_Settings.CaseSensitive)
            {
                mMessage = lineContent.Substring(lineContent.ToLower().IndexOf(keyworkRef.KeySearch) + keyworkRef.KeySearch.Length);
            }
            else
            {
                mMessage = lineContent.Substring(lineContent.IndexOf(keyworkRef.KeySearch) + keyworkRef.KeySearch.Length);
            }

            mMessage = mMessage.Trim();
            if (mMessage.StartsWith(":"))
            {
                mMessage = mMessage.Substring(1);
                mMessage = mMessage.Trim();
            }
            if (string.IsNullOrEmpty(mMessage))
            {
                mMessage = keyworkRef.Key;
            }

            Register();
        }
Пример #2
0
        CTL_TodoFile ParseFileAtPath(string path)
        {
            CTL_TodoFile fileObject = null;

            string       line;
            int          lineId = 0;
            StreamReader sr     = new StreamReader(path);
            string       lowerLine;

            //CTL...check potential comments
            Dictionary <int, string> potentialCommentList = new Dictionary <int, string>();

            while ((line = sr.ReadLine()) != null)
            {
                lineId++;

                if (line.Contains("//"))
                {
                    potentialCommentList.Add(lineId, line);
                }
            }
            sr.Close();
            sTotalLinesCount += lineId;

            //CTL...analyse if real comment
            Dictionary <int, string> realCommentList = new Dictionary <int, string>();
            int    stringPos;
            int    escapeStringPos = 0;
            int    commentPos;
            bool   commentFound;
            int    stringEndPos;
            string currentStr;

            foreach (KeyValuePair <int, string> keyVal in potentialCommentList)
            {
                currentStr      = keyVal.Value;
                commentFound    = false;
                commentPos      = 0;
                escapeStringPos = 0;
                while (currentStr.Length > 0 && commentPos > -1)
                {
                    escapeStringPos = 0;
                    stringPos       = currentStr.IndexOf("\"");
                    commentPos      = currentStr.IndexOf("//");



                    //CTL...check if the comment may be in a string (ex: "teststring//Foo" )
                    if (stringPos >= 0 && stringPos < commentPos)
                    {
                        stringEndPos    = stringPos;
                        escapeStringPos = stringPos + 1;
                        do
                        {
                            stringEndPos = currentStr.IndexOf("\"", stringEndPos + 1);
                            if (stringEndPos > -1)
                            {
                                escapeStringPos = currentStr.IndexOf("\\\"", stringEndPos - 1);                                    //check if close string escaped
                            }
                        }while (escapeStringPos > 0 && escapeStringPos < stringEndPos && stringEndPos > 0 && stringEndPos < currentStr.Length);

                        if (stringEndPos > -1)
                        {
                            currentStr = currentStr.Substring(stringEndPos + 1);
                        }
                        else
                        {
                            break;
                        }
                    }
                    else if (commentPos > -1)
                    {
                        currentStr   = currentStr.Substring(commentPos);
                        commentFound = true;
                        break;
                    }
                }
                if (commentFound)
                {
                    currentStr = currentStr.Substring(2);
                    if (CTL_Settings.TrimCommentOnParse)
                    {
                        currentStr = currentStr.Trim();
                    }
                    realCommentList.Add(keyVal.Key, currentStr);
                }
            }
            sCommentProcessedCount += realCommentList.Count;


            //CTL...generate object list if keyword found
            foreach (KeyValuePair <int, string> keyVal in realCommentList)
            {
                if (!CTL_Settings.CaseSensitive)
                {
                    lowerLine = keyVal.Value.ToLower();
                }
                else
                {
                    lowerLine = keyVal.Value;
                }

                foreach (CTL_KeywordObject obj in mValidsKeywords)
                {
                    if (lowerLine.StartsWith(obj.KeySearch))
                    {
                        if (fileObject == null)
                        {
                            fileObject = new CTL_TodoFile(path);
                        }
                        fileObject.AddObject(new CTL_TodoObject(keyVal.Value, keyVal.Key, fileObject, obj));
                    }
                }
            }

            return(fileObject);
        }
Пример #3
0
 public void Clear()
 {
     mFile = null;
     UnRegister();
 }
Пример #4
0
 public void SetFile(CTL_TodoFile file)
 {
     mFile = file;
 }