Transform string helpDocumentsPath to sequence of element helpDocument

This commit is contained in:
peterdell 2021-09-28 01:19:16 +02:00
parent fedec9d2f0
commit 457f773b53
11 changed files with 280 additions and 197 deletions

View File

@ -55,7 +55,6 @@
class="com.wudsn.ide.lng.asm.compiler.acme.AcmeCompiler"
defaultHardware="C64"
defaultParameters="-f cbm -o ${outputFilePath} ${sourceFilePath} "
helpDocumentPaths="./docs"
homePageURL="https://sourceforge.net/projects/acme-crossass"
id="acme"
language="ASM"
@ -73,13 +72,16 @@
<supportedTarget
target="MOS65816">
</supportedTarget>
<helpDocument
language="*"
path="./docs">
</helpDocument>
</compiler>
<compiler
class="com.wudsn.ide.lng.asm.compiler.asm6.Asm6Compiler"
defaultHardware="NES"
defaultParameters=" ${sourceFilePath} ${outputFilePath}"
helpDocumentPaths="./README.TXT"
homePageURL="http://3dscapture.com/NES/asm6.zip"
id="asm6"
language="ASM"
@ -91,12 +93,15 @@
<supportedTarget
target="MOS6502_ILLEGAL">
</supportedTarget>
<helpDocument
language="*"
path="./README.TXT">
</helpDocument>
</compiler>
<compiler
class="com.wudsn.ide.lng.asm.compiler.atasm.AtasmCompiler"
defaultHardware="ATARI8BIT"
defaultParameters="-s -o${outputFilePath} -l${outputFilePathWithoutExtension}.lab ${sourceFilePath}"
helpDocumentPaths="./docs/atasm.pdf"
homePageURL="http://atari.miribilist.com/atasm"
id="atasm"
language="ASM"
@ -108,12 +113,15 @@
<supportedTarget
target="MOS6502_ILLEGAL">
</supportedTarget>
<helpDocument
language="*"
path="./docs/atasm.pdf">
</helpDocument>
</compiler>
<compiler
class="com.wudsn.ide.lng.asm.compiler.dasm.DasmCompiler"
defaultHardware="ATARI2600"
defaultParameters="${sourceFilePath} -o${outputFilePath} -f3 -v5 -s${outputFilePathWithoutExtension}.sym -l${outputFilePathWithoutExtension}.lst"
helpDocumentPaths="../doc/dasm.TXT"
homePageURL="http://dasm-dillon.sourceforge.net"
id="dasm"
language="ASM"
@ -125,12 +133,15 @@
<supportedTarget
target="MOS6502_ILLEGAL">
</supportedTarget>
<helpDocument
language="*"
path="../doc/DASM.TXT">
</helpDocument>
</compiler>
<compiler
class="com.wudsn.ide.lng.asm.compiler.kickass.KickAssCompiler"
defaultHardware="C64"
defaultParameters="-o ${outputFilePath} ${sourceFilePath} "
helpDocumentPaths="./KickAssembler.pdf"
homePageURL="http://www.theweb.dk/KickAssembler"
id="kickass"
language="ASM"
@ -145,12 +156,15 @@
<supportedTarget
target="MOS6502_DTV">
</supportedTarget>
<helpDocument
language="*"
path="./KickAssembler.pdf">
</helpDocument>
</compiler>
<compiler
class="com.wudsn.ide.lng.asm.compiler.mads.MadsCompiler"
defaultHardware="ATARI8BIT"
defaultParameters=" ${sourceFilePath} -o:${outputFilePath} -p -t:${outputFilePathWithoutExtension}.lab -l:${outputFilePathWithoutExtension}.lst "
helpDocumentPaths="./doc/mads-eng.html, ./doc/mads-en.html (en), ./doc/mads.html (pl)"
homePageURL="http://mads.atari8.info"
id="mads"
language="ASM"
@ -165,12 +179,23 @@
<supportedTarget
target="MOS65816">
</supportedTarget>
<helpDocument
language="*"
path="./doc/mads-eng.html">
</helpDocument>
<helpDocument
language="en"
path="./doc/mads-en.html">
</helpDocument>
<helpDocument
language="pl"
path="./doc/mads.html">
</helpDocument>
</compiler>
<compiler
class="com.wudsn.ide.lng.asm.compiler.merlin32.Merlin32Compiler"
defaultHardware="APPLE2"
defaultParameters="-V ${sourceFilePath}"
helpDocumentPaths="../Documentation/Merlin32.pdf"
homePageURL="http://www.brutaldeluxe.fr/products/crossdevtools/merlin/index.html"
id="merlin32"
language="ASM"
@ -185,12 +210,15 @@
<supportedTarget
target="MOS65816">
</supportedTarget>
<helpDocument
language="*"
path="../Documentation/Merlin32.pdf">
</helpDocument>
</compiler>
<compiler
class="com.wudsn.ide.lng.asm.compiler.tass.TassCompiler"
defaultHardware="C64"
defaultParameters="-o ${outputFilePath} ${sourceFilePath} "
helpDocumentPaths="./README"
homePageURL="http://tass64.sourceforge.net"
id="tass"
language="ASM"
@ -205,13 +233,16 @@
<supportedTarget
target="MOS65C02">
</supportedTarget>
<helpDocument
language="*"
path="./README">
</helpDocument>
</compiler>
<compiler
class="com.wudsn.ide.lng.asm.compiler.xasm.XasmCompiler"
defaultHardware="ATARI8BIT"
defaultParameters="/o:${outputFilePath} /p /t:${outputFilePathWithoutExtension}.lab /l:${outputFilePathWithoutExtension}.lst ${sourceFilePath}"
helpDocumentPaths="./xasm.html"
homePageURL="https://github.com/pfusik/xasm"
id="xasm"
language="ASM"
@ -220,6 +251,10 @@
<supportedTarget
target="MOS6502">
</supportedTarget>
<helpDocument
language="*"
path="./xasm.html">
</helpDocument>
</compiler>
</extension>

View File

@ -2,46 +2,104 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="com.wudsn.ide.lng" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<appinfo>
<meta.schema plugin="com.wudsn.ide.lng" id="compilers" name="Compilers"/>
</appInfo>
</appinfo>
<documentation>
This extension point allows for adding new assemblers and compilers to the WUDSN IDE.
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<element name="supportedTarget">
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="compiler"/>
</sequence>
<attribute name="point" type="string" use="required">
<attribute name="target" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="MOS6502">
</enumeration>
<enumeration value="MOS6502_ILLEGAL">
</enumeration>
<enumeration value="MOS65C02">
</enumeration>
<enumeration value="MOS6502_DTV">
</enumeration>
<enumeration value="MOS65816">
</enumeration>
<enumeration value="PASCAL">
</enumeration>
</restriction>
</simpleType>
</attribute>
<attribute name="id" type="string">
</complexType>
</element>
<element name="helpDocument">
<complexType>
<attribute name="path" type="string" use="required">
<annotation>
<documentation>
Relative path of the help document or help folder, relative to the folder of the executables.
Or absolute URL starting with &quot;http://&quot; or &quot;https://&quot;.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<attribute name="language" type="string">
<annotation>
<documentation>
The 2 letter &quot;de&quot; or 5 letter &quot;de_DE&quot; representation of the language of the document.
Use &quot;*&quot; is the entry is valid for all languages
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="executable">
<complexType>
<attribute name="os" use="required">
<annotation>
<documentation>
OSGI OS value as described in org.eclipse.core.runtime.Platform
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="OS_MACOSX">
</enumeration>
<enumeration value="OS_LINUX">
</enumeration>
<enumeration value="OS_WIN32">
</enumeration>
</restriction>
</simpleType>
</attribute>
<attribute name="osArch" use="required">
<annotation>
<documentation>
OSGI OS archiecture value as described in org.eclipse.core.runtime.Platform
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="ARCH_X86">
</enumeration>
<enumeration value="ARCH_X86_64">
</enumeration>
<enumeration value="ARCH_PPC">
</enumeration>
</restriction>
</simpleType>
</attribute>
<attribute name="path" type="string" use="required">
<annotation>
<documentation>
Relative path of the executable inside the base folder
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
@ -54,6 +112,10 @@
<element ref="supportedTarget" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<sequence>
<element ref="helpDocument" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<sequence>
<element ref="executable" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</choice>
<attribute name="language" use="required">
@ -83,9 +145,9 @@
<documentation>
Translatable name of the compiler. Typically contains only upper case letters.
</documentation>
<appInfo>
<appinfo>
<meta.attribute translatable="true"/>
</appInfo>
</appinfo>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
@ -93,9 +155,9 @@
<documentation>
The name of the compiler class.
</documentation>
<appInfo>
<appinfo>
<meta.attribute kind="java" basedOn="com.wudsn.ide.lng.compiler.Compiler:"/>
</appInfo>
</appinfo>
</annotation>
</attribute>
<attribute name="version" type="string" use="required">
@ -112,17 +174,6 @@
</documentation>
</annotation>
</attribute>
<attribute name="helpDocumentPaths" type="string">
<annotation>
<documentation>
The relative paths to the local help documents.
Multiple paths are separated by comma.
Adding a language constraint in parentheses like &quot;./doc-de.html (de)&quot; acts as filter.
Each file path is evluated based on the absolute path of the compiler executable in the preferences.
Alternatively abolute URLs to web sites can be specified. They are used, if not file paths match.
</documentation>
</annotation>
</attribute>
<attribute name="defaultParameters" type="string" use="required">
<annotation>
<documentation>
@ -158,38 +209,47 @@ Alternatively abolute URLs to web sites can be specified. They are used, if not
</complexType>
</element>
<element name="supportedTarget">
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<attribute name="target">
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="compiler"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="MOS6502">
</enumeration>
<enumeration value="MOS6502_ILLEGAL">
</enumeration>
<enumeration value="MOS65C02">
</enumeration>
<enumeration value="MOS6502_DTV">
</enumeration>
<enumeration value="MOS65816">
</enumeration>
<enumeration value="PASCAL">
</enumeration>
</restriction>
</simpleType>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<appinfo>
<meta.section type="since"/>
</appInfo>
</appinfo>
<documentation>
WUDSN IDE 1.1.0
</documentation>
@ -197,9 +257,9 @@ Alternatively abolute URLs to web sites can be specified. They are used, if not
<annotation>
<appInfo>
<appinfo>
<meta.section type="apiinfo"/>
</appInfo>
</appinfo>
<documentation>
To implement this extension point, you have to create a sub-class of com.wudsn.ide.lng.compiler.Compiler, a sub-class of com.wudsn.ide.lng.compiler.parser.CompilerSourceParser and a sub-class of com.wudsn.ide.lng.compiler.CompilerLogParser. In the constructor of the compiler you have to set the source parser instance. In the &quot;createLogParser&quot; method of the compiler you have to create a new instance of the corresponding log parser.
</documentation>
@ -207,9 +267,9 @@ Alternatively abolute URLs to web sites can be specified. They are used, if not
<annotation>
<appInfo>
<appinfo>
<meta.section type="copyright"/>
</appInfo>
</appinfo>
<documentation>
(c) 2009 Peter Dell
</documentation>

View File

@ -167,7 +167,7 @@ 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 {0} '{1}' does not specify help document paths.
MESSAGE_E102=The {0} '{1}' does not specify help documents.
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}
@ -196,7 +196,7 @@ MESSAGE_E127={0} process ended with return code {1}. Check the error messages an
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 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_E131=Help for the '{0}' {1} cannot be displayed because no help file was found in the paths relative to the executable path '{2}'.
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

@ -165,7 +165,7 @@ 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 {0} '{1}' definiert keine Standardparameter.
MESSAGE_E102=Der {0} '{1}' definiert keine Pfade zu Hilfedokumenten.
MESSAGE_E102=Der {0} '{1}' definiert keine Hilfedokumentes.
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}
@ -193,8 +193,8 @@ MESSAGE_E126=Ausgabe-Datei erzeugt is aber leer. Pr
MESSAGE_E127=Kompilerprozess endete mit dem Rückgabewert {0}. Prüfen Sie die Fehlermeldungen und die Konsolenausgabe.
MESSAGE_E128=Hardware nicht angegeben. Gültige Werte sind '{0}'.
MESSAGE_E129=Haupt-Quell-Datei spezifiziert oder verwendet die Hardware '{0}' während die Include-Quell-Datei die Hardware '{1}' spezifiziert oder verwendet.
MESSAGE_E130=Handbuch zum Kompiler '{0}' kann nicht angezeigt werden, da der Pfad zur ausführbaren Datei des Kompilers in den Voreinstellungen nicht angegeben ist.
MESSAGE_E131=Handbuch zum Kompiler '{0}' kann nicht angezeigt werden, da keine Hilfe-Datei in den Pfaden '{1}' relativ zur ausführbaren Datei '{2}' des Kompilers gefunden wurde.
MESSAGE_E130=Handbuch zum {0} '{1}' kann nicht angezeigt werden, da der Pfad zur ausführbaren Datei des Kompilers in den Voreinstellungen nicht angegeben ist.
MESSAGE_E131=Handbuch zum {0} '{1}' kann nicht angezeigt werden, da keine Hilfe-Datei in den Pfaden relativ zur ausführbaren Datei '{2}' des Kompilers gefunden wurde.
MESSAGE_E132=Disketten-Image-Datei '{0}' existiert nicht. Lege ein bootfähiges Disketten-Image an, auf dem die Ausgabe-Datei '{1}' gespeichert werden kann.
MESSAGE_E133=Disketten-Image-Datei '{0}' ist nicht schreibbar. Mache das Diskettenimage schreibbbar, damit die Ausgabe-Datei '{1}' gespeichert werden kann.
MESSAGE_E134=Disketten-Image-Datei '{0}' kann not nicht zum Lesen geöffnet werden. Systemfehler: {1}

