-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix package of PreviewLayout #5702
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
820a7e8
Modernize code of TestVM
koppor 046928c
Add IEEEtran.bst
koppor eeb1c27
Fix package for PreviewLayout and TextBasedPreviewLayout
koppor 2d4eb08
Introduce BstPreviewLayout
koppor f16d690
Fix checkstyle
koppor 30e0ac3
Fix Bst.g to allow "_" as identifier
koppor fbde17a
Fix quotes and other output of IEEEtran.bst
koppor be142d5
Merge remote-tracking branch 'origin/master' into use-vm
koppor 68b8d0a
Merge remote-tracking branch 'origin/master' into use-vm
koppor 6865b13
Fix checkstyle
koppor 6b9ce8a
Merge branch 'master' into use-vm
koppor ad392c8
Remove calling of WIP preview functionality
koppor 62c7c76
Add JavaDoc on "TextBasedPreviewLayout"
koppor a026538
Fix reuse of variable
koppor 983aaa2
Move PreviewLayout to org.jabref.logic.preview
koppor f6ee3ac
Refine JavaDoc and fix variable name
koppor a89b7a1
Use public final instead of getters
koppor d72b8dc
JavaDoc improvements
koppor c64ce4a
Inline global variable stringBuilder and add some JavaDoc and Logging
koppor 09a4e90
Fix rendering of month field
koppor 0323f2c
Fix checkstyle
koppor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Use `public final` instead of getters to offer access to immutable variables | ||
|
||
## Context and Problem Statement | ||
|
||
When making immutable data accessible in a java class, should it be using getters or by non-modifiable fields? | ||
|
||
## Considered Options | ||
|
||
* Offer public static field | ||
* Offer getters | ||
|
||
## Decision Outcome | ||
|
||
Chosen option: "Offer public static field", because getters used to be a convention which was even more manifested due to libraries depending on the existence on getters/setters. In the case of immutable variables, adding public getters is just useless since one is not hiding anything. | ||
|
||
### Positive Consequences | ||
|
||
* Shorter code | ||
|
||
### Negative Consequences | ||
|
||
* new comers could get confused, because getters/setters are still teached |
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
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
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package org.jabref.logic.bst; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import org.jabref.logic.cleanup.ConvertToBibtexCleanup; | ||
import org.jabref.logic.formatter.bibtexfields.RemoveNewlinesFormatter; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.layout.format.LatexToUnicodeFormatter; | ||
import org.jabref.logic.layout.format.RemoveLatexCommandsFormatter; | ||
import org.jabref.logic.layout.format.RemoveTilde; | ||
import org.jabref.logic.preview.PreviewLayout; | ||
import org.jabref.model.database.BibDatabase; | ||
import org.jabref.model.entry.BibEntry; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class BstPreviewLayout implements PreviewLayout { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(BstPreviewLayout.class); | ||
|
||
private final String name; | ||
|
||
private VM vm; | ||
private String error; | ||
|
||
public BstPreviewLayout(Path path) { | ||
name = path.getFileName().toString(); | ||
if (!Files.exists(path)) { | ||
LOGGER.error("File {} not found", path.toAbsolutePath()); | ||
error = Localization.lang("Error opening file '%0'.", path.toString()); | ||
return; | ||
} | ||
try { | ||
vm = new VM(path.toFile()); | ||
} catch (Exception e) { | ||
LOGGER.error("Could not read {}.", path.toAbsolutePath(), e); | ||
error = Localization.lang("Error opening file '%0'.", path.toString()); | ||
} | ||
} | ||
|
||
@Override | ||
public String generatePreview(BibEntry originalEntry, BibDatabase database) { | ||
if (error != null) { | ||
return error; | ||
} | ||
// ensure that the entry is of BibTeX format (and do not modify the original entry) | ||
BibEntry entry = (BibEntry) originalEntry.clone(); | ||
new ConvertToBibtexCleanup().cleanup(entry); | ||
String result = vm.run(List.of(entry)); | ||
// Remove all comments | ||
result = result.replaceAll("%.*", ""); | ||
// Remove all LaTeX comments | ||
// The RemoveLatexCommandsFormatter keeps the words inside latex environments. Therefore, we remove them manually | ||
result = result.replace("\\begin{thebibliography}{1}", ""); | ||
result = result.replace("\\end{thebibliography}", ""); | ||
// The RemoveLatexCommandsFormatter keeps the word inside the latex command, but we want to remove that completely | ||
result = result.replaceAll("\\\\bibitem[{].*[}]", ""); | ||
// We want to replace \newblock by a space instead of completely removing it | ||
result = result.replace("\\newblock", " "); | ||
// remove all latex commands statements - assumption: command in a separate line | ||
result = result.replaceAll("(?m)^\\\\.*$", ""); | ||
// remove some IEEEtran.bst output (resulting from a multiline \providecommand) | ||
result = result.replace("#2}}", ""); | ||
// Have quotes right - and more | ||
result = new LatexToUnicodeFormatter().format(result); | ||
result = result.replace("``", "\""); | ||
result = result.replace("''", "\""); | ||
// Final cleanup | ||
result = new RemoveNewlinesFormatter().format(result); | ||
result = new RemoveLatexCommandsFormatter().format(result); | ||
result = new RemoveTilde().format(result); | ||
result = result.trim().replaceAll(" +", " "); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this also to the
citationstyle
package, because it's not really aboutbst
(which is only used as a tool)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see
org.jabref.logic.preview
as the other possibility to collect the preview generators. -- I would keep the packageorg.jabref.logic.citationstyle
for CSL only and keep out the relation to.bst
and to our other Layouts.