Package org.python.pydev.editor.refactoring

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


        //Now, aside from the marker, let's check if there's some definition we should show the user about.
        CompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();

        PyEdit edit = s.getEdit();
        RefactoringRequest request;
        IPythonNature nature = null;
        try {
            nature = edit.getPythonNature();
            request = new RefactoringRequest(edit.getEditorFile(), ps, new NullProgressMonitor(), nature, edit);
        } catch (MisconfigurationException e) {
            return;
        }
        String[] tokenAndQual = null;
        try {
View Full Code Here


    private void handleKeywordParam(CompletionRequest request, int line, Map<String, IToken> alreadyChecked)
            throws BadLocationException, CompletionRecursionException {
        if (request.isInMethodKeywordParam) {

            PySelection ps = new PySelection(request.doc, request.offsetForKeywordParam);
            RefactoringRequest findRequest = new RefactoringRequest(request.editorFile, ps, new NullProgressMonitor(),
                    request.nature, null);
            ArrayList<IDefinition> selected = new ArrayList<IDefinition>();
            PyRefactoringFindDefinition.findActualDefinition(findRequest, new CompletionCache(), selected);

            //Changed: showing duplicated parameters (only removing self and cls).
View Full Code Here

        //Now, aside from the marker, let's check if there's some definition we should show the user about.
        CompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();

        PyEdit edit = s.getEdit();
        RefactoringRequest request;
        IPythonNature nature = null;
        try {
            nature = edit.getPythonNature();
            request = new RefactoringRequest(edit.getEditorFile(), ps, new NullProgressMonitor(), nature, edit);
        } catch (MisconfigurationException e) {
            return;
        }
        String[] tokenAndQual = null;
        try {
View Full Code Here

     */
    private boolean fillWithOccurrences(IDocument document, LinkedPositionGroup group, IProgressMonitor monitor,
            PySelection ps) throws BadLocationException, OperationCanceledException, CoreException,
            MisconfigurationException {

        RefactoringRequest req = MarkOccurrencesJob.getRefactoringRequest(pyEdit,
                MarkOccurrencesJob.getRefactorAction(pyEdit), ps);
        if (monitor.isCanceled()) {
            return false;
        }

View Full Code Here

                            Log.log("Did not expect index < 0.");
                            continue CONTINUE_FOR;
                        }
                        callPs = new PySelection(ps.getDoc(), ps.getLineOffset() + indexOf + callWithoutParens.length());

                        RefactoringRequest request = new RefactoringRequest(f, callPs, null, nature, edit);
                        //Don't look in additional info.
                        request.setAdditionalInfo(
                                AstEntryRefactorerRequestConstants.FIND_DEFINITION_IN_ADDITIONAL_INFO, false);
                        pointers = pyRefactoring.findDefinition(request);

                        if (((pointers != null && pointers.length > 0) || StringUtils.count(possibleMatch.full, '.') <= 1)) {
                            break;
View Full Code Here

    public static ICallback<Boolean, Exception> onGetTddPropsError;

    private boolean checkMethodCreationAtClass(PyEdit edit, IPyRefactoring pyRefactoring, String callWithoutParens,
            PySelection callPs, List<ICompletionProposal> ret, String lineContents, TddPossibleMatches possibleMatch,
            File f, IPythonNature nature) throws MisconfigurationException, Exception {
        RefactoringRequest request;
        ItemPointer[] pointers;
        //Ok, no definition found for the full string, so, check if we have a dot there and check
        //if it could be a method in a local variable.
        String[] headAndTail = FullRepIterable.headAndTail(callWithoutParens);
        if (headAndTail[0].length() > 0) {

            String methodToCreate = headAndTail[1];
            if (headAndTail[0].equals("self")) {
                //creating something in the current class -- note that if it was self.bar here, we'd treat it as regular
                //(i.e.: no special support for self), so, we wouldn't enter here!
                int firstCharPosition = PySelection.getFirstCharPosition(lineContents);
                LineStartingScope scopeStart = callPs.getPreviousLineThatStartsScope(PySelection.CLASS_TOKEN, false,
                        firstCharPosition);
                String classNameInLine = null;
                if (scopeStart != null) {
                    for (Boolean isCall : new Boolean[] { true, false }) {
                        PyCreateMethodOrField pyCreateMethod = new PyCreateMethodOrField();
                        List<String> parametersAfterCall = null;
                        parametersAfterCall = configCreateAsAndReturnParametersAfterCall(callPs, isCall,
                                pyCreateMethod, parametersAfterCall, methodToCreate);
                        String startingScopeLineContents = callPs.getLine(scopeStart.iLineStartingScope);
                        classNameInLine = PySelection.getClassNameInLine(startingScopeLineContents);
                        if (classNameInLine != null && classNameInLine.length() > 0) {
                            pyCreateMethod.setCreateInClass(classNameInLine);

                            addCreateMethodOption(callPs, edit, ret, methodToCreate, parametersAfterCall,
                                    pyCreateMethod, classNameInLine);
                        }
                    }
                }
                return true;
            }

            int absoluteCursorOffset = callPs.getAbsoluteCursorOffset();
            absoluteCursorOffset = absoluteCursorOffset - (1 + methodToCreate.length()); //+1 for the dot removed too.
            PySelection newSelection = new PySelection(callPs.getDoc(), absoluteCursorOffset);
            request = new RefactoringRequest(f, newSelection, null, nature, edit);
            //Don't look in additional info.
            request.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_DEFINITION_IN_ADDITIONAL_INFO, false);
            pointers = pyRefactoring.findDefinition(request);
            if (pointers.length == 1) {
                if (checkCreationBasedOnFoundPointers(edit, callPs, ret, possibleMatch, pointers, methodToCreate,
                        newSelection, nature)) {
                    return true;
View Full Code Here

    public ItemPointer[] findDefinitionsAndOpen(boolean doOpenDefinition) {
        request = null;

        ps = new PySelection(getTextEditor());
        final PyEdit pyEdit = getPyEdit();
        RefactoringRequest refactoringRequest;
        try {
            refactoringRequest = getRefactoringRequest();
        } catch (MisconfigurationException e1) {
            Log.log(e1);
            return new ItemPointer[0];
View Full Code Here

    private ArrayList<IDefinition> findDefinitions(IPythonNature nature, PyEdit edit, int start, IDocument doc) {
        CompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();

        RefactoringRequest request = new RefactoringRequest(edit.getEditorFile(), new PySelection(doc,
                new TextSelection(doc, start, 0)), new NullProgressMonitor(), nature, edit);

        try {
            PyRefactoringFindDefinition.findActualDefinition(request, completionCache, selected);
        } catch (CompletionRecursionException e1) {
View Full Code Here

        }

        //ok, the editor is still there wit ha document... move on
        PyRefactorAction pyRefactorAction = getRefactorAction(pyEdit);

        final RefactoringRequest req = getRefactoringRequest(pyEdit, pyRefactorAction, this.ps);

        if (req == null || !req.nature.getRelatedInterpreterManager().isConfigured()) { //we check if it's configured because it may still be a stub...
            return new Tuple3<RefactoringRequest, PyRenameEntryPoint, Boolean>(null, null, false);
        }
View Full Code Here

     * @throws BadLocationException
     * @throws MisconfigurationException
     */
    public static RefactoringRequest getRefactoringRequest(final PyEdit pyEdit, PyRefactorAction pyRefactorAction,
            PySelection ps) throws BadLocationException, MisconfigurationException {
        final RefactoringRequest req = pyRefactorAction.getRefactoringRequest();
        req.ps = ps;
        req.fillInitialNameAndOffset();
        req.inputName = "foo";
        req.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_DEFINITION_IN_ADDITIONAL_INFO, false);
        req.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_REFERENCES_ONLY_IN_LOCAL_SCOPE, true);
        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.