예제 #1
0
        public bool FileSupportsOperation(string file, RefactorOperations operation)
        {
            IRefactorer r = LanguageBindingService.GetRefactorerForFile(file);

            if (r == null)
            {
                return(false);
            }
            return((r.SupportedOperations & operation) == operation);
        }
예제 #2
0
        void Refactor(IProgressMonitor monitor, LocalVariable var, RefactorDelegate refactorDelegate)
        {
            RefactorerContext gctx = GetGeneratorContext(var);
            string            file = var.FileName;

            IRefactorer gen = LanguageBindingService.GetRefactorerForFile(file);

            if (gen == null)
            {
                return;
            }

            refactorDelegate(monitor, gctx, gen, file);
            gctx.Save();
        }
예제 #3
0
        void RefactorProject(IProgressMonitor monitor, Project p, RefactorDelegate refactorDelegate)
        {
            RefactorerContext gctx = GetGeneratorContext(p);

            monitor.Log.WriteLine(GettextCatalog.GetString("Refactoring project {0}", p.Name));
            foreach (ProjectFile file in p.Files)
            {
                if (file.BuildAction != BuildAction.Compile || !System.IO.File.Exists(file.FilePath))
                {
                    continue;
                }
                IRefactorer gen = LanguageBindingService.GetRefactorerForFile(file.Name);
                if (gen == null)
                {
                    continue;
                }
                refactorDelegate(monitor, gctx, gen, file.Name);
                gctx.Save();
            }
        }
예제 #4
0
        void Refactor(IProgressMonitor monitor, IParameter param, RefactorDelegate refactorDelegate)
        {
            IMember           member = param.DeclaringMember;
            RefactorerContext gctx   = GetGeneratorContext(member.DeclaringType);
            IType             cls    = member.DeclaringType;
            IRefactorer       gen;
            string            file;

            foreach (IType part in cls.Parts)
            {
                file = part.CompilationUnit.FileName;

                if ((gen = LanguageBindingService.GetRefactorerForFile(file)) == null)
                {
                    continue;
                }

                refactorDelegate(monitor, gctx, gen, file);
                gctx.Save();
            }
        }
예제 #5
0
 IRefactorer GetGeneratorForVariable(LocalVariable var)
 {
     return(LanguageBindingService.GetRefactorerForFile(var.FileName));
 }
예제 #6
0
 IRefactorer GetGeneratorForClass(IType cls)
 {
     return(LanguageBindingService.GetRefactorerForFile(cls.CompilationUnit.FileName));
 }
예제 #7
0
        void Refactor(IProgressMonitor monitor, IType cls, RefactoryScope scope, RefactorDelegate refactorDelegate)
        {
            switch (scope)
            {
            case RefactoryScope.DeclaringType:
                ProjectDom ctx = GetParserContext(cls);
                if (cls is InstantiatedType)
                {
                    cls = ((InstantiatedType)cls).UninstantiatedType;
                }
                IType resolvedType = ctx.GetType(cls.FullName, cls.TypeParameters.Count, true, true);
                if (resolvedType == null)
                {
                    goto case RefactoryScope.Solution;
                }
                foreach (IType part in resolvedType.Parts)
                {
                    string            file = part.CompilationUnit.FileName;
                    RefactorerContext gctx = GetGeneratorContext(part);
                    IRefactorer       gen  = LanguageBindingService.GetRefactorerForFile(file);
                    if (gen == null)
                    {
                        return;
                    }
                    refactorDelegate(monitor, gctx, gen, file);
                    gctx.Save();
                }
                break;

            case RefactoryScope.File: {
                string            file = cls.CompilationUnit.FileName;
                RefactorerContext gctx = GetGeneratorContext(cls);
                IRefactorer       gen  = LanguageBindingService.GetRefactorerForFile(file);
                if (gen == null)
                {
                    return;
                }
                refactorDelegate(monitor, gctx, gen, file);
                gctx.Save();
                break;
            }

            case RefactoryScope.Project:
                Project prj = GetProjectForFile(cls.CompilationUnit.FileName);
                if (prj == null)
                {
                    return;
                }
                RefactorProject(monitor, prj, refactorDelegate);
                break;

            case RefactoryScope.Solution:
                if (solution == null)
                {
                    goto case RefactoryScope.File;
                }
                foreach (Project project in solution.GetAllProjects())
                {
                    RefactorProject(monitor, project, refactorDelegate);
                }
                break;
            }
        }
예제 #8
0
        public DomLocation CompleteStatement(ProjectDom dom, string fileName, DomLocation caretLocation)
        {
            IRefactorer refactorer = LanguageBindingService.GetRefactorerForFile(fileName);

            return(refactorer.CompleteStatement(new RefactorerContext(dom, fileProvider, null), fileName, caretLocation));
        }
예제 #9
0
        public void AddLocalNamespaceImport(ProjectDom dom, string fileName, string nsName, DomLocation caretLocation)
        {
            IRefactorer refactorer = LanguageBindingService.GetRefactorerForFile(fileName);

            refactorer.AddLocalNamespaceImport(new RefactorerContext(dom, fileProvider, null), fileName, nsName, caretLocation);
        }