Split preferences per language.

This commit is contained in:
peterdell 2021-09-26 22:54:47 +02:00
parent dc4ab9a552
commit 5c994c4c82
31 changed files with 785 additions and 216 deletions

View File

@ -19,7 +19,7 @@
modes="idl=$47,abl=$4f,idly=$57,alx=$5f"/>
<opcode targets="MOS65816" name="JMPL" title="_Ju_m_p to new address (_long)" proposal="JMPL _" modes="abl=$5c,ial=$7c"/>
<opcode targets="MOS65816" name="JSRL" title="_Jump to _sub _routine (_long)" proposal="JSRL _" modes="abs=$22"/>
<opcode targets="MOS65816" name="LDAL" title="_Loa_d _accumulator (_long)" proposal="LDAL _" modes="idl=$a7,ibl=$af,idly=$b7,alx=$bf"/>
<opcode targets="MOS65816" name="LDAL" title="_Loa_d _accumulator (_long)" proposal="LDAL _" modes="idl=$a7,abl=$af,idly=$b7,alx=$bf"/>
<opcode targets="MOS65816" name="ORAL" title="Binary _o_r with _accumulator (_long)" proposal="ORAL _"
modes="idl=$07,abl=$0f,idl=$17,alx=$1f"/>
<opcode targets="MOS65816" name="SBCL" title="_Su_btract from accumulator with _carry (_long)" proposal="SBCL _"

View File

