private void DeclareAsExplicitVariant(VBE vbe)
        {
            var instruction = Node.Instruction;
            var newContent  = string.Concat(_identifier.Name, " ", ReservedKeywords.As, " ", ReservedKeywords.Variant);
            var oldContent  = instruction.Line.Content;

            var result = oldContent.Replace(_identifier.Name, newContent);
            var module = vbe.FindCodeModules(instruction.Line.ProjectName, instruction.Line.ComponentName).First();

            module.ReplaceLine(instruction.Line.StartLineNumber, result);
            Handled = true;
        }
예제 #2
0
        private void SpecifyOptionExplicit(VBE vbe)
        {
            var instruction = Node.Instruction;
            var modules     = vbe.FindCodeModules(instruction.Line.ProjectName, instruction.Line.ComponentName);

            foreach (var codeModule in modules)
            {
                codeModule.InsertLines(1, string.Concat(ReservedKeywords.Option, " ", ReservedKeywords.Explicit));
            }

            Handled = true;
        }
        private void SplitDeclarations(VBE vbe)
        {
            var instruction = Node.Instruction;
            var newContent  = new StringBuilder();
            var indent      = new string(' ', instruction.StartColumn - 1);

            foreach (var node in Node.ChildNodes.Cast <IdentifierNode>())
            {
                newContent.AppendLine(indent + node);
            }

            var module = vbe.FindCodeModules(instruction.Line.ProjectName, instruction.Line.ComponentName).First();

            module.ReplaceLine(instruction.Line.StartLineNumber, newContent.ToString());
        }
        private void ReturnExplicitVariant(VBE vbe)
        {
            var instruction = Node.Instruction;

            if (!instruction.Line.IsMultiline)
            {
                var newContent = string.Concat(instruction.Value, " ", ReservedKeywords.As, " ", ReservedKeywords.Variant);
                var oldContent = instruction.Line.Content;

                var result = oldContent.Replace(instruction.Value, newContent);

                var module = vbe.FindCodeModules(instruction.Line.ProjectName, instruction.Line.ComponentName).First();
                module.ReplaceLine(instruction.Line.StartLineNumber, result);
                Handled = true;
            }
            else
            {
                // todo: implement for multiline
                throw new NotImplementedException("This method is not [yet] implemented for multiline instructions.");
            }
        }
        private void ChangeParameterPassing(VBE vbe, string newValue)
        {
            var instruction = Node.Instruction;

            if (!instruction.Line.IsMultiline)
            {
                var newContent = string.Concat(newValue, " ", instruction.Value);
                var oldContent = instruction.Line.Content;

                var result = oldContent.Replace(instruction.Value, newContent);

                var module = vbe.FindCodeModules(instruction.Line.ProjectName, instruction.Line.ComponentName).First();
                module.ReplaceLine(instruction.Line.StartLineNumber, result);
                Handled = true;
            }
            else
            {
                // todo: implement for multiline
                throw new NotImplementedException("This method is not yet implemented for multiline instructions.");
            }
        }