Module aya.ide
Package org.aya.ide

Class LspPrimFactory

java.lang.Object
org.aya.core.def.PrimDef.Factory
org.aya.ide.LspPrimFactory

public class LspPrimFactory extends org.aya.core.def.PrimDef.Factory
TL; DR: Patched primitive factory that reuses primitives from last compilation.

Our LSP reuses unchanged sources and only compiles changed ones. So there exist a scenario where the file containing primitive declarations (for example, Primitives.aya) can be unchanged while its importers are modified by users --- in this case, the recompile list does not contain Primitives.aya so primitives previously created and stored in the factory should be reused, thus we cannot clear the primitive factory after every recompilation.

Unfortunately, the original primitive factory does not fit our needs in the situation described above, which always reports redefinition errors because it is not designed to be used in an incremental compiler.

Patches in this file is safe (no definition leak). This can be proven by case-split:

When Primitives.aya is unchanged, the InMemoryCompilerAdvisor keeps track of the last compilation result (namely ResolveInfo), which ensures the re-resolve of changed source files always points primitives to the previously created PrimDefs.

When Primitives.aya is changed, the LibraryCompiler will recompile it together with its importers, which is a full remake of all primitive-related source files and the InMemoryCompilerAdvisor will be updated to the newest compilation result.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull org.aya.core.def.PrimDef
    factory(@NotNull org.aya.core.def.PrimDef.ID name, @NotNull org.aya.ref.DefVar<org.aya.core.def.PrimDef,org.aya.concrete.stmt.decl.TeleDecl.PrimDecl> ref)
     
    boolean
     

    Methods inherited from class org.aya.core.def.PrimDef.Factory

    checkDependency, clear, clear, getCall, getCall, getOption, getOrCreate, have, unfold

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LspPrimFactory

      public LspPrimFactory()
  • Method Details

    • suppressRedefinition

      public boolean suppressRedefinition()
      Overrides:
      suppressRedefinition in class org.aya.core.def.PrimDef.Factory
    • factory

      @NotNull public @NotNull org.aya.core.def.PrimDef factory(@NotNull org.aya.core.def.PrimDef.ID name, @NotNull @NotNull org.aya.ref.DefVar<org.aya.core.def.PrimDef,org.aya.concrete.stmt.decl.TeleDecl.PrimDecl> ref)
      Overrides:
      factory in class org.aya.core.def.PrimDef.Factory