Decrease number of warnings in PyReferenceImpl, PythonCompletionTest and Py3CompletionTest

This commit is contained in:
Semyon Proshev
2016-11-15 16:05:09 +03:00
parent 3b5e051bfe
commit 146abbc28c
3 changed files with 13 additions and 19 deletions
@@ -187,20 +187,15 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
ret.poke(definition, getRate(definition, context));
}
}
final ResolveResultList results = new ResolveResultList();
for (RatedResolveResult r : ret) {
final PsiElement e = r.getElement();
if (e == element) {
if (e == element || element instanceof PyTargetExpression && e != null && PyPsiUtils.isBefore(element, e)) {
continue;
}
if (element instanceof PyTargetExpression && e != null && PyPsiUtils.isBefore(element, e)) {
continue;
}
else {
results.add(r);
}
results.add(r);
}
return results;
}
@@ -643,9 +638,8 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
final List<LookupElement> ret = Lists.newArrayList();
// Use real context here to enable correct completion and resolve in case of PyExpressionCodeFragment!!!
final PsiElement originalElement = CompletionUtil.getOriginalElement(myElement);
final PyQualifiedExpression element = originalElement instanceof PyQualifiedExpression ?
(PyQualifiedExpression)originalElement : myElement;
final PyQualifiedExpression originalElement = CompletionUtil.getOriginalElement(myElement);
final PyQualifiedExpression element = originalElement != null ? originalElement : myElement;
final PsiElement realContext = PyPsiUtils.getRealContext(element);
// include our own names
@@ -147,7 +147,7 @@ public class Py3CompletionTest extends PyTestCase {
// PY-15390
public void testMatMul() {
runWithLanguageLevel(LanguageLevel.PYTHON35, () -> doTest());
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
}
// PY-11214
@@ -156,11 +156,11 @@ public class Py3CompletionTest extends PyTestCase {
}
public void testAsync() {
runWithLanguageLevel(LanguageLevel.PYTHON35, () -> doTest());
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
}
public void testAwait() {
runWithLanguageLevel(LanguageLevel.PYTHON35, () -> doTest());
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
}
// PY-17828
@@ -438,12 +438,12 @@ public class PythonCompletionTest extends PyTestCase {
// PY-16991
public void testSecondSectionNameInGoogleDocstring() {
runWithDocStringFormat(DocStringFormat.GOOGLE, () -> doTest());
runWithDocStringFormat(DocStringFormat.GOOGLE, this::doTest);
}
// PY-16877
public void testTwoWordsSectionNameInGoogleDocstring() throws Exception {
runWithDocStringFormat(DocStringFormat.GOOGLE, () -> doTest());
runWithDocStringFormat(DocStringFormat.GOOGLE, this::doTest);
}
// PY-16870
@@ -475,7 +475,7 @@ public class PythonCompletionTest extends PyTestCase {
// PY-16870, PY-16972
public void testClassNameInDocstring() {
runWithDocStringFormat(DocStringFormat.EPYTEXT, () -> doTest());
runWithDocStringFormat(DocStringFormat.EPYTEXT, this::doTest);
}
// PY-17002
@@ -754,8 +754,8 @@ public class PythonCompletionTest extends PyTestCase {
// PY-9342
public void testUnboundMethodSpecialAttributes() {
runWithLanguageLevel(LanguageLevel.PYTHON27, () -> assertUnderscoredMethodSpecialAttributesSuggested());
runWithLanguageLevel(LanguageLevel.PYTHON32, () -> assertUnderscoredFunctionAttributesSuggested());
runWithLanguageLevel(LanguageLevel.PYTHON27, this::assertUnderscoredMethodSpecialAttributesSuggested);
runWithLanguageLevel(LanguageLevel.PYTHON32, this::assertUnderscoredFunctionAttributesSuggested);
}
// PY-9342