Exemple #1
0
        /// <summary>
        /// Delete the given ParsedScopeBlock whose name is qualified through proCode.Name
        /// </summary>
        private void DeleteCode <T>(T toDelete) where T : ParsedScopeBlock
        {
            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 surroundingScope = GetPreProcBlock(toDelete, preProcBlockType);

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

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

            if (surroundingScope != null)
            {
                Sci.DeleteTextByRange(surroundingScope.Position, endPosition);
            }
            else
            {
                // if not found, we just delete the proto statement
                Sci.DeleteTextByRange(toDelete.Position, endPosition);
            }
        }