-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #522 from alex999990009/alex99999/fixes
Fix goto, run configuration and slow operations
- Loading branch information
Showing
8 changed files
with
36 additions
and
12 deletions.
There are no files selected for viewing
22 changes: 14 additions & 8 deletions
22
src/main/kotlin/org/arend/definition/ArendFileDefinitionScope.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
package org.arend.definition | ||
|
||
import org.arend.error.DummyErrorReporter | ||
import org.arend.naming.reference.LocatedReferable | ||
import org.arend.ext.module.ModulePath | ||
import org.arend.naming.reference.GlobalReferable | ||
import org.arend.naming.reference.Referable | ||
import org.arend.naming.scope.LexicalScope | ||
import org.arend.naming.scope.Scope | ||
import org.arend.psi.ArendFile | ||
import org.arend.resolving.PsiConcreteProvider | ||
import org.arend.term.concrete.Concrete | ||
|
||
class ArendFileDefinitionScope(private val arendFile: ArendFile) : Scope { | ||
class ArendFileDefinitionScope(private val arendFile: ArendFile, private val extraPath: ModulePath = ModulePath()) : Scope { | ||
override fun getElements(): Collection<Referable> { | ||
val result = ArrayList<Referable>() | ||
arendFile.apply { | ||
val concreteProvider = PsiConcreteProvider(arendFile.project, DummyErrorReporter.INSTANCE, null) | ||
LexicalScope.opened(this).elements.forEach { | ||
val ref = concreteProvider.getConcrete(it as LocatedReferable) | ||
val concreteProvider = PsiConcreteProvider(arendFile.project, DummyErrorReporter.INSTANCE, null) | ||
arendFile.getTCRefMap(Referable.RefKind.EXPR).forEach { | ||
if (ModulePath(it.key.toList().subList(0, extraPath.size())) == extraPath) { | ||
val ref = concreteProvider.getConcrete(it.value as GlobalReferable) | ||
if (ref is Concrete.Definition) { | ||
result.add(it) | ||
val referable = it.value | ||
referable.displayName = referable.refLongName.toString().removePrefix(extraPath.toString()).removePrefix(".") | ||
if (referable.displayName!!.isNotEmpty()) { | ||
result.add(referable) | ||
} | ||
} | ||
} | ||
} | ||
return result | ||
} | ||
|
||
override fun getElements(kind: Referable.RefKind?): Collection<Referable> = if (kind == null || kind == Referable.RefKind.EXPR) elements else emptyList() | ||
|
||
override fun resolveNamespace(name: String, onlyInternal: Boolean) = ArendFileDefinitionScope(arendFile, ModulePath(extraPath.toList() + name)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters