PY-48010 Warn about problems causing SyntaxErrors in PEP 634 patterns

GitOrigin-RevId: 718645cc5dfd6d0a14f1bd802f3c5bb2bb2c6074
This commit is contained in:
Mikhail Golubev
2021-07-21 13:55:49 +03:00
committed by intellij-monorepo-bot
parent 0686325b90
commit e9d11d1215
43 changed files with 529 additions and 55 deletions

View File

@@ -1,5 +1,11 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.psi;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface PyKeyValuePattern extends PyPattern {
@NotNull PyPattern getKeyPattern();
@Nullable PyPattern getValuePattern();
}

View File

@@ -1,5 +1,8 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.psi;
import org.jetbrains.annotations.NotNull;
public interface PyLiteralPattern extends PyPattern {
@NotNull PyExpression getExpression();
}

View File

@@ -2,4 +2,30 @@
package com.jetbrains.python.psi;
public interface PyPattern extends PyElement {
/**
* An irrefutable pattern is a pattern that always succeed (matches).
* <p>
* Primarily, these are capture patterns and wildcard patterns, as well as group and OR-patterns containing one of those.
* <p>
* <h3>Examples of irrefutable patterns:</h3>
* <ul>
* <li>{@code name}</li>
* <li>{@code _} (a wildcard)</li>
* <li>{@code 42 | name}</li>
* <li>{@code (42 | name) as alias}</li>
* <li>{@code ((name))}</li>
* <li>{@code *args}</li>
* <li>{@code **kwargs}</li>
* </ul>
* <p>
* <h3>Examples of refutable patterns:</h3>
* <ul>
* <li>{@code foo.bar}</li>
* <li>{@code 'foo'}</li>
* <li>{@code [_]}</li>
* <li>{@code [*args]}</li>
* <li>{@code str(foo)}</li>
* </ul>
*/
boolean isIrrefutable();
}

View File

@@ -1,5 +1,10 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.psi;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface PyPatternArgumentList extends PyElement {
@NotNull List<PyPattern> getPatterns();
}