mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -97,6 +97,7 @@ public class BuildoutFacet extends Facet<BuildoutFacetConfiguration> implements
|
||||
|
||||
/**
|
||||
* Generates a <code>sys.path[0:0] = [...]</code> with paths that buildout script wants.
|
||||
*
|
||||
* @param module to get a buildout facet from
|
||||
* @return the statement, or null if there's no buildout facet.
|
||||
*/
|
||||
@@ -158,7 +159,7 @@ public class BuildoutFacet extends Facet<BuildoutFacetConfiguration> implements
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
catch(IOException e) {
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
return null;
|
||||
}
|
||||
@@ -208,18 +209,20 @@ public class BuildoutFacet extends Facet<BuildoutFacetConfiguration> implements
|
||||
String text = VfsUtil.loadText(vFile);
|
||||
String[] lines = LineTokenizer.tokenize(text, false);
|
||||
int index = 0;
|
||||
while(index < lines.length && !lines [index].startsWith("def addsitepackages("))
|
||||
while (index < lines.length && !lines[index].startsWith("def addsitepackages(")) {
|
||||
index++;
|
||||
while(index < lines.length && !lines [index].trim().startsWith("buildout_paths = ["))
|
||||
}
|
||||
while (index < lines.length && !lines[index].trim().startsWith("buildout_paths = [")) {
|
||||
index++;
|
||||
}
|
||||
index++;
|
||||
while(index < lines.length && !lines [index].trim().equals("]")) {
|
||||
String line = lines [index].trim();
|
||||
while (index < lines.length && !lines[index].trim().equals("]")) {
|
||||
String line = lines[index].trim();
|
||||
if (line.endsWith(",")) {
|
||||
line = line.substring(0, line.length()-1);
|
||||
line = line.substring(0, line.length() - 1);
|
||||
}
|
||||
if (line.startsWith("'") && line.endsWith("'")) {
|
||||
result.add(StringUtil.unescapeStringCharacters(line.substring(1, line.length()-1)));
|
||||
result.add(StringUtil.unescapeStringCharacters(line.substring(1, line.length() - 1)));
|
||||
}
|
||||
index++;
|
||||
}
|
||||
@@ -243,10 +246,12 @@ public class BuildoutFacet extends Facet<BuildoutFacetConfiguration> implements
|
||||
// alter execution script
|
||||
ParamsGroup script_params = params.getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
|
||||
assert script_params != null;
|
||||
String normal_script = script_params.getParameters().get(0); // expect DjangoUtil.MANAGE_FILE
|
||||
String engulfer_path = PythonHelpersLocator.getHelperPath("pycharm/buildout_engulfer.py");
|
||||
new_env.put("PYCHARM_ENGULF_SCRIPT", getConfiguration().getScriptName());
|
||||
script_params.getParametersList().replaceOrPrepend(normal_script, engulfer_path);
|
||||
if (script_params.getParameters().size() > 0) {
|
||||
String normal_script = script_params.getParameters().get(0); // expect DjangoUtil.MANAGE_FILE
|
||||
String engulfer_path = PythonHelpersLocator.getHelperPath("pycharm/buildout_engulfer.py");
|
||||
new_env.put("PYCHARM_ENGULF_SCRIPT", getConfiguration().getScriptName());
|
||||
script_params.getParametersList().replaceOrPrepend(normal_script, engulfer_path);
|
||||
}
|
||||
// add pycharm helpers to pythonpath so that fixGetpass is importable
|
||||
|
||||
PythonEnvUtil.addToPythonPath(new_env, PythonHelpersLocator.getHelpersRoot().getAbsolutePath());
|
||||
@@ -280,7 +285,7 @@ public class BuildoutFacet extends Facet<BuildoutFacetConfiguration> implements
|
||||
String text = FileUtil.loadFile(cfg);
|
||||
final PsiFile configFile = PsiFileFactory
|
||||
.getInstance(getModule().getProject()).createFileFromText("buildout.cfg",
|
||||
BuildoutCfgLanguage.INSTANCE, text);
|
||||
BuildoutCfgLanguage.INSTANCE, text);
|
||||
if (configFile != null && configFile instanceof BuildoutCfgFile) {
|
||||
return (BuildoutCfgFile)configFile;
|
||||
}
|
||||
@@ -290,7 +295,7 @@ public class BuildoutFacet extends Facet<BuildoutFacetConfiguration> implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static List<File> getScripts(@Nullable BuildoutFacet buildoutFacet, final VirtualFile baseDir) {
|
||||
File rootPath = null;
|
||||
if (buildoutFacet != null) {
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
package com.jetbrains.python.buildout.config;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.psi.PyParameter;
|
||||
import com.jetbrains.python.psi.PyQualifiedExpression;
|
||||
import com.jetbrains.python.psi.PyReferenceExpression;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
@@ -32,8 +33,9 @@ public class PyTargetElementEvaluator implements TargetElementEvaluator {
|
||||
PsiElement result = ref.resolve();
|
||||
while (result instanceof PyReferenceExpression || result instanceof PyTargetExpression) {
|
||||
PsiElement nextResult = ((PyQualifiedExpression) result).getReference(PyResolveContext.noImplicits()).resolve();
|
||||
if (nextResult != null && nextResult != result && PsiTreeUtil.getParentOfType(element, ScopeOwner.class) ==
|
||||
PsiTreeUtil.getParentOfType(result, ScopeOwner.class)) {
|
||||
if (nextResult != null && nextResult != result &&
|
||||
PsiTreeUtil.getParentOfType(element, ScopeOwner.class) == PsiTreeUtil.getParentOfType(result, ScopeOwner.class) &&
|
||||
(nextResult instanceof PyReferenceExpression || nextResult instanceof PyTargetExpression || nextResult instanceof PyParameter)) {
|
||||
result = nextResult;
|
||||
}
|
||||
else {
|
||||
|
||||
+8
-3
@@ -51,12 +51,12 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
final ASTNode ctxNode = context.getNode();
|
||||
if (ctxNode != null && PyTokenTypes.STRING_NODES.contains(ctxNode.getElementType())) return false; // no sense inside string
|
||||
PsiElement p = (PsiElement)element;
|
||||
int first_offset = p.getTextOffset();
|
||||
int firstOffset = p.getTextRange().getStartOffset();
|
||||
// we must be a stmt ourselves, not a part of another stmt
|
||||
// try to climb to the stmt level with the same offset
|
||||
while (true) {
|
||||
if (p == null) return false;
|
||||
if (p.getTextOffset() != first_offset) return false;
|
||||
if (p.getTextRange().getStartOffset() != firstOffset) return false;
|
||||
if (p instanceof PyStatement) break;
|
||||
p = p.getParent();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
PsiDocumentManager docMgr = PsiDocumentManager.getInstance(p.getProject());
|
||||
Document doc = docMgr.getDocument(p.getContainingFile().getOriginalFile());
|
||||
if (doc != null) {
|
||||
if (doc.getLineNumber(prev.getTextRange().getEndOffset()) == doc.getLineNumber(first_offset)) {
|
||||
if (doc.getLineNumber(prev.getTextRange().getEndOffset()) == doc.getLineNumber(firstOffset)) {
|
||||
return false; // same line
|
||||
}
|
||||
}
|
||||
@@ -215,6 +215,9 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_STRING_LITERAL =
|
||||
psiElement().inside(PyStringLiteralExpression.class);
|
||||
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_FUNCTION_HEADER =
|
||||
psiElement().inside(PyFunction.class).andNot(psiElement().inside(PyStatementList.class));
|
||||
|
||||
public static final PsiElementPattern.Capture<PsiElement> AFTER_QUALIFIER =
|
||||
psiElement().afterLeaf(psiElement().withText(".").inside(PyReferenceExpression.class));
|
||||
|
||||
@@ -511,6 +514,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andNot(IN_COMMENT)
|
||||
.andNot(IN_IMPORT_STMT)
|
||||
.andNot(IN_PARAM_LIST)
|
||||
.andNot(IN_FUNCTION_HEADER)
|
||||
.andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL)
|
||||
,
|
||||
new PyKeywordCompletionProvider("not", "lambda")
|
||||
@@ -526,6 +530,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
.andNot(IN_IMPORT_STMT)
|
||||
.and(NOT_PARAMETER_OR_DEFAULT_VALUE)
|
||||
.andNot(AFTER_QUALIFIER)
|
||||
.andNot(IN_FUNCTION_HEADER)
|
||||
,
|
||||
new PyKeywordCompletionProvider(TailType.NONE, "True", "False", "None")
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.python.documentation.StructuredDocString;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyBuiltinCache;
|
||||
@@ -15,6 +16,7 @@ import com.jetbrains.python.psi.types.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
@@ -249,7 +251,7 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase {
|
||||
final String name = level.isPy3K() ? "StdlibTypes3" : "StdlibTypes2";
|
||||
if (result.isEmpty()) {
|
||||
try {
|
||||
final InputStream s = getClass().getResourceAsStream(String.format("%s.properties", name));
|
||||
final InputStream s = new FileInputStream(PythonHelpersLocator.getHelperFile(String.format("%s.properties", name)));
|
||||
try {
|
||||
result.load(s);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class PydevConsoleCommunication extends AbstractConsoleCommunication impl
|
||||
lock.wait(10);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
LOG.error(e);
|
||||
//pass
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static javax.swing.SwingUtilities.invokeLater;
|
||||
@@ -61,7 +58,7 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
|
||||
private final Map<String, XBreakpoint<? extends ExceptionBreakpointProperties>> myRegisteredExceptionBreakpoints =
|
||||
new ConcurrentHashMap<String, XBreakpoint<? extends ExceptionBreakpointProperties>>();
|
||||
|
||||
private final List<PyThreadInfo> mySuspendedThreads = Lists.newArrayList();
|
||||
private final List<PyThreadInfo> mySuspendedThreads = Collections.synchronizedList(Lists.<PyThreadInfo>newArrayList());
|
||||
private final Map<String, XValueChildrenList> myStackFrameCache = Maps.newHashMap();
|
||||
private final Map<String, PyDebugValue> myNewVariableValue = Maps.newHashMap();
|
||||
|
||||
|
||||
@@ -46,15 +46,17 @@ public class PyDebuggerEditorsProvider extends XDebuggerEditorsProvider {
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
if (psiFile != null) {
|
||||
int offset = sourcePosition.getOffset();
|
||||
final int lineEndOffset = document.getLineEndOffset(document.getLineNumber(offset));
|
||||
do {
|
||||
PsiElement element = psiFile.findElementAt(offset);
|
||||
if (element != null && !(element instanceof PsiWhiteSpace || element instanceof PsiComment)) {
|
||||
return PyPsiUtils.getStatement(element);
|
||||
if (offset >= 0 && offset < document.getTextLength()) {
|
||||
final int lineEndOffset = document.getLineEndOffset(document.getLineNumber(offset));
|
||||
do {
|
||||
PsiElement element = psiFile.findElementAt(offset);
|
||||
if (element != null && !(element instanceof PsiWhiteSpace || element instanceof PsiComment)) {
|
||||
return PyPsiUtils.getStatement(element);
|
||||
}
|
||||
offset = element.getTextRange().getEndOffset() + 1;
|
||||
}
|
||||
offset = element.getTextRange().getEndOffset() + 1;
|
||||
while (offset < lineEndOffset);
|
||||
}
|
||||
while (offset < lineEndOffset);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -141,7 +141,7 @@ public class PySignatureCacheManagerImpl extends PySignatureCacheManager {
|
||||
try {
|
||||
data = CALL_SIGNATURES_ATTRIBUTE.readAttributeBytes(file);
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (Exception e) {
|
||||
data = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -385,16 +386,22 @@ public class PythonDocumentationProvider extends AbstractDocumentationProvider i
|
||||
}
|
||||
|
||||
private static boolean pageExists(String url) {
|
||||
if (new File(url).exists()) {
|
||||
return true;
|
||||
}
|
||||
HttpClient client = new HttpClient();
|
||||
client.setTimeout(5 * 1000);
|
||||
client.setConnectionTimeout(5 * 1000);
|
||||
HeadMethod method = new HeadMethod(url);
|
||||
try {
|
||||
HeadMethod method = new HeadMethod(url);
|
||||
int rc = client.executeMethod(method);
|
||||
if (rc == 404) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
return false;
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -199,7 +199,7 @@ public class PySkeletonGenerator {
|
||||
return new ListBinariesResult(generatorVersion, binaries);
|
||||
}
|
||||
|
||||
public boolean deleteOrLog(File item) {
|
||||
public boolean deleteOrLog(@NotNull File item) {
|
||||
boolean deleted = item.delete();
|
||||
if (!deleted) LOG.warn("Failed to delete skeleton file " + item.getAbsolutePath());
|
||||
return deleted;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
def lab(): pass
|
||||
lab = 1
|
||||
print(l<caret>ab)
|
||||
@@ -0,0 +1,3 @@
|
||||
def lab(): pass
|
||||
bar = 1
|
||||
print(bar)
|
||||
@@ -95,6 +95,10 @@ public class PyRenameTest extends PyTestCase {
|
||||
doTest("bar");
|
||||
}
|
||||
|
||||
public void testRenameShadowingVariable() { // PY-7342
|
||||
doTest("bar");
|
||||
}
|
||||
|
||||
public void testRenameProperty() { // PY-5948
|
||||
setLanguageLevel(LanguageLevel.PYTHON26);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user