Search in sources :

Example 1 with InMemoryEclipsePreferences

use of org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences in project Pydev by fabioz.

the class CodeFoldingSetterTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    DEBUG = false;
    preferences = new InMemoryEclipsePreferences();
    CodeFoldingSetter.setPreferences(preferences);
    setAllOptions(false);
}
Also used : InMemoryEclipsePreferences(org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences)

Example 2 with InMemoryEclipsePreferences

use of org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences in project Pydev by fabioz.

the class PyParserEditorIntegrationTest method testChangeInput.

public void testChangeInput() throws Exception {
    IEclipsePreferences preferences = new InMemoryEclipsePreferences();
    PyParserManager pyParserManager = PyParserManager.getPyParserManager(preferences);
    Document doc = new Document();
    PydevFileEditorInputStub input1 = new PydevFileEditorInputStub();
    PydevFileEditorInputStub input2 = new PydevFileEditorInputStub();
    // create them with the same input
    PyEditStub pyEdit1 = new PyEditStub(doc, input1);
    PyEditStub pyEdit2 = new PyEditStub(doc, input2);
    pyParserManager.attachParserTo(pyEdit1);
    pyParserManager.attachParserTo(pyEdit2);
    assertEquals(2, pyParserManager.getParsers().size());
    pyEdit2.setInput(input1);
    pyParserManager.attachParserTo(pyEdit2);
    assertEquals(1, pyParserManager.getParsers().size());
    // different input
    pyEdit2.setInput(input2);
    pyParserManager.attachParserTo(pyEdit2);
    assertEquals(2, pyParserManager.getParsers().size());
    pyParserManager.notifyEditorDisposed(pyEdit1);
    pyParserManager.notifyEditorDisposed(pyEdit2);
    assertEquals(0, pyParserManager.getParsers().size());
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) InMemoryEclipsePreferences(org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences)

Example 3 with InMemoryEclipsePreferences

use of org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences in project Pydev by fabioz.

the class PyParserEditorIntegrationTest method testIntegration.

public void testIntegration() throws Exception {
    IEclipsePreferences preferences = new InMemoryEclipsePreferences();
    PyParserManager pyParserManager = PyParserManager.getPyParserManager(preferences);
    Document doc = new Document();
    PyEditStub pyEdit = new PyEditStub(doc, new PydevFileEditorInputStub());
    pyParserManager.attachParserTo(pyEdit);
    checkParserChanged(pyEdit, 1);
    doc.replace(0, 0, "\r\ntest");
    checkParserChanged(pyEdit, 2);
    pyParserManager.attachParserTo(pyEdit);
    checkParserChanged(pyEdit, 3);
    // after this change, only 1 reparse should be asked, as the editor and doc is the same
    doc.replace(0, 0, "\r\ntest");
    checkParserChanged(pyEdit, 4);
    pyParserManager.notifyEditorDisposed(pyEdit);
    // after this change, only 1 reparse should be asked, as the editor and doc is the same
    doc.replace(0, 0, "\r\ntest");
    waitABit();
    assertEquals(4, pyEdit.parserChanged);
    assertEquals(0, pyParserManager.getParsers().size());
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) InMemoryEclipsePreferences(org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences)

Example 4 with InMemoryEclipsePreferences

use of org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences in project Pydev by fabioz.

the class InterpreterManagerTest method testInterpreterManager.

public void testInterpreterManager() throws Exception {
    Collection<String> pythonpath = new ArrayList<String>();
    pythonpath.add(TestDependent.PYTHON2_LIB);
    pythonpath.add(TestDependent.PYTHON2_SITE_PACKAGES);
    IEclipsePreferences prefs = new InMemoryEclipsePreferences();
    String interpreterStr = new InterpreterInfo("2.6", TestDependent.PYTHON2_EXE, pythonpath).toString();
    prefs.put(IInterpreterManager.PYTHON_INTERPRETER_PATH, interpreterStr);
    PythonInterpreterManager manager = new PythonInterpreterManager(prefs);
    checkSameInterpreterInfo(manager);
    manager.clearCaches();
    InterpreterInfo info = checkSameInterpreterInfo(manager);
    pythonpath = new ArrayList<String>();
    pythonpath.add(TestDependent.PYTHON2_LIB);
    pythonpath.add(TestDependent.PYTHON2_SITE_PACKAGES);
    pythonpath.add(additionalPythonpathEntry.toString());
    interpreterStr = new InterpreterInfo("2.6", TestDependent.PYTHON2_EXE, pythonpath).toString();
    prefs.put(IInterpreterManager.PYTHON_INTERPRETER_PATH, interpreterStr);
    info = checkSameInterpreterInfo(manager);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) PythonInterpreterManager(org.python.pydev.ast.interpreter_managers.PythonInterpreterManager) ArrayList(java.util.ArrayList) InterpreterInfo(org.python.pydev.ast.interpreter_managers.InterpreterInfo) IInterpreterInfo(org.python.pydev.core.IInterpreterInfo) InMemoryEclipsePreferences(org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences)

Example 5 with InMemoryEclipsePreferences

use of org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences in project Pydev by fabioz.

the class ParameterCompletionTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    CompiledModule.COMPILED_MODULES_ENABLED = false;
    useOriginalRequestCompl = true;
    participant = new CtxParticipant();
    ExtensionHelper.testingParticipants = new HashMap<String, List<Object>>();
    ArrayList<Object> participants = new ArrayList<Object>();
    /*IPyDevCompletionParticipant*/
    participants.add(participant);
    ExtensionHelper.testingParticipants.put(ExtensionHelper.PYDEV_COMPLETION, participants);
    codeCompletion = new PyCodeCompletion();
    this.restorePythonPath(false);
    final IEclipsePreferences prefs = new InMemoryEclipsePreferences();
    PyCodeCompletionPreferences.getPreferencesForTests = () -> prefs;
    prefs.putBoolean(PyCodeCompletionPreferences.MATCH_BY_SUBSTRING_IN_CODE_COMPLETION, false);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) PyCodeCompletion(org.python.pydev.ast.codecompletion.PyCodeCompletion) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CtxParticipant(com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant) InMemoryEclipsePreferences(org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences)

Aggregations

InMemoryEclipsePreferences (org.python.pydev.shared_core.preferences.InMemoryEclipsePreferences)8 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)7 Document (org.eclipse.jface.text.Document)4 ArrayList (java.util.ArrayList)3 IDocument (org.eclipse.jface.text.IDocument)3 InterpreterInfo (org.python.pydev.ast.interpreter_managers.InterpreterInfo)2 PythonInterpreterManager (org.python.pydev.ast.interpreter_managers.PythonInterpreterManager)2 IInterpreterInfo (org.python.pydev.core.IInterpreterInfo)2 AbstractAdditionalDependencyInfo (com.python.pydev.analysis.additionalinfo.AbstractAdditionalDependencyInfo)1 AdditionalSystemInterpreterInfo (com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo)1 CtxParticipant (com.python.pydev.codecompletion.ctxinsensitive.CtxParticipant)1 File (java.io.File)1 List (java.util.List)1 PyCodeCompletion (org.python.pydev.ast.codecompletion.PyCodeCompletion)1 SourceToken (org.python.pydev.ast.codecompletion.revisited.modules.SourceToken)1 IInfo (org.python.pydev.core.IInfo)1 ISystemModulesManager (org.python.pydev.core.ISystemModulesManager)1 IToken (org.python.pydev.core.IToken)1 MisconfigurationException (org.python.pydev.core.MisconfigurationException)1 TokensList (org.python.pydev.core.TokensList)1