@ -40,6 +40,7 @@ import com.wudsn.ide.lng.compiler.CompilerRegistry;
import com.wudsn.ide.lng.preferences.LanguagePreferences;
import com.wudsn.ide.lng.preferences.LanguagePreferencesChangeListener;
import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants;
import com.wudsn.ide.lng.preferences.LanguagesPreferences;
import com.wudsn.ide.lng.runner.RunnerRegistry;
/**
@ -64,7 +65,7 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
/**
* The preferences.
*/
private LanguagePreferences preferences;
private LanguagesPreferences preferences;
private ListenerList<LanguagePreferencesChangeListener> preferencesChangeListeners;
/**
@ -117,7 +118,7 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
preferences = new LanguagePreferences(getPreferenceStore());
preferences = new LanguagesPreferences(getPreferenceStore());
plugin = this;
try {
compilerRegistry.init();
@ -141,7 +142,9 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(JFaceResources.TEXT_FONT)
|| event.getProperty().equals(BLOCK_SELECTION_MODE_FONT)) {
firePreferencesChangeEvent(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTES);
for (Language language : languages) {
firePreferencesChangeEvent(language, LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTES);
}
}
}
@ -221,13 +224,20 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
*
* @return The preferences, not <code>null</code>.
*/
public LanguagePreferences getPreferences() {
public LanguagesPreferences getPreferences() {
if (preferences == null) {
throw new IllegalStateException("Field 'preferences' must not be null.");
}
return preferences;
}
public LanguagePreferences getLanguagePreferences(Language language) {
if (language == null) {
throw new IllegalArgumentException("Parameter 'language' must not be null.");
}
return getPreferences().getLanguagePreferences(language);
}
/**
* Adds a listener for immediate preferences changes.
*
@ -257,19 +267,22 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
/**
* Fire the change events for all registered listeners.
*
* @param language
*
* @param changedPropertyNames The set of property changed property names, not
* <code>null</code>.
*
* @since 1.6.3
*/
public void firePreferencesChangeEvent(Set<String> changedPropertyNames) {
public void firePreferencesChangeEvent(Language language, Set<String> changedPropertyNames) {
if (changedPropertyNames == null) {
throw new IllegalArgumentException("Parameter 'changedPropertyNames' must not be null.");
}
if (!changedPropertyNames.isEmpty()) {
LanguagePreferences languagPreferences = getLanguagePreferences(language);
for (Object listener : preferencesChangeListeners.getListeners()) {
((LanguagePreferencesChangeListener) listener).preferencesChanged(preferences, changedPropertyNames);
((LanguagePreferencesChangeListener) listener).preferencesChanged(languagPreferences,
changedPropertyNames);
}
}
}

View File

@ -0,0 +1,67 @@
/**
* Copyright (C) 2009 - 2021 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wudsn.ide.lng;
/**
* Utility class for languages
*
* @author Peter Dell
*
* @since 1.7.2
*/
public final class LanguageUtility {
/**
* Creation is private.
*/
private LanguageUtility() {
}
/**
* Gets the text for type of compilers for a language.
*
* @param language The language, not <code>null</code>.
* @return The text, not empty and not <code>null</code>.
*/
public static String getCompilerTextLower(Language language) {
switch (language) {
case ASM:
return "assembler";
case PAS:
return "compiler";
}
throw new IllegalArgumentException("Unknown language '" + language + "'.");
}
public static String getCompilerPreferencesText(Language language) {
switch (language) {
case ASM:
return "Languages/Assemblers";
case PAS:
return "Languages/Compilers";
}
throw new IllegalArgumentException("Unknown language '" + language + "'.");
}
}

View File

@ -19,7 +19,7 @@
package com.wudsn.ide.lng;
/**
* Enum for the supported CPUs. Used for restricting the visible instructions.
* Enum for the supported targets. Used for restricting the visible instructions.
*
* @author Peter Dell
*

View File

@ -0,0 +1,49 @@
/**
* Copyright (C) 2009 - 2021 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wudsn.ide.lng;
/**
* Enum for the supported targets. Used for restricting the visible instructions.
*
* @author Peter Dell
*
* @since 1.7.2
*/
public final class TargetUtility {
private TargetUtility() {
}
/**
* Gets the language for a target.
*
* @param target The target, not <code>null</code>.
* @return The language, not <code>null</code>.
*/
public static Language getLanguage(Target target) {
if (target == null) {
throw new IllegalArgumentException("Parameter 'target' must not be null.");
}
if (target.equals(Target.PASCAL)) {
return Language.PAS;
}
return Language.ASM;
}
}

View File

@ -25,7 +25,6 @@ import org.eclipse.osgi.util.NLS;
//COMPILER_HYPERLINK_DETECTOR_OPEN_SOURCE_WITH_LANGUAGE_EDITOR=Öffnen mit {0} Editor
//LANGUAGE_BREAKPOINT_TOGGLE_TYPE_MENU_TEXT={0} Breakpoints
//
//TOC_COMPILERS_TOPIC_LABEL={0}
//MESSAGE_E100=Path to '{0}' {1} executable is not set in the '{2}' preferences.
//MESSAGE_E101=The {0} '{1}' does not specify default parameters.
//MESSAGE_E102=The {1} '{1}' does not specify a help file path.
@ -224,6 +223,7 @@ public final class Texts extends NLS {
public static String TOC_COMPILER_GENERAL_TOPIC_LABEL;
public static String TOC_COMPILER_NAME_LABEL;
public static String TOC_COMPILER_HOME_PAGE_LABEL;
public static String TOC_COMPILER_HELP_DOCUMENTS_LABEL;
public static String TOC_COMPILER_DEFAULT_HARDWARE_LABEL;
public static String TOC_COMPILER_SUPPORTED_TARGETS_LABEL;
public static String TOC_COMPILER_DEFAULT_PARAMETERS_LABEL;
@ -248,7 +248,9 @@ public final class Texts extends NLS {
public static String TOC_HARDWARE_DEFAULT_PARAMETERS_LABEL;
public static String TOC_TARGETS_TOPIC_LABEL;
public static String TOC_TARGETS_NAME_LABEL;
public static String TOC_TARGET_NAME_LABEL;
public static String TOC_TARGET_LANGUAGE_LABEL;
public static String TOC_TARGET_OPCODE_LABEL;
/**

View File

@ -120,6 +120,7 @@ TOC_COMPILERS_TOPIC_LABEL={0}
TOC_COMPILER_GENERAL_TOPIC_LABEL=General
TOC_COMPILER_NAME_LABEL=Name
TOC_COMPILER_HOME_PAGE_LABEL=Home Page
TOC_COMPILER_HELP_DOCUMENTS_LABEL=Help Documents
TOC_COMPILER_DEFAULT_HARDWARE_LABEL=Default Hardware
TOC_COMPILER_SUPPORTED_TARGETS_LABEL=Supported Targets
TOC_COMPILER_DEFAULT_PARAMETERS_LABEL=Default Parameters
@ -159,13 +160,14 @@ TOC_HARDWARE_HOME_PAGE_LABEL=Home Page
TOC_HARDWARE_DEFAULT_PARAMETERS_LABEL=Default Parameters
TOC_TARGETS_TOPIC_LABEL=Targets
TOC_TARGETS_NAME_LABEL=Target
TOC_TARGET_NAME_LABEL=Target
TOC_TARGET_LANGUAGE_LABEL=Language
TOC_TARGET_OPCODE_LABEL=Opcode
MESSAGE_E100=Path to '{0}' {1} executable is not set in the '{2}' preferences.
MESSAGE_E101=The {0} '{1}' does not specify default parameters.
MESSAGE_E102=The {1} '{1}' does not specify a help file path.
MESSAGE_E103=Path to '{0}' {1} executable in the preferences points to non-existing file '{1}'.
MESSAGE_E102=The {0} '{1}' does not specify help document paths.
MESSAGE_E103=Path to '{0}' {1} executable in the '{2}' preferences points to non-existing file '{3}'.
MESSAGE_E104=Output file extension must be set in the preferences of {0} '{1}' or via the annotation '{2}'.
MESSAGE_E105=Cannot execute {0} process '{1}' in working directory '{2}'. System error: {3}
MESSAGE_E106=Output file '{0}' cannot be opened for writing. End all applications which may keep the file open.
@ -192,8 +194,8 @@ MESSAGE_E126=Output file created but empty. Check the error messages and the con
MESSAGE_E127={0} process ended with return code {1}. Check the error messages and the console log.
MESSAGE_E128=Hardware not specified. Specify one of the following valid values '{0}'.
MESSAGE_E129=Main source file specifies or defaults to hardware '{0}' while include file specifies or defaults to hardware '{1}'.
MESSAGE_E130=Help for the '{0}' {1} cannot be displayed because the path to the compiler executable is not set in the preferences.
MESSAGE_E131=Help for the '{0}' {1} cannot be displayed because no help file was found in the paths '{2}' relative to the compiler executable path '{3}'.
MESSAGE_E130=Help for the '{0}' {1} cannot be displayed because the path to the executable is not set in the '{2}' preferences.
MESSAGE_E131=Help for the '{0}' {1} cannot be displayed because no help file was found in the paths '{2}' relative to the executable path '{3}'.
MESSAGE_E132=Disk image file '{0}' does not exist. Create a bootable disk image where the output file '{1}' can be stored.
MESSAGE_E133=Disk image file '{0}' is not writeable. Make the disk image file is writeable, so the output file '{1}' can be stored.
MESSAGE_E134=Disk image file '{0}' cannot be opened for reading. System error: {1}

View File

@ -118,6 +118,7 @@ TOC_COMPILERS_TOPIC_LABEL={0}
TOC_COMPILER_GENERAL_TOPIC_LABEL=Allgemein
TOC_COMPILER_NAME_LABEL=Name
TOC_COMPILER_HOME_PAGE_LABEL=Home Page
TOC_COMPILER_HELP_DOCUMENTS_LABEL=Hilfe Dokomente
TOC_COMPILER_DEFAULT_HARDWARE_LABEL=Standardhardware
TOC_COMPILER_SUPPORTED_TARGETS_LABEL=Unterstütze Ziele
TOC_COMPILER_DEFAULT_PARAMETERS_LABEL=Standardparameter
@ -158,11 +159,12 @@ TOC_HARDWARE_DEFAULT_PARAMETERS_LABEL=Standardparameter
TOC_TARGETS_TOPIC_LABEL=Ziele
TOC_TARGET_NAME_LABEL=Ziel
TOC_TARGET_LANGUAGE_LABEL=Sprache
TOC_TARGET_OPCODE_LABEL=Opcode
MESSAGE_E100=Pfad zur ausführbaren Datei des Kompilers '{0}' ist in den '{1}' Voreinstellungen nicht angegeben.
MESSAGE_E101=Der Kompiler '{0}' definiert keine Standardparameter.
MESSAGE_E102=Der Kompiler '{0}' getHelpFile keine Pfade zu Hilfe-Dateien.
MESSAGE_E101=Der {0} '{1}' definiert keine Standardparameter.
MESSAGE_E102=Der {0} '{1}' definiert keine Pfade zu Hilfedokumenten.
MESSAGE_E103=Pfad zur ausführbaren Datei des Kompilers '{0}' in den Voreinstellungen verweist auf die nicht existierende Datei '{1}'.
MESSAGE_E104=Ausgabe-Dateierweiterung muss in den Voreinstellungen des Kompilers '{0}' oder mit der Annotation '{1}' angegeben werden.
MESSAGE_E105=Kompilerprozess '{0}' kann im Arbeitsverzeichnis '{1}' nicht ausgeführt werden. Systemfehler: {2}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Common 6502 opcodes used by all compilers -->
<!-- See http://www.65xx.com/wdc/documentation/w65c816s.pdf for the description of the 16bit opcodes. -->
<!-- See https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf for the description of the 16bit opcodes. -->
<!-- http://www.westerndesigncenter.com/wdc/datasheets/Programmanual.pdf -->
<opcodes>

View File

@ -22,19 +22,20 @@ package com.wudsn.ide.lng.compiler;
import java.io.File;
import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import com.wudsn.ide.base.common.FileUtility;
import com.wudsn.ide.base.common.StringUtility;
import com.wudsn.ide.base.common.TextUtility;
import com.wudsn.ide.base.hardware.Hardware;
import com.wudsn.ide.lng.Language;
import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.LanguageUtility;
import com.wudsn.ide.lng.Target;
import com.wudsn.ide.lng.Texts;
import com.wudsn.ide.lng.compiler.CompilerHelp.HelpDocument;
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
/**
@ -47,7 +48,7 @@ import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
public final class CompilerDefinition implements Comparable<CompilerDefinition> {
// Language
private String language;
private Language language;
// Id
private String id;
@ -55,7 +56,7 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
private String className;
// Installation and use.
private String helpFilePaths;
private String helpDocumentPaths;
private String homePageURL;
// Editing and source parsing.
@ -81,7 +82,7 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
*
* @return The key that uniquely identifies the compiler, not <code>null</code>.
*/
public static String getKey(String language, String id) {
public static String getKey(Language language, String id) {
if (language == null) {
throw new IllegalStateException("Field 'language' must not be null for this or for argument.");
}
@ -89,7 +90,7 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
throw new IllegalStateException("Field 'id' must not be null for this or for argument.");
}
return language + "/" + id;
return language.name() + "/" + id;
}
/**
@ -115,15 +116,15 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
if (StringUtility.isEmpty(language)) {
throw new IllegalArgumentException("Parameter 'language' must not be empty.");
}
this.language = language;
this.language = Language.valueOf(language);
}
/**
* Gets the language of the compiler.
*
* @return The language of the compiler, not empty and not <code>null</code>.
* @return The language of the compiler, not <code>null</code>.
*/
public final String getLanguage() {
public final Language getLanguage() {
if (language == null) {
throw new IllegalStateException("Field 'language' must not be null.");
}
@ -243,43 +244,46 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
* Sets the help file paths to locate the help file for the compiler. Called by
* {@link CompilerRegistry} only.
*
* @param helpFilePaths The relative file path to locate the help file for the
* compiler based on the folder of the executable. ".",
* ".." and "/" may be used to specify the path. A path may
* end with a language in the form "(en)". Multiple paths
* are separated by ",". May be empty or <code>null</code>.
* @param helpDocumentPaths The relative file path starting with "." to locate
* the help file for the compiler based on the folder
* of the executable. ".". ".." and "/" may be used to
* specify the file path. Alternatively the path can be
* an absolute URL. A path may end with a language in
* the form "(en)". Multiple paths are separated by
* ",". May be empty or <code>null</code>.
*/
final void setHelpFilePaths(String helpFilePaths) {
if (helpFilePaths == null) {
helpFilePaths = "";
final void setHelpDocumentPaths(String helpDocumentPaths) {
if (helpDocumentPaths == null) {
helpDocumentPaths = "";
}
this.helpFilePaths = helpFilePaths;
this.helpDocumentPaths = helpDocumentPaths;
}
/**
* Gets the help file paths to locate the help file for the compiler.
*
* @return The relative file path to locate the help file for the compiler based
* on the folder of the executable. ".", ".." and "/" may be used to
* specify the path. A path may end with a language in the form
* "(en)".Multiple paths are separated by ",". The result may be empty,
* not <code>null</code>.
* @return The relative file path starting with "." to locate the help file for
* the compiler based on the folder of the executable. ".". ".." and "/"
* may be used to specify the file path. Alternatively the path can be
* an absolute URL. A path may end with a language in the form "(en)".
* Multiple paths are separated by ",". May be empty or
* <code>null</code>.
*/
public final String getHelpFilePaths() {
if (helpFilePaths == null) {
throw new IllegalStateException("Field 'helpFilePaths' must not be null.");
public final String getHelpDocumentPaths() {
if (helpDocumentPaths == null) {
throw new IllegalStateException("Field 'helpDocumentPaths' must not be null.");
}
return helpFilePaths;
return helpDocumentPaths;
}
/**
* Determines if this compiler offers a help file at all.
* Determines if this compiler offers help at all.
*
* @return <code>true</code> if this compiler offers a help file,
* <code>false</code> otherwise.
*/
public final boolean hasHelpFile() {
return StringUtility.isSpecified(helpFilePaths);
public final boolean hasHelpDocumentPaths() {
return StringUtility.isSpecified(helpDocumentPaths);
}
/**
@ -294,57 +298,82 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
* does not specify a help path or no help file can be
* found.
*/
public final File getHelpFile(String compilerExecutablePath) throws CoreException {
public final List<HelpDocument> getHelpDocuments(String compilerExecutablePath) throws CoreException {
if (compilerExecutablePath == null) {
throw new IllegalArgumentException("Parameter 'compilerExecutablePath' must not be null.");
}
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.
throw new CoreException(
new Status(IStatus.ERROR, LanguagePlugin.ID, TextUtility.format(Texts.MESSAGE_E130, name)));
String compilerText = LanguageUtility.getCompilerTextLower(language);
if (!hasHelpDocumentPaths()) {
// INFO: The {0} '{1}' does not specify help document paths.
throw new CoreException(new Status(IStatus.INFO, LanguagePlugin.ID,
TextUtility.format(Texts.MESSAGE_E102, compilerText, name)));
}
if (!hasHelpFile()) {
// ERROR: The compiler '{0}' does not specify a help file path.
throw new CoreException(
new Status(IStatus.ERROR, LanguagePlugin.ID, TextUtility.format(Texts.MESSAGE_E102, name)));
String compilerPreferencesText = LanguageUtility.getCompilerPreferencesText(language);
if (StringUtility.isEmpty(compilerExecutablePath)) {
// ERROR: Help for the '{0}' {1} cannot be displayed because the path to the
// compiler executable is not set in the {2} preferences.
throw new CoreException(new Status(IStatus.ERROR, LanguagePlugin.ID,
TextUtility.format(Texts.MESSAGE_E130, name, compilerText, compilerPreferencesText)));
}
return CompilerHelp.getHelpDocuments(helpDocumentPaths, compilerExecutablePath);
}
public final HelpDocument getHelpForCurrentLocale(String compilerExecutablePath) throws CoreException {
List<HelpDocument> helpDocuments = getHelpDocuments(compilerExecutablePath);
String localeLanguage = Locale.getDefault().getLanguage();
File firstFile = null;
File firstLanguageFile = null;
StringTokenizer tokenizer = new StringTokenizer(helpFilePaths, ",");
while (tokenizer.hasMoreTokens()) {
String helpFilePath = tokenizer.nextToken().trim();
String helpFileLanguage = "";
int index = helpFilePath.lastIndexOf("(");
if (index > 0) {
helpFileLanguage = helpFilePath.substring(index + 1, index + 3);
helpFilePath = helpFilePath.substring(0, index - 1).trim();
}
File file = FileUtility
.getCanonicalFile(new File(new File(compilerExecutablePath).getParent(), helpFilePath));
if (file.exists()) {
// Find the first existing local file and the first existing local file with
// matching language.
HelpDocument firstFile = null;
HelpDocument firstLanguageFile = null;
for (HelpDocument helpDocument : helpDocuments) {
if (helpDocument.file != null && helpDocument.file.exists()) {
if (firstFile == null) {
firstFile = file;
firstFile = helpDocument;
}
if (firstLanguageFile == null && helpFileLanguage.equals(localeLanguage)) {
firstLanguageFile = file;
if (firstLanguageFile == null && helpDocument.language.equals(localeLanguage)) {
firstLanguageFile = helpDocument;
}
}
}
// Use language specific file if present, use first file otherwise.
File result = firstLanguageFile;
HelpDocument result = firstLanguageFile;
if (result == null) {
result = firstFile;
}
// No local file specified or found. Try the URIs.
if (result == null) {
// ERROR: Help for the '{0}' compiler cannot be displayed because no
// help file was found in the paths '{1}' for the compiler
// executable path '{0}'.
throw new CoreException(new Status(IStatus.ERROR, LanguagePlugin.ID,
TextUtility.format(Texts.MESSAGE_E131, name, helpFilePaths, compilerExecutablePath)));
for (HelpDocument helpDocument : helpDocuments) {
if (helpDocument.uri != null) {
if (firstFile == null) {
firstFile = helpDocument;
}
if (firstLanguageFile == null && helpDocument.language.equals(localeLanguage)) {
firstLanguageFile = helpDocument;
}
}
}
// Use language specific URI if present, use first URI otherwise.
result = firstLanguageFile;
if (result == null) {
result = firstFile;
}
}
// No local file specified or found and no URIs found.
if (result == null) {
// ERROR: Help for the '{0}' {1} cannot be displayed because no help file was
// found in the paths '{2}' relative to the executable path '{3}'.
throw new CoreException(new Status(IStatus.ERROR, LanguagePlugin.ID, TextUtility.format(Texts.MESSAGE_E131,
name, LanguageUtility.getCompilerTextLower(language), helpDocumentPaths, compilerExecutablePath)));
}
return result;

View File

@ -0,0 +1,79 @@
/**
* Copyright (C) 2009 - 2021 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wudsn.ide.lng.compiler;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import com.wudsn.ide.base.common.FileUtility;
import com.wudsn.ide.base.common.StringUtility;
/**
* Compiler help access.
*
* @author Peter Dell
*
* @since 1.7.2
*/
public final class CompilerHelp {
public static class HelpDocument {
public String path;
public String language;
public File file;
public URI uri;
}
public static List<HelpDocument> getHelpDocuments(String helpDocumentPaths, String compilerExecutablePath) {
List<HelpDocument> helpDocuments = new ArrayList<CompilerHelp.HelpDocument>();
StringTokenizer tokenizer = new StringTokenizer(helpDocumentPaths, ",");
while (tokenizer.hasMoreTokens()) {
String helpFilePath = tokenizer.nextToken().trim();
String helpFileLanguage = "";
int index = helpFilePath.lastIndexOf("(");
if (index > 0) {
helpFileLanguage = helpFilePath.substring(index + 1, index + 3);
helpFilePath = helpFilePath.substring(0, index - 1).trim();
}
HelpDocument helpDocument = new HelpDocument();
helpDocument.path = helpFilePath;
helpDocument.language = helpFileLanguage;
// Relative paths are local files.
if (helpFilePath.startsWith(".") && StringUtility.isSpecified(compilerExecutablePath)) {
helpDocument.file = FileUtility
.getCanonicalFile(new File(new File(compilerExecutablePath).getParent(), helpFilePath));
} else {
try {
helpDocument.uri = new URI(helpFilePath);
} catch (URISyntaxException ex) {
throw new RuntimeException("Invalid URI for '" + helpFilePath + "' help file path", ex);
}
}
helpDocuments.add(helpDocument);
}
return helpDocuments;
}
}

View File

@ -97,7 +97,7 @@ public final class CompilerRegistry {
compilerDefinition.setId(configurationElement.getAttribute("id"));
compilerDefinition.setName(configurationElement.getAttribute("name"));
compilerDefinition.setClassName(configurationElement.getAttribute("class"));
compilerDefinition.setHelpFilePaths(configurationElement.getAttribute("helpFilePaths"));
compilerDefinition.setHelpDocumentPaths(configurationElement.getAttribute("helpDocumentPaths"));
compilerDefinition.setHomePageURL(configurationElement.getAttribute("homePageURL"));
compilerDefinition.setDefaultParameters(configurationElement.getAttribute("defaultParameters"));
@ -192,7 +192,7 @@ public final class CompilerRegistry {
}
List<CompilerDefinition> result = new ArrayList<CompilerDefinition>();
for (CompilerDefinition compilerDefinition : compilerDefinitionList) {
if (compilerDefinition.getLanguage().equals(language.name())) {
if (compilerDefinition.getLanguage().equals(language)) {
result.add(compilerDefinition);
}
}

View File

@ -486,6 +486,9 @@ public final class CompilerSyntax {
try {
InputStream inputStream = compilerClass.getResourceAsStream(syntaxFileName);
if (inputStream==null) {
throw new RuntimeException("Cannot create parser for file '" + syntaxFileName + "'. Resource not found in class path.");
}
parser.parse(inputStream, xmlHandler);
} catch (SAXParseException ex) {
throw new RuntimeException("Cannot create parser for file '" + syntaxFileName + "'. Error in line "

View File

@ -19,7 +19,7 @@
package com.wudsn.ide.lng.compiler.syntax;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@ -31,18 +31,56 @@ public final class Opcode extends Instruction {
public static final int MAX_OPCODES = 256;
public final static class OpcodeAddressingMode {
private static Map<String, String> addressingModeText;
static {
addressingModeText = new TreeMap<String, String>();
// 6502 mode.
addressingModeText.put("abs", " abs"); // Absolute
addressingModeText.put("abx", " abs,x"); // Absolute withX
addressingModeText.put("aby", " abs,y"); // Absolute with Y
addressingModeText.put("imm", " #$nn"); // Immediate
addressingModeText.put("imp", ""); // Implied
addressingModeText.put("ind", " (abs)"); // Indirect absolute
addressingModeText.put("izx", " (zp,x)"); // Indirect zero page with X
addressingModeText.put("izy", " (zp),y"); // Indirect zero page with Y
addressingModeText.put("rel", " rel"); // Relative
addressingModeText.put("zp", " zp"); // Zero page
addressingModeText.put("zpx", " zp,x"); // Zero page with X
addressingModeText.put("zpy", " zp,y"); // Zero page with Y
// 65816 modes. Some are equals to 6502 mode, but have different a code.
addressingModeText.put("abl", " abs (long)"); // Absolute long
addressingModeText.put("alx", " abs,x (long)"); // Absolute long with X
addressingModeText.put("bm", " $nn,$mm"); // Block move
addressingModeText.put("dp", " dp"); // Direct page
addressingModeText.put("dpx", " dp,x"); // Direct page with X
addressingModeText.put("dpy", " dp,y"); // Direct page with Y
addressingModeText.put("ial", " (abs) (long)"); // Indirect absolute long
addressingModeText.put("idl", " (abs) (long)"); // Indirect absolute long for JMP
addressingModeText.put("iax", " (abs,x) (long)"); // Indirect absolute long with X
addressingModeText.put("idly", " (abs),y (long)"); // Indirect absolute long with Y
addressingModeText.put("idp", " (dp)"); // Indirect direct page
addressingModeText.put("isy", " ($00,S),Y"); // Stack indirect with Y in first 64k
addressingModeText.put("rell", " rel (long)"); // Relative long
addressingModeText.put("sr", "$00,S"); // Stack in first 64k
}
private Opcode opcode;
private Set<Target> cpus;
private Set<Target> targets;
private String addressingMode;
private int opcodeValue;
OpcodeAddressingMode(Opcode opcode, Set<Target> cpus, String addressingMode, int opcodeValue) {
OpcodeAddressingMode(Opcode opcode, Set<Target> targets, String addressingMode, int opcodeValue) {
if (opcode == null) {
throw new IllegalArgumentException("Parameter 'opcode' must not be null.");
}
if (cpus == null) {
if (targets == null) {
throw new IllegalArgumentException(
"Parameter 'cpus' must not be null for opcode '" + opcode.getName() + "'.");
"Parameter 'targets' must not be null for opcode '" + opcode.getName() + "'.");
}
if (addressingMode == null) {
throw new IllegalArgumentException(
@ -54,7 +92,7 @@ public final class Opcode extends Instruction {
}
this.opcode = opcode;
this.cpus = cpus;
this.targets = targets;
this.addressingMode = addressingMode;
this.opcodeValue = opcodeValue;
}
@ -64,7 +102,7 @@ public final class Opcode extends Instruction {
}
public Set<Target> getCPUs() {
return cpus;
return targets;
}
public String getAddressingMode() {
@ -74,47 +112,9 @@ public final class Opcode extends Instruction {
public String getFormattedText() {
StringBuffer result = new StringBuffer(opcode.getName());
if (addressingMode.equals("imp")) {
} else if (addressingMode.equals("imm")) {
result.append(" #$nn");
} else if (addressingMode.equals("zp")) {
result.append(" zp");
} else if (addressingMode.equals("zpx")) {
result.append(" zp,x");
} else if (addressingMode.equals("zpy")) {
result.append(" zp,y");
} else if (addressingMode.equals("izx")) {
result.append(" (zp,x)");
} else if (addressingMode.equals("izy")) {
result.append(" (zp),y");
} else if (addressingMode.equals("abs")) {
result.append(" abs");
} else if (addressingMode.equals("abx")) {
result.append(" abs,x");
} else if (addressingMode.equals("aby")) {
result.append(" abs,y");
} else if (addressingMode.equals("ind")) {
result.append(" (abs)");
} else if (addressingMode.equals("rel")) {
result.append(" rel");
} else
// 65816 modes
if (addressingMode.equals("abl")) {
result.append(" adr (long)");
} else if (addressingMode.equals("bm")) {
result.append(" $nn,$nn");
} else if (addressingMode.equals("dp")) {
result.append(" (zp)");
} else if (addressingMode.equals("ial")) {
result.append(" abs (long)");
} else if (addressingMode.equals("iax")) {
result.append(" (abs,x)");
} else if (addressingMode.equals("idp")) {
result.append(" (zp)");
} else if (addressingMode.equals("rell")) {
result.append(" rel (long)");
String text = addressingModeText.get(addressingMode);
if (text != null) {
result.append(text);
} else {
throw new RuntimeException(
"Unmapped addressing mode " + addressingMode + " for opcode " + opcode.getName());

View File

@ -305,7 +305,7 @@ final class LanguageContentAssistProcessor implements IContentAssistProcessor {
if (proposalList == null) {
throw new IllegalArgumentException("Parameter 'proposalList' must not be null.");
}
LanguagePreferences languagePreferences = editor.getPlugin().getPreferences();
LanguagePreferences languagePreferences = editor.getLanguagePreferences();
int offset = region.getOffset();
boolean lowerCase;

View File

@ -66,6 +66,7 @@ import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObject;
import com.wudsn.ide.lng.compiler.parser.CompilerSourcePartitionScanner;
import com.wudsn.ide.lng.outline.LanguageOutlinePage;
import com.wudsn.ide.lng.preferences.CompilerPreferences;
import com.wudsn.ide.lng.preferences.LanguagePreferences;
/**
* The language editor.
@ -153,13 +154,22 @@ public abstract class LanguageEditor extends TextEditor {
return plugin;
}
/**
* Gets the language preferences.
*
* @return The language preferences, not <code>null</code>.
*/
public final LanguagePreferences getLanguagePreferences() {
return plugin.getLanguagePreferences(getCompilerDefinition().getLanguage());
}
/**
* Gets the compiler preferences.
*
* @return The compiler preferences, not <code>null</code>.
*/
public final CompilerPreferences getCompilerPreferences() {
return plugin.getPreferences().getCompilerPreferences(getCompilerDefinition(), getHardware());
return getLanguagePreferences().getCompilerPreferences(getCompilerDefinition(), getHardware());
}
/**

View File

@ -37,7 +37,7 @@ public final class LanguageEditorCompileAndRunCommandMenu extends WorkbenchWindo
public LanguageEditorCompileAndRunCommandMenu() {
if (System.getProperty("user.name").equals("JAC")) {
new Exception("JAC! Test for Startup!").printStackTrace();
// new Exception("JAC! Test for Startup!").printStackTrace();
}
}

View File

@ -56,8 +56,10 @@ import com.wudsn.ide.base.common.MarkerUtility;
import com.wudsn.ide.base.common.NumberUtility;
import com.wudsn.ide.base.common.ProcessWithLogs;
import com.wudsn.ide.base.common.StringUtility;
import com.wudsn.ide.base.common.TextUtility;
import com.wudsn.ide.base.hardware.Hardware;
import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.LanguageUtility;
import com.wudsn.ide.lng.HardwareUtility;
import com.wudsn.ide.lng.Texts;
import com.wudsn.ide.lng.breakpoint.LanguageBreakpoint;
@ -246,20 +248,23 @@ final class LanguageEditorCompileCommand {
}
// Get and check path to compiler executable.
String compilerExecutablePath = plugin.getPreferences().getCompilerExecutablePath(compilerDefinition.getId());
String compilerDefinitionText = LanguageUtility.getCompilerTextLower(compilerDefinition.getLanguage());
String compilerPreferencesText = LanguageUtility.getCompilerPreferencesText(compilerDefinition.getLanguage());
String compilerExecutablePath = languageEditor.getLanguagePreferences()
.getCompilerExecutablePath(compilerDefinition.getId());
if (StringUtility.isEmpty(compilerExecutablePath)) {
// ERROR: Path to '{0}' compiler executable is not set in the
// preferences.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E100,
compilerDefinition.getName());
// ERROR: Path to '{0}' {1} executable is not set in the '{2}' preferences.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E100, compilerDefinitionText,
compilerDefinition.getName(), compilerPreferencesText);
return false;
}
File compilerExecutableFile = new File(compilerExecutablePath);
if (!compilerExecutableFile.exists()) {
// Path to '{0}' compiler executable in the preferences points
// to non-existing file '{1}'.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E103, compilerDefinition.getName(),
compilerExecutablePath);
// ERROR: Path to '{0}' {1} executable in the {2} preferences points to
// non-existing file '{3}'.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E103, compilerDefinitionText,
compilerDefinition.getName(), compilerPreferencesText, compilerExecutablePath);
return false;
}
@ -278,9 +283,10 @@ final class LanguageEditorCompileCommand {
compilerParameters = compilerParameters.trim();
String compilerParameterArray[] = compilerParameters.split(" ");
if (compilerParameterArray.length == 0) {
// ERROR: The compiler '{0}' does not specify default
// ERROR: The {0} '{1}' does not specify default
// parameters.
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E101);
createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E101, compilerDefinitionText,
compilerDefinition.getId());
return false;
}
@ -716,7 +722,7 @@ final class LanguageEditorCompileCommand {
});
String positioningMode = plugin.getPreferences().getEditorCompileCommandPositioningMode();
String positioningMode = languageEditor.getLanguagePreferences().getEditorCompileCommandPositioningMode();
boolean ignoreWarnings = positioningMode.equals(LanguageEditorCompileCommandPositioningMode.FIRST_ERROR);
IMarker firstWarningMarker = null;
IMarker firstErrorMarker = null;

View File

@ -33,6 +33,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.compiler.CompilerDefinition;
import com.wudsn.ide.lng.compiler.CompilerHelp.HelpDocument;
import com.wudsn.ide.lng.preferences.LanguagePreferences;
/**
@ -57,12 +58,17 @@ public final class LanguageEditorCompilerHelpCommandHandler extends AbstractHand
languageEditor = (LanguageEditor) editor;
CompilerDefinition compilerDefinition = languageEditor.getCompilerDefinition();
LanguagePreferences languagePreferences = LanguagePlugin.getInstance().getPreferences();
LanguagePreferences languagePreferences = languageEditor.getLanguagePreferences();
String compilerExecutablePath = languagePreferences.getCompilerExecutablePath(compilerDefinition.getId());
try {
File file = compilerDefinition.getHelpFile(compilerExecutablePath);
Program.launch(file.getPath());
HelpDocument helpDocument = compilerDefinition.getHelpForCurrentLocale(compilerExecutablePath);
if (helpDocument.file != null) {
Program.launch(helpDocument.file.getPath());
} else {
Program.launch(helpDocument.uri.toString());
}
} catch (CoreException ex) {
// ERROR: Display text from core exception.

View File

@ -25,7 +25,6 @@ import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.Token;
import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.preferences.LanguagePreferences;
import com.wudsn.ide.lng.preferences.TextAttributeConverter;
@ -37,28 +36,32 @@ import com.wudsn.ide.lng.preferences.TextAttributeConverter;
*/
final class LanguageRuleBasedScanner extends RuleBasedScanner {
/** Default Token for the text attributes * */
private Token defaultToken;
/** Key for preference store * */
// Key for preference store
private LanguagePreferences languagePreferences;
private String preferencesKey;
// Default Token for the text attributes
private Token defaultToken;
/**
* Creates a new instance. Called by {@link LanguageSourceViewerConfiguration}.
*
* @param preferencesKey The preference key to listen to for text attribute
* changes, not <code>null</code>..
* @param languagePreferences The language preferences, not <code>null</code>.
* @param preferencesKey The preference key to listen to for text attribute
* changes, not <code>null</code>.
*/
LanguageRuleBasedScanner(String preferencesKey) {
LanguageRuleBasedScanner(LanguagePreferences languagePreferences, String preferencesKey) {
if (languagePreferences == null) {
throw new IllegalArgumentException("Parameter 'language' must not be null.");
}
if (preferencesKey == null) {
throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null.");
}
this.languagePreferences = languagePreferences;
this.preferencesKey = preferencesKey;
LanguagePreferences preferences = LanguagePlugin.getInstance().getPreferences();
defaultToken = new Token(preferences.getEditorTextAttribute(preferencesKey));
defaultToken = new Token(languagePreferences.getEditorTextAttribute(preferencesKey));
super.setDefaultReturnToken(defaultToken);
}
@ -88,7 +91,8 @@ final class LanguageRuleBasedScanner extends RuleBasedScanner {
throw new IllegalArgumentException("Parameter 'changedPropertyNames' must not be null.");
}
boolean refresh = false;
if (changedPropertyNames.contains(preferencesKey)) {
if (preferences.getLanguage().equals(languagePreferences.getLanguage())
&& changedPropertyNames.contains(preferencesKey)) {
TextAttributeConverter.dispose((TextAttribute) defaultToken.getData());
defaultToken.setData(preferences.getEditorTextAttribute(preferencesKey));
refresh = true;

View File

@ -433,7 +433,7 @@ final class LanguageSourceScanner extends RuleBasedScanner {
}
LanguagePreferences preferences;
Token token;
preferences = editor.getPlugin().getPreferences();
preferences = editor.getLanguagePreferences();
token = new Token(preferences.getEditorTextAttribute(textAttributeName));
tokens.put(textAttributeName, token);
return token;

View File

@ -81,8 +81,7 @@ final class LanguageSourceViewerConfiguration extends TextSourceViewerConfigurat
/**
* Creates a new instance. Called by {@link LanguageEditor#initializeEditor()}.
*
* @param editor The underlying language editor, not
* <code>null</code>.
* @param editor The underlying language editor, not <code>null</code>.
*
* @param preferenceStore The preferences store, not <code>null</code>.
*/
@ -154,8 +153,7 @@ final class LanguageSourceViewerConfiguration extends TextSourceViewerConfigurat
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
assistant.setContentAssistProcessor(new LanguageContentAssistProcessor(editor),
IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContentAssistProcessor(new LanguageContentAssistProcessor(editor), IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
assistant.enableAutoActivation(true);
assistant.enableAutoInsert(true);
@ -173,19 +171,22 @@ final class LanguageSourceViewerConfiguration extends TextSourceViewerConfigurat
PresentationReconciler reconciler = new PresentationReconciler();
DefaultDamagerRepairer dr;
commentSingleScanner = new LanguageRuleBasedScanner(
LanguagePreferences languagePreferences = editor.getLanguagePreferences();
commentSingleScanner = new LanguageRuleBasedScanner(languagePreferences,
LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT);
dr = new DefaultDamagerRepairer(commentSingleScanner);
reconciler.setDamager(dr, CompilerSourcePartitionScanner.PARTITION_COMMENT_SINGLE);
reconciler.setRepairer(dr, CompilerSourcePartitionScanner.PARTITION_COMMENT_SINGLE);
commentMultipleScanner = new LanguageRuleBasedScanner(
commentMultipleScanner = new LanguageRuleBasedScanner(languagePreferences,
LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT);
dr = new DefaultDamagerRepairer(commentMultipleScanner);
reconciler.setDamager(dr, CompilerSourcePartitionScanner.PARTITION_COMMENT_MULTIPLE);
reconciler.setRepairer(dr, CompilerSourcePartitionScanner.PARTITION_COMMENT_MULTIPLE);
stringScanner = new LanguageRuleBasedScanner(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_STRING);
stringScanner = new LanguageRuleBasedScanner(languagePreferences,
LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_STRING);
dr = new DefaultDamagerRepairer(stringScanner);
reconciler.setDamager(dr, CompilerSourcePartitionScanner.PARTITION_STRING);
reconciler.setRepairer(dr, CompilerSourcePartitionScanner.PARTITION_STRING);

View File

@ -25,9 +25,11 @@ 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;
import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase;
import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode;
/**
* Facade class for typed access to the plugin preferences.
*
@ -38,35 +40,29 @@ public final class LanguagePreferences {
/**
* The preference store to which all calls are delegated.
*/
private IPreferenceStore preferenceStore;
private LanguagesPreferences languagesPreferences;
private Language language;
/**
* Created by {@link AbstractIDEPlugin} only.
*
* @param preferenceStore The preference store, not <code>null</code>.
* @param languagesPreferences The languages preferences, not <code>null</code>.
*/
public LanguagePreferences(IPreferenceStore preferenceStore) {
if (preferenceStore == null) {
throw new IllegalArgumentException("Parameter 'preferenceStore' must not be null.");
public LanguagePreferences(LanguagesPreferences languagesPreferences, Language language) {
if (languagesPreferences == null) {
throw new IllegalArgumentException("Parameter 'languagesPreferences' must not be null.");
}
this.preferenceStore = preferenceStore;
if (language == null) {
throw new IllegalArgumentException("Parameter 'language' must not be null.");
}
this.languagesPreferences = languagesPreferences;
this.language = language;
}
/**
* Gets the text attribute for a token type.
*
* @param name The name of the preferences for the token type, see
* {@link LanguagePreferencesConstants}.
*
* @return The text attribute, not <code>null</code>.
*/
public TextAttribute getEditorTextAttribute(String name) {
if (name == null) {
throw new IllegalArgumentException("Parameter 'name' must not be null.");
}
return TextAttributeConverter.fromString(preferenceStore.getString(name));
public Language getLanguage() {
return language;
}
/**
* Gets the default case content assist.
*
@ -109,9 +105,10 @@ public final class LanguagePreferences {
/**
* Gets the preferences for a compiler.
*
* @param compilerDefinition The compiler definition, not empty and not <code>null</code>.
* @param hardware The preferences or <code>null</code> if the compiler is not
* active for that hardware.
* @param compilerDefinition The compiler definition, not empty and not
* <code>null</code>.
* @param hardware The preferences or <code>null</code> if the
* compiler is not active for that hardware.
*
* @return The compiler preferences, not <code>null</code>.
*/
@ -127,6 +124,21 @@ public final class LanguagePreferences {
}
/**
* Gets the current value of the boolean preference with the given name. Returns
* the default value <code>false</code> if there is no preference with the given
* name, or if the current value cannot be treated as a boolean.
*
* @param name The name of the preference, not <code>null</code>.
* @return The preference value.
*/
boolean getBoolean(String name) {
if (name == null) {
throw new IllegalArgumentException("Parameter 'name' must not be null.");
}
return languagesPreferences.getBoolean(language.name() + "." + name);
}
/**
* Gets the current value of the string-valued preference with the given name.
* Returns the default-default value (the empty string <code>""</code> ) if
@ -138,32 +150,25 @@ public final class LanguagePreferences {
*/
String getString(String name) {
if (name == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null.");
throw new IllegalArgumentException("Parameter 'name' must not be null.");
}
String result;
result = preferenceStore.getString(name);
if (result == null) {
result = "";
} else {
result = result.trim();
}
return result;
return languagesPreferences.getString(language.name() + "." + name);
}
/**
* Gets the current value of the boolean preference with the given name. Returns
* the default-default value <code>false</code> if there is no preference with
* the given name, or if the current value cannot be treated as a boolean.
* Gets the text attribute for a token type.
*
* @param name The name of the preference, not <code>null</code>.
* @return The preference value.
* @param name The name of the preferences for the token type, see
* {@link LanguagePreferencesConstants}.
*
* @return The text attribute, not <code>null</code>.
*/
boolean getBoolean(String name) {
public TextAttribute getEditorTextAttribute(String name) {
if (name == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null.");
throw new IllegalArgumentException("Parameter 'name' must not be null.");
}
return preferenceStore.getBoolean(name);
return languagesPreferences.getEditorTextAttribute(language.name() + "." + name);
}
}

View File

@ -457,7 +457,7 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
throw new IllegalArgumentException("Parameter 'tab' must not be null.");
}
LanguagePreferences languagePreferences = plugin.getPreferences();
LanguagePreferences languagePreferences = plugin.getLanguagePreferences(language);
boolean enabled = StringUtility.isSpecified(languagePreferences.getCompilerExecutablePath(tab.compilerId));

View File

@ -507,7 +507,7 @@ public abstract class LanguagePreferencesPage extends FieldEditorPreferencePage
public boolean performOk() {
if (super.performOk()) {
saveChanges();
plugin.firePreferencesChangeEvent(changedPropertyNames);
plugin.firePreferencesChangeEvent(language, changedPropertyNames);
return true;
}
return false;

View File

@ -0,0 +1,130 @@
/**
* Copyright (C) 2009 - 2021 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wudsn.ide.lng.preferences;
import org.eclipse.jface.preference.IPreferenceStore;
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;
import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase;
import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode;
/**
* Facade class for typed access to the plugin preferences.
*
* @author Peter Dell
*/
public final class LanguagesPreferences {
/**
* The preference store to which all calls are delegated.
*/
private IPreferenceStore preferenceStore;
/**
* Created by {@link AbstractIDEPlugin} only.
*
* @param preferenceStore The preference store, not <code>null</code>.
*/
public LanguagesPreferences(IPreferenceStore preferenceStore) {
if (preferenceStore == null) {
throw new IllegalArgumentException("Parameter 'preferenceStore' must not be null.");
}
this.preferenceStore = preferenceStore;
}
/**
* Gets the preferences for a language.
*
* @param language The language, not <code>null</code>.
*
* @return The language preferences, not <code>null</code>.
*/
public LanguagePreferences getLanguagePreferences(Language language) {
if (language == null) {
throw new IllegalArgumentException("Parameter 'language' must not be null.");
}
return new LanguagePreferences(this, language);
}
/**
* Gets the current value of the boolean preference with the given name. Returns
* the default-default value <code>false</code> if there is no preference with
* the given name, or if the current value cannot be treated as a boolean.
*
* @param name The name of the preference, not <code>null</code>.
* @return The preference value.
*/
boolean getBoolean(String name) {
if (name == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null.");
}
return preferenceStore.getBoolean(name);
}
/**
* Gets the current value of the string-valued preference with the given name.
* Returns the default-default value (the empty string <code>""</code> ) if
* there is no preference with the given name, or if the current value cannot be
* treated as a string.
*
* @param name The name of the preference, not <code>null</code>.
* @return The preference value, may be empty, not <code>null</code>.
*/
String getString(String name) {
if (name == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null.");
}
String result;
result = preferenceStore.getString(name);
if (result == null) {
result = "";
} else {
result = result.trim();
}
return result;
}
/**
* Gets the text attribute for a token type.
*
* @param name The name of the preferences for the token type, see
* {@link LanguagePreferencesConstants}.
*
* @return The text attribute, not <code>null</code>.
*/
TextAttribute getEditorTextAttribute(String name) {
if (name == null) {
throw new IllegalArgumentException("Parameter 'name' must not be null.");
}
return TextAttributeConverter.fromString(preferenceStore.getString(name));
}
}

View File

@ -18,6 +18,20 @@
*/
package com.wudsn.ide.lng.pas.compiler.mp;
public class MadPascalCompiler {
import com.wudsn.ide.lng.compiler.Compiler;
import com.wudsn.ide.lng.compiler.CompilerProcessLogParser;
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
public class MadPascalCompiler extends Compiler {
@Override
public CompilerSourceParser createSourceParser() {
return new MadPascalCompilerSourceParser();
}
@Override
public CompilerProcessLogParser createLogParser() {
return new MadPascalCompilerProcessLogParser();
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<instructionset
completionProposalAutoActivationCharacters=".#"
singleLineCommentDelimiters="//"
multipleLinesCommentDelimiters="{ } (* *)"
stringDelimiterCharacters="'"
blockDefinitionCharacters=""
identifiersCaseSensitive="false"
identifierStartCharacters="_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
identifierPartCharacters="_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
identifierSeparatorCharacter="."
labelDefinitionSuffixCharacter=""
macroUsagePrefixCharacter=""
instructionsCaseSensitive="false"
sourceIncludeDefaultExtension="pas">
</instructionset>

View File

@ -0,0 +1,59 @@
/**
* Copyright (C) 2009 - 2021 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wudsn.ide.lng.pas.compiler.mp;
import java.io.BufferedReader;
import java.io.StringReader;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import com.wudsn.ide.lng.compiler.CompilerProcessLogParser;
import com.wudsn.ide.lng.compiler.CompilerSymbol;
/**
* Process log parser for {@link MadsCompiler}.
*
* @author Peter Dell
*/
final class MadPascalCompilerProcessLogParser extends CompilerProcessLogParser {
private BufferedReader bufferedReader;
@Override
protected void initialize() {
bufferedReader = new BufferedReader(new StringReader(outputLog));
}
@Override
protected void findNextMarker() {
}
@Override
public void addCompilerSymbols(List<CompilerSymbol> compilerSymbols) throws CoreException {
if (compilerSymbols == null) {
throw new IllegalArgumentException("Parameter 'compilerSymbols' must not be null.");
}
}
}

View File

@ -0,0 +1,70 @@
/**
* Copyright (C) 2009 - 2021 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
*
* This file is part of WUDSN IDE.
*
* WUDSN IDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* WUDSN IDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
*/
package com.wudsn.ide.lng.pas.compiler.mp;
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
/**
* Source parser for {@link MadsCompiler}.
*
* @author Peter Dell
*/
final class MadPascalCompilerSourceParser extends CompilerSourceParser {
@Override
protected void parseLine(int startOffset, String symbol, int symbolOffset, String instruction,
int instructionOffset, String operand, String comment) {
// if (symbol.length() > 0) {
//
// if (instruction.equals("=") || instruction.equals("EQU")) {
// createEquateDefinitionChild(startOffset, startOffset + symbolOffset, symbol, operand, comment);
//
// } else {
// createLabelDefinitionChild(startOffset, startOffset + symbolOffset, symbol, comment);
// }
//
// } // Symbol not empty
//
// // TODO Make .VAR an own type of instruction
// if (instruction.equals(".VAR") || instruction.equals(".ZPVAR")) {
// operand = operand.trim();
// int index = operand.indexOf('=');
// String variable;
// String value;
// if (index < 0) {
// variable = operand;
// value = "";
// } else {
// variable = operand.substring(0, index).trim();
// value = operand.substring(index).trim();
// if (value.startsWith("=")) {
// value = value.substring(1).trim();
// }
// }
// if (value.length() > 0) {
// createEquateDefinitionChild(startOffset, startOffset + instructionOffset, variable, value, comment);
// } else {
// createLabelDefinitionChild(startOffset, startOffset + instructionOffset, variable, comment);
// }
//
// }
}
}

View File

@ -125,7 +125,7 @@ public interface SoundInfo {
public int getPlayerAddress();
/**
* Gets the music address or <code>-1</code> if the moduls type does not have
* Gets the music address or <code>-1</code> if the module type does not have
* one.
*
* @return TODO