Skip to content

Add FileMonitor for LaTeX citations #10585

@koppor

Description

@koppor

The LaTeX citations are NOT backed by a file update monitor.

a

Rewrite the code to use our org.jabref.gui.util.DefaultFileUpdateMonitor (or a new file update monitor) with proper shutdown at the end.

(Note: This is the technically sound fix for #10584)


Update

A first PR was submitted at #10937. It turned out, that a new FileMonitor is needed. It should watch a directory.

  • New .tex file: Parse the tex file, remove all non-existant citaton keys and add the new ones. Add the tex file to file listeners
  • Deleted .tex file: Remove the .tex file from the file listeners

The file listeners:

  • Changed.tex file: Parse the tex file, remove all non-existant citaton keys and add the new ones

  • Class org.jabref.logic.texparser.DefaultLatexParser needs to be modified to know the found latex citation keys per latex file. In case an "udpate" of the informaiton is triggered (by the file update monitor!!), all existing keys should be dropped and readded. Thus, org.jabref.model.texparser.LatexParserResult also needs to adapted (see below)
  • Refactor org.jabref.gui.entryeditor.LatexCitationsTabViewModel: Move away org.jabref.gui.entryeditor.LatexCitationsTabViewModel#searchDirectory, org.jabref.gui.entryeditor.LatexCitationsTabViewModel#searchAndParse as class CitationFinder in package org.jabref.logic.texparser. -- Also test cases need to be added
  • Refactor org.jabref.model.texparser.LatexParserResult to allow partial updates. That means: If file X is changed, call new DefaultLatexParser().parse(X) and change the contents of org.jabref.model.texparser.LatexParserResult#citations accordingly. IMHO, a map from Path to Set<Citations> (Multimap) should be kept. The value before the update and after the update be stored. A diff calculated. That diff should be applied to citations. - The method update can be implemented in LatexParserResult. - The class LatexParserResult should be renamed in CitationState.
  • A new file watcher, which works on directories and handles both file editing and creation of new files. On both events, CitationState#update(path) can be called. That method should simply add the file to the currently known files. -- Deletion has to be handled separately. event: delete, new method CitationState#remove(path) called

Reasons: Energy saving. Very little CPU usage for an update on one file. Although your current method works, it parses ALL .tex files again, and handles the content. Large LaTeX projects have dozens of tex files, which are very long. This costs time.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions