Transition of annotations from @com.wudsn.ide.asm to @com.wudsn.ide.lng

Split and rename LanguageProperty/LanguageProperties to LanguageAnnotation/LanguageAnnotationValue/LanguageAnnotationValues

Resolves https://github.com/peterdell/wudsn-ide/issues/7
This commit is contained in:
Peter Dell 2023-01-12 01:10:59 +01:00
parent 3fae54c02e
commit f85cc96663
26 changed files with 519 additions and 403 deletions

View File

@ -25,7 +25,7 @@
<ul>
<li><a href="#FAQFileAssociations">How do I associate my source file extensions with the correct editor?</a>
</li>
<li><a href="#FAQHardwareAnnotation">Why do I have to put ";@com.wudsn.ide.asm.hardware=..." in the source
<li><a href="#FAQHardwareAnnotation">Why do I have to put ";@com.wudsn.ide.lng.hardware=..." in the source
file?</a></li>
<li><a href="#FAQProblemsView">Why do I see wrong messages in the "Problems" view?</a></li>
</ul>
@ -150,7 +150,7 @@
Extensions correctly</a>.</p>
</div>
<div id="FAQHardwareAnnotation">
<h4>Why do I have to put ";@com.wudsn.ide.asm.hardware=..." in the source file?</h4>
<h4>Why do I have to put ";@com.wudsn.ide.lng.hardware=..." in the source file?</h4>
<p>The association with the file extension with the editor for your compiler (that is done in the preferences,
see before) does not determine for which platform you want to create output. Therefore this additional
annotation in the main source file is required used to tell the IDE which is the target platform. It is used

View File

@ -514,12 +514,14 @@
different output formats (".XEX" and ".BIN") with the same compiler it may become cumbersome to change the
preferences every time. Therefore WUDSN IDE offers annotations that you can put into the source code files.
These annotations override the defaults and the preferences.</li>
<li>All annotations start with the prefix "@com.wudsn.ide.asm." followed by the lower case name of the annotation,
an equals sign, and the unquoted value. Example: "@com.wudsn.ide.asm.hardware=ATARI8BIT"</li>
<li>All language annotations start with the prefix "@com.wudsn.ide.lng." followed by the lower case name of the annotation,
an equals sign, and the unquoted value. Example: "@com.wudsn.ide.lng.hardware=ATARI8BIT"</li>
<li>In earlier versions of WUDSN, language annotations started with the prefix "@com.wudsn.ide.asm.".
While they are still evaluated, it is strongly recommended to adapt to the new prefix.</li>
<li>All annotations can be placed in comment lines at the beginning of a source file. Some of the annotations are
only relevant for the main source file, some are only relevant in include source files, some are relevant for
all source files.</li>
<li>@com.wudsn.ide.asm.hardware
<li>@com.wudsn.ide.lng.hardware
<ul>
<li>Defines the target hardware for which the preferences shall be evaluated, in particular, which emulator
is used to run the output file.</li>
@ -527,63 +529,66 @@
<li>This annotation is relevant for all source files.</li>
<li>This annotation is only evaluated when a file is opened. So if you add this annotation or change its
value, you have to close and re-open the file once.</li>
<li>Example: @com.wudsn.ide.asm.hardware=ATARI8BIT</li>
<li>Example: @com.wudsn.ide.lng.hardware=ATARI8BIT</li>
</ul>
</li>
<li>@com.wudsn.ide.asm.mainsourcefile
<li>@com.wudsn.ide.lng.mainsourcefile
<ul>
<li>Defines the main source file to which the current include source file belongs. When the "Compile" action
is executed, the main source file is compiler instead of the current file.</li>
<li>Allowed values are file paths relative to the folder of the current include source file and absolute
file paths.</li>
<li>This annotation is only relevant in include source files.</li>
<li>Example: @com.wudsn.ide.asm.mainsourcefile=ExampleMain.asm</li>
<li>Example: @com.wudsn.ide.lng.mainsourcefile=ExampleMain.asm</li>
</ul>
</li>
<li>@com.wudsn.ide.asm.outputfoldermode (planned for 1.7.0)
<li>@com.wudsn.ide.lng.outputfoldermode
<ul>
<li>Overrides the "Output Folder Mode" from the preferences.</li>
<li>Allowed values are "SOURCE_FOLDER", "TEMP_FOLDER", "FIXED_FOLDER".</li>
<li>This annotation is only relevant in the main source file.</li>
<li>Example: @com.wudsn.ide.asm.outputfoldermode=SOURCE_FOLDER</li>
<li>Example: @com.wudsn.ide.lng.outputfoldermode=SOURCE_FOLDER</li>
</ul>
</li>
<li>@com.wudsn.ide.asm.outputfolder (planned for 1.7.0)
<li>@com.wudsn.ide.lng.outputfolder
<ul>
<li>Overrides the "Output Folder" from the preferences and the "@com.wudsn.ide.asm.outputfoldermode"
<li>Overrides the "Output Folder" from the preferences and the "@com.wudsn.ide.lng.outputfoldermode"
annotation.</li>
<li>Allowed values are file paths relative to the folder of the main source file and absolute file paths.
</li>
<li>This annotation is only relevant in the main source file.</li>
<li>Example: @com.wudsn.ide.asm.outputfolder=..\out</li>
<li>Example: @com.wudsn.ide.lng.outputfolder=..\out</li>
</ul>
</li>
<li>@com.wudsn.ide.asm.outputfileextension (planned for 1.7.0)
<li>@com.wudsn.ide.lng.outputfileextension
<ul>
<li>Overrides the "Output File Extension" from the preferences.</li>
<li>Allowed values have to start with a period.</li>
<li>This annotation is only relevant in the main source file.</li>
<li>Example: @com.wudsn.ide.asm.outputfileextension=.bin</li>
<li>Example: @com.wudsn.ide.lng.outputfileextension=.bin</li>
</ul>
</li>
<li>@com.wudsn.ide.asm.outputfile (planned for 1.7.0)
<li>@com.wudsn.ide.lng.outputfile
<ul>
<li>Overrides the "Output Folder", "Output File Extension" from the preferences and the automatic
computation of the out file name based on the main source file name.</li>
<li>Allowed values are file paths relative to the folder of the main source file and absolute file paths.
</li>
<li>This annotation is only relevant in the main source file.</li>
<li>Example: @com.wudsn.ide.asm.outputfile=..\out\output.bin</li>
<li>Example: @com.wudsn.ide.lng.outputfile=..\out\output.bin</li>
</ul>
</li>
</ul>
<h5 id="KnownBugs">Known bugs   <a href="#ide_features">» top</a></h5>
<p>Open bugs:</p>
<ul>
<li>If you find any, please contact me</li>
<li>If you find any, please report them on <a href="https://github.com/peterdell/wudsn-ide/issues" target="_blank">github</a> or contact me directly</li>
</ul>
<p>Fixed bugs:</p>
<ul>
<li>1.7.2 and newer</br>
See <a href="https://github.com/peterdell/wudsn-ide/issues" target="_blank">github</a>.
<li>
<li>1.6.5 <br />
<ul>
<li>Automatic creation of ".DSK" disk images for Apple II now works correctly</li>

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;
import java.util.ArrayList;
import java.util.List;
public final class LanguageAnnotation {
/**
* Source code annotations.
*/
public final static String PREFIX = "@com.wudsn.ide.lng.";
public final static String OLD_PREFIX = "@com.wudsn.ide.asm.";
public final static String HARDWARE = "@com.wudsn.ide.lng.hardware";
public final static String MAIN_SOURCE_FILE = "@com.wudsn.ide.lng.mainsourcefile";
public final static String OUTPUT_FOLDER_MODE = "@com.wudsn.ide.lng.outputfoldermode";
public final static String OUTPUT_FOLDER = "@com.wudsn.ide.lng.outputfolder";
public final static String OUTPUT_FILE_EXTENSION = "@com.wudsn.ide.lng.outputfileextension";
public final static String OUTPUT_FILE = "@com.wudsn.ide.lng.outputfile";
public static List<String> getAnnotations() {
List<String> result = new ArrayList<String>();
result.add(HARDWARE);
result.add(MAIN_SOURCE_FILE);
result.add(OUTPUT_FOLDER_MODE);
result.add(OUTPUT_FOLDER);
result.add(OUTPUT_FILE_EXTENSION);
result.add(OUTPUT_FILE);
return result;
}
}

