mirror of
https://github.com/peterdell/wudsn-ide.git
synced 2025-01-22 00:31:47 +00:00
Replace Compiler by CompilerDefinition where possible. Move getCompilerExecutablePath() to CompilerPrefrences.
This commit is contained in:
parent
cbb82f2ca3
commit
f054b7842a
@ -250,8 +250,7 @@ final class LanguageEditorCompileCommand {
|
||||
String compilerDefinitionText = LanguageUtility.getCompilerTextLower(compilerDefinition.getLanguage());
|
||||
String compilerPreferencesText = LanguageUtility.getCompilerPreferencesText(compilerDefinition.getLanguage());
|
||||
|
||||
String compilerExecutablePath = languageEditor.getLanguagePreferences()
|
||||
.getCompilerExecutablePath(compilerDefinition.getId());
|
||||
String compilerExecutablePath = languageEditor.getCompilerPreferences().getCompilerExecutablePath();
|
||||
if (StringUtility.isEmpty(compilerExecutablePath)) {
|
||||
// ERROR: Path to '{0}' {1} executable is not set in the '{2}' preferences.
|
||||
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E100, compilerDefinitionText,
|
||||
|
@ -31,7 +31,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||
import com.wudsn.ide.lng.compiler.CompilerHelp.HelpDocument;
|
||||
import com.wudsn.ide.lng.preferences.LanguagePreferences;
|
||||
import com.wudsn.ide.lng.preferences.CompilerPreferences;
|
||||
|
||||
/**
|
||||
* Event handler for the "Compiler Help" command.
|
||||
@ -55,8 +55,8 @@ public final class LanguageEditorCompilerHelpCommandHandler extends AbstractHand
|
||||
languageEditor = (LanguageEditor) editor;
|
||||
|
||||
CompilerDefinition compilerDefinition = languageEditor.getCompilerDefinition();
|
||||
LanguagePreferences languagePreferences = languageEditor.getLanguagePreferences();
|
||||
String compilerExecutablePath = languagePreferences.getCompilerExecutablePath(compilerDefinition.getId());
|
||||
CompilerPreferences compilerPreferences = languageEditor.getCompilerPreferences();
|
||||
String compilerExecutablePath = compilerPreferences.getCompilerExecutablePath();
|
||||
|
||||
try {
|
||||
HelpDocument helpDocument = compilerDefinition.getHelpForCurrentLocale(compilerExecutablePath);
|
||||
|
@ -53,7 +53,6 @@ import com.wudsn.ide.lng.LanguagePlugin;
|
||||
import com.wudsn.ide.lng.Target;
|
||||
import com.wudsn.ide.lng.TargetUtility;
|
||||
import com.wudsn.ide.lng.Texts;
|
||||
import com.wudsn.ide.lng.compiler.Compiler;
|
||||
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||
import com.wudsn.ide.lng.compiler.CompilerHelp.HelpDocument;
|
||||
import com.wudsn.ide.lng.compiler.CompilerRegistry;
|
||||
@ -65,6 +64,7 @@ import com.wudsn.ide.lng.compiler.syntax.InstructionSet;
|
||||
import com.wudsn.ide.lng.compiler.syntax.InstructionType;
|
||||
import com.wudsn.ide.lng.compiler.syntax.Opcode;
|
||||
import com.wudsn.ide.lng.compiler.syntax.Opcode.OpcodeAddressingMode;
|
||||
import com.wudsn.ide.lng.preferences.CompilerPreferences;
|
||||
import com.wudsn.ide.lng.preferences.LanguagePreferences;
|
||||
import com.wudsn.ide.lng.runner.RunnerDefinition;
|
||||
import com.wudsn.ide.lng.runner.RunnerId;
|
||||
@ -302,26 +302,27 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
|
||||
// Find non-empty compiler executable path.
|
||||
Language language = Language.valueOf(languageString);
|
||||
String compilerKey = CompilerDefinition.getKey(language, compilerId);
|
||||
Compiler compiler = compilerRegistry.getCompilerByKey(compilerKey);
|
||||
CompilerDefinition compilerDefinition = compilerRegistry.getCompilerByKey(compilerKey).getDefinition();
|
||||
|
||||
if (section.startsWith(SECTION_GENERAL)) {
|
||||
return getInputStream(getCompilerGeneralSection(compiler));
|
||||
return getInputStream(getCompilerGeneralSection(compilerDefinition));
|
||||
} else if (section.startsWith(SECTION_MANUAL)) {
|
||||
LanguagePreferences languagePreferences = languagePlugin.getLanguagePreferences(language);
|
||||
String compilerExecutablePath = languagePreferences.getCompilerExecutablePath(compilerId);
|
||||
CompilerPreferences compilerPreferences = languagePreferences.getCompilerPreferences(compilerDefinition,
|
||||
Hardware.GENERIC);
|
||||
String compilerExecutablePath = compilerPreferences.getCompilerExecutablePath();
|
||||
if (StringUtility.isEmpty(compilerExecutablePath)) {
|
||||
// ERROR: Help for the '{0}' compiler cannot be
|
||||
// displayed because the path to the compiler executable
|
||||
// is not set in the preferences.
|
||||
String message = TextUtility.format(Texts.MESSAGE_E130,
|
||||
new String[] { compiler.getDefinition().getName() });
|
||||
String message = TextUtility.format(Texts.MESSAGE_E130, compilerDefinition.getName());
|
||||
HTMLWriter writer = createHeader();
|
||||
writer.writeText(message);
|
||||
return getInputStream(writer);
|
||||
}
|
||||
|
||||
try {
|
||||
HelpDocument helpDocDocument = compiler.getDefinition().getHelpForCurrentLocale(compilerExecutablePath);
|
||||
HelpDocument helpDocDocument = compilerDefinition.getHelpForCurrentLocale(compilerExecutablePath);
|
||||
File file = helpDocDocument.file;
|
||||
if (file == null) {
|
||||
throw new RuntimeException(
|
||||
@ -360,15 +361,16 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
|
||||
}
|
||||
|
||||
} else if (section.equals(SECTION_INSTRUCTIONS)) {
|
||||
return getInputStream(getCompilerInstructionsSection(compiler.getDefinition()));
|
||||
return getInputStream(getCompilerInstructionsSection(compilerDefinition));
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private HTMLWriter getCompilerGeneralSection(Compiler compiler) {
|
||||
CompilerDefinition compilerDefinition = compiler.getDefinition();
|
||||
|
||||
private HTMLWriter getCompilerGeneralSection(CompilerDefinition compilerDefinition) {
|
||||
if (compilerDefinition == null) {
|
||||
throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null.");
|
||||
}
|
||||
HTMLWriter writer = createHeader();
|
||||
|
||||
writer.beginTable(true);
|
||||
|
@ -47,6 +47,7 @@ import com.wudsn.ide.lng.Texts;
|
||||
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||
import com.wudsn.ide.lng.compiler.CompilerHelp.HelpDocument;
|
||||
import com.wudsn.ide.lng.compiler.CompilerRegistry;
|
||||
import com.wudsn.ide.lng.preferences.CompilerPreferences;
|
||||
import com.wudsn.ide.lng.preferences.LanguagePreferences;
|
||||
|
||||
/**
|
||||
@ -267,7 +268,9 @@ public final class LanguageTocProvider extends AbstractTocProvider {
|
||||
|
||||
LanguagePreferences languagePreferences = LanguagePlugin.getInstance()
|
||||
.getLanguagePreferences(compilerDefinition.getLanguage());
|
||||
String compilerExecutablePath = languagePreferences.getCompilerExecutablePath(compilerDefinition.getId());
|
||||
CompilerPreferences compilerPreferences = languagePreferences.getCompilerPreferences(compilerDefinition,
|
||||
Hardware.GENERIC);
|
||||
String compilerExecutablePath = compilerPreferences.getCompilerExecutablePath();
|
||||
|
||||
String icon = "";
|
||||
List<ITopic> manualTopics = new ArrayList<ITopic>();
|
||||
|
@ -64,6 +64,16 @@ public final class CompilerPreferences {
|
||||
return compilerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the executable path for the compiler.
|
||||
*
|
||||
* @return The executable path for the runner, may be empty, not
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public String getCompilerExecutablePath() {
|
||||
return languagePreferences.getString(LanguagePreferencesConstants.getCompilerExecutablePathName(compilerId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hardware for which the compiler is invoked.
|
||||
*
|
||||
|
@ -22,7 +22,6 @@ package com.wudsn.ide.lng.preferences;
|
||||
import org.eclipse.jface.text.TextAttribute;
|
||||
|
||||
import com.wudsn.ide.base.common.AbstractIDEPlugin;
|
||||
import com.wudsn.ide.base.common.StringUtility;
|
||||
import com.wudsn.ide.base.hardware.Hardware;
|
||||
import com.wudsn.ide.lng.Language;
|
||||
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||
@ -83,24 +82,6 @@ public final class LanguagePreferences {
|
||||
return getString(LanguagePreferencesConstants.EDITOR_COMPILE_COMMAND_POSITIONING_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the executable path for the compiler.
|
||||
*
|
||||
* @param compilerId The compiler id, not empty and not <code>null</code>.
|
||||
*
|
||||
* @return The executable path for the compiler, may be empty, not
|
||||
* <code>null</code>.
|
||||
*/
|
||||
public String getCompilerExecutablePath(String compilerId) {
|
||||
if (compilerId == null) {
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(compilerId)) {
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be empty.");
|
||||
}
|
||||
return getString(LanguagePreferencesConstants.getCompilerExecutablePathName(compilerId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferences for a compiler.
|
||||
*
|
||||
|
@ -67,8 +67,8 @@ import com.wudsn.ide.lng.runner.RunnerId;
|
||||
import com.wudsn.ide.lng.runner.RunnerRegistry;
|
||||
|
||||
/**
|
||||
* Visual editor page for the language preferences regarding compilers. There
|
||||
* is a separate page per {@link Hardware}. Subclasses only implement the
|
||||
* Visual editor page for the language preferences regarding compilers. There is
|
||||
* a separate page per {@link Hardware}. Subclasses only implement the
|
||||
* constructor.
|
||||
*
|
||||
* @author Peter Dell
|
||||
@ -78,6 +78,7 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
|
||||
|
||||
private static final class Tab {
|
||||
|
||||
public final CompilerDefinition compilerDefinition;
|
||||
public final String compilerId;
|
||||
public final int tabIndex;
|
||||
public final TabItem tabItem;
|
||||
@ -87,9 +88,10 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
|
||||
public boolean initialized;
|
||||
public boolean enabled;
|
||||
|
||||
public Tab(String compilerId, int tabIndex, TabItem tabItem, Control enabledControl, Control disabledControl,
|
||||
List<ControlDecoration> controlDecorations) {
|
||||
this.compilerId = compilerId;
|
||||
public Tab(CompilerDefinition compilerDefinition, int tabIndex, TabItem tabItem, Control enabledControl,
|
||||
Control disabledControl, List<ControlDecoration> controlDecorations) {
|
||||
this.compilerDefinition = compilerDefinition;
|
||||
this.compilerId = compilerDefinition.getId();
|
||||
this.tabIndex = tabIndex;
|
||||
this.tabItem = tabItem;
|
||||
this.enabledControl = enabledControl;
|
||||
@ -438,7 +440,7 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
|
||||
Composite disabledControl = SWTFactory.createComposite(tabFolder, 1, 1, GridData.FILL_BOTH);
|
||||
label = new Label(disabledControl, SWT.NONE);
|
||||
label.setText(TextUtility.format(Texts.MESSAGE_E100, compilerDefinition.getName()));
|
||||
Tab tab = new Tab(compilerId, tabs.size(), tabItem, tabContent, disabledControl, controlDecorations);
|
||||
Tab tab = new Tab(compilerDefinition, tabs.size(), tabItem, tabContent, disabledControl, controlDecorations);
|
||||
tabs.put(compilerId, tab);
|
||||
|
||||
}
|
||||
@ -458,8 +460,9 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
|
||||
}
|
||||
|
||||
LanguagePreferences languagePreferences = plugin.getLanguagePreferences(language);
|
||||
|
||||
boolean enabled = StringUtility.isSpecified(languagePreferences.getCompilerExecutablePath(tab.compilerId));
|
||||
CompilerPreferences compilerPreferences = languagePreferences.getCompilerPreferences(tab.compilerDefinition,
|
||||
hardware);
|
||||
boolean enabled = StringUtility.isSpecified(compilerPreferences.getCompilerExecutablePath());
|
||||
|
||||
if (!tab.initialized || enabled != tab.enabled) {
|
||||
tab.initialized = true;
|
||||
@ -572,8 +575,8 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
|
||||
|
||||
// Field: illegalOpcodesVisible
|
||||
composite = SWTFactory.createComposite(tabContent, 2, 3, GridData.FILL_HORIZONTAL);
|
||||
FieldEditor booleanFieldEditor = new BooleanFieldEditor(LanguagePreferencesConstants
|
||||
.getCompilerRunnerWaitForCompletionName(compilerId, hardware, runnerId),
|
||||
FieldEditor booleanFieldEditor = new BooleanFieldEditor(
|
||||
LanguagePreferencesConstants.getCompilerRunnerWaitForCompletionName(compilerId, hardware, runnerId),
|
||||
Texts.PREFERENCES_COMPILER_RUNNER_WAIT_FOR_COMPLETION_LABEL, composite);
|
||||
|
||||
addField(booleanFieldEditor);
|
||||
|
Loading…
x
Reference in New Issue
Block a user