Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stubRoots.length != roots.size() when Jinja2 is enabled for LaTeX #1839

Closed
CarliJoy opened this issue Apr 2, 2021 · 4 comments
Closed

stubRoots.length != roots.size() when Jinja2 is enabled for LaTeX #1839

CarliJoy opened this issue Apr 2, 2021 · 4 comments
Assignees
Labels
crash-report Reports of crashes that popped up in IDEA.

Comments

@CarliJoy
Copy link

CarliJoy commented Apr 2, 2021

Type of JetBrains IDE (IntelliJ, PyCharm, etc.) and version

PyCharm 2020.3.5

Operating System

Kubuntu 20.04 LTS

TeXiFy IDEA version

0.7.5

Description

Popped up.
BTW: I activated Jinja support for LaTeX as I use it in combination.

Stacktrace

java.lang.Throwable: readOrBuilt roots = {PsiFileStubImpl Language: ANY}; , stubBindingRoot = DjangoTemplateFileImpl, languages = [Jinja2, Latex], fileTypes = [Jinja2, LaTeX source file], files = [DjangoTemplateFileImpl, LatexFile], roots = [(JINJA2_TEMPLATE_FILE, Language: Jinja2 -> DjangoTemplateFileImpl), (FILE, Language: Latex -> LatexFile)]
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:165)
	at com.intellij.psi.impl.source.PsiFileImpl.getStubTree(PsiFileImpl.java:649)
	at com.intellij.psi.impl.source.PsiFileImpl.getGreenStubTree(PsiFileImpl.java:951)
	at com.intellij.psi.impl.source.PsiFileImpl.getStubbedSpine(PsiFileImpl.java:256)
	at com.intellij.psi.stubs.StubProcessingHelperBase.lambda$getAllSpines$0(StubProcessingHelperBase.java:84)
	at com.intellij.util.containers.ContainerUtil.map(ContainerUtil.java:1983)
	at com.intellij.psi.stubs.StubProcessingHelperBase.getAllSpines(StubProcessingHelperBase.java:84)
	at com.intellij.psi.stubs.StubProcessingHelperBase.processStubsInFile(StubProcessingHelperBase.java:64)
	at com.intellij.psi.stubs.StubIndexImpl.lambda$processElements$2(StubIndexImpl.java:291)
	at com.intellij.psi.stubs.StubIndexImpl.processElements(StubIndexImpl.java:327)
	at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:105)
	at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:93)
	at nl.hannahsten.texifyidea.index.IndexUtilBase.getItemsByName(IndexUtilBase.kt:132)
	at nl.hannahsten.texifyidea.index.IndexUtilBase.getItems(IndexUtilBase.kt:116)
	at nl.hannahsten.texifyidea.index.IndexUtilBase.getItems(IndexUtilBase.kt:103)
	at nl.hannahsten.texifyidea.util.files.ReferencedFileSetCache.getSetFromCache(ReferencedFileSetCache.kt:97)
	at nl.hannahsten.texifyidea.util.files.ReferencedFileSetCache.fileSetFor(ReferencedFileSetCache.kt:54)
	at nl.hannahsten.texifyidea.util.files.impl.ReferencedFileSetServiceImpl.referencedFileSetOf(ReferencedFileSetServiceImpl.kt:15)
	at nl.hannahsten.texifyidea.util.files.FileSetKt.referencedFileSet(FileSet.kt:65)
	at nl.hannahsten.texifyidea.index.IndexUtilBase.getItemsInFileSet(IndexUtilBase.kt:42)
	at nl.hannahsten.texifyidea.util.files.FileSetKt.commandsInFileSet(FileSet.kt:77)
	at nl.hannahsten.texifyidea.util.LabelsKt.findLabelingCommandsInFileSetAsSequence(Labels.kt:78)
	at nl.hannahsten.texifyidea.util.LabelsKt.findLatexLabelPsiElementsInFileSetAsSequence(Labels.kt:68)
	at nl.hannahsten.texifyidea.inspections.latex.LatexDuplicateLabelInspection.inspectFile(LatexDuplicateLabelInspection.kt:42)
	at nl.hannahsten.texifyidea.inspections.TexifyInspectionBase.checkFile(TexifyInspectionBase.kt:135)
	at com.intellij.codeInspection.LocalInspectionTool$1.visitFile(LocalInspectionTool.java:145)
	at com.intellij.extapi.psi.PsiFileBase.accept(PsiFileBase.java:60)
	at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:66)
	at com.intellij.codeInspection.InspectionEngine.createVisitorAndAcceptElements(InspectionEngine.java:57)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.runToolOnElements(LocalInspectionsPass.java:311)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$4(LocalInspectionsPass.java:270)
	at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:156)
	at com.intellij.util.AstLoadingFilter.forceAllowTreeLoading(AstLoadingFilter.java:148)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$5(LocalInspectionsPass.java:268)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:127)
	at com.intellij.util.AstLoadingFilter.disallowTreeLoading(AstLoadingFilter.java:116)
	at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$visitPriorityElementsAndInit$6(LocalInspectionsPass.java:268)
	at com.intellij.concurrency.ApplierCompleter.execAndForkSubTasks(ApplierCompleter.java:136)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1137)
	at com.intellij.concurrency.ApplierCompleter.lambda$wrapInReadActionAndIndicator$1(ApplierCompleter.java:92)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65)
	at com.intellij.concurrency.ApplierCompleter.wrapInReadActionAndIndicator(ApplierCompleter.java:104)
	at com.intellij.concurrency.ApplierCompleter.lambda$compute$0(ApplierCompleter.java:83)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:172)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:183)
	at com.intellij.concurrency.ApplierCompleter.compute(ApplierCompleter.java:83)
	at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
