Simplify compiler classes and add MP Compiler

This commit is contained in:
peterdell 2021-09-26 16:05:27 +02:00
parent 11722d1939
commit d9b833c87e
24 changed files with 187 additions and 101 deletions

View File

@ -5,6 +5,7 @@ Bundle-SymbolicName: com.wudsn.ide.lng.asm.test;singleton:=true
Bundle-Version: 1.7.2.qualifier Bundle-Version: 1.7.2.qualifier
Bundle-Vendor: Peter Dell Bundle-Vendor: Peter Dell
Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: com.wudsn.ide.lng Require-Bundle: com.wudsn.ide.lng,
com.wudsn.ide.lng.asm
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Automatic-Module-Name: com.wudsn.ide.asm.compilers.test Automatic-Module-Name: com.wudsn.ide.asm.compilers.test

View File

@ -4,7 +4,7 @@
<extension <extension
point="org.eclipse.ui.preferencePages"> point="org.eclipse.ui.preferencePages">
<page <page
category="com.wudsn.ide.lng.preferences.AssemblerPreferencesPage" category="com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesPage"
class="com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesTestCompilersPage" class="com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesTestCompilersPage"
id="com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesTestCompilersPage" id="com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesTestCompilersPage"
name="%com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesTestCompilersPage.name"> name="%com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesTestCompilersPage.name">

View File

@ -11,8 +11,4 @@ public final class TestEditor extends LanguageEditor {
} }
@Override
public String getCompilerId() {
return "test";
}
} }

View File

@ -58,6 +58,7 @@
helpFilePaths="./docs" helpFilePaths="./docs"
homePageURL="https://sourceforge.net/projects/acme-crossass" homePageURL="https://sourceforge.net/projects/acme-crossass"
id="acme" id="acme"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.acme.AcmeCompiler.name" name="%com.wudsn.ide.lng.asm.compiler.acme.AcmeCompiler.name"
version="0.90 (preview)"> version="0.90 (preview)">
<supportedTarget <supportedTarget
@ -81,6 +82,7 @@
helpFilePaths="./README.TXT" helpFilePaths="./README.TXT"
homePageURL="http://3dscapture.com/NES/asm6.zip" homePageURL="http://3dscapture.com/NES/asm6.zip"
id="asm6" id="asm6"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.asm6.Asm6Compiler.name" name="%com.wudsn.ide.lng.asm.compiler.asm6.Asm6Compiler.name"
version="1.6"> version="1.6">
<supportedTarget <supportedTarget
@ -90,13 +92,14 @@
target="MOS6502_ILLEGAL"> target="MOS6502_ILLEGAL">
</supportedTarget> </supportedTarget>
</compiler> </compiler>
<compiler <compiler
class="com.wudsn.ide.lng.asm.compiler.atasm.AtasmCompiler" class="com.wudsn.ide.lng.asm.compiler.atasm.AtasmCompiler"
defaultHardware="ATARI8BIT" defaultHardware="ATARI8BIT"
defaultParameters="-s -o${outputFilePath} -l${outputFilePathWithoutExtension}.lab ${sourceFilePath}" defaultParameters="-s -o${outputFilePath} -l${outputFilePathWithoutExtension}.lab ${sourceFilePath}"
helpFilePaths="./docs/atasm.pdf" helpFilePaths="./docs/atasm.pdf"
homePageURL="http://atari.miribilist.com/atasm" homePageURL="http://atari.miribilist.com/atasm"
id="atasm" id="atasm"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.atasm.AtasmCompiler.name" name="%com.wudsn.ide.lng.asm.compiler.atasm.AtasmCompiler.name"
version="1.07"> version="1.07">
<supportedTarget <supportedTarget
@ -113,6 +116,7 @@
helpFilePaths="../doc/dasm.TXT" helpFilePaths="../doc/dasm.TXT"
homePageURL="http://dasm-dillon.sourceforge.net" homePageURL="http://dasm-dillon.sourceforge.net"
id="dasm" id="dasm"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.dasm.DasmCompiler.name" name="%com.wudsn.ide.lng.asm.compiler.dasm.DasmCompiler.name"
version="2.20.10 (preview)"> version="2.20.10 (preview)">
<supportedTarget <supportedTarget
@ -129,6 +133,7 @@
helpFilePaths="./KickAssembler.pdf" helpFilePaths="./KickAssembler.pdf"
homePageURL="http://www.theweb.dk/KickAssembler" homePageURL="http://www.theweb.dk/KickAssembler"
id="kickass" id="kickass"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.kickass.KickAssCompiler.name" name="%com.wudsn.ide.lng.asm.compiler.kickass.KickAssCompiler.name"
version="V3.21 (preview)"> version="V3.21 (preview)">
<supportedTarget <supportedTarget
@ -141,13 +146,14 @@
target="MOS6502_DTV"> target="MOS6502_DTV">
</supportedTarget> </supportedTarget>
</compiler> </compiler>
<compiler <compiler
class="com.wudsn.ide.lng.asm.compiler.mads.MadsCompiler" class="com.wudsn.ide.lng.asm.compiler.mads.MadsCompiler"
defaultHardware="ATARI8BIT" defaultHardware="ATARI8BIT"
defaultParameters=" ${sourceFilePath} -o:${outputFilePath} -p -t:${outputFilePathWithoutExtension}.lab -l:${outputFilePathWithoutExtension}.lst " defaultParameters=" ${sourceFilePath} -o:${outputFilePath} -p -t:${outputFilePathWithoutExtension}.lab -l:${outputFilePathWithoutExtension}.lst "
helpFilePaths="./doc/mads-en.html, ./doc/mads.html (pl)" helpFilePaths="./doc/mads-en.html, ./doc/mads.html (pl)"
homePageURL="http://mads.atari8.info" homePageURL="http://mads.atari8.info"
id="mads" id="mads"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.mads.MadsCompiler.name" name="%com.wudsn.ide.lng.asm.compiler.mads.MadsCompiler.name"
version="1.9.0"> version="1.9.0">
<supportedTarget <supportedTarget
@ -159,7 +165,7 @@
<supportedTarget <supportedTarget
target="MOS65816"> target="MOS65816">
</supportedTarget> </supportedTarget>
</compiler> </compiler>
<compiler <compiler
class="com.wudsn.ide.lng.asm.compiler.merlin32.Merlin32Compiler" class="com.wudsn.ide.lng.asm.compiler.merlin32.Merlin32Compiler"
defaultHardware="APPLE2" defaultHardware="APPLE2"
@ -167,6 +173,7 @@
helpFilePaths="../Documentation/Merlin32.pdf" helpFilePaths="../Documentation/Merlin32.pdf"
homePageURL="http://www.brutaldeluxe.fr/products/crossdevtools/merlin/index.html" homePageURL="http://www.brutaldeluxe.fr/products/crossdevtools/merlin/index.html"
id="merlin32" id="merlin32"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.merlin32.Merlin32Compiler.name" name="%com.wudsn.ide.lng.asm.compiler.merlin32.Merlin32Compiler.name"
version="1.0"> version="1.0">
<supportedTarget <supportedTarget
@ -186,6 +193,7 @@
helpFilePaths="./README" helpFilePaths="./README"
homePageURL="http://tass64.sourceforge.net" homePageURL="http://tass64.sourceforge.net"
id="tass" id="tass"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.tass.TassCompiler.name" name="%com.wudsn.ide.lng.asm.compiler.tass.TassCompiler.name"
version="1.46 r38 (preview)"> version="1.46 r38 (preview)">
<supportedTarget <supportedTarget
@ -199,13 +207,14 @@
</supportedTarget> </supportedTarget>
</compiler> </compiler>
<compiler <compiler
class="com.wudsn.ide.lng.asm.compiler.xasm.XasmCompiler" class="com.wudsn.ide.lng.asm.compiler.xasm.XasmCompiler"
defaultHardware="ATARI8BIT" defaultHardware="ATARI8BIT"
defaultParameters="/o:${outputFilePath} /p /t:${outputFilePathWithoutExtension}.lab /l:${outputFilePathWithoutExtension}.lst ${sourceFilePath}" defaultParameters="/o:${outputFilePath} /p /t:${outputFilePathWithoutExtension}.lab /l:${outputFilePathWithoutExtension}.lst ${sourceFilePath}"
helpFilePaths="./xasm.html" helpFilePaths="./xasm.html"
homePageURL="https://github.com/pfusik/xasm" homePageURL="https://github.com/pfusik/xasm"
id="xasm" id="xasm"
language="ASM"
name="%com.wudsn.ide.lng.asm.compiler.xasm.XasmCompiler.name" name="%com.wudsn.ide.lng.asm.compiler.xasm.XasmCompiler.name"
version="3.0.2"> version="3.0.2">
<supportedTarget <supportedTarget
@ -394,6 +403,6 @@
contentTypeId="com.wudsn.ide.lng.asm.compiler.xasm.XasmSourceFile"> contentTypeId="com.wudsn.ide.lng.asm.compiler.xasm.XasmSourceFile">
</contentTypeBinding> </contentTypeBinding>
</editor> </editor>
</extension> </extension>
</plugin> </plugin>

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.acme; package com.wudsn.ide.lng.asm.compiler.acme;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class AcmeEditor extends LanguageEditor { public final class AcmeEditor extends LanguageEditor {
@ -29,9 +28,4 @@ public final class AcmeEditor extends LanguageEditor {
*/ */
public AcmeEditor() { public AcmeEditor() {
} }
@Override
public String getCompilerId() {
return CompilerId.ACME;
}
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.asm6; package com.wudsn.ide.lng.asm.compiler.asm6;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class Asm6Editor extends LanguageEditor { public final class Asm6Editor extends LanguageEditor {
@ -30,8 +29,4 @@ public final class Asm6Editor extends LanguageEditor {
public Asm6Editor() { public Asm6Editor() {
} }
@Override
public String getCompilerId() {
return CompilerId.ASM6;
}
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.atasm; package com.wudsn.ide.lng.asm.compiler.atasm;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class AtasmEditor extends LanguageEditor { public final class AtasmEditor extends LanguageEditor {
@ -29,9 +28,4 @@ public final class AtasmEditor extends LanguageEditor {
*/ */
public AtasmEditor() { public AtasmEditor() {
} }
@Override
public String getCompilerId() {
return CompilerId.ATASM;
}
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.dasm; package com.wudsn.ide.lng.asm.compiler.dasm;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class DasmEditor extends LanguageEditor { public final class DasmEditor extends LanguageEditor {
@ -30,8 +29,4 @@ public final class DasmEditor extends LanguageEditor {
public DasmEditor() { public DasmEditor() {
} }
@Override
public String getCompilerId() {
return CompilerId.DASM;
}
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.kickass; package com.wudsn.ide.lng.asm.compiler.kickass;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class KickAssEditor extends LanguageEditor { public final class KickAssEditor extends LanguageEditor {
@ -31,8 +30,4 @@ public final class KickAssEditor extends LanguageEditor {
} }
@Override
public String getCompilerId() {
return CompilerId.KICKASS;
}
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.mads; package com.wudsn.ide.lng.asm.compiler.mads;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class MadsEditor extends LanguageEditor { public final class MadsEditor extends LanguageEditor {
@ -31,8 +30,4 @@ public final class MadsEditor extends LanguageEditor {
} }
@Override
public String getCompilerId() {
return CompilerId.MADS;
}
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.merlin32; package com.wudsn.ide.lng.asm.compiler.merlin32;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class Merlin32Editor extends LanguageEditor { public final class Merlin32Editor extends LanguageEditor {
@ -31,8 +30,5 @@ public final class Merlin32Editor extends LanguageEditor {
} }
@Override
public String getCompilerId() {
return CompilerId.MERLIN32;
}
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.tass; package com.wudsn.ide.lng.asm.compiler.tass;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class TassEditor extends LanguageEditor { public final class TassEditor extends LanguageEditor {
@ -31,8 +30,4 @@ public final class TassEditor extends LanguageEditor {
} }
@Override
public String getCompilerId() {
return CompilerId.TASS;
}
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.lng.asm.compiler.xasm; package com.wudsn.ide.lng.asm.compiler.xasm;
import com.wudsn.ide.lng.asm.compiler.CompilerId;
import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditor;
public final class XasmEditor extends LanguageEditor { public final class XasmEditor extends LanguageEditor {
@ -31,8 +30,4 @@ public final class XasmEditor extends LanguageEditor {
} }
@Override
public String getCompilerId() {
return CompilerId.XASM;
}
} }

View File

@ -76,12 +76,12 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
} }
/** /**
* Gets the key that uniquely identifies the compiler. They key has the format * Gets the key that uniquely identifies a compiler. They key has the format
* "<language>/<id>". * "<language>/<id>".
* *
* @return The key that uniquely identifies the compiler, not <code>null</code>. * @return The key that uniquely identifies the compiler, not <code>null</code>.
*/ */
public String getKey() { public static String getKey(String language, String id) {
if (language == null) { if (language == null) {
throw new IllegalStateException("Field 'language' must not be null for this or for argument."); throw new IllegalStateException("Field 'language' must not be null for this or for argument.");
} }
@ -92,6 +92,16 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
return language + "/" + id; return language + "/" + id;
} }
/**
* Gets the key that uniquely identifies the compiler. They key has the format
* "<language>/<id>".
*
* @return The key that uniquely identifies the compiler, not <code>null</code>.
*/
public String getKey() {
return getKey(language, id);
}
/** /**
* Sets the language of the compiler. Called by {@link CompilerRegistry} only. * Sets the language of the compiler. Called by {@link CompilerRegistry} only.
* *

View File

@ -93,7 +93,7 @@ public final class CompilerRegistry {
try { try {
CompilerDefinition compilerDefinition; CompilerDefinition compilerDefinition;
compilerDefinition = new CompilerDefinition(); compilerDefinition = new CompilerDefinition();
compilerDefinition.setId(configurationElement.getAttribute("language")); compilerDefinition.setLanguage(configurationElement.getAttribute("language"));
compilerDefinition.setId(configurationElement.getAttribute("id")); compilerDefinition.setId(configurationElement.getAttribute("id"));
compilerDefinition.setName(configurationElement.getAttribute("name")); compilerDefinition.setName(configurationElement.getAttribute("name"));
compilerDefinition.setClassName(configurationElement.getAttribute("class")); compilerDefinition.setClassName(configurationElement.getAttribute("class"));
@ -145,13 +145,13 @@ public final class CompilerRegistry {
throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null.");
} }
String id = compilerDefinition.getId(); String key = compilerDefinition.getKey();
Compiler compiler; Compiler compiler;
try { try {
// The class loading must be delegated to the framework. // The class loading must be delegated to the framework.
compiler = (Compiler) configurationElement.createExecutableExtension("class"); compiler = (Compiler) configurationElement.createExecutableExtension("class");
} catch (CoreException ex) { } catch (CoreException ex) {
throw new RuntimeException("Cannot create compiler instance for id '" + id + "'.", ex); throw new RuntimeException("Cannot create compiler instance for key '" + key + "'.", ex);
} }
// Build the list of common and specific syntax definition files. // Build the list of common and specific syntax definition files.
@ -160,7 +160,7 @@ public final class CompilerRegistry {
compilerClasses.add(Compiler.class); compilerClasses.add(Compiler.class);
CompilerSyntax syntax; CompilerSyntax syntax;
syntax = new CompilerSyntax(id); syntax = new CompilerSyntax(key);
syntax.loadXMLData(compilerClasses); syntax.loadXMLData(compilerClasses);
@ -168,27 +168,66 @@ public final class CompilerRegistry {
compiler.setDefinition(compilerDefinition); compiler.setDefinition(compilerDefinition);
compiler = compilerMap.put(id, compiler); compiler = compilerMap.put(key, compiler);
if (compiler != null) { if (compiler != null) {
throw new RuntimeException( throw new RuntimeException("Compiler id '" + key + "' is already registered to class '"
"Compiler id '" + id + "' is already registered to class '" + compiler.getClass().getName() + "'."); + compiler.getClass().getName() + "'.");
} }
} }
/** /**
* Gets the unmodifiable list of compiler definitions for a language, sorted by their key. * Gets the unmodifiable list of compiler definitions for a language, sorted by
* their key.
* *
* @param language The language or <code>null</code>. * @param language The language, not <code>null</code>.
* @return The unmodifiable list of compiler definitions, sorted by their key, * @return The unmodifiable list of compiler definitions, sorted by their key,
* may be empty, not <code>null</code> * may be empty, not <code>null</code>
* *
* @since 1.6.1 * @since 1.6.1
*/ */
public List<CompilerDefinition> getCompilerDefinitions(Language language) { public List<CompilerDefinition> getCompilerDefinitions(Language language) {
if (language == null) {
List<CompilerDefinition> result=new ArrayList<CompilerDefinition>(); throw new IllegalArgumentException("Parameter 'language' must not be null.");
return compilerDefinitionList; }
List<CompilerDefinition> result = new ArrayList<CompilerDefinition>();
for (CompilerDefinition compilerDefinition : compilerDefinitionList) {
if (compilerDefinition.getLanguage().equals(language.name())) {
result.add(compilerDefinition);
}
}
return Collections.unmodifiableList(result);
}
/**
* Gets the compiler for a given class. Instances of compiler are stateless
* singletons within the plugin.
*
* @param key The compiler key, not <code>null</code>.
*
* @return The compiler, not <code>null</code>.
*/
public Compiler getCompilerByEditorClassName(String editorClassName) {
if (editorClassName == null) {
throw new IllegalArgumentException("Parameter 'editorClassName' must not be null.");
}
final String SUFFIX = "Editor";
int index = editorClassName.lastIndexOf(SUFFIX);
if (index < 0 || index + SUFFIX.length() != editorClassName.length()) {
throw new IllegalArgumentException("Parameter 'editorClassName' must end with 'Editor'.");
}
String compilerClassName = editorClassName.substring(0, index) + "Compiler";
synchronized (compilerMap) {
for (Compiler compiler : compilerMap.values()) {
if (compiler.getClass().getName().equals(compilerClassName)) {
return compiler;
}
}
}
throw new IllegalArgumentException("Unknown compiler class '" + compilerClassName + "'.");
} }
/** /**
@ -199,13 +238,12 @@ public final class CompilerRegistry {
* *
* @return The compiler, not <code>null</code>. * @return The compiler, not <code>null</code>.
*/ */
public Compiler getCompiler(String key) { public Compiler getCompilerByKey(String key) {
if (key == null) { if (key == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null."); throw new IllegalArgumentException("Parameter 'key' must not be null.");
} }
Compiler result; Compiler result;
synchronized (compilerMap) { synchronized (compilerMap) {
result = compilerMap.get(key); result = compilerMap.get(key);
} }
if (result == null) { if (result == null) {

View File

@ -48,7 +48,6 @@ import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.ide.IDE; import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
@ -130,14 +129,13 @@ public abstract class LanguageEditor extends TextEditor {
* *
* @return The compiler id for this editor, not empty and not <code>null</code>. * @return The compiler id for this editor, not empty and not <code>null</code>.
*/ */
protected abstract String getCompilerId();
@Override @Override
protected final void initializeEditor() { protected final void initializeEditor() {
super.initializeEditor(); super.initializeEditor();
plugin = LanguagePlugin.getInstance(); plugin = LanguagePlugin.getInstance();
compiler = plugin.getCompilerRegistry().getCompiler(getCompilerId()); compiler = plugin.getCompilerRegistry().getCompilerByEditorClassName(getClass().getName());
setSourceViewerConfiguration(new LanguageSourceViewerConfiguration(this, getPreferenceStore())); setSourceViewerConfiguration(new LanguageSourceViewerConfiguration(this, getPreferenceStore()));
@ -161,7 +159,7 @@ public abstract class LanguageEditor extends TextEditor {
* @return The compiler preferences, not <code>null</code>. * @return The compiler preferences, not <code>null</code>.
*/ */
public final CompilerPreferences getCompilerPreferences() { public final CompilerPreferences getCompilerPreferences() {
return plugin.getPreferences().getCompilerPreferences(getCompilerId(), getHardware()); return plugin.getPreferences().getCompilerPreferences(getCompilerDefinition(), getHardware());
} }
/** /**

View File

@ -244,6 +244,13 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
return params; return params;
} }
/**
* Gets the input stream for a compiler.
*
* @param href Hyperlink reference in the form
* /compiler/<language>/<compilerId>/section.
* @return The input stream or <code>null</code> if the path is not valid.
*/
private InputStream getCompilerInputStream(String href) { private InputStream getCompilerInputStream(String href) {
if (href == null) { if (href == null) {
throw new IllegalArgumentException("Parameter 'href' must not be null."); throw new IllegalArgumentException("Parameter 'href' must not be null.");
@ -257,13 +264,22 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
if (index <= 0) { if (index <= 0) {
return null; return null;
} }
String language = path.substring(0, index);
path = path.substring(index + 1);
index = path.indexOf("/");
if (index <= 0) {
return null;
}
String compilerId = path.substring(0, index); String compilerId = path.substring(0, index);
String section = path.substring(index + 1); path = path.substring(index + 1);
String section = path;
LanguagePlugin languagePlugin = LanguagePlugin.getInstance(); LanguagePlugin languagePlugin = LanguagePlugin.getInstance();
CompilerRegistry compilerRegistry = languagePlugin.getCompilerRegistry(); CompilerRegistry compilerRegistry = languagePlugin.getCompilerRegistry();
// Find non-empty compiler executable path. // Find non-empty compiler executable path.
Compiler compiler = compilerRegistry.getCompiler(compilerId); String compilerKey = CompilerDefinition.getKey(language, compilerId);
Compiler compiler = compilerRegistry.getCompilerByKey(compilerKey);
if (section.startsWith(SECTION_GENERAL)) { if (section.startsWith(SECTION_GENERAL)) {
return getInputStream(getCompilerGeneralSection(compiler)); return getInputStream(getCompilerGeneralSection(compiler));
@ -594,7 +610,7 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
return getInputStream(writer); return getInputStream(writer);
} }
private InputStream getCPUInputStream( Language language, String href) { private InputStream getCPUInputStream(Language language, String href) {
if (href == null) { if (href == null) {
throw new IllegalArgumentException("Parameter 'href' must not be null."); throw new IllegalArgumentException("Parameter 'href' must not be null.");
@ -623,7 +639,7 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
writer.writeTableHeader(Texts.TOC_TARGET_OPCODE_LABEL); writer.writeTableHeader(Texts.TOC_TARGET_OPCODE_LABEL);
writer.writeTableHeader(Texts.TOC_COMPILER_INSTRUCTION_DESCRIPTION_LABEL); writer.writeTableHeader(Texts.TOC_COMPILER_INSTRUCTION_DESCRIPTION_LABEL);
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions(language); List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions(language);
int compilerDefinitionCount = compilerDefinitions.size(); int compilerDefinitionCount = compilerDefinitions.size();
InstructionSet[] instructionSets = new InstructionSet[compilerDefinitions.size()]; InstructionSet[] instructionSets = new InstructionSet[compilerDefinitions.size()];
for (int c = 0; c < compilerDefinitionCount; c++) { for (int c = 0; c < compilerDefinitionCount; c++) {

View File

@ -255,13 +255,15 @@ public final class LanguageTocProvider extends AbstractTocProvider {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
CompilerDefinition compilerDefinition = compilerDefinitions.get(i); CompilerDefinition compilerDefinition = compilerDefinitions.get(i);
String href = LanguageHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getId() + "/" String hrefCompiler = LanguageHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getLanguage() + "/"
+ LanguageHelpContentProducer.SECTION_GENERAL + LanguageHelpContentProducer.EXTENSION; + compilerDefinition.getId() + "/";
String href = hrefCompiler + LanguageHelpContentProducer.SECTION_GENERAL
+ LanguageHelpContentProducer.EXTENSION;
ITopic generalTopic = createTopic("", Texts.TOC_COMPILER_GENERAL_TOPIC_LABEL, href, null); ITopic generalTopic = createTopic("", Texts.TOC_COMPILER_GENERAL_TOPIC_LABEL, href, null);
href = LanguageHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getId() + "/" href = hrefCompiler + LanguageHelpContentProducer.SECTION_INSTRUCTIONS
+ LanguageHelpContentProducer.SECTION_INSTRUCTIONS + LanguageHelpContentProducer.EXTENSION; + LanguageHelpContentProducer.EXTENSION;
ITopic opcodesTopic = createTopic("", Texts.TOC_COMPILER_INSTRUCTIONS_TOPIC_LABEL, href, null); ITopic opcodesTopic = createTopic("", Texts.TOC_COMPILER_INSTRUCTIONS_TOPIC_LABEL, href, null);
LanguagePreferences languagePreferences = LanguagePlugin.getInstance().getPreferences(); LanguagePreferences languagePreferences = LanguagePlugin.getInstance().getPreferences();
@ -286,8 +288,7 @@ public final class LanguageTocProvider extends AbstractTocProvider {
extension = ".html"; extension = ".html";
} }
href = LanguageHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getId() + "/" href = hrefCompiler + LanguageHelpContentProducer.SECTION_MANUAL + extension;
+ LanguageHelpContentProducer.SECTION_MANUAL + extension;
if (file.isDirectory()) { if (file.isDirectory()) {
File[] files = file.listFiles(); File[] files = file.listFiles();
@ -310,8 +311,7 @@ public final class LanguageTocProvider extends AbstractTocProvider {
href = ""; href = "";
} }
} catch (CoreException ex) { } catch (CoreException ex) {
href = LanguageHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getId() + "/" href = hrefCompiler + LanguageHelpContentProducer.SECTION_MANUAL + ".html";
+ LanguageHelpContentProducer.SECTION_MANUAL + ".html";
} }
ITopic manualTopic = createTopic(icon, Texts.TOC_COMPILER_MANUAL_TOPIC_LABEL, href, ITopic manualTopic = createTopic(icon, Texts.TOC_COMPILER_MANUAL_TOPIC_LABEL, href,

View File

@ -25,9 +25,9 @@ import org.eclipse.jface.text.TextAttribute;
import com.wudsn.ide.base.common.AbstractIDEPlugin; import com.wudsn.ide.base.common.AbstractIDEPlugin;
import com.wudsn.ide.base.common.StringUtility; import com.wudsn.ide.base.common.StringUtility;
import com.wudsn.ide.base.hardware.Hardware; import com.wudsn.ide.base.hardware.Hardware;
import com.wudsn.ide.lng.compiler.CompilerDefinition;
import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase; import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase;
import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode; import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode;
/** /**
* Facade class for typed access to the plugin preferences. * Facade class for typed access to the plugin preferences.
* *
@ -109,23 +109,21 @@ public final class LanguagePreferences {
/** /**
* Gets the preferences for a compiler. * Gets the preferences for a compiler.
* *
* @param compilerId The compiler id, not empty and not <code>null</code>. * @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 * @param hardware The preferences or <code>null</code> if the compiler is not
* active for that hardware. * active for that hardware.
* *
* @return The compiler preferences, not <code>null</code>. * @return The compiler preferences, not <code>null</code>.
*/ */
public CompilerPreferences getCompilerPreferences(String compilerId, Hardware hardware) { public CompilerPreferences getCompilerPreferences(CompilerDefinition compilerDefinition, Hardware hardware) {
if (compilerId == null) { if (compilerDefinition == null) {
throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null.");
}
if (StringUtility.isEmpty(compilerId)) {
throw new IllegalArgumentException("Parameter 'compilerId' must not be empty.");
} }
if (hardware == null) { if (hardware == null) {
throw new IllegalArgumentException("Parameter 'hardware' must not be null."); throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
} }
return new CompilerPreferences(this, compilerId, hardware); return new CompilerPreferences(this, compilerDefinition.getId(), hardware);
} }

View File

@ -19,7 +19,6 @@
package com.wudsn.ide.base.common; package com.wudsn.ide.base.common;
import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;

View File

@ -20,7 +20,6 @@ package com.wudsn.ide.base.gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; import java.util.ResourceBundle;

View File

@ -106,5 +106,21 @@
class="com.wudsn.ide.lng.pas.editor.ValidatorDocumentSetupParticipant"> class="com.wudsn.ide.lng.pas.editor.ValidatorDocumentSetupParticipant">
</participant> </participant>
</extension> </extension>
<extension
point="com.wudsn.ide.lng.compilers">
<compiler
class="com.wudsn.ide.lng.pas.compiler.mp.MadPascalCompiler"
defaultHardware="ATARI8BIT"
defaultParameters="${sourceFilePath} "
helpFilePaths="https://mads.atari8.info/doc/en/index.html"
homePageURL="https://github.com/tebe6502/Mad-Pascal/releases"
id="MP"
language="PAS"
name="%com.wudsn.ide.lng.pas.compiler.mp.MadPascalCompiler.name"
version="1.6.5">
<supportedTarget
target="PASCAL"></supportedTarget>
</compiler>
</extension>
</plugin> </plugin>

View File

@ -0,0 +1,23 @@
/**
* 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;
public class MadPascalCompiler {
}

View File

@ -0,0 +1,29 @@
/**
* 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.editor.LanguageEditor;
public class MadPascalEditor extends LanguageEditor {
/**
* Creation is public. Called by the extension "org.eclipse.ui.editors".
*/
public MadPascalEditor() {
}
}