static private void CompleteTemplate(string Context)
        {
            // get indentation
            ScintillaNet.ScintillaControl Sci = ASContext.CurSciControl;
            if (Sci == null)
            {
                return;
            }
            int    position = Sci.CurrentPos;
            int    line     = Sci.LineFromPosition(position);
            int    indent   = Sci.LineIndentPosition(line) - Sci.PositionFromLine(line);
            string tab      = Sci.GetLine(line).Substring(0, indent);
            // get EOL
            int    eolMode = Sci.EOLMode;
            string newline = ASComplete.GetNewLineMarker(eolMode);
            string star    = PluginBase.Settings.CommentBlockStyle == CommentBlockStyle.Indented ? " *" : "*";

            // empty box
            if (Context == null)
            {
                Sci.ReplaceSel(newline + tab + star + " " + newline + tab + star + "/");
                position += newline.Length + tab.Length + 1 + star.Length;
                Sci.SetSel(position, position);
            }

            // method details
            else
            {
                string box  = newline + tab + star + " ";
                Match  mFun = re_splitFunction.Match(Context);
                if (mFun.Success && !re_property.IsMatch(mFun.Groups["fname"].Value))
                {
                    // parameters
                    MemberList list = ParseMethodParameters(mFun.Groups["params"].Value);
                    foreach (MemberModel param in list)
                    {
                        box += newline + tab + star + " @param\t" + param.Name;
                    }
                    // return type
                    Match mType = re_variableType.Match(mFun.Groups["type"].Value);
                    if (mType.Success && !mType.Groups["type"].Value.Equals("void", StringComparison.OrdinalIgnoreCase))
                    {
                        box += newline + tab + star + " @return"; //+mType.Groups["type"].Value;
                    }
                }
                box += newline + tab + star + "/";
                Sci.ReplaceSel(box);
                position += newline.Length + tab.Length + 1 + star.Length;
                Sci.SetSel(position, position);
            }
        }
Пример #2
0
        /// <summary>
        /// Inserts the imports to the current document
        /// </summary>
        private void InsertImports(List <MemberModel> imports, String searchInText, ScintillaControl sci, Int32 indent)
        {
            String eol = ASComplete.GetNewLineMarker(sci.EOLMode);

            if (imports.Count > 1 || (imports.Count > 0 && this.TruncateImports))
            {
                Int32 line = imports[0].LineFrom - DeletedImportsCompensation;
                ImportsComparerType comparerType = new ImportsComparerType();
                imports.Sort(comparerType);
                sci.GotoLine(line);
                Int32         curLine = 0;
                List <String> uniques = this.GetUniqueImports(imports, searchInText);
                // correct position compensation for private imports
                DeletedImportsCompensation = imports.Count - uniques.Count;
                String prevPackage    = null;
                String currentPackage = null;
                String importStringToInsert;
                for (Int32 i = 0; i < uniques.Count; i++)
                {
                    importStringToInsert = "import " + uniques[i] + ";" + eol;
                    if (this.SeparatePackages)
                    {
                        currentPackage = importStringToInsert.Substring(0, importStringToInsert.LastIndexOf("."));
                        if (prevPackage != null && prevPackage != currentPackage)
                        {
                            sci.NewLine();
                            sci.GotoLine(++curLine);
                            sci.SetLineIndentation(sci.LineFromPosition(sci.CurrentPos) - 1, indent);
                            DeletedImportsCompensation--;
                        }
                        prevPackage = currentPackage;
                    }
                    curLine = sci.LineFromPosition(sci.CurrentPos);
                    sci.InsertText(sci.CurrentPos, importStringToInsert);
                    sci.SetLineIndentation(curLine, indent);
                    sci.GotoLine(++curLine);
                }
            }
        }