예제 #1
0
        private void BaseForIn(bool aternate)
        {
            ScintillaControl sci = PluginBase.MainForm.CurrentDocument.SciControl;

            sci.BeginUndoAction();

            // Settings
            String setAlt = this.settingObject.AlternateFunction.Trim();

            if (setAlt == "")
            {
                setAlt = "MyLogger.log";
            }
            Boolean setIns = this.settingObject.InsertNewLine;
            Boolean setCmp = this.settingObject.CompactMode;

            String tr0 = "for( var i:String in ";
            String tr1 = " ) trace( \"key : \" + i + \", value : \" + ";

            if (aternate)
            {
                tr1 = " ) " + setAlt + "( \"key : \" + i + \", value : \" + ";
            }
            String tr2 = "[ i ] );";

            if (setCmp)
            {
                tr0 = "for(var i:String in ";
                tr1 = ") trace(\"key: \"+i+\", value: \"+";
                if (aternate)
                {
                    tr1 = ") " + setAlt + "(\"key: \"+i+\", value: \"+";
                }
                tr2 = "[i]);";
            }

            PositionInfos t    = new PositionInfos(sci, sci.CurrentPos, PluginBase.MainForm.ProcessArgString(sArgsString));
            Boolean       exec = false;
            String        sel  = "";

            if (t.HasSelection)
            {
                if (!t.SelectionIsMultiline)
                {
                    sel  = t.SelectedText.Trim();
                    exec = true;
                }
            }
            else
            {
                if (t.WordFromPosition != "")
                {
                    sel  = t.WordFromPosition;
                    exec = true;
                }
            }

            if (exec)
            {
                HelpTools.SetCaretReadyToTrace(sci, true);

                String trace = tr0 + sel + tr1 + sel + tr2;

                sci.InsertText(sci.CurrentPos, trace);

                HelpTools.GoToLineEnd(sci, setIns);
            }

            sci.EndUndoAction();
        }
예제 #2
0
        private void BaseSimple(bool aternate)
        {
            ScintillaControl sci = PluginBase.MainForm.CurrentDocument.SciControl;

            sci.BeginUndoAction();

            // Settings
            String setAlt = this.settingObject.AlternateFunction.Trim();

            if (setAlt == "")
            {
                setAlt = "MyLogger.log";
            }
            Boolean setIns = this.settingObject.InsertNewLine;
            Boolean setCmp = this.settingObject.CompactMode;
            Boolean setPkg = this.settingObject.ShowPackageName;
            Boolean setCls = this.settingObject.ShowClassName;

            PositionInfos t     = new PositionInfos(sci, sci.CurrentPos, PluginBase.MainForm.ProcessArgString(sArgsString));
            String        trace = "";
            Boolean       exec  = false;

            if (t.HasSelection)
            {
                if (!t.SelectionIsMultiline)
                {
                    String sel1 = t.SelectedText.Trim();
                    if (sel1.EndsWith(";"))
                    {
                        sel1 = sel1.Substring(0, sel1.Length - 1);
                    }

                    String sel0 = sel1;
                    if (sel0.IndexOf('"') > -1)
                    {
                        sel0 = sel0.Replace("\"", "\\\"");
                    }

                    String tr0 = "trace( \"";
                    if (aternate)
                    {
                        tr0 = setAlt + "( \"";
                    }
                    String tr1 = " : \" + ";
                    String tr2 = " );";
                    if (setCmp)
                    {
                        tr0 = "trace(\"";
                        if (aternate)
                        {
                            tr0 = setAlt + "(\"";
                        }
                        tr1 = ": \"+";
                        tr2 = ");";
                    }

                    trace = tr0 + sel0 + tr1 + sel1 + tr2;
                    exec  = true;
                }
            }
            else
            {
                if (t.PreviousWordIsFunction)
                {
                    String pckg = "";
                    String clas = "";

                    if (!t.HasArguments)
                    {
                        String tr0 = "trace( \"";
                        if (aternate)
                        {
                            tr0 = setAlt + "( \"";
                        }
                        String tr1 = "\" );";
                        if (setCmp)
                        {
                            tr0 = "trace(\"";
                            if (aternate)
                            {
                                tr0 = setAlt + "(\"";
                            }
                            tr1 = "\");";
                        }

                        if (setPkg)
                        {
                            pckg = t.ArgPackageName + ".";
                        }

                        if (setCls)
                        {
                            clas = t.ArgClassName + ".";
                        }

                        trace = tr0 + pckg + clas + t.WordFromPosition + tr1;
                        exec  = true;
                    }
                    else
                    {
                        String tr0 = "trace( \"";
                        if (aternate)
                        {
                            tr0 = setAlt + "( \"";
                        }
                        String tr1 = " > ";
                        String tr2 = " );";
                        if (setCmp)
                        {
                            tr0 = "trace(\"";
                            if (aternate)
                            {
                                tr0 = setAlt + "(\"";
                            }
                            tr1 = " > ";
                            tr2 = ");";
                        }

                        if (setPkg)
                        {
                            pckg = t.ArgPackageName + ".";
                        }

                        if (setCls)
                        {
                            clas = t.ArgClassName + ".";
                        }

                        String args = "";
                        String a    = "";
                        for (Int32 i = 0; i < t.Arguments.Count; i++)
                        {
                            a = (String)t.Arguments[i];
                            if (i == 0)
                            {
                                if (!setCmp)
                                {
                                    args += a + " : \" + " + a + " + ";
                                }
                                else
                                {
                                    args += a + ": \"+" + a + "+";
                                }
                            }
                            else
                            {
                                if (!setCmp)
                                {
                                    args += "\", " + a + " : \" + " + a + " + ";
                                }
                                else
                                {
                                    args += "\", " + a + ": \"+" + a + "+";
                                }
                            }
                        }

                        if (!setCmp)
                        {
                            args = args.Substring(0, args.Length - 3);
                        }
                        else
                        {
                            args = args.Substring(0, args.Length - 1);
                        }

                        trace = tr0 + pckg + clas + t.WordFromPosition + tr1 + args + tr2;
                        exec  = true;
                    }
                }
                else
                {
                    if (t.WordFromPosition != "")
                    {
                        String tr0 = "trace( \"";
                        if (aternate)
                        {
                            tr0 = setAlt + "( \"";
                        }
                        String tr1 = " : \" + ";
                        String tr2 = " );";
                        if (setCmp)
                        {
                            tr0 = "trace(\"";
                            if (aternate)
                            {
                                tr0 = setAlt + "(\"";
                            }
                            tr1 = ": \"+";
                            tr2 = ");";
                        }

                        trace = tr0 + t.WordFromPosition + tr1 + t.WordFromPosition + tr2;
                        exec  = true;
                    }
                }
            }

            if (exec)
            {
                HelpTools.SetCaretReadyToTrace(sci, true);

                sci.InsertText(sci.CurrentPos, trace);

                HelpTools.GoToLineEnd(sci, setIns);
            }

            sci.EndUndoAction();
        }