PyStatementList list = function.getStatementList();
PyParameterList paramList = function.getParameterList();
- final StringBuilder functionText = new StringBuilder("def foo(");
+ final StringBuilder functionText = new StringBuilder("def " + function.getName() + "(");
int size = paramList.getParameters().length;
for (int i = 0; i != size; ++i) {
PyParameter p = paramList.getParameters()[i];
if (next instanceof PyExpressionStatement) {
final PyExpression expr = ((PyExpressionStatement)next).getExpression();
if (expr instanceof PyBinaryExpression) {
- addInArguments(stringBuilder, (PyBinaryExpression)expr);
+ final PsiElement operator = ((PyBinaryExpression)expr).getPsiOperator();
+ if (operator instanceof LeafPsiElement && ((LeafPsiElement)operator).getElementType() == PyTokenTypes.IN_KEYWORD) {
+ addInArguments(stringBuilder, (PyBinaryExpression)expr);
+ }
+ else {
+ stringBuilder.append(next.getText());
+ }
}
else if (expr instanceof PyTupleExpression) {
final PyExpression[] elements = ((PyTupleExpression)expr).getElements();
}
private static void addInArguments(@NotNull final StringBuilder stringBuilder, @NotNull final PyBinaryExpression binaryExpression) {
- final PsiElement operator = binaryExpression.getPsiOperator();
- if (operator instanceof LeafPsiElement && ((LeafPsiElement)operator).getElementType() == PyTokenTypes.IN_KEYWORD) {
- stringBuilder.append(binaryExpression.getLeftExpression().getText());
- stringBuilder.append(", ");
- final PyExpression rightExpression = binaryExpression.getRightExpression();
- if (rightExpression != null)
- stringBuilder.append(rightExpression.getText());
- }
+ stringBuilder.append(binaryExpression.getLeftExpression().getText());
+ stringBuilder.append(", ");
+ final PyExpression rightExpression = binaryExpression.getRightExpression();
+ if (rightExpression != null)
+ stringBuilder.append(rightExpression.getText());
}
private static void replacePrint(@NotNull final PsiElement expression) {
import com.intellij.facet.FacetManager;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.FileTypeManager;
+import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleType;
oStream.close();
for (VirtualFile child : fileOrDir.getChildren()) {
- if (!child.isDirectory() && PythonFileType.INSTANCE.equals(child.getFileType())) {
+ final FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(child.getName());
+ if (!child.isDirectory() && PythonFileType.INSTANCE.equals(fileType)) {
PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child);
}
}
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Python\\PythonCore", "python.exe",
"HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython", "ipy.exe");
+ private static Set<String> ourRegistryCache;
+
private WinPythonSdkFlavor() {
}
}
public static void findInRegistry(Collection<String> candidates) {
- for (Map.Entry<String, String> entry : ourRegistryMap.entrySet()) {
- final String prefix = entry.getKey();
- final String exePath = entry.getValue();
- List<String> strings = WindowsRegistryUtil.readRegistryBranch(prefix);
- for (String string : strings) {
- final String path =
- WindowsRegistryUtil.readRegistryDefault(prefix + "\\" + string +
- "\\InstallPath");
- if (path != null) {
- File f = new File(path, exePath);
- if (f.exists()) {
- candidates.add(FileUtil.toSystemDependentName(f.getPath()));
+ fillRegistryCache();
+ candidates.addAll(ourRegistryCache);
+ }
+
+ private static void fillRegistryCache() {
+ if (ourRegistryCache == null) {
+ ourRegistryCache = new HashSet<String>();
+ for (Map.Entry<String, String> entry : ourRegistryMap.entrySet()) {
+ final String prefix = entry.getKey();
+ final String exePath = entry.getValue();
+ List<String> strings = WindowsRegistryUtil.readRegistryBranch(prefix);
+ for (String string : strings) {
+ final String path = WindowsRegistryUtil.readRegistryDefault(prefix + "\\" + string +
+ "\\InstallPath");
+ if (path != null) {
+ File f = new File(path, exePath);
+ if (f.exists()) {
+ ourRegistryCache.add(FileUtil.toSystemDependentName(f.getPath()));
+ }
}
}
}
-def foo(args=<warning descr="Default argument value is mutable">[<caret>]</warning>):<EOLError descr="Indent expected"></EOLError>
\ No newline at end of file
+def bar(args=<warning descr="Default argument value is mutable">[<caret>]</warning>):<EOLError descr="Indent expected"></EOLError>
\ No newline at end of file
-def foo(args=None):
+def bar(args=None):
if not args:
args = []
\ No newline at end of file