use of org.python.pydev.ast.codecompletion.revisited.ProjectModulesManager in project Pydev by fabioz.
the class ClassHierarchySearchTest method tearDown.
@Override
public void tearDown() throws Exception {
CompiledModule.COMPILED_MODULES_ENABLED = false;
SourceModule.TESTING = false;
ProjectModulesManager projectModulesManager = ((ProjectModulesManager) nature.getAstManager().getModulesManager());
projectModulesManager.doRemoveSingleModule(new ModulesKey("foo", null));
projectModulesManager.doRemoveSingleModule(new ModulesKey("foo0", null));
projectModulesManager.doRemoveSingleModule(new ModulesKey("fooIn1", null));
projectModulesManager.doRemoveSingleModule(new ModulesKey("fooIn10", null));
projectModulesManager = ((ProjectModulesManager) nature2.getAstManager().getModulesManager());
projectModulesManager.doRemoveSingleModule(new ModulesKey("fooIn2", null));
projectModulesManager.doRemoveSingleModule(new ModulesKey("fooIn20", null));
FileUtils.deleteDirectoryTree(baseDir);
FileUtils.deleteDirectoryTree(baseDir2);
super.tearDown();
}
use of org.python.pydev.ast.codecompletion.revisited.ProjectModulesManager in project Pydev by fabioz.
the class DjangoProjectProperties method createContents.
@Override
protected Control createContents(Composite parent) {
project = getElement().getAdapter(IProject.class);
Composite topComp = new Composite(parent, SWT.NONE);
GridLayout innerLayout = new GridLayout();
innerLayout.numColumns = 2;
innerLayout.marginHeight = 0;
innerLayout.marginWidth = 0;
topComp.setLayout(innerLayout);
GridData gd = new GridData(GridData.FILL_BOTH);
topComp.setLayoutData(gd);
if (project != null) {
try {
IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
final PythonNature nature = PythonNature.getPythonNature(project);
Map<String, String> variableSubstitution = pathNature.getVariableSubstitution(false);
Label label = new Label(topComp, SWT.None);
label.setText("Django manage.py");
Text text = new Text(topComp, SWT.BORDER);
textDjangoManage = text;
textDjangoManage.setToolTipText("This is the name of the project-relative location of manage.py (i.e.: src/myapp/manage.py)");
label = new Label(topComp, SWT.None);
labelErrorManage = new Label(topComp, SWT.None);
labelErrorManage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
ModifyListener manageValidator = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
try {
String path = textDjangoManage.getText().trim();
if (path.trim().length() == 0) {
labelErrorSettings.setText("Please specify the manage.py relative name (i.e.: src/myapp/manage.py)");
return;
}
IFile file = project.getFile(new Path(path));
if (!file.exists()) {
labelErrorManage.setText(StringUtils.format("File: %s could not be found.", path));
} else {
labelErrorManage.setText("");
}
} catch (Exception e1) {
Log.log(e1);
}
}
};
text.addModifyListener(manageValidator);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
String string = variableSubstitution.get(DjangoConstants.DJANGO_MANAGE_VARIABLE);
if (string != null) {
text.setText(string);
} else {
text.setText("");
}
// Settings
label = new Label(topComp, SWT.None);
label.setText("Django settings module");
text = new Text(topComp, SWT.BORDER);
textDjangoSettings = text;
textDjangoSettings.setToolTipText("This is the name of the django settings module (i.e.: myapp.settings)");
label = new Label(topComp, SWT.None);
labelErrorSettings = new Label(topComp, SWT.None);
labelErrorSettings.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
ModifyListener settingsValidator = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
try {
String moduleName = textDjangoSettings.getText().trim();
if (moduleName.trim().length() == 0) {
labelErrorSettings.setText("Please specify the name of the module (i.e.: myapp.settings)");
return;
}
ICodeCompletionASTManager astManager = nature.getAstManager();
ProjectModulesManager modulesManager = (ProjectModulesManager) astManager.getModulesManager();
IModule moduleInDirectManager = modulesManager.getModuleInDirectManager(moduleName, nature, true, new BaseModuleRequest(false));
if (moduleInDirectManager == null) {
labelErrorSettings.setText(StringUtils.format("Module: %s could not be found.", moduleName));
} else {
labelErrorSettings.setText("");
}
} catch (Exception e1) {
Log.log(e1);
}
}
};
text.addModifyListener(settingsValidator);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
string = variableSubstitution.get(DjangoConstants.DJANGO_SETTINGS_MODULE);
if (string != null) {
text.setText(string);
} else {
text.setText("");
}
} catch (Exception e) {
Log.log(e);
}
} else {
Label label = new Label(topComp, SWT.None);
label.setText("Internal error: project not set!");
}
return topComp;
}
use of org.python.pydev.ast.codecompletion.revisited.ProjectModulesManager in project Pydev by fabioz.
the class PyDevBuilderVisitor method isResourceInPythonpathProjectSources.
public boolean isResourceInPythonpathProjectSources(IResource resource, IPythonNature nature, boolean addExternal) throws CoreException, MisconfigurationException {
Boolean isInProjectPythonpath = (Boolean) memo.get(MODULE_IN_PROJECT_PYTHONPATH + addExternal);
if (isInProjectPythonpath == null) {
// This was simply: String moduleName = nature.resolveModuleOnlyInProjectSources(resource, addExternal);
// Inlined with the code below because nature.getPythonPathNature().getOnlyProjectPythonPathStr was one of
// the slowest things when doing a full build.
List<String> onlyProjectPythonPathLst = memo.getOnlyProjectPythonPathStr(nature, addExternal);
String resourceOSString = SharedCorePlugin.getIResourceOSString(resource);
String moduleName = null;
if (resourceOSString != null) {
ICodeCompletionASTManager astManager = nature.getAstManager();
if (astManager != null) {
IModulesManager modulesManager = astManager.getModulesManager();
if (modulesManager instanceof ProjectModulesManager) {
PythonPathHelper pythonPathHelper = ((ProjectModulesManager) modulesManager).getPythonPathHelper();
moduleName = pythonPathHelper.resolveModule(resourceOSString, false, onlyProjectPythonPathLst, nature.getProject());
}
}
}
isInProjectPythonpath = (moduleName != null);
if (isInProjectPythonpath) {
setModuleNameInCache(memo, resource, moduleName);
}
}
return isInProjectPythonpath;
}
Aggregations