Package com.python.pydev.analysis.additionalinfo

Examples of com.python.pydev.analysis.additionalinfo.AbstractAdditionalTokensInfo


            if (nature == null) {
                Log.log("Finished analysis: null nature -- " + moduleName);
                return;
            }
            AbstractAdditionalTokensInfo info = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);

            if (info == null) {
                Log.log("Unable to get additional info for: " + r + " -- " + moduleName);
                return;
            }
View Full Code Here


        TreeSet<ModulesKey> inModulesManager = new TreeSet<ModulesKey>(Arrays.asList(onlyDirectModules));

        Set<String> allAdditionalInfoModuleNames = new TreeSet<String>();
        List<Tuple<AbstractAdditionalTokensInfo, IPythonNature>> additionalInfoAndNature = AdditionalProjectInterpreterInfo
                .getAdditionalInfoAndNature(nature, false, false, false);
        AbstractAdditionalTokensInfo additionalProjectInfo;
        if (additionalInfoAndNature.size() == 0) {
            addChild(new LeafElement(this, "No additional infos found (1 expected) -- skipping other checks."));
            return;

        } else {
            if (additionalInfoAndNature.size() > 1) {
                addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format(
                        "%s additional infos found (only 1 expected) -- continuing checks but analysis may be wrong.",
                        additionalInfoAndNature.size())));
            }
            additionalProjectInfo = additionalInfoAndNature.get(0).o1;
            allAdditionalInfoModuleNames.addAll(additionalProjectInfo.getAllModulesWithTokens());
        }

        for (ModulesKey key : inModulesManager) {
            if (!expectedModuleNames.contains(key)) {
                info.modulesNotInDisk.add(key);
                addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format("%s exists in memory but not in the disk.", key)));
            }
        }

        ModulesKey tempKey = new ModulesKey(null, null);
        for (String s : allAdditionalInfoModuleNames) {
            tempKey.name = s;
            if (!expectedModuleNames.contains(tempKey)) {
                info.additionalModulesNotInDisk.add(s);
                addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format(
                        "%s exists in the additional info but not in the disk.", s)));
            }
        }

        for (ModulesKey key : expectedModuleNames) {
            boolean isInModulesManager = inModulesManager.contains(key);
            if (!isInModulesManager) {
                info.modulesNotInMemory.add(key);
                addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format("%s exists in the disk but not in memory.", key)));
            }
            if (!allAdditionalInfoModuleNames.contains(key.name)) {
                try {
                    AbstractModule mod = AbstractModule.createModule(key.name, key.file, info.nature, true);
                    if (!(mod instanceof SourceModule)) {
                        continue;
                    }
                    SourceModule module = (SourceModule) mod;
                    if (module == null || module.getAst() == null) {
                        addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format(
                                "Warning: cannot parse: %s - %s (so, it's ok not having additional info on it)",
                                key.name, key.file)));
                    } else {
                        try {
                            Iterator<ASTEntry> innerEntriesForAST = AbstractAdditionalDependencyInfo
                                    .getInnerEntriesForAST(module.getAst()).o2;
                            if (innerEntriesForAST.hasNext()) {
                                info.moduleNotInAdditionalInfo.add(module);
                                addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format(
                                        "The additional info index of the module: %s is not updated.", key.name)));
                            }
                        } catch (Exception e) {
                            addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format(
                                    "Unexpected error happened on: %s - %s: %s", key.name, key.file, e.getMessage())));
                        }
                    }
                } catch (IOException e) {
                    //OK, it cannot be parsed, so, we cannot generate its info
                    addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format(
                            "Warning: cannot parse: %s - %s (so, it's ok not having additional info on it)", key.name,
                            key.file)));
                }
            }
        }

        //modules manager
        if (info.modulesNotInDisk.size() > 0) {
            for (ModulesKey m : info.modulesNotInDisk) {
                addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format("FIX: Removing from modules manager: %s", m)));
            }
            projectModulesManager.removeModules(info.modulesNotInDisk);
        }

        for (ModulesKey key : info.modulesNotInMemory) {
            addChild(new LeafElement(this, "FIX: Adding to modules manager: " + key));
            projectModulesManager.addModule(key);
        }

        //additional info
        for (String s : info.additionalModulesNotInDisk) {
            addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format("FIX: Removing from additional info: %s", s)));
            additionalProjectInfo.removeInfoFromModule(s, true);
        }

        for (SourceModule mod : info.moduleNotInAdditionalInfo) {
            addChild(new LeafElement(this, com.aptana.shared_core.string.StringUtils.format("FIX: Adding to additional info: %s", mod.getName())));
            additionalProjectInfo.addAstInfo(mod.getAst(), mod.getModulesKey(), true);
        }

    }
