mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix after rebase on master
This commit is contained in:
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiReferenceBase;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.jetbrains.python.inspections.PyStringFormatParser;
|
||||
import com.jetbrains.python.inspections.PyStringFormatParser.NewStyleSubstitutionChunk;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
@@ -130,7 +131,7 @@ public class PySubstitutionChunkReference extends PsiReferenceBase<PyStringLiter
|
||||
@NotNull
|
||||
private Ref<PyExpression> resolveKeywordFormat(@NotNull PyArgumentList argumentList) {
|
||||
final Ref<PyExpression> valueExprRef = getKeyValueFromArguments(argumentList);
|
||||
final String indexElement = ((PyStringFormatParser.NewStyleSubstitutionChunk)myChunk).getMappingKeyElementIndex();
|
||||
final String indexElement = myChunk instanceof NewStyleSubstitutionChunk ? ((NewStyleSubstitutionChunk)myChunk).getMappingKeyElementIndex() : null;
|
||||
if (valueExprRef != null && !valueExprRef.isNull() && indexElement != null) {
|
||||
final PyExpression valueExpr = PyPsiUtils.flattenParens(valueExprRef.get());
|
||||
assert valueExpr != null;
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class NewStyleConvertToFStringProcessor extends BaseConvertToFStringProce
|
||||
@NotNull
|
||||
@Override
|
||||
protected PySubstitutionChunkReference createReference(@NotNull Field field) {
|
||||
return new PySubstitutionChunkReference(myPyString, field, ObjectUtils.chooseNotNull(field.getAutoPosition(), 0), false);
|
||||
return new PySubstitutionChunkReference(myPyString, field, ObjectUtils.chooseNotNull(field.getAutoPosition(), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-2
@@ -22,6 +22,8 @@ import com.intellij.util.ObjectUtils;
|
||||
import com.jetbrains.python.codeInsight.PySubstitutionChunkReference;
|
||||
import com.jetbrains.python.inspections.PyStringFormatParser;
|
||||
import com.jetbrains.python.inspections.PyStringFormatParser.SubstitutionChunk;
|
||||
import com.jetbrains.python.inspections.PyStringFormatParser.PercentSubstitutionChunk;
|
||||
import com.jetbrains.python.inspections.PyStringFormatParser.NewStyleSubstitutionChunk;
|
||||
import com.jetbrains.python.psi.PyBinaryExpression;
|
||||
import com.jetbrains.python.psi.PyExpression;
|
||||
import com.jetbrains.python.psi.PyStringLiteralExpression;
|
||||
@@ -50,7 +52,7 @@ public class OldStyleConvertToFStringProcessor extends BaseConvertToFStringProce
|
||||
@NotNull
|
||||
@Override
|
||||
protected PySubstitutionChunkReference createReference(@NotNull SubstitutionChunk chunk) {
|
||||
return new PySubstitutionChunkReference(myPyString, chunk, ObjectUtils.chooseNotNull(chunk.getAutoPosition(), 0), true);
|
||||
return new PySubstitutionChunkReference(myPyString, chunk, ObjectUtils.chooseNotNull(chunk.getAutoPosition(), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +94,9 @@ public class OldStyleConvertToFStringProcessor extends BaseConvertToFStringProce
|
||||
widthAndPrecision += "." + subsChunk.getPrecision();
|
||||
}
|
||||
|
||||
final String conversionFlags = subsChunk.getConversionFlags();
|
||||
final String conversionFlags = subsChunk instanceof PercentSubstitutionChunk ?
|
||||
((PercentSubstitutionChunk)subsChunk).getConversionFlags() :
|
||||
((NewStyleSubstitutionChunk)subsChunk).getConversion();
|
||||
|
||||
fStringText.append("{");
|
||||
final PySubstitutionChunkReference reference = createReference(subsChunk);
|
||||
|
||||
@@ -258,7 +258,7 @@ public class PyNewStyleStringFormatParser {
|
||||
int endOffset,
|
||||
int autoPosition,
|
||||
int depth) {
|
||||
super(leftBraceOffset);
|
||||
super(leftBraceOffset, endOffset);
|
||||
myNodeText = nodeText;
|
||||
myLeftBraceOffset = leftBraceOffset;
|
||||
myAttributesAndLookups = attrAndLookupBounds;
|
||||
@@ -269,7 +269,6 @@ public class PyNewStyleStringFormatParser {
|
||||
myEndOffset = endOffset;
|
||||
myDepth = depth;
|
||||
|
||||
setEndIndex(myEndOffset);
|
||||
final String name = getFirstName();
|
||||
if (name.isEmpty()) {
|
||||
setAutoPosition(autoPosition);
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.jetbrains.python.codeInsight.PySubstitutionChunkReference;
|
||||
import com.jetbrains.python.inspections.quickfix.PyAddSpecifierToFormatQuickFix;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyBuiltinCache;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.types.*;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -650,9 +649,7 @@ public class PyStringFormatInspection extends PyInspection {
|
||||
if (((PyUnionType)callType).getMembers().stream().allMatch(PyType::isBuiltin)) return 1;
|
||||
}
|
||||
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -663,8 +660,6 @@ public class PyStringFormatInspection extends PyInspection {
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static PyReturnStatement[] getFunctionReturnValues(@NotNull PyCallExpression callExpression,
|
||||
|
||||
@@ -74,6 +74,8 @@ public class PyStringFormatParser {
|
||||
@Nullable private Integer myPosition;
|
||||
@Nullable private Integer myAutoPosition;
|
||||
|
||||
private char myConversionType;
|
||||
|
||||
public SubstitutionChunk(int startIndex, int endIndex) {
|
||||
super(startIndex, endIndex);
|
||||
}
|
||||
@@ -108,6 +110,14 @@ public class PyStringFormatParser {
|
||||
myAutoPosition = autoPosition;
|
||||
}
|
||||
|
||||
public char getConversionType() {
|
||||
return myConversionType;
|
||||
}
|
||||
|
||||
public void setConversionType(char conversionType) {
|
||||
myConversionType = conversionType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPrecision() {
|
||||
return myPrecision;
|
||||
@@ -139,21 +149,12 @@ public class PyStringFormatParser {
|
||||
public static class PercentSubstitutionChunk extends SubstitutionChunk {
|
||||
@Nullable private String myConversionFlags;
|
||||
private char myLengthModifier;
|
||||
private char myConversionType;
|
||||
private boolean myUnclosedMapping;
|
||||
|
||||
public PercentSubstitutionChunk(int startIndex) {
|
||||
super(startIndex, startIndex);
|
||||
}
|
||||
|
||||
public char getConversionType() {
|
||||
return myConversionType;
|
||||
}
|
||||
|
||||
private void setConversionType(char conversionType) {
|
||||
myConversionType = conversionType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getConversionFlags() {
|
||||
return myConversionFlags;
|
||||
@@ -184,7 +185,6 @@ public class PyStringFormatParser {
|
||||
@Nullable private String myConversion;
|
||||
@Nullable private String myMappingKeyAttributeName;
|
||||
@Nullable private String myMappingKeyElementIndex;
|
||||
private char myConversionType;
|
||||
private boolean signOption;
|
||||
private boolean zeroPadding;
|
||||
private boolean alternateForm;
|
||||
@@ -211,14 +211,6 @@ public class PyStringFormatParser {
|
||||
this.signOption = true;
|
||||
}
|
||||
|
||||
public char getConversionType() {
|
||||
return myConversionType;
|
||||
}
|
||||
|
||||
public void setConversionType(char conversionType) {
|
||||
myConversionType = conversionType;
|
||||
}
|
||||
|
||||
public boolean useAlternateForm() {
|
||||
return alternateForm;
|
||||
}
|
||||
|
||||
-1
@@ -41,7 +41,6 @@ import com.jetbrains.python.PyCustomType;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
|
||||
import com.jetbrains.python.codeInsight.PyCustomMember;
|
||||
import com.jetbrains.python.codeInsight.PyFunctionTypeCommentReferenceContributor;
|
||||
import com.jetbrains.python.codeInsight.PySubstitutionChunkReference;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
|
||||
|
||||
Reference in New Issue
Block a user