View File

@ -1,140 +1,135 @@
/**
* 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;
import java.util.Map;
import java.util.TreeMap;
import org.eclipse.core.resources.IMarker;
import com.wudsn.ide.base.common.StringUtility;
public final class LanguageProperties {
/**
* A single key value pair.
*
* @since 1.6.1
*/
public static final class LanguageProperty {
public final String key;
public final String value;
public final int lineNumber;
LanguageProperty(String key, String value, int lineNumber) {
this.key = key;
this.value = value;
this.lineNumber = lineNumber;
}
@Override
public String toString() {
return key + "=" + value + " in line " + lineNumber;
}
}
@SuppressWarnings("serial")
public final static class InvalidLanguagePropertyException extends Exception {
public final LanguageProperty property;
public final IMarker marker;
public InvalidLanguagePropertyException(LanguageProperty property, IMarker marker) {
if (property == null) {
throw new IllegalArgumentException("Parameter 'property' must not be null.");
}
this.property = property;
this.marker = marker;
}
}
/**
* Source code constants.
*/
public final static String PREFIX = "@com.wudsn.ide.lng.";
public final static String HARDWARE = "@com.wudsn.ide.lng.hardware";
public final static String MAIN_SOURCE_FILE = "@com.wudsn.ide.lng.mainsourcefile";
public final static String OUTPUT_FOLDER_MODE = "@com.wudsn.ide.lng.outputfoldermode";
public final static String OUTPUT_FOLDER = "@com.wudsn.ide.lng.outputfolder";
public final static String OUTPUT_FILE_EXTENSION = "@com.wudsn.ide.lng.outputfileextension";
public final static String OUTPUT_FILE = "@com.wudsn.ide.lng.outputfile";
private Map<String, LanguageProperty> properties;
/**
* Creation is public.
*/
public LanguageProperties() {
properties = new TreeMap<String, LanguageProperties.LanguageProperty>();
}
/**
* Puts a new value into the properties provided not other value is already
* there.
*
* @param key The property key, not empty and not <code>null</code>.
* @param value The property value, may be empty, not <code>null</code>.
* @param lineNumber The line number, a positive integer or 0 if the line number
* is undefined.
* @since 1.6.1
*/
public void put(String key, String value, int lineNumber) {
if (key == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null.");
}
if (StringUtility.isEmpty(key)) {
throw new IllegalArgumentException("Parameter 'key' must not be empty.");
}
if (value == null) {
throw new IllegalArgumentException("Parameter 'value' must not be null.");
}
if (lineNumber < 0l) {
throw new IllegalArgumentException(
"Parameter 'lineNumber' must not be negative. Specified value is " + lineNumber + ".");
}
if (!properties.containsKey(key)) {
LanguageProperty property = new LanguageProperty(key, value, lineNumber);
properties.put(key, property);
}
}
/**
* Gets a property from the properties map.
*
* @param key The property key, not empty and not <code>null</code>.
* @return The property or <code>null</code> if the property is not defined.
*
* @since 1.6.1
*/
public LanguageProperty get(String key) {
if (key == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null.");
}
if (StringUtility.isEmpty(key)) {
throw new IllegalArgumentException("Parameter 'key' must not be empty.");
}
return properties.get(key);
}
@Override
public String toString() {
return properties.toString();
}
}
/**
* 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;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import org.eclipse.core.resources.IMarker;
import com.wudsn.ide.base.common.StringUtility;
public final class LanguageAnnotationValues {
/**
* A single key value pair.
*
* @since 1.6.1
*/
public static final class LanguageAnnotationValue {
public final String key;
public final String value;
public final int lineNumber;
LanguageAnnotationValue(String key, String value, int lineNumber) {
this.key = key;
this.value = value;
this.lineNumber = lineNumber;
}
@Override
public String toString() {
return key + "=" + value + " in line " + lineNumber;
}
}
@SuppressWarnings("serial")
public final static class InvalidLanguageAnnotationException extends Exception {
public final LanguageAnnotationValue value;
public final IMarker marker;
public InvalidLanguageAnnotationException(LanguageAnnotationValue property, IMarker marker) {
if (property == null) {
throw new IllegalArgumentException("Parameter 'value' must not be null.");
}
this.value = property;
this.marker = marker;
}
}
private Map<String, LanguageAnnotationValue> properties;
/**
* Creation is public.
*/
public LanguageAnnotationValues() {
properties = new TreeMap<String, LanguageAnnotationValues.LanguageAnnotationValue>();
}
/**
* Puts a new value into the properties provided not other value is already
* there.
*
* @param key The value key, not empty and not <code>null</code>.
* @param value The value value, may be empty, not <code>null</code>.
* @param lineNumber The line number, a positive integer or 0 if the line number
* is undefined.
* @since 1.6.1
*/
public void put(String key, String value, int lineNumber) {
if (key == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null.");
}
if (StringUtility.isEmpty(key)) {
throw new IllegalArgumentException("Parameter 'key' must not be empty.");
}
if (value == null) {
throw new IllegalArgumentException("Parameter 'value' must not be null.");
}
if (lineNumber < 0l) {
throw new IllegalArgumentException(
"Parameter 'lineNumber' must not be negative. Specified value is " + lineNumber + ".");
}
if (!properties.containsKey(key)) {
LanguageAnnotationValue property = new LanguageAnnotationValue(key, value, lineNumber);
properties.put(key, property);
}
}
public Set<String> keySet() {
return new TreeSet<String>(properties.keySet());
}
/**
* Gets a value from the properties map.
*
* @param key The value key, not empty and not <code>null</code>.
* @return The value or <code>null</code> if the value is not defined.
*
* @since 1.6.1
*/
public LanguageAnnotationValue get(String key) {
if (key == null) {
throw new IllegalArgumentException("Parameter 'key' must not be null.");
}
if (StringUtility.isEmpty(key)) {
throw new IllegalArgumentException("Parameter 'key' must not be empty.");
}
return properties.get(key);
}
@Override
public String toString() {
return properties.toString();
}
}

