Skip to content

Commit

Permalink
Rename file association service since it really only affects syntax h…
Browse files Browse the repository at this point in the history
…ighlighting
  • Loading branch information
Col-E committed Sep 22, 2024
1 parent 4bb5c8e commit e060831
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
* for use by {@link RegexSyntaxHighlighter}.
* <p>
* Users can change which highlighter is used for different file extensions by updating the
* {@link FileTypeAssociationServiceConfig#getExtensionsToLangKeys() extensions map config}.
* {@link FileTypeSyntaxAssociationServiceConfig#getExtensionsToLangKeys() extensions map config}.
*
* @author Matt Coley
*/
@ApplicationScoped
public class FileTypeAssociationService implements Service {
public static final String SERVICE_ID = "file-type-association";
private final FileTypeAssociationServiceConfig config;
public class FileTypeSyntaxAssociationService implements Service {
public static final String SERVICE_ID = "file-type-syntax-association";
private final FileTypeSyntaxAssociationServiceConfig config;

@Inject
public FileTypeAssociationService(@Nonnull FileTypeAssociationServiceConfig config) {
public FileTypeSyntaxAssociationService(@Nonnull FileTypeSyntaxAssociationServiceConfig config) {
this.config = config;
}

Expand Down Expand Up @@ -85,7 +85,7 @@ public String getServiceId() {

@Nonnull
@Override
public FileTypeAssociationServiceConfig getServiceConfig() {
public FileTypeSyntaxAssociationServiceConfig getServiceConfig() {
return config;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import software.coley.recaf.config.BasicMapConfigValue;
import software.coley.recaf.config.ConfigGroups;
import software.coley.recaf.services.ServiceConfig;
import software.coley.recaf.services.info.association.FileTypeAssociationService;
import software.coley.recaf.ui.LanguageStylesheets;
import software.coley.recaf.ui.control.richtext.syntax.RegexLanguages;

Expand All @@ -19,7 +18,7 @@
import java.util.stream.Collectors;

/**
* Config for {@link FileTypeAssociationService}.
* Config for {@link FileTypeSyntaxAssociationService}.
* <p>
* Retains mapping of file extensions to language keys used by:
* <ul>
Expand All @@ -30,12 +29,12 @@
* @author Matt Coley
*/
@ApplicationScoped
public class FileTypeAssociationServiceConfig extends BasicConfigContainer implements ServiceConfig {
public class FileTypeSyntaxAssociationServiceConfig extends BasicConfigContainer implements ServiceConfig {
private final ExtensionMapping extensionsToLangKeys;

@Inject
public FileTypeAssociationServiceConfig() {
super(ConfigGroups.SERVICE_UI, FileTypeAssociationService.SERVICE_ID + CONFIG_SUFFIX);
public FileTypeSyntaxAssociationServiceConfig() {
super(ConfigGroups.SERVICE_UI, FileTypeSyntaxAssociationService.SERVICE_ID + CONFIG_SUFFIX);

extensionsToLangKeys = new ExtensionMapping(List.of(
new Pair<>("java", "java"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import software.coley.recaf.analytics.logging.Logging;
import software.coley.recaf.services.compile.CompilerDiagnostic;
import software.coley.recaf.services.file.RecafDirectoriesConfig;
import software.coley.recaf.services.info.association.FileTypeAssociationService;
import software.coley.recaf.services.info.association.FileTypeSyntaxAssociationService;
import software.coley.recaf.services.script.ScriptEngine;
import software.coley.recaf.services.script.ScriptFile;
import software.coley.recaf.services.script.ScriptManager;
Expand Down Expand Up @@ -69,7 +69,7 @@ public class ScriptManagerPane extends BorderPane {
private final ScriptManager scriptManager;
private final ScriptManagerConfig config;
private final ScriptEngine engine;
private final FileTypeAssociationService associationService;
private final FileTypeSyntaxAssociationService languageAssociation;
private final WindowFactory windowFactory;
private final RecafDirectoriesConfig directories;
private final KeybindingConfig keys;
Expand All @@ -79,7 +79,7 @@ public class ScriptManagerPane extends BorderPane {
public ScriptManagerPane(@Nonnull ScriptManagerConfig config,
@Nonnull ScriptManager scriptManager,
@Nonnull ScriptEngine engine,
@Nonnull FileTypeAssociationService associationService,
@Nonnull FileTypeSyntaxAssociationService languageAssociation,
@Nonnull WindowFactory windowFactory,
@Nonnull RecafDirectoriesConfig directories,
@Nonnull KeybindingConfig keys,
Expand All @@ -88,7 +88,7 @@ public ScriptManagerPane(@Nonnull ScriptManagerConfig config,
this.scriptManager = scriptManager;
this.config = config;
this.engine = engine;
this.associationService = associationService;
this.languageAssociation = languageAssociation;
this.directories = directories;
this.keys = keys;
this.searchBarProvider = searchBarProvider;
Expand Down Expand Up @@ -138,7 +138,7 @@ private void refreshScripts() {
* Script to edit.
*/
private void editScript(@Nonnull ScriptFile script) {
ScriptEditor scriptEditor = new ScriptEditor(associationService, script.source(), searchBarProvider.get())
ScriptEditor scriptEditor = new ScriptEditor(languageAssociation, script.source(), searchBarProvider.get())
.withPath(script.path());
Scene scene = new RecafScene(scriptEditor, 750, 400);
windowFactory.createAnonymousStage(scene, getBinding("menu.scripting.editor"), 750, 400).show();
Expand All @@ -160,7 +160,7 @@ public void newScript() {
System.out.println("Hello world");
""";
ScriptEditor scriptEditor = new ScriptEditor(associationService, template, searchBarProvider.get());
ScriptEditor scriptEditor = new ScriptEditor(languageAssociation, template, searchBarProvider.get());
Scene scene = new RecafScene(scriptEditor, 750, 400);
windowFactory.createAnonymousStage(scene, getBinding("menu.scripting.editor"), 750, 400).show();
}
Expand All @@ -184,7 +184,7 @@ private class ScriptEditor extends BorderPane {
private final Editor editor = new Editor();
private Path scriptPath;

private ScriptEditor(@Nonnull FileTypeAssociationService associationService, @Nonnull String initialText, @Nonnull SearchBar searchBar) {
private ScriptEditor(@Nonnull FileTypeSyntaxAssociationService associationService, @Nonnull String initialText, @Nonnull SearchBar searchBar) {
editor.setText(initialText);
editor.getCodeArea().getUndoManager().forgetHistory();
associationService.configureEditorSyntax("java", editor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import software.coley.recaf.services.decompile.DecompilerManager;
import software.coley.recaf.services.decompile.JvmDecompiler;
import software.coley.recaf.services.decompile.NoopJvmDecompiler;
import software.coley.recaf.services.info.association.FileTypeAssociationService;
import software.coley.recaf.services.info.association.FileTypeSyntaxAssociationService;
import software.coley.recaf.services.mapping.MappingResults;
import software.coley.recaf.services.mapping.Mappings;
import software.coley.recaf.services.navigation.ClassNavigable;
Expand Down Expand Up @@ -88,7 +88,7 @@ public class AbstractDecompilePane extends BorderPane implements ClassNavigable,
protected AbstractDecompilePane(@Nonnull DecompilerPaneConfig config,
@Nonnull SearchBar searchBar,
@Nonnull JavaContextActionSupport contextActionSupport,
@Nonnull FileTypeAssociationService languageAssociation,
@Nonnull FileTypeSyntaxAssociationService languageAssociation,
@Nonnull DecompilerManager decompilerManager) {
this.config = config;
this.contextActionSupport = contextActionSupport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import software.coley.recaf.services.decompile.DecompilerManager;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.services.source.AstResolveResult;
import software.coley.recaf.services.info.association.FileTypeAssociationService;
import software.coley.recaf.services.info.association.FileTypeSyntaxAssociationService;
import software.coley.recaf.ui.config.KeybindingConfig;
import software.coley.recaf.ui.control.richtext.Editor;
import software.coley.recaf.ui.control.richtext.search.SearchBar;
Expand All @@ -29,7 +29,7 @@ public AndroidDecompilerPane(@Nonnull DecompilerPaneConfig config,
@Nonnull SearchBar searchBar,
@Nonnull ToolsContainerComponent toolsContainer,
@Nonnull JavaContextActionSupport contextActionSupport,
@Nonnull FileTypeAssociationService languageAssociation,
@Nonnull FileTypeSyntaxAssociationService languageAssociation,
@Nonnull DecompilerManager decompilerManager,
@Nonnull Actions actions) {
super(config, searchBar, contextActionSupport, languageAssociation, decompilerManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import software.coley.recaf.services.assembler.ExpressionCompiler;
import software.coley.recaf.services.assembler.ExpressionResult;
import software.coley.recaf.services.compile.CompilerDiagnostic;
import software.coley.recaf.services.info.association.FileTypeAssociationService;
import software.coley.recaf.services.info.association.FileTypeSyntaxAssociationService;
import software.coley.recaf.ui.LanguageStylesheets;
import software.coley.recaf.ui.control.richtext.Editor;
import software.coley.recaf.ui.control.richtext.bracket.BracketMatchGraphicFactory;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class JvmExpressionCompilerPane extends AstBuildConsumerComponent {

@Inject
public JvmExpressionCompilerPane(@Nonnull ExpressionCompiler expressionCompiler,
@Nonnull FileTypeAssociationService languageAssociation,
@Nonnull FileTypeSyntaxAssociationService languageAssociation,
@Nonnull Instance<SearchBar> searchBarProvider) {
this.expressionCompiler = expressionCompiler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import software.coley.recaf.services.navigation.FileNavigable;
import software.coley.recaf.services.navigation.Navigable;
import software.coley.recaf.services.navigation.UpdatableNavigable;
import software.coley.recaf.services.info.association.FileTypeAssociationService;
import software.coley.recaf.services.info.association.FileTypeSyntaxAssociationService;
import software.coley.recaf.ui.control.richtext.Editor;
import software.coley.recaf.ui.control.richtext.bracket.BracketMatchGraphicFactory;
import software.coley.recaf.ui.control.richtext.bracket.SelectedBracketTracking;
import software.coley.recaf.ui.control.richtext.problem.ProblemSquiggleGraphicFactory;
import software.coley.recaf.ui.control.richtext.search.SearchBar;
import software.coley.recaf.util.FxThreadUtil;
import software.coley.recaf.util.StringUtil;
Expand All @@ -42,12 +41,12 @@ public class DecodingXmlPane extends BorderPane implements FileNavigable, Updata
protected FilePathNode path;

@Inject
public DecodingXmlPane(@Nonnull SearchBar searchBar, @Nonnull FileTypeAssociationService associationService) {
public DecodingXmlPane(@Nonnull SearchBar searchBar, @Nonnull FileTypeSyntaxAssociationService languageAssociation) {
// Configure the editor
editor = new Editor();
editor.setSelectedBracketTracking(new SelectedBracketTracking());
editor.getRootLineGraphicFactory().addLineGraphicFactory(new BracketMatchGraphicFactory());
associationService.configureEditorSyntax("xml", editor);
languageAssociation.configureEditorSyntax("xml", editor);
editor.getCodeArea().setEditable(false);
searchBar.install(editor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import software.coley.recaf.services.decompile.DecompileResult;
import software.coley.recaf.services.decompile.DecompilerManager;
import software.coley.recaf.services.decompile.JvmDecompiler;
import software.coley.recaf.services.info.association.FileTypeAssociationService;
import software.coley.recaf.services.info.association.FileTypeSyntaxAssociationService;
import software.coley.recaf.services.navigation.Actions;
import software.coley.recaf.services.phantom.GeneratedPhantomWorkspaceResource;
import software.coley.recaf.services.phantom.PhantomGenerationException;
Expand Down Expand Up @@ -85,7 +85,7 @@ public JvmDecompilerPane(@Nonnull DecompilerPaneConfig config,
@Nonnull SearchBar searchBar,
@Nonnull ToolsContainerComponent toolsContainer,
@Nonnull JavaContextActionSupport contextActionSupport,
@Nonnull FileTypeAssociationService languageAssociation,
@Nonnull FileTypeSyntaxAssociationService languageAssociation,
@Nonnull DecompilerManager decompilerManager,
@Nonnull JavacCompiler javac,
@Nonnull JavacCompilerConfig javacConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
import software.coley.recaf.info.TextFileInfo;
import software.coley.recaf.path.FilePathNode;
import software.coley.recaf.path.PathNode;
import software.coley.recaf.services.info.association.FileTypeAssociationService;
import software.coley.recaf.services.info.association.FileTypeSyntaxAssociationService;
import software.coley.recaf.services.navigation.FileNavigable;
import software.coley.recaf.services.navigation.Navigable;
import software.coley.recaf.services.navigation.UpdatableNavigable;
import software.coley.recaf.ui.config.KeybindingConfig;
import software.coley.recaf.ui.control.richtext.Editor;
import software.coley.recaf.ui.control.richtext.bracket.BracketMatchGraphicFactory;
import software.coley.recaf.ui.control.richtext.bracket.SelectedBracketTracking;
import software.coley.recaf.ui.control.richtext.problem.ProblemSquiggleGraphicFactory;
import software.coley.recaf.ui.control.richtext.search.SearchBar;
import software.coley.recaf.util.Animations;
import software.coley.recaf.util.FxThreadUtil;
Expand All @@ -35,12 +34,12 @@
@Dependent
public class TextPane extends BorderPane implements FileNavigable, UpdatableNavigable {
protected final AtomicBoolean updateLock = new AtomicBoolean();
private final FileTypeAssociationService languageAssociation;
private final FileTypeSyntaxAssociationService languageAssociation;
protected final Editor editor;
protected FilePathNode path;

@Inject
public TextPane(@Nonnull FileTypeAssociationService languageAssociation,
public TextPane(@Nonnull FileTypeSyntaxAssociationService languageAssociation,
@Nonnull KeybindingConfig keys,
@Nonnull SearchBar searchBar) {
this.languageAssociation = languageAssociation;
Expand Down

0 comments on commit e060831

Please sign in to comment.