Examples of IPythonNature


Examples of org.python.pydev.core.IPythonNature

        IToken[] toks = new IToken[0];

        if (COMPILED_MODULES_ENABLED) {
            try {
                final IPythonNature nature = manager.getNature();

                final AbstractShell shell;
                try {
                    shell = AbstractShell.getServerShell(nature, AbstractShell.COMPLETION_SHELL);
                } catch (Exception e) {
                    throw new RuntimeException("Unable to create shell for CompiledModule: " + this.name, e);
                }
                synchronized (shell) {
                    String act = name + '.' + activationToken;
                    String tokenToCompletion = act;
                    if (isPythonBuiltin) {
                        String replacement = BUILTIN_REPLACEMENTS.get(activationToken);
                        if (replacement != null) {
                            tokenToCompletion = name + '.' + replacement;
                        }
                    }

                    List<String[]> completions = shell.getImportCompletions(
                            tokenToCompletion,
                            manager.getModulesManager().getCompletePythonPath(nature.getProjectInterpreter(),
                                    nature.getRelatedInterpreterManager())).o2;

                    ArrayList<IToken> array = new ArrayList<IToken>();

                    for (Iterator<String[]> iter = completions.iterator(); iter.hasNext();) {
                        String[] element = iter.next();
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        if (project == null || !project.exists()) {
            throw new RuntimeException("The project selected does not exist in the workspace.");
        }
        IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
        if (pathNature == null) {
            IPythonNature nature = PythonNature.addNature(project, monitor, null, null, null, null, null);
            pathNature = nature.getPythonPathNature();
            if (pathNature == null) {
                throw new RuntimeException("Unable to add the nature to the seleted project.");
            }
        }
        IFolder folder = project.getFolder(name);
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        try {
            PyEdit pyEdit = getPyEdit();

            PySelection pySelection = new PySelection(pyEdit);

            IPythonNature nature = pyEdit.getPythonNature();
            File editorFile = pyEdit.getEditorFile();
            buf.append(nature.resolveModule(editorFile));

            List<stmtType> path = FastParser.parseToKnowGloballyAccessiblePath(pySelection.getDoc(),
                    pySelection.getStartLineIndex());
            for (stmtType stmtType : path) {
                if (buf.length() > 0) {
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

                //add one to the relative import level
                level++;
            }
        }
        ICompletionRequest request = r;
        IPythonNature nature = request.getNature();

        String relative = null;
        String moduleName = null;
        if (request.getEditorFile() != null) {
            moduleName = modulesManager.resolveModule(FileUtils.getFileAbsolutePath(request.getEditorFile()));
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

    /**
     * @return the builtin completions
     */
    public List<IToken> getBuiltinCompletions(ICompletionState state, List<IToken> completions) {
        IPythonNature nature = state.getNature();
        IToken[] builtinCompletions = getBuiltinComps(nature);
        if (builtinCompletions != null) {
            for (int i = 0; i < builtinCompletions.length; i++) {
                completions.add(builtinCompletions[i]);
            }
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        Tuple<IModule, String> modTok = null;
        IModule mod = null;

        //ok, check if it is a token for the new import
        IPythonNature nature = state.getNature();
        if (importedModule instanceof SourceToken) {
            SourceToken token = (SourceToken) importedModule;

            if (token.isImportFrom()) {
                ImportFrom importFrom = (ImportFrom) token.getAst();
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

            String tok = tokenAndQual[0] + tokenAndQual[1];
            //2. check findDefinition (SourceModule)
            try {
                int beginLine = request.getBeginLine();
                int beginCol = request.getBeginCol() + 1;
                IPythonNature pythonNature = request.nature;

                PyRefactoringFindDefinition.findActualDefinition(request.getMonitor(), mod, tok, selected, beginLine,
                        beginCol, pythonNature, completionCache);
            } catch (OperationCanceledException e) {
                throw e;
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

    private void visitWith(int visitType, final IResource resource, ICallback0<IDocument> document,
            IProgressMonitor monitor) {
        if (monitor.isCanceled()) {
            return; //it's already cancelled
        }
        IPythonNature nature = PythonNature.getPythonNature(resource);
        if (nature == null) {
            return;
        }
        if (!nature.startRequests()) {
            return;
        }

        try {

            try {
                //we visit external because we must index them
                if (!isResourceInPythonpathProjectSources(resource, nature, true)) {
                    return; // we only analyze resources that are in the pythonpath
                }
            } catch (Exception e1) {
                Log.log(e1);
                return; // we only analyze resources that are in the pythonpath
            }

            HashMap<String, Object> copyMemo = new HashMap<String, Object>(this.memo);
            FastStringBuffer bufferToCommunicateProgress = new FastStringBuffer();

            for (PyDevBuilderVisitor visitor : visitors) {
                // some visitors cannot visit too many elements because they do a lot of processing
                if (visitor.maxResourcesToVisit() == PyDevBuilderVisitor.MAX_TO_VISIT_INFINITE
                        || visitor.maxResourcesToVisit() >= totalResources) {
                    visitor.memo = copyMemo; //setting the memo must be the first thing.
                    try {
                        //communicate progress for each visitor
                        PyDevBuilder.communicateProgress(monitor, totalResources, currentResourcesVisited, resource,
                                visitor, bufferToCommunicateProgress);
                        switch (visitType) {
                            case VISIT_ADD:
                                visitor.visitAddedResource(resource, document, monitor);
                                break;

                            case VISIT_CHANGE:
                                visitor.visitChangedResource(resource, document, monitor);
                                break;

                            case VISIT_REMOVE:
                                visitor.visitRemovedResource(resource, document, monitor);
                                break;

                            default:
                                throw new RuntimeException("Error: visit type not properly given!"); //$NON-NLS-1$
                        }
                    } catch (Exception e) {
                        Log.log(e);
                    }
                }
            }

        } finally {
            nature.endRequests();
        }

    }
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

        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;
View Full Code Here

Examples of org.python.pydev.core.IPythonNature

     * @throws MisconfigurationException
     */
    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
TOP
Copyright © 2018 www.massapi.com. 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.