@PHPirates PHPirates added the crash-report Reports of crashes that popped up in IDEA. label Apr 2, 2021
@PHPirates PHPirates added this to the b0.7.6 milestone Apr 2, 2021
@PHPirates PHPirates self-assigned this Apr 7, 2021
@PHPirates PHPirates changed the title java.lang.Throwable: readOrBuilt roots = {PsiFileStubImpl Language: ANY}; , stubBindingRoot = DjangoTemplateFileImpl, languages = [Jinja2, Latex], fileTypes = [Jinja2, LaTeX source file], files = [DjangoTemplateFileImpl, LatexFile], roots = [(JINJA2_TEMPLATE_FILE, Language: Jinja2 -> DjangoTemplateFileImpl), (FILE, Language: Latex -> LatexFile)] stubRoots.length != roots.size() when Jinja2 is enabled for LaTeX Apr 8, 2021
@PHPirates
Copy link
Collaborator

How is your experience with using Jinja2? It seems like the default delimiters get Jinja2 confused, for example \section{ {{my_var}} } doesn't work.
If you want, update the wiki with your findings: https://github.com/Hannah-Sten/TeXiFy-IDEA/wiki/External-tools#Jinja2-support

The thing is, I don't know how to resolve this exception, because it's something inside IntelliJ platform and not inside TeXiFy. So it doesn't make much sense to me to spend time on resolving this, when Jinja2 support isn't working with LaTeX anyway.

@PHPirates PHPirates added the wontfix Issue will be discarded by the development team. label Apr 8, 2021
@PHPirates PHPirates removed this from the b0.7.6 milestone Apr 8, 2021
@CarliJoy
Copy link
Author

CarliJoy commented Apr 8, 2021

Hi @PHPirates,

for me it works quite fine and Jinja doesn't get confused.
I am using https://github.com/weinbusch/django-tex to compile the Template and so far everything works.

The exceptions didn't occur a second time so far (at least currently as I am working under Windows for work)

I also create PR for Jinja to allow autoescape, even for LaTeX (or anything, see: pallets/jinja#1386)

There is also https://github.com/mbr/latex that uses Jinja.
I will look if I find time to extend something in the wiki..

@PHPirates
Copy link
Collaborator

Aha, thanks for the info, I had just missed the slightly different syntax \section{ {{- text -}} } which does work.

I don't know of any other examples that don't work, so I will ask the IntelliJ team for this exception (I can reproduce it, it happens because Jinja and TeXiFy are both claiming .tex files, but it shouldn't really affect usability).

@PHPirates PHPirates added external Issue is submitted elsewhere as it is (most likely) not a TeXiFy issue and removed wontfix Issue will be discarded by the development team. external Issue is submitted elsewhere as it is (most likely) not a TeXiFy issue labels Apr 9, 2021
@PHPirates
Copy link
Collaborator

I just realised after looking inside intellij that the exception is saying that the number of indexed stub roots does not match the number of actual stub roots after enabling jinja, so invalidate caches and restart will fix it.

@Hannah-Sten Hannah-Sten locked and limited conversation to collaborators Apr 10, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
crash-report Reports of crashes that popped up in IDEA.
Projects
None yet
Development

No branches or pull requests

2 participants