public override void MakeVirtual(IMember member)
        {
            SDRefactoringContext refactoringContext = member.CreateRefactoringContext();
            var entityDeclaration = refactoringContext.GetNode <EntityDeclaration>();

            using (Script script = refactoringContext.StartScript()) {
                script.ChangeModifier(entityDeclaration, entityDeclaration.Modifiers | Modifiers.Virtual);
            }
        }
        public override void MakePartial(ITypeDefinition td)
        {
            SDRefactoringContext refactoringContext = td.CreateRefactoringContext();
            var typeDeclaration = refactoringContext.GetNode <TypeDeclaration>();

            using (Script script = refactoringContext.StartScript()) {
                script.ChangeModifier(typeDeclaration, typeDeclaration.Modifiers | Modifiers.Partial);
            }
        }
		public void Execute(EditorRefactoringContext context)
		{
			var resolver = context.GetAstResolverAsync().Result;
			var refactoringContext = new SDRefactoringContext(context.Editor, resolver, context.CaretLocation);
			var action = getUpdatedCodeAction(refactoringContext);
			if (action != null) {
				using (var script = refactoringContext.StartScript()) {
					action.Run(script);
				}
			}
		}
Esempio n. 4
0
		public override void AddMethodAtStart(ITypeDefinition declaringType, Accessibility accessibility, IType returnType, string name)
		{
			SDRefactoringContext context = declaringType.CreateRefactoringContext();
			var typeDecl = context.GetNode<TypeDeclaration>();
			using (var script = context.StartScript()) {
				var astBuilder = context.CreateTypeSystemAstBuilder(typeDecl.FirstChild);
				var methodDecl = new MethodDeclaration();
				methodDecl.Name = name;
				methodDecl.ReturnType = astBuilder.ConvertType(context.Compilation.Import(returnType));
				
				script.AddTo(typeDecl, methodDecl);
			}
		}
Esempio n. 5
0
		public override void AddField(ITypeDefinition declaringType, Accessibility accessibility, IType fieldType, string name)
		{
			SDRefactoringContext context = declaringType.CreateRefactoringContext();
			var typeDecl = context.GetNode<TypeDeclaration>();
			using (var script = context.StartScript()) {
				var astBuilder = context.CreateTypeSystemAstBuilder(typeDecl.FirstChild);
				var fieldDecl = new FieldDeclaration();
				fieldDecl.Modifiers = TypeSystemAstBuilder.ModifierFromAccessibility(accessibility);
				fieldDecl.ReturnType = astBuilder.ConvertType(context.Compilation.Import(fieldType));
				fieldDecl.Variables.Add(new VariableInitializer(name));
				script.InsertWithCursor("Add field: " + name, Script.InsertPosition.End, fieldDecl);
			}
		}
        public void Execute(EditorRefactoringContext context)
        {
            var resolver           = context.GetAstResolverAsync().Result;
            var refactoringContext = new SDRefactoringContext(context.Editor, resolver, context.CaretLocation);
            var action             = getUpdatedCodeAction(refactoringContext);

            if (action != null)
            {
                using (var script = refactoringContext.StartScript()) {
                    action.Run(script);
                }
            }
        }