Commit Graph

4 Commits

Author SHA1 Message Date
Marco Pennekamp 1870189e47 [AA] Fix write access configuration in unit test application environments
- We cannot configure the application's write action accessibility on a
  per-test basis because (1) the application may be shared across
  concurrent tests and (2) the application is usually cached, so the
  configuration will be missed entirely.
- There is actually a much easier solution to allow write access
  selectively: We can enable it in `runWriteAction` blocks, and keep it
  in a thread local to support concurrent test runs. As Analysis API
  tests never call `runWriteAction`, there will be no "analyze cannot be
  called from a write action" error, and if `analyze` is somehow called
  from a write action, it will now be caught.

^KT-63560 fixed
2023-11-20 16:29:26 +00:00
Marco Pennekamp 271f83d07d [LL] Disable declaration modification service tests temporarily
- We cannot configure write access using the application environment
  creation because application environments are cached between test
  runs.

^KT-63560
2023-11-17 18:09:55 +00:00
Marco Pennekamp 6668cc281d [LL] Avoid exceptions when analyzing inconsistent PSI in LLFirDeclarationModificationService
- The exceptions in KT-63130 occur because PSI tree change events may be
  published when parts of the PSI under modification are inconsistent.
  Such inconsistent elements are then analyzed by
  `LLFirDeclarationModificationService` to check if the modification
  occurs in a contract statement.
- The solution adds `*OrNull` functions to `KtQualifiedExpression` which
  return `null` instead of failing with an exception when the receiver
  or selector cannot be found.

^KT-63130 fixed
2023-11-16 19:50:51 +00:00
Marco Pennekamp 6c67835128 [LL] Add PSI resilience tests for LLFirDeclarationModificationService
- The cause of KT-63130 is that `LLFirDeclarationModificationService`
  tries to analyze inconsistent PSI. These new tests replicate the
  inconsistent PSI by deleting different children and then call the
  declaration modification service with it, making sure that the service
  doesn't throw any exceptions. Both exceptions mentioned in the issue
  are reproduced by the added tests, specifically, the receiver and
  selector resilience tests for dot-qualified expressions.
- A few of the tests need to be marked with `IGNORE_FIR` until the error
  has been fixed in the subsequent commit.

^KT-63130
2023-11-16 19:50:51 +00:00