Package org.python.pydev.editor.refactoring

Examples of org.python.pydev.editor.refactoring.RefactoringRequest


    public static final boolean DEBUG_FIND_REFERENCES = false;

    @Override
    protected String perform(IAction action, IProgressMonitor monitor) throws Exception {
        IPyRefactoring2 r = (IPyRefactoring2) AbstractPyRefactoring.getPyRefactoring();
        RefactoringRequest req = getRefactoringRequest(new NullProgressMonitor()); //as we're doing it in the background
        req.fillInitialNameAndOffset();
        if (req.initialName != null && req.initialName.trim().length() > 0) {
            NewSearchUI.runQueryInBackground(newQuery(r, req));
        }
        return null;
    }
View Full Code Here


     */
    public static RefactoringRequest createRefactoringRequest(IProgressMonitor monitor, PyEdit pyEdit, PySelection ps)
            throws MisconfigurationException {
        File file = pyEdit.getEditorFile();
        IPythonNature nature = pyEdit.getPythonNature();
        return new RefactoringRequest(file, ps, monitor, nature, pyEdit);
    }
View Full Code Here

    public void run(final IAction action) {
        // Select from text editor
        request = null; //clear the cache from previous runs
        ps = new PySelection(getTextEditor());

        RefactoringRequest req;
        try {
            req = getRefactoringRequest();
        } catch (MisconfigurationException e2) {
            Log.log(e2);
            return;
View Full Code Here

    PyEdit pyEdit = new PyEdit(){
      public File getEditorFile() {
        return file;
      }
    };
    RefactoringRequest request = new RefactoringRequest(
        file, selection, null, nature, pyEdit);

    ArrayList<Position> results = new ArrayList<Position>();

    String context = commandLine.getValue(Options.CONTEXT_OPTION);
    // find references
    if (CONTEXT_REFERENCES.equals(context)){
      // for some reason the pydev project's path isn't initialized properly
      // leading to findAllOccurrences only finding results from the current
      // file. This seems to be plenty fast for my reasonably sized project, so
      // hopefully it won't be a bottleneck for others.
      PythonNature pythonNature = PythonNature.getPythonNature(project);
      pythonNature.rebuildPath();

      request.fillInitialNameAndOffset();
      IPyRefactoring2 pyRefactoring = (IPyRefactoring2)
        AbstractPyRefactoring.getPyRefactoring();
      Map<Tuple<String,File>, HashSet<ASTEntry>> refs =
        pyRefactoring.findAllOccurrences(request);
      for (Tuple<String,File> tuple : refs.keySet()){
View Full Code Here

    protected void checkRename(String strDoc, int line, int col, String initialName, boolean expectError,
            boolean onlyOnLocalScope, String newName) throws CoreException {
        Document doc = new Document(com.aptana.shared_core.string.StringUtils.format(strDoc, getSame(initialName)));
        PySelection ps = new PySelection(doc, line, col);

        RefactoringRequest request = new RefactoringRequest(null, ps, nature);
        request.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_REFERENCES_ONLY_IN_LOCAL_SCOPE,
                onlyOnLocalScope);
        request.moduleName = "foo";
        request.inputName = newName;
        request.fillInitialNameAndOffset();

        applyRenameRefactoring(request, expectError);
        String refactored = doc.get();
        if (DEBUG) {
            System.out.println(refactored);
View Full Code Here

            String strDoc = FileUtils.getFileContents(module.getFile());

            Document doc = new Document(strDoc);
            PySelection ps = new PySelection(doc, line, col);

            RefactoringRequest request = new RefactoringRequest(null, ps, natureRefactoring);
            request.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_REFERENCES_ONLY_IN_LOCAL_SCOPE, false);
            request.moduleName = moduleName;
            request.fillInitialNameAndOffset();

            PyRenameEntryPoint processor = new PyRenameEntryPoint(request);
            NullProgressMonitor nullProgressMonitor = new NullProgressMonitor();
            checkStatus(processor.checkInitialConditions(nullProgressMonitor), expectError);
            lastProcessorUsed = processor;
View Full Code Here

        //searching for import.
        //Line contents (1):
        //from toimport import Test1
        String line = "from toimport import Test1";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "testlib/unittest/relative/testrelative.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(new File(TestDependent.TEST_PYSRC_LOC + "testlib/unittest/relative/toimport.py"), pointers[0].file);
        assertEquals(0, pointers[0].start.line);
View Full Code Here

    }

    public void testSearch2() throws Exception {
        String line = "from testlib.unittest import testcase as t";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "testlib/unittest/anothertest.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(new File(TestDependent.TEST_PYSRC_LOC + "testlib/unittest/testcase.py"), pointers[0].file);
        //found the module
View Full Code Here

        assertEquals(0, pointers[0].start.column);

    }

    private RefactoringRequest createRefactoringRequest(String line, final File file) {
        return new RefactoringRequest(file, new PySelection(new Document(FileUtils.getFileContents(file)),
                line.length()),
                nature);
    }
View Full Code Here

                nature);
    }

    private RefactoringRequest createRefactoringRequest(final IDocument doc, String modName, int line, int col) {
        PySelection sel = new PySelection(doc, line, col);
        RefactoringRequest req = new RefactoringRequest(null, sel, nature);
        req.moduleName = modName;
        return req;
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.editor.refactoring.RefactoringRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.