[java-completion] IDEA-344077, IDEA-343842, IDEA-343839 new transformer for java

- support for generics, empty parameters
- formatting

GitOrigin-RevId: 4f0e392627c0ee6f0965d43110600364472c18de
This commit is contained in:
Mikhail Pyltsin
2024-01-25 14:59:08 +01:00
committed by intellij-monorepo-bot
parent 67fc8cba2c
commit 345e1cc7e9
3 changed files with 12 additions and 5 deletions

View File

@@ -24,5 +24,6 @@ interface CorrectnessChecker {
fun checkSemantic(file: PsiFile,
suggestion: String,
offset: Int,
prefix: String): CheckResult
prefix: String,
matchedEnclosuresIndices: Set<Int>? = null): CheckResult
}

View File

@@ -25,7 +25,7 @@ open class CorrectnessCheckerBase(private val semanticCheckers: List<SemanticChe
* @return a file to be passed to [semanticCheckers].
* @see [checkSemantic]
*/
protected open fun buildPsiForSemanticChecks(file: PsiFile, suggestion: String, offset: Int, prefix: String): PsiFile {
protected open fun buildPsiForSemanticChecks(file: PsiFile, suggestion: String, offset: Int, prefix: String, matchedEnclosuresIndices: Set<Int>?): PsiFile {
return file
}
@@ -39,8 +39,8 @@ open class CorrectnessCheckerBase(private val semanticCheckers: List<SemanticChe
private val rawSemanticCheckers = semanticCheckers.filterIsInstance<RawSemanticChecker>()
final override fun checkSemantic(file: PsiFile, suggestion: String, offset: Int, prefix: String): CorrectnessChecker.CheckResult {
val fullPsi = buildPsiForSemanticChecks(file, suggestion, offset, prefix)
final override fun checkSemantic(file: PsiFile, suggestion: String, offset: Int, prefix: String, matchedEnclosuresIndices: Set<Int>?): CorrectnessChecker.CheckResult {
val fullPsi = buildPsiForSemanticChecks(file, suggestion, offset, prefix, matchedEnclosuresIndices)
val range = TextRange(offset - prefix.length, offset + suggestion.length - prefix.length)

View File

@@ -13,7 +13,13 @@ class PythonCorrectnessChecker : CorrectnessCheckerBase(listOf(
PyRedeclarationSemanticChecker,
PyAssignmentToLibraryScopeSemanticChecker,
)) {
override fun buildPsiForSemanticChecks(file: PsiFile, suggestion: String, offset: Int, prefix: String): PsiFile {
override fun buildPsiForSemanticChecks(
file: PsiFile,
suggestion: String,
offset: Int,
prefix: String,
matchedEnclosuresIndices: Set<Int>?
): PsiFile {
return PyExpressionCodeFragmentImpl(
file.project,
FileUtil.getNameWithoutExtension(file.name) + ".py",