Esempio n. 1
0
        /// <summary>
        /// Delete the given ParsedScopeItem whose name is qualified through proCode.Name
        /// </summary>
        private void DeleteCode <T>(T toDelete) where T : ParsedScopeItem
        {
            string preProcBlockType = null;

            if (typeof(ParsedImplementation) == typeof(T))
            {
                preProcBlockType = @"_FUNCTION";
            }
            else if (typeof(ParsedPrototype) == typeof(T))
            {
                preProcBlockType = @"_FUNCTION-FORWARD";
            }
            else if (typeof(ParsedProcedure) == typeof(T))
            {
                preProcBlockType = @"_PROCEDURE";
            }

            // find a pre proc block that surrounds it
            var protoPreProcBlock = GetPreProcBlock(toDelete, preProcBlockType);

            // we also want to delete the trailing new lines
            int endPosition = (protoPreProcBlock != null ? protoPreProcBlock.EndBlockPosition : toDelete.EndBlockPosition);

            while (Sci.GetTextByRange(endPosition, endPosition + 2).Equals(Sci.GetEolString))
            {
                endPosition += 2;
            }

            if (protoPreProcBlock != null)
            {
                Sci.DeleteTextByRange(protoPreProcBlock.Position, endPosition);
            }
            else
            {
                // if not found, we just delete the proto statement
                Sci.DeleteTextByRange(toDelete.Position, endPosition);
            }
        }
Esempio n. 2
0
        private bool AddPrototypes(ref StringBuilder outputMessage, ParsedImplementation function)
        {
            var protoStr = Sci.GetTextByRange(function.Position, function.EndPosition);

            // get the best position to insert the prototype
            bool insertBefore;
            int  insertPos = GetCaretPositionForInsertion <ParsedPrototype>(function.Name, ProInsertPosition.Last, out insertBefore);

            // if we didn't find a good position, then let's assume the user doesn't need one
            if (insertPos > 0 && protoStr.Length > 1)
            {
                // replace the end ":" or "." by a " FOWARD."
                protoStr = FormatInsertion(protoStr.Substring(0, protoStr.Length - 1).TrimEnd(' ') + " FORWARD.", "_FUNCTION-FORWARD " + function.Name + " Procedure", insertBefore);

                Sci.SetTextByRange(insertPos, insertPos, protoStr);

                //outputMessage.Append("<br> - <a href='" + function.FilePath + "#" + insertPos + "'>" + function.Name + "</a>");
                outputMessage.Append("<br> - " + function.Name);

                return(true);
            }

            return(false);
        }