View File

@ -352,7 +352,7 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
*
* @param language
*
* @param changedPropertyNames The set of property changed property names, not
* @param changedPropertyNames The set of value changed value names, not
* <code>null</code>.
*
* @since 1.6.3
@ -371,11 +371,11 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
}
/**
* Gets a UI property.
* Gets a UI value.
*
* @param key The property key, not <code>null</code>.
* @param key The value key, not <code>null</code>.
*
* @return The UI property, may be empty, not <code>null</code>.
* @return The UI value, may be empty, not <code>null</code>.
*/
public String getProperty(QualifiedName key) {
if (key == null) {
@ -393,11 +393,11 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
}
/**
* Set a UI property.
* Set a UI value.
*
* @param key The property key, not <code>null</code>.
* @param key The value key, not <code>null</code>.
*
* @param value The UI property, may be empty, not <code>null</code>.
* @param value The UI value, may be empty, not <code>null</code>.
*/
public void setProperty(QualifiedName key, String value) {
if (key == null) {

View File

@ -300,6 +300,9 @@ public final class Texts extends NLS {
public static String MESSAGE_E141;
public static String MESSAGE_E142;
public static String MESSAGE_S143;
public static String MESSAGE_W144;
public static String MESSAGE_E145;
/**
* Initializes the constants.
*/

View File

@ -220,4 +220,6 @@ MESSAGE_E139=Output file extension '{0}' must start with ".".
MESSAGE_E140=Output folder mode be set in the preferences of compiler '{0}' or via the annotation '{1}'.
MESSAGE_E141=Unknown output folder mode '{0}'. Specify one of the following valid values '{1}'.
MESSAGE_E142=Include statement for file '{0}' uses a file name that has a different case different from real file system name '{1}'. Correct the file name in the include statement.
MESSAGE_S143=In include file '{0}', line {1}.
MESSAGE_S143=In include file '{0}', line {1}.
MESSAGE_W144=Use annotation '{0}' instead of the deprecated annotation '{1}'.
MESSAGE_E145=Annotation '{0}' is unknown.

View File

@ -218,4 +218,6 @@ MESSAGE_E139=Ausgabe-Dateierweiterung '{0}' muss mit "." beginnen.
MESSAGE_E140=Ausgabe-Ordnermodus muss in den Voreinstellungen des Kompilers '{0}' oder mit der Annotation '{1}' angegeben werden.
MESSAGE_E141=Unbekannter Ausgabe-Ordnermodus '{0}'. Geben Sie einen der folgenden gültigen Werte an '{1}'.
MESSAGE_E142=Include Anweisung für die Datei '{0}' verwendet im Dateinamen eine andere Groß-Kleinschreibung als der echte Dateiname {1} auf dem Dateisystem. Korrigieren Sie den Dateinamen in der Include Anweisung.
MESSAGE_S143=In Include-Datei '{0}', Zeile {1}.
MESSAGE_S143=In Include-Datei '{0}', Zeile {1}.
MESSAGE_W144=Verwenden Sie die Annotation '{0}' anstatt der veralteten Annotation '{1}'.
MESSAGE_E145=Die Annotation '{0}' ist unbekannt.

View File

@ -221,4 +221,6 @@ MESSAGE_E139=Output file extension '{0}' must start with ".".
MESSAGE_E140=Output folder mode be set in the preferences of compiler '{0}' or via the annotation '{1}'.
MESSAGE_E141=Unknown output folder mode '{0}'. Specify one of the following valid values '{1}'.
MESSAGE_E142=Include statement for file '{0}' uses a file name that has a different case different from real file system name '{1}'. Correct the file name in the include statement.
MESSAGE_S143=In include file '{0}', line {1}.
MESSAGE_S143=In include file '{0}', line {1}.
MESSAGE_W144=Use annotation '{0}' instead of the deprecated annotation '{1}'.
MESSAGE_E145=Annotation '{0}' is unknown.

View File

@ -25,8 +25,9 @@ import org.eclipse.core.resources.IFile;
import com.wudsn.ide.base.common.FileUtility;
import com.wudsn.ide.base.common.StringUtility;
import com.wudsn.ide.lng.LanguageProperties;
import com.wudsn.ide.lng.LanguageProperties.LanguageProperty;
import com.wudsn.ide.lng.LanguageAnnotation;
import com.wudsn.ide.lng.LanguageAnnotationValues;
import com.wudsn.ide.lng.LanguageAnnotationValues.LanguageAnnotationValue;
import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferences;
/**
@ -50,19 +51,19 @@ public final class CompilerFiles {
public final String fileName;
public final String fileNameWithoutExtension;
public final LanguageProperties languageProperties;
public final LanguageAnnotationValues languageAnnotationValues;
SourceFile(IFile iFile, LanguageProperties languageProperties) {
SourceFile(IFile iFile, LanguageAnnotationValues languageAnnotationValues) {
if (iFile == null) {
throw new IllegalArgumentException("Parameter 'iFile' must not be null.");
}
if (languageProperties == null) {
throw new IllegalArgumentException("Parameter 'languageProperties' must not be null.");
if (languageAnnotationValues == null) {
throw new IllegalArgumentException("Parameter 'languageAnnotationValues' must not be null.");
}
this.iFile = iFile;
this.languageProperties = languageProperties;
this.languageAnnotationValues = languageAnnotationValues;
// Source file.
filePath = iFile.getLocation().toOSString();
@ -88,14 +89,14 @@ public final class CompilerFiles {
/**
* The main source file which is either the current file or the file indicated
* by the property "@com.wudsn.ide.lng.editor.MainSourceFile".
* by the value "@com.wudsn.ide.lng.editor.MainSourceFile".
*/
public final SourceFile mainSourceFile;
public final LanguageProperty outputFolderModeProperty;
public final LanguageAnnotationValue outputFolderModeProperty;
public final String outputFolderMode;
public final LanguageProperty outputFolderProperty;
public final LanguageAnnotationValue outputFolderProperty;
public final File outputFolder;
public final String outputFolderPath;
@ -103,10 +104,10 @@ public final class CompilerFiles {
public final String outputFilePath;
public final String outputFilePathWithoutExtension;
public final LanguageProperty outputFileProperty;
public final LanguageAnnotationValue outputFileProperty;
public final String outputFileName;
public final String outputFileNameWithoutExtension;
public final LanguageProperty outputFileExtensionProperty;
public final LanguageAnnotationValue outputFileExtensionProperty;
public final String outputFileExtension;
public final String outputFileNameShortWithoutExtension;
@ -114,8 +115,8 @@ public final class CompilerFiles {
public final String symbolsFilePath;
public final String symbolsFileName;
public CompilerFiles(IFile mainSourceIFile, LanguageProperties mainSourceFileLanguageProperties,
IFile sourceIFile, LanguageProperties sourceFileLanguageProperties,
public CompilerFiles(IFile mainSourceIFile, LanguageAnnotationValues mainSourceFileLanguageProperties,
IFile sourceIFile, LanguageAnnotationValues sourceFileLanguageProperties,
LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences) {
if (mainSourceIFile == null) {
@ -131,16 +132,16 @@ public final class CompilerFiles {
this.sourceFile = new SourceFile(sourceIFile, sourceFileLanguageProperties);
// Output folder mode
// Can be overridden via annotation property in main source file
// Can be overridden via annotation value in main source file
String localOutputFolderPath = languageHardwareCompilerDefinitionPreferences.getOutputFolderPath();
String localOutputFolderMode = languageHardwareCompilerDefinitionPreferences.getOutputFolderMode();
String localOutputFileExtension = languageHardwareCompilerDefinitionPreferences.getOutputFileExtension();
// Properties which override the preferences
outputFolderModeProperty = mainSourceFileLanguageProperties.get(LanguageProperties.OUTPUT_FOLDER_MODE);
outputFolderProperty = mainSourceFileLanguageProperties.get(LanguageProperties.OUTPUT_FOLDER);
outputFileExtensionProperty = mainSourceFileLanguageProperties.get(LanguageProperties.OUTPUT_FILE_EXTENSION);
outputFileProperty = mainSourceFileLanguageProperties.get(LanguageProperties.OUTPUT_FILE);
outputFolderModeProperty = mainSourceFileLanguageProperties.get(LanguageAnnotation.OUTPUT_FOLDER_MODE);
outputFolderProperty = mainSourceFileLanguageProperties.get(LanguageAnnotation.OUTPUT_FOLDER);
outputFileExtensionProperty = mainSourceFileLanguageProperties.get(LanguageAnnotation.OUTPUT_FILE_EXTENSION);
outputFileProperty = mainSourceFileLanguageProperties.get(LanguageAnnotation.OUTPUT_FILE);
// The following sequence sets the instance fields "outputFolder" and
// "outputFileNameWithoutExtension" as well as the

View File

@ -35,7 +35,8 @@ import com.wudsn.ide.base.BasePlugin;
import com.wudsn.ide.base.common.FileUtility;
import com.wudsn.ide.base.common.StringUtility;
import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.LanguageProperties;
import com.wudsn.ide.lng.LanguageAnnotation;
import com.wudsn.ide.lng.LanguageAnnotationValues;
import com.wudsn.ide.lng.compiler.Compiler;
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
import com.wudsn.ide.lng.compiler.syntax.Instruction;
@ -81,46 +82,66 @@ public abstract class CompilerSourceParser {
private boolean logEnabled = false;
/**
* Extract all {@link LanguageProperties} properties from a document.
* Extract all {@link LanguageAnnotationValues} properties from a document.
*
* @param document The document, not <code>null</code>.
* @return The properties, may be empty, not <code>null</code>.
*/
public static LanguageProperties getDocumentProperties(IDocument document) {
public static LanguageAnnotationValues getDocumentProperties(IDocument document) {
if (document == null) {
throw new IllegalArgumentException("Parameter 'document' must not be null.");
}
String content = document.get();
LanguageProperties properties = new LanguageProperties();
LanguageAnnotationValues properties = new LanguageAnnotationValues();
int index1 = content.indexOf(LanguageProperties.PREFIX);
while (index1 >= 0) {
int index = getMinIndex(content.indexOf(LanguageAnnotation.PREFIX),
content.indexOf(LanguageAnnotation.OLD_PREFIX));
while (index >= 0) {
int indexEqualSign = content.indexOf('=', index1);
int indexNewLine = content.indexOf('\n', index1);
int indexEqualSign = content.indexOf('=', index);
int indexNewLine = content.indexOf('\n', index);
if (indexNewLine < 0) {
indexNewLine = content.indexOf('\r', index1);
indexNewLine = content.indexOf('\r', index);
}
if (indexNewLine < 0) {
indexNewLine = content.length();
}
if (indexEqualSign >= 0 && indexEqualSign < indexNewLine) {
String key = content.substring(index1, indexEqualSign).trim();
String key = content.substring(index, indexEqualSign).trim();
String value = content.substring(indexEqualSign + 1, indexNewLine).trim();
int lineNumber;
try {
lineNumber = document.getLineOfOffset(index1) + 1;
lineNumber = document.getLineOfOffset(index) + 1;
} catch (BadLocationException ex) {
lineNumber = 0;
}
properties.put(key, value, lineNumber);
}
index1 = content.indexOf(LanguageProperties.PREFIX, indexNewLine);
index = getMinIndex(content.indexOf(LanguageAnnotation.PREFIX, indexNewLine),
content.indexOf(LanguageAnnotation.OLD_PREFIX, indexNewLine));
}
return properties;
}
/**
* Gets the smaller of two string indexes. Values less than 0 indicate "not
* found" and are ignored.
*
* @param index1 The first index
* @param index2 The second index
* @return The smaller index or a value less than 0 if no index is valid.
*/
private static int getMinIndex(int index1, int index2) {
if (index1 < 0) {
return index2;
}
if (index2 < 0) {
return index1;
}
return Math.min(index1, index2);
}
/**
* Creation is protected.
*/

View File

@ -395,7 +395,7 @@ final class LanguageContentAssistProcessor implements IContentAssistProcessor {
proposal = proposal.replace("\n", "\n\t");
newCursorOffset = offset + proposalIndex;
proposalList.add(new LanguagetTextCompletionProposal(proposal, offset, region.getLength(),
proposalList.add(new LanguageTextCompletionProposal(proposal, offset, region.getLength(),
newCursorOffset, image, displayString, styledDisplayString, null));
}
}
@ -458,7 +458,7 @@ final class LanguageContentAssistProcessor implements IContentAssistProcessor {
int newCursorOffset = regionOffset + proposal.length();
proposalList.add(new LanguagetTextCompletionProposal(proposal, regionOffset, regionLength,
proposalList.add(new LanguageTextCompletionProposal(proposal, regionOffset, regionLength,
newCursorOffset, image, displayString, styledDisplayString, null));
}
}

View File

@ -56,8 +56,8 @@ import com.wudsn.ide.base.common.ResourceBundleUtility;
import com.wudsn.ide.base.hardware.Hardware;
import com.wudsn.ide.lng.Language;
import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.LanguageProperties;
import com.wudsn.ide.lng.LanguageProperties.InvalidLanguagePropertyException;
import com.wudsn.ide.lng.LanguageAnnotationValues;
import com.wudsn.ide.lng.LanguageAnnotationValues.InvalidLanguageAnnotationException;
import com.wudsn.ide.lng.Target;
import com.wudsn.ide.lng.compiler.Compiler;
import com.wudsn.ide.lng.compiler.CompilerDefinition;
@ -244,13 +244,13 @@ public abstract class LanguageEditor extends TextEditor {
compiler.getDefinition().getSyntax());
partitionScanner.createDocumentPartitioner(document);
LanguageProperties properties = CompilerSourceParser.getDocumentProperties(document);
LanguageAnnotationValues properties = CompilerSourceParser.getDocumentProperties(document);
IFile iFile = getCurrentIFile();
if (iFile != null) {
try {
hardware = filesLogic.getHardware(iFile, properties);
} catch (InvalidLanguagePropertyException ex) {
} catch (InvalidLanguageAnnotationException ex) {
// Do not use MarkerUtility.gotoMarker to make sure this
// editor instance is used.
IDE.gotoMarker(this, ex.marker);

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.HardwareUtility;
import com.wudsn.ide.lng.LanguageAnnotation;
import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.LanguageUtility;
import com.wudsn.ide.lng.Texts;
@ -67,6 +69,7 @@ import com.wudsn.ide.lng.compiler.CompilerConsole;
import com.wudsn.ide.lng.compiler.CompilerDefinition;
import com.wudsn.ide.lng.compiler.CompilerFileWriter;
import com.wudsn.ide.lng.compiler.CompilerFiles;
import com.wudsn.ide.lng.compiler.CompilerFiles.SourceFile;
import com.wudsn.ide.lng.compiler.CompilerProcessLogParser;
import com.wudsn.ide.lng.compiler.CompilerProcessLogParser.Marker;
import com.wudsn.ide.lng.compiler.CompilerSymbol;
@ -204,6 +207,12 @@ final class LanguageEditorCompileCommand {
return false;
}
// Check annotations
checkAnnotations(files.mainSourceFile);
if (!files.sourceFile.filePath.equals(files.mainSourceFile.filePath)) {
checkAnnotations(files.sourceFile);
}
// Determine and check hardware.
Hardware hardware = languageEditorFilesLogic.getHardware(files);
if (hardware == null) {
@ -218,7 +227,7 @@ final class LanguageEditorCompileCommand {
// Create wrapper for run properties.
CompilerDefinition compilerDefinition = languageEditor.getCompilerDefinition();
CompilerRunPreferences compilerRunPreferences = new CompilerRunPreferences(
languageEditor.getLanguageHardwareCompilerPreferences(), files.mainSourceFile.languageProperties);
languageEditor.getLanguageHardwareCompilerPreferences(), files.mainSourceFile.languageAnnotationValues);
// Check if output file is modifiable in case it already exists.
long outputFileLastModified = -1;
@ -409,6 +418,32 @@ final class LanguageEditorCompileCommand {
return true;
}
private void checkAnnotations(SourceFile sourceFile) {
if (sourceFile == null) {
throw new IllegalArgumentException("Parameter 'sourceFile' must not be null.");
}
var annotationValues = sourceFile.languageAnnotationValues;
var annotations = LanguageAnnotation.getAnnotations();
for (String key : annotationValues.keySet()) {
var value = annotationValues.get(key);
if (key.startsWith(LanguageAnnotation.OLD_PREFIX)) {
var newKey = LanguageAnnotation.PREFIX + key.substring(LanguageAnnotation.OLD_PREFIX.length());
// WARNING: Use annotation '{0}' instead of the deprecated annotation '{1}'.
MarkerUtility.createMarker(sourceFile.iFile, value.lineNumber, IMarker.SEVERITY_WARNING,
Texts.MESSAGE_W144, new String[] { newKey, key });
annotationValues.put(newKey, value.value, value.lineNumber);
key = newKey;
}
if (!annotations.contains(key)) {
// ERROR: Annotation '{0}' is unknown.
MarkerUtility.createMarker(sourceFile.iFile, value.lineNumber, IMarker.SEVERITY_WARNING,
Texts.MESSAGE_E145, new String[] { key });
}
}
}
/**
* Creates or deletes the breakpoints file based on the runner.
*

View File

@ -37,9 +37,10 @@ import com.wudsn.ide.base.common.MarkerUtility;
import com.wudsn.ide.base.common.StringUtility;
import com.wudsn.ide.base.hardware.Hardware;
import com.wudsn.ide.lng.LanguagePlugin;
import com.wudsn.ide.lng.LanguageProperties;
import com.wudsn.ide.lng.LanguageProperties.InvalidLanguagePropertyException;
import com.wudsn.ide.lng.LanguageProperties.LanguageProperty;
import com.wudsn.ide.lng.LanguageAnnotation;
import com.wudsn.ide.lng.LanguageAnnotationValues;
import com.wudsn.ide.lng.LanguageAnnotationValues.InvalidLanguageAnnotationException;
import com.wudsn.ide.lng.LanguageAnnotationValues.LanguageAnnotationValue;
import com.wudsn.ide.lng.Texts;
import com.wudsn.ide.lng.compiler.CompilerDefinition;
import com.wudsn.ide.lng.compiler.CompilerFiles;
@ -87,15 +88,15 @@ public final class LanguageEditorFilesLogic {
if (sourceIFile != null) {
IDocument document = languageEditor.getDocumentProvider().getDocument(languageEditor.getEditorInput());
LanguageProperties sourceFileProperties = CompilerSourceParser.getDocumentProperties(document);
LanguageAnnotationValues sourceFileProperties = CompilerSourceParser.getDocumentProperties(document);
IFile mainSourceIFile;
LanguageProperties mainSourceFileProperties;
LanguageAnnotationValues mainSourceFileProperties;
mainSourceIFile = sourceIFile;
mainSourceFileProperties = sourceFileProperties;
LanguageProperty property = sourceFileProperties.get(LanguageProperties.MAIN_SOURCE_FILE);
LanguageAnnotationValue property = sourceFileProperties.get(LanguageAnnotation.MAIN_SOURCE_FILE);
if (property != null) {
if (StringUtility.isSpecified(property.value)) {
IPath mainSourceFileIPath;
@ -114,7 +115,7 @@ public final class LanguageEditorFilesLogic {
plugin.logError("Cannot read main source file '{0'}", new Object[] { mainSourceFile.getPath() },
ex);
mainSourceFileProperties = new LanguageProperties();
mainSourceFileProperties = new LanguageAnnotationValues();
}
}
@ -143,7 +144,7 @@ public final class LanguageEditorFilesLogic {
// the include source file. In all other cases, the main source file
// exists and is the main message target.
if (!files.mainSourceFile.iFile.exists()) {
int lineNumber = files.sourceFile.languageProperties.get(LanguageProperties.MAIN_SOURCE_FILE).lineNumber;
int lineNumber = files.sourceFile.languageAnnotationValues.get(LanguageAnnotation.MAIN_SOURCE_FILE).lineNumber;
// ERROR: Main source file '{0}' does not exist.
IMarker marker = MarkerUtility.createMarker(files.sourceFile.iFile, lineNumber, IMarker.SEVERITY_ERROR,
@ -163,8 +164,8 @@ public final class LanguageEditorFilesLogic {
}
/**
* Determine the hardware defined by the property
* {@link LanguageProperties#HARDWARE}.
* Determine the hardware defined by the value
* {@link LanguageAnnotationValues#HARDWARE}.
*
* @param iFile The IFile to which error message will be associated, not
* <code>null</code>.
@ -172,18 +173,18 @@ public final class LanguageEditorFilesLogic {
*
* @return The hardware or <code>null</code> if is the not defined in the
* properties.
* @throws InvalidLanguagePropertyException If the hardware is specified but
* @throws InvalidLanguageAnnotationException If the hardware is specified but
* invalid. Error message will be
* assigned to the iFile in this case.
*
* @since 1.6.1
*/
Hardware getHardware(IFile iFile, LanguageProperties properties) throws InvalidLanguagePropertyException {
Hardware getHardware(IFile iFile, LanguageAnnotationValues properties) throws InvalidLanguageAnnotationException {
if (iFile == null) {
throw new IllegalArgumentException("Parameter 'iFile' must not be null.");
}
Hardware hardware = null;
LanguageProperty hardwareProperty = properties.get(LanguageProperties.HARDWARE);
LanguageAnnotationValue hardwareProperty = properties.get(LanguageAnnotation.HARDWARE);
if (hardwareProperty != null) {
Map<String, Hardware> allowedValues = new TreeMap<String, Hardware>();
StringBuilder allowedValuesBuilder = new StringBuilder();
@ -209,7 +210,7 @@ public final class LanguageEditorFilesLogic {
// following valid values '{0}'.
IMarker marker = MarkerUtility.createMarker(iFile, hardwareProperty.lineNumber, IMarker.SEVERITY_ERROR,
Texts.MESSAGE_E128, new String[] { allowedValuesBuilder.toString() });
throw new InvalidLanguagePropertyException(hardwareProperty, marker);
throw new InvalidLanguageAnnotationException(hardwareProperty, marker);
}
hardware = allowedValues.get(hardwarePropertyValue);
@ -223,7 +224,7 @@ public final class LanguageEditorFilesLogic {
// following valid values '{1}'.
IMarker marker = MarkerUtility.createMarker(iFile, hardwareProperty.lineNumber, IMarker.SEVERITY_ERROR,
Texts.MESSAGE_E124, new String[] { hardwarePropertyValue, allowedValuesBuilder.toString() });
throw new InvalidLanguagePropertyException(hardwareProperty, marker);
throw new InvalidLanguageAnnotationException(hardwareProperty, marker);
}
}
@ -247,14 +248,14 @@ public final class LanguageEditorFilesLogic {
Hardware mainSourceFileHardware;
Hardware sourceFileHardware;
try {
sourceFileHardware = getHardware(files.sourceFile.iFile, files.sourceFile.languageProperties);
} catch (InvalidLanguagePropertyException ex) {
sourceFileHardware = getHardware(files.sourceFile.iFile, files.sourceFile.languageAnnotationValues);
} catch (InvalidLanguageAnnotationException ex) {
MarkerUtility.gotoMarker(languageEditor, ex.marker);
return null;
}
try {
mainSourceFileHardware = getHardware(files.mainSourceFile.iFile, files.mainSourceFile.languageProperties);
} catch (InvalidLanguagePropertyException ex) {
mainSourceFileHardware = getHardware(files.mainSourceFile.iFile, files.mainSourceFile.languageAnnotationValues);
} catch (InvalidLanguageAnnotationException ex) {
MarkerUtility.gotoMarker(languageEditor, ex.marker);
return null;
}
@ -265,14 +266,14 @@ public final class LanguageEditorFilesLogic {
sourceFileHardware = defaultHardware;
sourceFileLineNumber = 0;
} else {
sourceFileLineNumber = files.sourceFile.languageProperties.get(LanguageProperties.HARDWARE).lineNumber;
sourceFileLineNumber = files.sourceFile.languageAnnotationValues.get(LanguageAnnotation.HARDWARE).lineNumber;
}
if (mainSourceFileHardware == null) {
mainSourceFileHardware = defaultHardware;
mainSourceFileLineNumber = 0;
} else {
mainSourceFileLineNumber = files.mainSourceFile.languageProperties
.get(LanguageProperties.HARDWARE).lineNumber;
mainSourceFileLineNumber = files.mainSourceFile.languageAnnotationValues
.get(LanguageAnnotation.HARDWARE).lineNumber;
}
if (!sourceFileHardware.equals(mainSourceFileHardware)) {
@ -304,7 +305,7 @@ public final class LanguageEditorFilesLogic {
// via the annotation '{2}'.
createMainSourceFileMessage(files, files.outputFileExtensionProperty, IMarker.SEVERITY_ERROR,
Texts.MESSAGE_E104, compilerDefinition.getText(), compilerDefinition.getName(),
LanguageProperties.OUTPUT_FILE_EXTENSION);
LanguageAnnotation.OUTPUT_FILE_EXTENSION);
return false;
}
@ -319,7 +320,7 @@ public final class LanguageEditorFilesLogic {
// ERROR: Output folder mode be set in the preferences of
// compiler '{0}' or via the annotation '{1}'.
createMainSourceFileMessage(files, files.outputFolderModeProperty, IMarker.SEVERITY_ERROR,
Texts.MESSAGE_E140, compilerDefinition.getName(), LanguageProperties.OUTPUT_FOLDER_MODE);
Texts.MESSAGE_E140, compilerDefinition.getName(), LanguageAnnotation.OUTPUT_FOLDER_MODE);
return false;
}
@ -338,11 +339,11 @@ public final class LanguageEditorFilesLogic {
/**
* Creates a message associated with the main source file of an
* {@link LanguageEditorFilesLogic} instance. The message is is bound to the
* line number number of the property (if available). Also the editor is
* line number number of the value (if available). Also the editor is
* position to the marker.
*
* @param files The {@link CompilerFiles} not <code>null</code>.
* @param property The language property to which the message belongs or
* @param value The language value to which the message belongs or
* <code>null</code>.
* @param severity The message severity, see {@link IMarker#SEVERITY}
* @param message The message, may contain parameter "{0}" to "{9}". May be
@ -350,7 +351,7 @@ public final class LanguageEditorFilesLogic {
* @param parameters The format parameters for the message, may be empty, not
* <code>null</code>.
*/
private void createMainSourceFileMessage(CompilerFiles files, LanguageProperty property, int severity,
private void createMainSourceFileMessage(CompilerFiles files, LanguageAnnotationValue property, int severity,
String message, String... parameters) {
if (files == null) {
throw new IllegalArgumentException("Parameter 'files' must not be null.");

View File

@ -78,7 +78,7 @@ final class LanguageRuleBasedScanner extends RuleBasedScanner {
* {@link LanguageSourceViewerConfiguration}.
*
* @param preferences The preferences, not <code>null</code>.
* @param changedPropertyNames The set of changed property names, not
* @param changedPropertyNames The set of changed value names, not
* <code>null</code>.
*
* @return <code>true</code> If the editor has to be refreshed.

View File

@ -483,7 +483,7 @@ final class LanguageSourceScanner extends RuleBasedScanner {
* {@link LanguageSourceViewerConfiguration}.
*
* @param preferences The preferences, not <code>null</code>.
* @param changedPreferencesKeys The set of changed property names, not
* @param changedPreferencesKeys The set of changed value names, not
* <code>null</code>.
*
* @return <code>true</code> If the editor has to be refreshed.

View File

@ -109,7 +109,7 @@ final class LanguageSourceViewerConfiguration extends TextSourceViewerConfigurat
}
/**
* Remove all rule scanners from property change listener. Used by
* Remove all rule scanners from value change listener. Used by
* {@link LanguageEditor#dispose()}.
*/
final void dispose() {

View File

@ -1,157 +1,157 @@
/**
* 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.editor;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension6;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
/**
* The standard implementation of the <code>ICompletionProposal</code>
* interface.
*
* @author Peter Dell
*/
final class LanguagetTextCompletionProposal implements ICompletionProposal, ICompletionProposalExtension6 {
/** The string to be displayed in the completion proposal popup. */
private String displayString;
private StyledString styledDisplayString;
/** The replacement string. */
private String replacementString;
/** The replacement offset. */
private int replacementOffset;
/** The replacement length. */
private int replacementLength;
/** The offset of the cursor after applying the replacement. */
private int cursorOffset;
/** The image to be displayed in the completion proposal popup. */
private Image image;
/** The context information of this proposal. */
private IContextInformation contextInformation;
/**
* Creates a new completion proposal. All fields are initialized based on the
* provided information.
*
* @param replacementString The actual string to be inserted into the
* document.
* @param replacementOffset The offset of the text to be replaced.
* @param replacementLength The length of the text to be replaced.
* @param cursorOffset The offset of the cursor after applying the
* replacement.
* @param image The image to display for this proposal.
* @param displayString The string to be displayed for the proposal.
* @param styledDisplayString The styles display string for the proposal.
* @param contextInformation The context information associated with this
* proposal.
*/
LanguagetTextCompletionProposal(String replacementString, int replacementOffset, int replacementLength,
int cursorOffset, Image image, String displayString, StyledString styledDisplayString,
IContextInformation contextInformation) {
Assert.isNotNull(replacementString);
Assert.isNotNull(displayString);
Assert.isTrue(replacementOffset >= 0);
Assert.isTrue(replacementLength >= 0);
Assert.isTrue(cursorOffset >= 0);
this.replacementString = replacementString;
this.replacementOffset = replacementOffset;
this.replacementLength = replacementLength;
this.cursorOffset = cursorOffset;
this.image = image;
this.displayString = displayString;
this.styledDisplayString = styledDisplayString;
this.contextInformation = contextInformation;
}
/*
* @see ICompletionProposal#apply(IDocument)
*/
@Override
public void apply(IDocument document) {
try {
document.replace(replacementOffset, replacementLength, replacementString);
} catch (BadLocationException ex) {
throw new RuntimeException("Replacement offset " + replacementOffset + " no valid", ex);
}
}
/*
* @see ICompletionProposal#getSelection(IDocument)
*/
@Override
public Point getSelection(IDocument document) {
return new Point(cursorOffset, 0);
}
/*
* @see ICompletionProposal#getContextInformation()
*/
@Override
public IContextInformation getContextInformation() {
return contextInformation;
}
/*
* @see ICompletionProposal#getImage()
*/
@Override
public Image getImage() {
return image;
}
/*
* @see ICompletionProposal#getDisplayString()
*/
@Override
public String getDisplayString() {
if (displayString != null)
return displayString;
return replacementString;
}
/*
* @see ICompletionProposalExtension6#getStyledDisplayString()
*/
@Override
public StyledString getStyledDisplayString() {
return styledDisplayString;
}
/*
* @see ICompletionProposal#getAdditionalProposalInfo()
*/
@Override
public String getAdditionalProposalInfo() {
return "";
}
}
/**
* 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.editor;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension6;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
/**
* The standard implementation of the <code>ICompletionProposal</code>
* interface.
*
* @author Peter Dell
*/
final class LanguageTextCompletionProposal implements ICompletionProposal, ICompletionProposalExtension6 {
/** The string to be displayed in the completion proposal popup. */
private String displayString;
private StyledString styledDisplayString;
/** The replacement string. */
private String replacementString;
/** The replacement offset. */
private int replacementOffset;
/** The replacement length. */
private int replacementLength;
/** The offset of the cursor after applying the replacement. */
private int cursorOffset;
/** The image to be displayed in the completion proposal popup. */
private Image image;
/** The context information of this proposal. */
private IContextInformation contextInformation;
/**
* Creates a new completion proposal. All fields are initialized based on the
* provided information.
*
* @param replacementString The actual string to be inserted into the
* document.
* @param replacementOffset The offset of the text to be replaced.
* @param replacementLength The length of the text to be replaced.
* @param cursorOffset The offset of the cursor after applying the
* replacement.
* @param image The image to display for this proposal.
* @param displayString The string to be displayed for the proposal.
* @param styledDisplayString The styles display string for the proposal.
* @param contextInformation The context information associated with this
* proposal.
*/
LanguageTextCompletionProposal(String replacementString, int replacementOffset, int replacementLength,
int cursorOffset, Image image, String displayString, StyledString styledDisplayString,
IContextInformation contextInformation) {
Assert.isNotNull(replacementString);
Assert.isNotNull(displayString);
Assert.isTrue(replacementOffset >= 0);
Assert.isTrue(replacementLength >= 0);
Assert.isTrue(cursorOffset >= 0);
this.replacementString = replacementString;
this.replacementOffset = replacementOffset;
this.replacementLength = replacementLength;
this.cursorOffset = cursorOffset;
this.image = image;
this.displayString = displayString;
this.styledDisplayString = styledDisplayString;
this.contextInformation = contextInformation;
}
/*
* @see ICompletionProposal#apply(IDocument)
*/
@Override
public void apply(IDocument document) {
try {
document.replace(replacementOffset, replacementLength, replacementString);
} catch (BadLocationException ex) {
throw new RuntimeException("Replacement offset " + replacementOffset + " no valid", ex);
}
}
/*
* @see ICompletionProposal#getSelection(IDocument)
*/
@Override
public Point getSelection(IDocument document) {
return new Point(cursorOffset, 0);
}
/*
* @see ICompletionProposal#getContextInformation()
*/
@Override
public IContextInformation getContextInformation() {
return contextInformation;
}
/*
* @see ICompletionProposal#getImage()
*/
@Override
public Image getImage() {
return image;
}
/*
* @see ICompletionProposal#getDisplayString()
*/
@Override
public String getDisplayString() {
if (displayString != null)
return displayString;
return replacementString;
}
/*
* @see ICompletionProposalExtension6#getStyledDisplayString()
*/
@Override
public StyledString getStyledDisplayString() {
return styledDisplayString;
}
/*
* @see ICompletionProposal#getAdditionalProposalInfo()
*/
@Override
public String getAdditionalProposalInfo() {
return "";
}
}

View File

@ -90,7 +90,7 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
+ "<html><head>" + "<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">"
+ "<link rel=\"stylesheet\" href=\"../../../content/org.eclipse.platform/book.css\" type=\"text/css\"></link>"
+ "<style type=\"text/css\">table,tbody,td,th {border-style:solid;border-width:1px;border-collapse:collapse; "
+ "transition-property: background-color;transition-duration: 0.25s;transition-timing-function: linear;transition-delay: 0ms;} "
+ "transition-value: background-color;transition-duration: 0.25s;transition-timing-function: linear;transition-delay: 0ms;} "
+ "th {background-color:#0074cc;color:#fff } </style>" + "</head><body>";
private static final String SECTION_SUFFIX = "</body></html>";

View File

@ -128,7 +128,7 @@ public final class LanguageOutlinePage extends ContentOutlinePage {
boolean checked = isChecked();
setChecked(checked);
// Store the property.
// Store the value.
String checkedProperty = Boolean.toString(checked);
try {
IFile iFile = editor.getCurrentIFile();
@ -136,7 +136,7 @@ public final class LanguageOutlinePage extends ContentOutlinePage {
iFile.setPersistentProperty(CHECKED, checkedProperty);
}
} catch (CoreException ex) {
editor.getPlugin().logError("Cannot set property {0}", new Object[] { CHECKED }, ex);
editor.getPlugin().logError("Cannot set value {0}", new Object[] { CHECKED }, ex);
}
editor.getPlugin().setProperty(CHECKED, checkedProperty);

View File

@ -21,7 +21,7 @@ package com.wudsn.ide.lng.preferences;
import com.wudsn.ide.base.common.StringUtility;
import com.wudsn.ide.base.hardware.Hardware;
import com.wudsn.ide.lng.LanguageProperties;
import com.wudsn.ide.lng.LanguageAnnotationValues;
/**
* Facade class to mix compiler run specific preferences into the global
@ -33,10 +33,10 @@ import com.wudsn.ide.lng.LanguageProperties;
public final class CompilerRunPreferences {
private LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences;
private LanguageProperties mainSourceFileProperties;
private LanguageAnnotationValues mainSourceFileProperties;
public CompilerRunPreferences(LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences,
LanguageProperties mainSourceFileProperties) {
LanguageAnnotationValues mainSourceFileProperties) {
if (languageHardwareCompilerDefinitionPreferences == null) {
throw new IllegalArgumentException("Parameter 'languageHardwareCompilerDefinitionPreferences' must not be null.");
}

View File

@ -160,7 +160,7 @@ public final class LanguagePreferences {
}
/**
* Create the preferences key for a property of a given language.
* Create the preferences key for a value of a given language.
*
* @param language The language, not <code>null</code>
* @param preferencesKeySuffix The suffix as defined by the constants of this

View File

@ -269,7 +269,7 @@ public final class LanguagePreferencesConstants {
}
/**
* Create the preferences key for a property of a given language.
* Create the preferences key for a value of a given language.
*
* @param language The language, not <code>null</code>
* @param preferencesKeySuffix The suffix as defined by the constants of this

View File

@ -115,7 +115,7 @@ public abstract class LanguagePreferencesPage extends FieldEditorPreferencePage
private LanguagePlugin plugin;
/**
* The set of property names for which the value was changed since the page was
* The set of value names for which the value was changed since the page was
* opened.
*/
private Set<String> changedPropertyNames;

View File

@ -20,7 +20,7 @@
package com.wudsn.ide.lng.preferences;
/**
* A property key with it's label
* A value key with it's label
*
* @author Peter Dell
*/