View File

@ -34,7 +34,7 @@ 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.CompilerHelp.InstalledHelpDocument;
import com.wudsn.ide.lng.compiler.CompilerPaths.CompilerPath;
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
@ -47,6 +47,27 @@ import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
*/
public final class CompilerDefinition implements Comparable<CompilerDefinition> {
public final static class HelpDocument {
public final String path;
public final String language;
HelpDocument(String path, String language) {
if (path == null) {
throw new IllegalArgumentException("Parameter 'path' must not be null.");
}
if (language == null) {
throw new IllegalArgumentException("Parameter 'language' must not be null.");
}
this.path = path;
this.language = language;
}
public boolean isURL() {
return path.startsWith("http://") || path.startsWith("https://");
}
}
// Language
private Language language;
@ -56,7 +77,7 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
private String className;
// Installation and use.
private String helpDocumentPaths;
private List<HelpDocument> helpDocuments;
private String homePageURL;
// Editing and source parsing.
@ -240,40 +261,18 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
return homePageURL;
}
/**
* Sets the help file paths to locate the help file for the compiler. Called by
* {@link CompilerRegistry} only.
*
* @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 setHelpDocumentPaths(String helpDocumentPaths) {
if (helpDocumentPaths == null) {
helpDocumentPaths = "";
final void setHelpDocuments(List<HelpDocument> helpDocuments) {
if (helpDocuments == null) {
throw new IllegalArgumentException("Parameter 'helpDocuments' must not be null.");
}
this.helpDocumentPaths = helpDocumentPaths;
this.helpDocuments = helpDocuments;
}
/**
* Gets the help file paths to locate the help file for the compiler.
*
* @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 getHelpDocumentPaths() {
if (helpDocumentPaths == null) {
throw new IllegalStateException("Field 'helpDocumentPaths' must not be null.");
public List<HelpDocument> getHelpDocuments() {
if (helpDocuments == null) {
throw new IllegalStateException("Field 'helpDocuments' must not be null.");
}
return helpDocumentPaths;
return helpDocuments;
}
/**
@ -282,8 +281,8 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
* @return <code>true</code> if this compiler offers a help file,
* <code>false</code> otherwise.
*/
public final boolean hasHelpDocumentPaths() {
return StringUtility.isSpecified(helpDocumentPaths);
public final boolean hasHelpDocuments() {
return !helpDocuments.isEmpty();
}
/**
@ -298,13 +297,14 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
* does not specify a help path or no help file can be
* found.
*/
public final List<HelpDocument> getInstalledHelpDocuments(String compilerExecutablePath) throws CoreException {
private final List<InstalledHelpDocument> getInstalledHelpDocuments(String compilerExecutablePath)
throws CoreException {
if (compilerExecutablePath == null) {
throw new IllegalArgumentException("Parameter 'compilerExecutablePath' must not be null.");
}
String compilerText = LanguageUtility.getCompilerTextLower(language);
if (!hasHelpDocumentPaths()) {
// INFO: The {0} '{1}' does not specify help document paths.
if (!hasHelpDocuments()) {
// INFO: The {0} '{1}' does not specify help documents.
throw new CoreException(new Status(IStatus.INFO, LanguagePlugin.ID,
TextUtility.format(Texts.MESSAGE_E102, compilerText, name)));
}
@ -316,25 +316,22 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
TextUtility.format(Texts.MESSAGE_E130, name, compilerText, compilerPreferencesText)));
}
return getHelpDocuments(compilerExecutablePath);
return CompilerHelp.getInstalledHelpDocuments(getHelpDocuments(), compilerExecutablePath);
}
public final List<HelpDocument> getHelpDocuments(String compilerExecutablePath) {
return CompilerHelp.getHelpDocuments(helpDocumentPaths, compilerExecutablePath);
public final InstalledHelpDocument getInstalledHelpForCurrentLocale(String compilerExecutablePath)
throws CoreException {
}
var helpDocuments = getInstalledHelpDocuments(compilerExecutablePath);
public final HelpDocument getHelpForCurrentLocale(String compilerExecutablePath) throws CoreException {
List<HelpDocument> helpDocuments = getInstalledHelpDocuments(compilerExecutablePath);
String localeLanguage = Locale.getDefault().getLanguage();
var localeLanguage = Locale.getDefault().getLanguage();
// 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) {
InstalledHelpDocument firstFile = null;
InstalledHelpDocument firstLanguageFile = null;
for (var helpDocument : helpDocuments) {
if (helpDocument.file != null && helpDocument.file.exists()) {
if (firstFile == null) {
@ -347,14 +344,14 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
}
// Use language specific file if present, use first file otherwise.
HelpDocument result = firstLanguageFile;
var result = firstLanguageFile;
if (result == null) {
result = firstFile;
}
// No local file specified or found. Try the URIs.
if (result == null) {
for (HelpDocument helpDocument : helpDocuments) {
for (InstalledHelpDocument helpDocument : helpDocuments) {
if (helpDocument.uri != null) {
if (firstFile == null) {
firstFile = helpDocument;
@ -376,9 +373,9 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
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}'.
// found in the paths relative to the executable path '{2}'.
throw new CoreException(new Status(IStatus.ERROR, LanguagePlugin.ID, TextUtility.format(Texts.MESSAGE_E131,
name, LanguageUtility.getCompilerTextLower(language), helpDocumentPaths, compilerExecutablePath)));
name, LanguageUtility.getCompilerTextLower(language), compilerExecutablePath)));
}
return result;

View File

@ -24,10 +24,10 @@ 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;
import com.wudsn.ide.lng.compiler.CompilerDefinition.HelpDocument;
/**
* Compiler help access.
@ -37,43 +37,37 @@ import com.wudsn.ide.base.common.StringUtility;
* @since 1.7.2
*/
public final class CompilerHelp {
public static class HelpDocument {
public static class InstalledHelpDocument {
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>();
public static List<InstalledHelpDocument> getInstalledHelpDocuments(List<HelpDocument> list,
String compilerExecutablePath) {
var result = new ArrayList<CompilerHelp.InstalledHelpDocument>();
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;
for (var helpDocument : list) {
var installeHelpDocument = new InstalledHelpDocument();
installeHelpDocument.path = helpDocument.path;
installeHelpDocument.language = helpDocument.language;
// Relative paths are local files.
if (helpFilePath.startsWith(".") && StringUtility.isSpecified(compilerExecutablePath)) {
helpDocument.file = FileUtility
.getCanonicalFile(new File(new File(compilerExecutablePath).getParent(), helpFilePath));
if (installeHelpDocument.path.startsWith(".") && StringUtility.isSpecified(compilerExecutablePath)) {
installeHelpDocument.file = FileUtility.getCanonicalFile(
new File(new File(compilerExecutablePath).getParent(), installeHelpDocument.path));
} else {
try {
helpDocument.uri = new URI(helpFilePath);
installeHelpDocument.uri = new URI(installeHelpDocument.path);
} catch (URISyntaxException ex) {
throw new RuntimeException("Invalid URI for '" + helpFilePath + "' help file path", ex);
throw new RuntimeException("Invalid URI for '" + helpDocument.path + "' help file path", ex);
}
}
helpDocuments.add(helpDocument);
result.add(installeHelpDocument);
}
return helpDocuments;
return result;
}
}

View File

@ -36,6 +36,7 @@ import com.wudsn.ide.base.hardware.Hardware;
import com.wudsn.ide.lng.Language;
import com.wudsn.ide.lng.Target;
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
import com.wudsn.ide.lng.compiler.CompilerDefinition.HelpDocument;
/**
* Registry for compilers, based on the extension points
@ -97,18 +98,23 @@ public final class CompilerRegistry {
compilerDefinition.setId(configurationElement.getAttribute("id"));
compilerDefinition.setName(configurationElement.getAttribute("name"));
compilerDefinition.setClassName(configurationElement.getAttribute("class"));
compilerDefinition.setHelpDocumentPaths(configurationElement.getAttribute("helpDocumentPaths"));
var helpDocumentsArray = configurationElement.getChildren("helpDocument");
var helpDocuments = new ArrayList<HelpDocument>(helpDocumentsArray.length);
for (var helpDocument : helpDocumentsArray) {
helpDocuments.add(new HelpDocument(helpDocument.getAttribute("path"),
helpDocument.getAttribute("language")));
}
compilerDefinition.setHelpDocuments(Collections.unmodifiableList(helpDocuments));
compilerDefinition.setHomePageURL(configurationElement.getAttribute("homePageURL"));
compilerDefinition.setDefaultParameters(configurationElement.getAttribute("defaultParameters"));
IConfigurationElement[] supportedTargetsArray;
supportedTargetsArray = configurationElement.getChildren("supportedTarget");
List<Target> supportedTargets = new ArrayList<Target>(supportedTargetsArray.length);
for (IConfigurationElement supportedTarget : supportedTargetsArray) {
var supportedTargetsArray = configurationElement.getChildren("supportedTarget");
var supportedTargets = new ArrayList<Target>(supportedTargetsArray.length);
for (var supportedTarget : supportedTargetsArray) {
supportedTargets.add(Target.valueOf(supportedTarget.getAttribute("target")));
}
supportedTargets = Collections.unmodifiableList(supportedTargets);
compilerDefinition.setSupportedTargets(supportedTargets);
compilerDefinition.setSupportedTargets(Collections.unmodifiableList(supportedTargets));
compilerDefinition
.setDefaultHardware(Hardware.valueOf(configurationElement.getAttribute("defaultHardware")));

View File

@ -25,14 +25,8 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
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.CompilerPreferences;
/**
* Event handler for the "Compiler Help" command.
*
@ -42,24 +36,20 @@ public final class LanguageEditorCompilerHelpCommandHandler extends AbstractHand
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell;
shell = HandlerUtil.getActiveShell(event);
var shell = HandlerUtil.getActiveShell(event);
IEditorPart editor;
editor = HandlerUtil.getActiveEditorChecked(event);
var editor = HandlerUtil.getActiveEditorChecked(event);
if (!(editor instanceof LanguageEditor)) {
return null;
}
LanguageEditor languageEditor;
languageEditor = (LanguageEditor) editor;
CompilerDefinition compilerDefinition = languageEditor.getCompilerDefinition();
CompilerPreferences compilerPreferences = languageEditor.getCompilerPreferences();
String compilerExecutablePath = compilerPreferences.getCompilerExecutablePathOrDefault();
var languageEditor = (LanguageEditor) editor;
var compilerDefinition = languageEditor.getCompilerDefinition();
var compilerPreferences = languageEditor.getCompilerPreferences();
var compilerExecutablePath = compilerPreferences.getCompilerExecutablePathOrDefault();
try {
HelpDocument helpDocument = compilerDefinition.getHelpForCurrentLocale(compilerExecutablePath);
var helpDocument = compilerDefinition.getInstalledHelpForCurrentLocale(compilerExecutablePath);
if (helpDocument.file != null) {
Program.launch(helpDocument.file.getPath());
} else {

View File

@ -45,7 +45,6 @@ import org.eclipse.help.IHelpContentProducer;
import com.wudsn.ide.base.common.EnumUtility;
import com.wudsn.ide.base.common.HexUtility;
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.base.hardware.HardwareUtility;
import com.wudsn.ide.lng.Language;
@ -54,7 +53,6 @@ import com.wudsn.ide.lng.Target;
import com.wudsn.ide.lng.TargetUtility;
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.CompilerPaths.CompilerPath;
import com.wudsn.ide.lng.compiler.CompilerRegistry;
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
@ -314,8 +312,8 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
Hardware.GENERIC);
try {
HelpDocument helpDocDocument = compilerDefinition
.getHelpForCurrentLocale(compilerPreferences.getCompilerExecutablePathOrDefault());
var helpDocDocument = compilerDefinition
.getInstalledHelpForCurrentLocale(compilerPreferences.getCompilerExecutablePathOrDefault());
File file = helpDocDocument.file;
if (file == null) {
throw new RuntimeException(
@ -373,13 +371,13 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
writer.writeTableRow(Texts.TOC_COMPILER_HOME_PAGE_LABEL,
HTMLWriter.getLink(compilerDefinition.getHomePageURL(), compilerDefinition.getHomePageURL()));
List<HelpDocument> helpDocuments = compilerDefinition.getHelpDocuments("");
var helpDocuments = compilerDefinition.getHelpDocuments();
HTMLWriter innerWriter = new HTMLWriter(); // TODO: Breaks layout if there are no paths
if (!helpDocuments.isEmpty()) {
innerWriter.beginTable(false);
for (HelpDocument helpDocument : helpDocuments) {
for (var helpDocument : helpDocuments) {
innerWriter.beginTableRow();
if (helpDocument.uri != null) {
if (helpDocument.isURL()) {
innerWriter.writeTableCell(HTMLWriter.getLink(helpDocument.path, helpDocument.path));
} else {
innerWriter.writeTableCell(helpDocument.path);

View File

@ -45,10 +45,7 @@ import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.Target;
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;
/**
* Dynamic help content provider. Uses static pages and the meta data from the
@ -251,31 +248,30 @@ public final class LanguageTocProvider extends AbstractTocProvider {
if (compilerDefinitions == null) {
throw new IllegalArgumentException("Parameter 'compilerDefinitions' must not be null.");
}
int size = compilerDefinitions.size();
List<ITopic> compilerTopics = new ArrayList<ITopic>(size);
var size = compilerDefinitions.size();
var compilerTopics = new ArrayList<ITopic>(size);
for (int i = 0; i < size; i++) {
CompilerDefinition compilerDefinition = compilerDefinitions.get(i);
var compilerDefinition = compilerDefinitions.get(i);
String href = LanguageHelpContentProducer.getComplierHref(compilerDefinition,
var href = LanguageHelpContentProducer.getComplierHref(compilerDefinition,
LanguageHelpContentProducer.SECTION_GENERAL, null);
ITopic generalTopic = createTopic("", Texts.TOC_COMPILER_GENERAL_TOPIC_LABEL, href, null);
var generalTopic = createTopic("", Texts.TOC_COMPILER_GENERAL_TOPIC_LABEL, href, null);
href = LanguageHelpContentProducer.getComplierHref(compilerDefinition,
LanguageHelpContentProducer.SECTION_INSTRUCTIONS, null);
ITopic opcodesTopic = createTopic("", Texts.TOC_COMPILER_INSTRUCTIONS_TOPIC_LABEL, href, null);
var opcodesTopic = createTopic("", Texts.TOC_COMPILER_INSTRUCTIONS_TOPIC_LABEL, href, null);
LanguagePreferences languagePreferences = LanguagePlugin.getInstance()
var languagePreferences = LanguagePlugin.getInstance()
.getLanguagePreferences(compilerDefinition.getLanguage());
CompilerPreferences compilerPreferences = languagePreferences.getCompilerPreferences(compilerDefinition,
Hardware.GENERIC);
String compilerExecutablePath = compilerPreferences.getCompilerExecutablePathOrDefault();
var compilerPreferences = languagePreferences.getCompilerPreferences(compilerDefinition, Hardware.GENERIC);
var compilerExecutablePath = compilerPreferences.getCompilerExecutablePathOrDefault();
String icon = "";
List<ITopic> manualTopics = new ArrayList<ITopic>();
var icon = "";
var manualTopics = new ArrayList<ITopic>();
try {
HelpDocument helpDocument = compilerDefinition.getHelpForCurrentLocale(compilerExecutablePath);
var helpDocument = compilerDefinition.getInstalledHelpForCurrentLocale(compilerExecutablePath);
if (helpDocument.file != null) {
File file = helpDocument.file;
@ -327,7 +323,7 @@ public final class LanguageTocProvider extends AbstractTocProvider {
LanguageHelpContentProducer.SECTION_MANUAL, null);
}
ITopic manualTopic = createTopic(icon, Texts.TOC_COMPILER_MANUAL_TOPIC_LABEL, href,
var manualTopic = createTopic(icon, Texts.TOC_COMPILER_MANUAL_TOPIC_LABEL, href,
createTopicsArray(manualTopics));
compilerTopics.add(createTopic("", compilerDefinition.getName(), "",

View File

@ -112,7 +112,6 @@
class="com.wudsn.ide.lng.pas.compiler.mp.MadPascalCompiler"
defaultHardware="ATARI8BIT"
defaultParameters="${sourceFilePath} "
helpDocumentPaths="https://mads.atari8.info/doc/en/index.html, https://mads.atari8.info/doc/pl/index.html (pl)"
homePageURL="https://github.com/tebe6502/Mad-Pascal/releases"
id="MP"
language="PAS"
@ -120,6 +119,14 @@
version="1.6.5">
<supportedTarget
target="PASCAL"></supportedTarget>
<helpDocument
language="*"
path="https://mads.atari8.info/doc/en/index.html">
</helpDocument>
<helpDocument
language="pl"
path="https://mads.atari8.info/doc/pl/index.html">
</helpDocument>
</compiler>
</extension>