View Full Code Here

    /**
     * Gets it using all the natures that match a given interpreter manager.
     * @throws MisconfigurationException
     */
    private static void getFromManagerAndRelatedNatures(String selectedText, IInterpreterManager useManager) {
        AbstractAdditionalTokensInfo additionalSystemInfo;
        try {
            additionalSystemInfo = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(useManager, useManager
                    .getDefaultInterpreterInfo(true).getExecutableOrJar());
        } catch (MisconfigurationException e) {
            MessageDialog.openError(getShell(), "Error",
View Full Code Here

    }

    // ------------------------------------------------------------------------------------------------- tests

    public void testSetup() {
        AbstractAdditionalTokensInfo additionalSystemInfo;
        try {
            additionalSystemInfo = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(getInterpreterManager(),
                    getInterpreterManager().getDefaultInterpreterInfo(false).getExecutableOrJar(), true);
        } catch (MisconfigurationException e) {
            throw new RuntimeException(e);
        }
        assertTrue(additionalSystemInfo.getAllTokens().size() > 0);
        Collection<IInfo> tokensStartingWith = additionalSystemInfo.getTokensStartingWith("TestC",
                AbstractAdditionalTokensInfo.TOP_LEVEL);
        assertIsIn("TestCase", "unittest", tokensStartingWith);
    }
View Full Code Here

    public void testCompletion() throws Exception {
        requestCompl("Tes", -1, -1, new String[] { "TestCase - unittest" }); //at least 3 chars needed by default
    }

    public void testSetup2() throws Exception {
        AbstractAdditionalTokensInfo additionalInfo = AdditionalProjectInterpreterInfo
                .getAdditionalInfoForProject(nature);
        assertTrue(additionalInfo.getAllTokens().size() > 0);
        Collection<IInfo> tokensStartingWith = additionalInfo.getTokensStartingWith("MyInvalidClassInInvalidFil",
                AbstractAdditionalTokensInfo.TOP_LEVEL);
        assertEquals("Expecting no tokens. Found: " + tokensStartingWith, 0, tokensStartingWith.size());
    }
View Full Code Here

    }

    private void fillNatureCompletionsForConsole(IScriptConsoleViewer viewer, int requestOffset,
            List<ICompletionProposal> completions, String qual, boolean addAutoImport, int qlen, String lowerQual,
            IPythonNature nature, boolean getSystem) {
        AbstractAdditionalTokensInfo additionalInfoForProject;

        if (getSystem) {
            try {
                additionalInfoForProject = AdditionalSystemInterpreterInfo.getAdditionalSystemInfo(
                        PydevPlugin.getInterpreterManager(nature), nature.getProjectInterpreter().getExecutableOrJar());
            } catch (Exception e) {
                Log.log(e);
                return;
            }
        } else {
            try {
                additionalInfoForProject = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
            } catch (Exception e) {
                Log.log(e);
                return;
            }
        }

        Collection<IInfo> tokensStartingWith = additionalInfoForProject.getTokensStartingWith(qual,
                AbstractAdditionalTokensInfo.TOP_LEVEL);

        FastStringBuffer realImportRep = new FastStringBuffer();
        FastStringBuffer displayString = new FastStringBuffer();
        FastStringBuffer tempBuf = new FastStringBuffer();
View Full Code Here

    }

    // ------------------------------------------------------------------------------------------------- tests

    public void testSetup() throws MisconfigurationException {
        AbstractAdditionalTokensInfo additionalInfo = AdditionalProjectInterpreterInfo
                .getAdditionalInfoForProject(nature);
        assertTrue(additionalInfo.getAllTokens().size() > 0);
        Collection<IInfo> tokensStartingWith = additionalInfo.getTokensStartingWith("existingM",
                AbstractAdditionalTokensInfo.INNER);
        assertTrue(tokensStartingWith.size() == 1);
        assertIsIn("existingMethod", "testAssist.assist", tokensStartingWith);
    }
View Full Code Here

        editor.close(false);
        goToIdleLoopUntilCondition(getInitialParsesCondition(), getParsesDone(), false); //just to have any parse events consumed
        goToManual(TIME_FOR_ANALYSIS); //give it a bit more time...

        PythonNature nature = PythonNature.getPythonNature(mod1);
        AbstractAdditionalTokensInfo info = AdditionalProjectInterpreterInfo.getAdditionalInfoForProject(nature);
        //all modules are empty
        assertEquals(new HashSet<String>(), info.getAllModulesWithTokens());

        ICallback<Object, IResource> analysisCallback = getAnalysisCallback();
        AnalysisBuilderRunnable.analysisBuilderListeners.add(analysisCallback);

        try {
View Full Code Here

                modules.add(modulesKey);

                SourceModule mod = (SourceModule) AbstractModule.createModule(modName, f, natureRefactoring, true);

                //also create the additional info so that it can be used for finds
                AbstractAdditionalTokensInfo additionalInfo = AdditionalProjectInterpreterInfo
                        .getAdditionalInfoForProject(natureRefactoring);
                additionalInfo.addAstInfo(mod.getAst(), modulesKey, false);
            }

            RefactorerFindReferences.FORCED_RETURN = iFiles;
        }
    }
View Full Code Here

TOP

Related Classes of com.python.pydev.analysis.additionalinfo.AbstractAdditionalTokensInfo

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.