mirror of
https://github.com/peterdell/wudsn-ide.git
synced 2024-06-03 06:29:35 +00:00
Refactor towards ILanguageEditor
This commit is contained in:
parent
4a5bb29da4
commit
29116e8160
|
@ -95,7 +95,7 @@
|
||||||
contributorClass="org.eclipse.ui.part.EditorActionBarContributor"
|
contributorClass="org.eclipse.ui.part.EditorActionBarContributor"
|
||||||
default="true"
|
default="true"
|
||||||
extensions="bmp, ico, gif, jpg, png, cnv"
|
extensions="bmp, ico, gif, jpg, png, cnv"
|
||||||
icon="icons/graphics-editor.png"
|
icon="icons/graphics-editor-16x16.png"
|
||||||
id="com.wudsn.ide.gfx.editor.GraphicsConversionEditor"
|
id="com.wudsn.ide.gfx.editor.GraphicsConversionEditor"
|
||||||
name="%com.wudsn.ide.gfx.editor.GraphicsConversionEditor.name">
|
name="%com.wudsn.ide.gfx.editor.GraphicsConversionEditor.name">
|
||||||
<contentTypeBinding
|
<contentTypeBinding
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
<with
|
<with
|
||||||
variable="activeEditor">
|
variable="activeEditor">
|
||||||
<instanceof
|
<instanceof
|
||||||
value="com.wudsn.ide.lng.editor.LanguageEditor">
|
value="com.wudsn.ide.lng.editor.ILanguageEditor">
|
||||||
</instanceof>
|
</instanceof>
|
||||||
</with></activeWhen>
|
</with></activeWhen>
|
||||||
</handler>
|
</handler>
|
||||||
|
@ -123,63 +123,11 @@
|
||||||
<with
|
<with
|
||||||
variable="activeEditor">
|
variable="activeEditor">
|
||||||
<instanceof
|
<instanceof
|
||||||
value="com.wudsn.ide.lng.editor.LanguageEditor">
|
value="com.wudsn.ide.lng.editor.ILanguageEditor">
|
||||||
</instanceof>
|
</instanceof>
|
||||||
</with>
|
</with>
|
||||||
</activeWhen>
|
</activeWhen>
|
||||||
</handler>
|
</handler>
|
||||||
<handler
|
|
||||||
class="com.wudsn.ide.lng.editor.LanguageEditorCompileCommandHandler"
|
|
||||||
commandId="com.wudsn.ide.lng.editor.LanguageEditorAssembleCommand">
|
|
||||||
<activeWhen>
|
|
||||||
<with
|
|
||||||
variable="activeEditor">
|
|
||||||
<test
|
|
||||||
property="com.wudsn.ide.lng.IsLanguageEditor"
|
|
||||||
value="true">
|
|
||||||
</test>
|
|
||||||
</with>
|
|
||||||
</activeWhen>
|
|
||||||
</handler>
|
|
||||||
<handler
|
|
||||||
class="com.wudsn.ide.lng.editor.LanguageEditorCompileCommandHandler"
|
|
||||||
commandId="com.wudsn.ide.lng.editor.LanguageEditorAssembleAndRunCommand">
|
|
||||||
<activeWhen>
|
|
||||||
<with
|
|
||||||
variable="activeEditor">
|
|
||||||
<test
|
|
||||||
property="com.wudsn.ide.lng.IsLanguageEditor"
|
|
||||||
value="true">
|
|
||||||
</test>
|
|
||||||
</with>
|
|
||||||
</activeWhen>
|
|
||||||
</handler>
|
|
||||||
<handler
|
|
||||||
class="com.wudsn.ide.lng.editor.LanguageEditorCompileCommandHandler"
|
|
||||||
commandId="com.wudsn.ide.lng.editor.LanguageEditorAssembleAndRunWithCommand">
|
|
||||||
<activeWhen>
|
|
||||||
<with
|
|
||||||
variable="activeEditor">
|
|
||||||
<test
|
|
||||||
property="com.wudsn.ide.lng.IsLanguageEditor"
|
|
||||||
value="true">
|
|
||||||
</test>
|
|
||||||
</with>
|
|
||||||
</activeWhen>
|
|
||||||
</handler>
|
|
||||||
<handler
|
|
||||||
class="com.wudsn.ide.lng.editor.LanguageEditorCompilerHelpCommandHandler"
|
|
||||||
commandId="com.wudsn.ide.lng.editor.LanguageEditorAssemblerHelpCommand">
|
|
||||||
<activeWhen>
|
|
||||||
<with
|
|
||||||
variable="activeEditor">
|
|
||||||
<test
|
|
||||||
property="com.wudsn.ide.lng.IsLanguageEditor"
|
|
||||||
value="true">
|
|
||||||
</test>
|
|
||||||
</with>
|
|
||||||
</activeWhen>
|
|
||||||
</handler>
|
|
||||||
<handler
|
<handler
|
||||||
class="com.wudsn.ide.lng.editor.LanguageEditorCompileCommandHandler"
|
class="com.wudsn.ide.lng.editor.LanguageEditorCompileCommandHandler"
|
||||||
commandId="com.wudsn.ide.lng.editor.LanguageEditorCompileCommand">
|
commandId="com.wudsn.ide.lng.editor.LanguageEditorCompileCommand">
|
||||||
|
@ -239,7 +187,7 @@
|
||||||
<with
|
<with
|
||||||
variable="activeEditor">
|
variable="activeEditor">
|
||||||
<instanceof
|
<instanceof
|
||||||
value="com.wudsn.ide.lng.editor.LanguageEditor">
|
value="com.wudsn.ide.lng.editor.ILanguageEditor">
|
||||||
</instanceof>
|
</instanceof>
|
||||||
</with>
|
</with>
|
||||||
</activeWhen>
|
</activeWhen>
|
||||||
|
|
|
@ -32,10 +32,8 @@ import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
|
||||||
import com.wudsn.ide.base.common.MarkerUtility;
|
|
||||||
import com.wudsn.ide.base.common.StringUtility;
|
import com.wudsn.ide.base.common.StringUtility;
|
||||||
import com.wudsn.ide.base.common.TextUtility;
|
import com.wudsn.ide.base.common.TextUtility;
|
||||||
import com.wudsn.ide.lng.compiler.CompilerFiles.SourceFile;
|
|
||||||
|
|
||||||
public final class LanguageAnnotationValues {
|
public final class LanguageAnnotationValues {
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.wudsn.ide.base.common.TextUtility;
|
||||||
import com.wudsn.ide.lng.Language;
|
import com.wudsn.ide.lng.Language;
|
||||||
import com.wudsn.ide.lng.LanguageUtility;
|
import com.wudsn.ide.lng.LanguageUtility;
|
||||||
import com.wudsn.ide.lng.Texts;
|
import com.wudsn.ide.lng.Texts;
|
||||||
import com.wudsn.ide.lng.editor.LanguageEditor;
|
import com.wudsn.ide.lng.editor.ILanguageEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory for {@LanguageBreakpointsTarget} instances. Used by extension
|
* Factory for {@LanguageBreakpointsTarget} instances. Used by extension
|
||||||
|
@ -51,7 +51,7 @@ public final class LanguageBreakpointAdapterFactory implements IToggleBreakpoint
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) {
|
public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) {
|
||||||
if (part instanceof LanguageEditor) {
|
if (part instanceof ILanguageEditor) {
|
||||||
Set<String> defaultSet = new HashSet<String>();
|
Set<String> defaultSet = new HashSet<String>();
|
||||||
defaultSet.add(getDefaultToggleTarget(part, selection));
|
defaultSet.add(getDefaultToggleTarget(part, selection));
|
||||||
return defaultSet;
|
return defaultSet;
|
||||||
|
@ -61,8 +61,8 @@ public final class LanguageBreakpointAdapterFactory implements IToggleBreakpoint
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) {
|
public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) {
|
||||||
if (part instanceof LanguageEditor) {
|
if (part instanceof ILanguageEditor) {
|
||||||
LanguageEditor languageEditor = (LanguageEditor) part;
|
var languageEditor = (ILanguageEditor) part;
|
||||||
return TARGET_ID_PREFIX + languageEditor.getLanguage().name();
|
return TARGET_ID_PREFIX + languageEditor.getLanguage().name();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -26,15 +26,13 @@ import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
import org.eclipse.debug.core.model.ILineBreakpoint;
|
import org.eclipse.debug.core.model.ILineBreakpoint;
|
||||||
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
|
||||||
|
|
||||||
import com.wudsn.ide.base.common.StringUtility;
|
import com.wudsn.ide.base.common.StringUtility;
|
||||||
import com.wudsn.ide.lng.editor.LanguageEditor;
|
import com.wudsn.ide.lng.editor.ILanguageEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target which creates {@link LanguageBreakpoint} instances. Used by
|
* Target which creates {@link LanguageBreakpoint} instances. Used by
|
||||||
|
@ -50,7 +48,7 @@ public final class LanguageBreakpointsTarget implements IToggleBreakpointsTarget
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
|
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
|
||||||
LanguageEditor languageEditor = getEditor(part);
|
var languageEditor = getEditor(part);
|
||||||
if (languageEditor != null) {
|
if (languageEditor != null) {
|
||||||
IBreakpointManager breakPointManager = DebugPlugin.getDefault().getBreakpointManager();
|
IBreakpointManager breakPointManager = DebugPlugin.getDefault().getBreakpointManager();
|
||||||
String editorId = languageEditor.getClass().getName();
|
String editorId = languageEditor.getClass().getName();
|
||||||
|
@ -71,8 +69,7 @@ public final class LanguageBreakpointsTarget implements IToggleBreakpointsTarget
|
||||||
}
|
}
|
||||||
// Create line breakpoint (doc line numbers start at 0)
|
// Create line breakpoint (doc line numbers start at 0)
|
||||||
String description;
|
String description;
|
||||||
IDocumentProvider provider = languageEditor.getDocumentProvider();
|
var document = languageEditor.getDocument();
|
||||||
IDocument document = provider.getDocument(languageEditor.getEditorInput());
|
|
||||||
try {
|
try {
|
||||||
int startOffset = document.getLineOffset(lineNumber);
|
int startOffset = document.getLineOffset(lineNumber);
|
||||||
int lineLength = document.getLineLength(lineNumber);
|
int lineLength = document.getLineLength(lineNumber);
|
||||||
|
@ -156,9 +153,9 @@ public final class LanguageBreakpointsTarget implements IToggleBreakpointsTarget
|
||||||
* @param part The editor part or <code>null</code>.
|
* @param part The editor part or <code>null</code>.
|
||||||
* @return The language editor or <code>null</code>.
|
* @return The language editor or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
private LanguageEditor getEditor(IWorkbenchPart part) {
|
private ILanguageEditor getEditor(IWorkbenchPart part) {
|
||||||
if (part instanceof LanguageEditor) {
|
if (part instanceof ILanguageEditor) {
|
||||||
LanguageEditor languageEditor = (LanguageEditor) part;
|
var languageEditor = (ILanguageEditor) part;
|
||||||
if (languageEditor.getCurrentFile() != null) {
|
if (languageEditor.getCurrentFile() != null) {
|
||||||
return languageEditor;
|
return languageEditor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,8 @@ import org.eclipse.jface.text.IRegion;
|
||||||
import com.wudsn.ide.base.BasePlugin;
|
import com.wudsn.ide.base.BasePlugin;
|
||||||
import com.wudsn.ide.base.common.FileUtility;
|
import com.wudsn.ide.base.common.FileUtility;
|
||||||
import com.wudsn.ide.base.common.StringUtility;
|
import com.wudsn.ide.base.common.StringUtility;
|
||||||
import com.wudsn.ide.lng.LanguagePlugin;
|
|
||||||
import com.wudsn.ide.lng.LanguageAnnotation;
|
|
||||||
import com.wudsn.ide.lng.LanguageAnnotationValues;
|
import com.wudsn.ide.lng.LanguageAnnotationValues;
|
||||||
|
import com.wudsn.ide.lng.LanguagePlugin;
|
||||||
import com.wudsn.ide.lng.compiler.Compiler;
|
import com.wudsn.ide.lng.compiler.Compiler;
|
||||||
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
|
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
|
||||||
import com.wudsn.ide.lng.compiler.syntax.Instruction;
|
import com.wudsn.ide.lng.compiler.syntax.Instruction;
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.jface.text.rules.MultiLineRule;
|
||||||
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
|
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
|
||||||
import org.eclipse.jface.text.rules.SingleLineRule;
|
import org.eclipse.jface.text.rules.SingleLineRule;
|
||||||
import org.eclipse.jface.text.rules.Token;
|
import org.eclipse.jface.text.rules.Token;
|
||||||
|
import org.eclipse.ui.IEditorInput;
|
||||||
|
|
||||||
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
|
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
|
||||||
import com.wudsn.ide.lng.editor.LanguageEditor;
|
import com.wudsn.ide.lng.editor.LanguageEditor;
|
||||||
|
@ -63,7 +64,7 @@ public final class CompilerSourcePartitionScanner extends RuleBasedPartitionScan
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*
|
*
|
||||||
* Called by
|
* Called by
|
||||||
* {@link LanguageEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)}
|
* {@link LanguageEditor#doSetInput(IEditorInput input)
|
||||||
* .
|
* .
|
||||||
*
|
*
|
||||||
* @param compilerSyntax The compiler syntax, not <code>null</code>.
|
* @param compilerSyntax The compiler syntax, not <code>null</code>.
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
/**
|
||||||
|
* 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 java.io.File;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
|
||||||
|
import com.wudsn.ide.lng.Language;
|
||||||
|
import com.wudsn.ide.lng.LanguagePlugin;
|
||||||
|
import com.wudsn.ide.lng.compiler.Compiler;
|
||||||
|
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||||
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
||||||
|
import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferences;
|
||||||
|
import com.wudsn.ide.lng.preferences.LanguagePreferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The language editor interface.
|
||||||
|
*
|
||||||
|
* @author Peter Dell
|
||||||
|
*/
|
||||||
|
public interface ILanguageEditor extends IEditorPart {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the plugin this compiler instance belongs to.
|
||||||
|
*
|
||||||
|
* @return The plugin this compiler instance belongs to, not <code>null</code>.
|
||||||
|
*/
|
||||||
|
public LanguagePlugin getPlugin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the language.
|
||||||
|
*
|
||||||
|
* @return The language, not <code>null</code>.
|
||||||
|
*/
|
||||||
|
public Language getLanguage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the language preferences.
|
||||||
|
*
|
||||||
|
* @return The language preferences, not <code>null</code>.
|
||||||
|
*/
|
||||||
|
public LanguagePreferences getLanguagePreferences();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the compiler preferences.
|
||||||
|
*
|
||||||
|
* @return The compiler preferences, not <code>null</code>.
|
||||||
|
*/
|
||||||
|
public LanguageHardwareCompilerDefinitionPreferences getLanguageHardwareCompilerPreferences();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the compiler for this editor.
|
||||||
|
*
|
||||||
|
* @return The compiler for this editor, not <code>null</code>.
|
||||||
|
*/
|
||||||
|
public Compiler getCompiler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the compiler definition for this editor.
|
||||||
|
*
|
||||||
|
* @return The compiler definition for this editor, not <code>null</code>.
|
||||||
|
*
|
||||||
|
* @sine 1.6.1
|
||||||
|
*/
|
||||||
|
public CompilerDefinition getCompilerDefinition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the the current file.
|
||||||
|
*
|
||||||
|
* @return The current file or <code>null</code>.
|
||||||
|
*/
|
||||||
|
public IFile getCurrentIFile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the the current file.
|
||||||
|
*
|
||||||
|
* @return The current file or <code>null</code>.
|
||||||
|
*/
|
||||||
|
public File getCurrentFile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the directory of the current file.
|
||||||
|
*
|
||||||
|
* @return The directory of the current file or <code>null</code>.
|
||||||
|
*/
|
||||||
|
public File getCurrentDirectory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this text editor's document.
|
||||||
|
*
|
||||||
|
* @return the document or <code>null</code> if none, e.g. after closing the
|
||||||
|
* editor
|
||||||
|
*/
|
||||||
|
IDocument getDocument();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a compiler source parser for this editor and the currently selected
|
||||||
|
* instruction set.
|
||||||
|
*
|
||||||
|
* @return The compiler source parser for this editor, not <code>null</code> .
|
||||||
|
*/
|
||||||
|
public CompilerSourceParser createCompilerSourceParser();
|
||||||
|
}
|
|
@ -39,7 +39,6 @@ import org.eclipse.swt.graphics.TextStyle;
|
||||||
|
|
||||||
import com.wudsn.ide.base.common.StringUtility;
|
import com.wudsn.ide.base.common.StringUtility;
|
||||||
import com.wudsn.ide.lng.LanguagePlugin;
|
import com.wudsn.ide.lng.LanguagePlugin;
|
||||||
import com.wudsn.ide.lng.compiler.CompilerFiles;
|
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserLineCallback;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserLineCallback;
|
||||||
|
@ -146,7 +145,7 @@ final class LanguageContentAssistProcessor implements IContentAssistProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LanguageEditor editor;
|
private ILanguageEditor editor;
|
||||||
|
|
||||||
private Image directiveImage;
|
private Image directiveImage;
|
||||||
private Image legalOpcodeImage;
|
private Image legalOpcodeImage;
|
||||||
|
@ -165,7 +164,7 @@ final class LanguageContentAssistProcessor implements IContentAssistProcessor {
|
||||||
* @param editor The language editor for which this instance is created, not
|
* @param editor The language editor for which this instance is created, not
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
*/
|
*/
|
||||||
LanguageContentAssistProcessor(LanguageEditor editor) {
|
LanguageContentAssistProcessor(ILanguageEditor editor) {
|
||||||
if (editor == null) {
|
if (editor == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
||||||
}
|
}
|
||||||
|
@ -189,7 +188,7 @@ final class LanguageContentAssistProcessor implements IContentAssistProcessor {
|
||||||
if (viewer == null) {
|
if (viewer == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'viewer' must not be null.");
|
throw new IllegalArgumentException("Parameter 'viewer' must not be null.");
|
||||||
}
|
}
|
||||||
ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection();
|
var selection = (ITextSelection) viewer.getSelectionProvider().getSelection();
|
||||||
|
|
||||||
int selectionOffset = offset;
|
int selectionOffset = offset;
|
||||||
|
|
||||||
|
@ -212,13 +211,13 @@ final class LanguageContentAssistProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
// Parse the current compiler file and try to find the line in the
|
// Parse the current compiler file and try to find the line in the
|
||||||
// correct source file.
|
// correct source file.
|
||||||
CompilerFiles files = LanguageEditorFilesLogic.createInstance(editor).createCompilerFiles();
|
var files = LanguageEditorFilesLogic.createInstance(editor).createCompilerFiles();
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
SourceParserCallback compilerSourceCallback = new SourceParserCallback(files.sourceFile.filePath, lineNumber);
|
var compilerSourceCallback = new SourceParserCallback(files.sourceFile.filePath, lineNumber);
|
||||||
CompilerSourceParser compilerSourceParser = editor.createCompilerSourceParser();
|
var compilerSourceParser = editor.createCompilerSourceParser();
|
||||||
CompilerSourceFile compilerSourceFile = compilerSourceParser.createCompilerSourceFile(files.sourceFile.file,
|
var compilerSourceFile = compilerSourceParser.createCompilerSourceFile(files.sourceFile.file,
|
||||||
viewer.getDocument());
|
viewer.getDocument());
|
||||||
compilerSourceParser.parse(compilerSourceFile, compilerSourceCallback);
|
compilerSourceParser.parse(compilerSourceFile, compilerSourceCallback);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.editors.text.TextEditor;
|
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.TextOperationAction;
|
import org.eclipse.ui.texteditor.TextOperationAction;
|
||||||
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
||||||
|
|
||||||
|
@ -57,7 +56,6 @@ import com.wudsn.ide.base.hardware.Hardware;
|
||||||
import com.wudsn.ide.lng.Language;
|
import com.wudsn.ide.lng.Language;
|
||||||
import com.wudsn.ide.lng.LanguageAnnotationValues.InvalidLanguageAnnotationException;
|
import com.wudsn.ide.lng.LanguageAnnotationValues.InvalidLanguageAnnotationException;
|
||||||
import com.wudsn.ide.lng.LanguagePlugin;
|
import com.wudsn.ide.lng.LanguagePlugin;
|
||||||
import com.wudsn.ide.lng.Target;
|
|
||||||
import com.wudsn.ide.lng.compiler.Compiler;
|
import com.wudsn.ide.lng.compiler.Compiler;
|
||||||
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
||||||
|
@ -74,7 +72,7 @@ import com.wudsn.ide.lng.preferences.LanguagePreferences;
|
||||||
* @author Peter Dell
|
* @author Peter Dell
|
||||||
* @author Andy Reek
|
* @author Andy Reek
|
||||||
*/
|
*/
|
||||||
public abstract class LanguageEditor extends TextEditor {
|
public abstract class LanguageEditor extends TextEditor implements ILanguageEditor {
|
||||||
|
|
||||||
private static final class Actions {
|
private static final class Actions {
|
||||||
|
|
||||||
|
@ -102,13 +100,46 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
filesLogic = LanguageEditorFilesLogic.createInstance(this);
|
filesLogic = LanguageEditorFilesLogic.createInstance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets the files logic associated with this editor.
|
protected final void initializeEditor() {
|
||||||
*
|
super.initializeEditor();
|
||||||
* @return The files logic, not <code>null</code>.
|
|
||||||
*/
|
plugin = LanguagePlugin.getInstance();
|
||||||
public LanguageEditorFilesLogic getFilesLogic() {
|
compiler = plugin.getCompilerRegistry().getCompilerByEditorClassName(getClass().getName());
|
||||||
return filesLogic;
|
|
||||||
|
setSourceViewerConfiguration(new LanguageSourceViewerConfiguration(this, getPreferenceStore()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final LanguagePlugin getPlugin() {
|
||||||
|
if (plugin == null) {
|
||||||
|
throw new IllegalStateException("Field 'plugin' must not be null.");
|
||||||
|
}
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Language getLanguage() {
|
||||||
|
return getCompilerDefinition().getLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final LanguagePreferences getLanguagePreferences() {
|
||||||
|
return getPlugin().getLanguagePreferences(getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Compiler getCompiler() {
|
||||||
|
if (compiler == null) {
|
||||||
|
throw new IllegalStateException("Field 'compiler' must not be null.");
|
||||||
|
}
|
||||||
|
return compiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final CompilerDefinition getCompilerDefinition() {
|
||||||
|
return getCompiler().getDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,125 +153,46 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
if (hardware != null) {
|
if (hardware != null) {
|
||||||
return hardware;
|
return hardware;
|
||||||
}
|
}
|
||||||
return compiler.getDefinition().getDefaultHardware();
|
return getCompilerDefinition().getDefaultHardware();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the compiler id for this editor.
|
|
||||||
*
|
|
||||||
* @return The compiler id for this editor, not empty and not <code>null</code>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final void initializeEditor() {
|
|
||||||
super.initializeEditor();
|
|
||||||
|
|
||||||
plugin = LanguagePlugin.getInstance();
|
|
||||||
compiler = plugin.getCompilerRegistry().getCompilerByEditorClassName(getClass().getName());
|
|
||||||
|
|
||||||
setSourceViewerConfiguration(new LanguageSourceViewerConfiguration(this, getPreferenceStore()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the plugin this compiler instance belongs to.
|
|
||||||
*
|
|
||||||
* @return The plugin this compiler instance belongs to, not <code>null</code>.
|
|
||||||
*/
|
|
||||||
public final LanguagePlugin getPlugin() {
|
|
||||||
if (plugin == null) {
|
|
||||||
throw new IllegalStateException("Field 'plugin' must not be null.");
|
|
||||||
}
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the language.
|
|
||||||
*
|
|
||||||
* @return The language, not <code>null</code>.
|
|
||||||
*/
|
|
||||||
public final Language getLanguage() {
|
|
||||||
return getCompilerDefinition().getLanguage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the language preferences.
|
|
||||||
*
|
|
||||||
* @return The language preferences, not <code>null</code>.
|
|
||||||
*/
|
|
||||||
public final LanguagePreferences getLanguagePreferences() {
|
|
||||||
return plugin.getLanguagePreferences(getLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the compiler preferences.
|
|
||||||
*
|
|
||||||
* @return The compiler preferences, not <code>null</code>.
|
|
||||||
*/
|
|
||||||
public final LanguageHardwareCompilerDefinitionPreferences getLanguageHardwareCompilerPreferences() {
|
public final LanguageHardwareCompilerDefinitionPreferences getLanguageHardwareCompilerPreferences() {
|
||||||
return getLanguagePreferences().getLanguageHardwareCompilerDefinitionPreferences(getHardware(), getCompilerDefinition());
|
return getLanguagePreferences().getLanguageHardwareCompilerDefinitionPreferences(getHardware(),
|
||||||
|
getCompilerDefinition());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the compiler for this editor.
|
* Creates a compiler source parser for this editor and the currently selected
|
||||||
*
|
|
||||||
* @return The compiler for this editor, not <code>null</code>.
|
|
||||||
*/
|
|
||||||
public final Compiler getCompiler() {
|
|
||||||
if (compiler == null) {
|
|
||||||
throw new IllegalStateException("Field 'compiler' must not be null.");
|
|
||||||
}
|
|
||||||
return compiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the compiler definition for this editor.
|
|
||||||
*
|
|
||||||
* @return The compiler definition for this editor, not <code>null</code>.
|
|
||||||
*
|
|
||||||
* @sine 1.6.1
|
|
||||||
*/
|
|
||||||
public final CompilerDefinition getCompilerDefinition() {
|
|
||||||
if (compiler == null) {
|
|
||||||
throw new IllegalStateException("Field 'compiler' must not be null.");
|
|
||||||
}
|
|
||||||
return compiler.getDefinition();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the compiler source parser for this editor and the currently selected
|
|
||||||
* instruction set.
|
* instruction set.
|
||||||
*
|
*
|
||||||
* @return The compiler source parser for this editor, not <code>null</code> .
|
* @return The compiler source parser for this editor, not <code>null</code> .
|
||||||
*/
|
*/
|
||||||
public final CompilerSourceParser createCompilerSourceParser() {
|
public static CompilerSourceParser createCompilerSourceParser(ILanguageEditor languageEditor) {
|
||||||
Target target;
|
if (languageEditor == null) {
|
||||||
CompilerSourceParser result;
|
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
||||||
if (compiler == null) {
|
|
||||||
throw new IllegalStateException("Field 'compiler' must not be null.");
|
|
||||||
}
|
}
|
||||||
target = getLanguageHardwareCompilerPreferences().getTarget();
|
var compiler = languageEditor.getCompiler();
|
||||||
result = compiler.createSourceParser();
|
var target = languageEditor.getLanguageHardwareCompilerPreferences().getTarget();
|
||||||
|
var result = compiler.createSourceParser();
|
||||||
result.init(compiler.getDefinition().getSyntax().getInstructionSet(target));
|
result.init(compiler.getDefinition().getSyntax().getInstructionSet(target));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* This method is called whenever the input changes, i.e. after loading and
|
public final CompilerSourceParser createCompilerSourceParser() {
|
||||||
* after saving as new file.
|
return createCompilerSourceParser(this);
|
||||||
*
|
}
|
||||||
* @param input The new input, may be <code>null</code>
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected final void doSetInput(IEditorInput input) throws CoreException {
|
protected final void doSetInput(IEditorInput input) throws CoreException {
|
||||||
super.doSetInput(input);
|
super.doSetInput(input);
|
||||||
|
|
||||||
hardware = null;
|
hardware = null;
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
IDocument document = getDocumentProvider().getDocument(getEditorInput());
|
var document = getDocument();
|
||||||
|
|
||||||
CompilerSourcePartitionScanner partitionScanner = new CompilerSourcePartitionScanner(
|
var partitionScanner = new CompilerSourcePartitionScanner(getCompilerDefinition().getSyntax());
|
||||||
compiler.getDefinition().getSyntax());
|
|
||||||
partitionScanner.createDocumentPartitioner(document);
|
partitionScanner.createDocumentPartitioner(document);
|
||||||
|
|
||||||
var iFile = getCurrentIFile();
|
var iFile = getCurrentIFile();
|
||||||
|
@ -258,6 +210,11 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IDocument getDocument() {
|
||||||
|
return getDocumentProvider().getDocument(getEditorInput());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected final void createActions() {
|
protected final void createActions() {
|
||||||
super.createActions();
|
super.createActions();
|
||||||
|
@ -286,8 +243,7 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
actionDefintionId = LanguageEditorActionDefinitionIds.ToggleBreakpoint;
|
actionDefintionId = LanguageEditorActionDefinitionIds.ToggleBreakpoint;
|
||||||
actionId = Actions.RulerDoubleClick;
|
actionId = Actions.RulerDoubleClick;
|
||||||
action.setActionDefinitionId(actionId);
|
action.setActionDefinitionId(actionId);
|
||||||
toggleBreakpointAction = new ToggleBreakpointAction(this, getDocumentProvider().getDocument(getEditorInput()),
|
toggleBreakpointAction = new ToggleBreakpointAction(this, getDocument(), getVerticalRuler());
|
||||||
getVerticalRuler());
|
|
||||||
toggleBreakpointAction.setId(actionId);
|
toggleBreakpointAction.setId(actionId);
|
||||||
setAction(actionId, toggleBreakpointAction);
|
setAction(actionId, toggleBreakpointAction);
|
||||||
markAsStateDependentAction(actionId, true);
|
markAsStateDependentAction(actionId, true);
|
||||||
|
@ -392,16 +348,16 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
if (ruler == null) {
|
if (ruler == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'ruler' must not be null.");
|
throw new IllegalArgumentException("Parameter 'ruler' must not be null.");
|
||||||
}
|
}
|
||||||
ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(),
|
var viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(),
|
||||||
styles);
|
styles);
|
||||||
|
|
||||||
// Ensure decoration support has been created and configured.
|
// Ensure decoration support has been created and configured.
|
||||||
getSourceViewerDecorationSupport(viewer);
|
getSourceViewerDecorationSupport(viewer);
|
||||||
|
|
||||||
// The first single line comment delimiter is used as the default.
|
// The first single line comment delimiter is used as the default.
|
||||||
List<String> singleLineCommentDelimiters = compiler.getDefinition().getSyntax()
|
List<String> singleLineCommentDelimiters = getCompilerDefinition().getSyntax()
|
||||||
.getSingleLineCommentDelimiters();
|
.getSingleLineCommentDelimiters();
|
||||||
String[] array = singleLineCommentDelimiters.toArray(new String[singleLineCommentDelimiters.size()]);
|
var array = singleLineCommentDelimiters.toArray(new String[singleLineCommentDelimiters.size()]);
|
||||||
viewer.setDefaultPrefixes(array, IDocument.DEFAULT_CONTENT_TYPE);
|
viewer.setDefaultPrefixes(array, IDocument.DEFAULT_CONTENT_TYPE);
|
||||||
viewer.setDefaultPrefixes(array, CompilerSourcePartitionScanner.PARTITION_COMMENT_SINGLE);
|
viewer.setDefaultPrefixes(array, CompilerSourcePartitionScanner.PARTITION_COMMENT_SINGLE);
|
||||||
|
|
||||||
|
@ -479,11 +435,11 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Annotation[] removeAnnotations = deletions.toArray(new Annotation[deletions.size()]);
|
var removeAnnotations = deletions.toArray(new Annotation[deletions.size()]);
|
||||||
|
|
||||||
// This will hold the new annotations along
|
// This will hold the new annotations along
|
||||||
// with their corresponding folding positions.
|
// with their corresponding folding positions.
|
||||||
HashMap<ProjectionAnnotation, Position> newAnnotations = new HashMap<ProjectionAnnotation, Position>();
|
var newAnnotations = new HashMap<ProjectionAnnotation, Position>();
|
||||||
|
|
||||||
for (int i = 0; i < foldingPositions.size(); i++) {
|
for (int i = 0; i < foldingPositions.size(); i++) {
|
||||||
annotation = new ProjectionAnnotation();
|
annotation = new ProjectionAnnotation();
|
||||||
|
@ -499,30 +455,26 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
annotationModel.modifyAnnotations(removeAnnotations, newAnnotations, new Annotation[] {});
|
annotationModel.modifyAnnotations(removeAnnotations, newAnnotations, new Annotation[] {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets the directory of the current file.
|
public final IFile getCurrentIFile() {
|
||||||
*
|
IFile result;
|
||||||
* @return The directory of the current file or <code>null</code>.
|
var editorInput = getEditorInput();
|
||||||
*/
|
if (editorInput instanceof FileEditorInput) {
|
||||||
public final File getCurrentDirectory() {
|
var fileEditorInput = (FileEditorInput) editorInput;
|
||||||
File result;
|
result = fileEditorInput.getFile();
|
||||||
result = getCurrentFile();
|
|
||||||
if (result != null) {
|
} else {
|
||||||
result = result.getParentFile();
|
result = null;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets the the current file.
|
|
||||||
*
|
|
||||||
* @return The current file or <code>null</code>.
|
|
||||||
*/
|
|
||||||
public final File getCurrentFile() {
|
public final File getCurrentFile() {
|
||||||
File result;
|
File result;
|
||||||
IEditorInput editorInput = getEditorInput();
|
var editorInput = getEditorInput();
|
||||||
if (editorInput instanceof FileEditorInput) {
|
if (editorInput instanceof FileEditorInput) {
|
||||||
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
|
var fileEditorInput = (FileEditorInput) editorInput;
|
||||||
result = new File(fileEditorInput.getPath().toOSString());
|
result = new File(fileEditorInput.getPath().toOSString());
|
||||||
} else {
|
} else {
|
||||||
result = null;
|
result = null;
|
||||||
|
@ -530,20 +482,11 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets the the current file.
|
public final File getCurrentDirectory() {
|
||||||
*
|
var result = getCurrentFile();
|
||||||
* @return The current file or <code>null</code>.
|
if (result != null) {
|
||||||
*/
|
result = result.getParentFile();
|
||||||
public final IFile getCurrentIFile() {
|
|
||||||
IFile result;
|
|
||||||
IEditorInput editorInput = getEditorInput();
|
|
||||||
if (editorInput instanceof FileEditorInput) {
|
|
||||||
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
|
|
||||||
result = fileEditorInput.getFile();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
result = null;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -559,8 +502,7 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
if (line < 1) {
|
if (line < 1) {
|
||||||
throw new IllegalArgumentException("Parameter 'line' must be positive. Specified value is " + line + ".");
|
throw new IllegalArgumentException("Parameter 'line' must be positive. Specified value is " + line + ".");
|
||||||
}
|
}
|
||||||
IDocumentProvider provider = getDocumentProvider();
|
var document = getDocument();
|
||||||
IDocument document = provider.getDocument(getEditorInput());
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
try {
|
try {
|
||||||
int startOffset = document.getLineOffset(line - 1);
|
int startOffset = document.getLineOffset(line - 1);
|
||||||
|
@ -571,7 +513,7 @@ public abstract class LanguageEditor extends TextEditor {
|
||||||
selectAndReveal(startOffset, lineLength);
|
selectAndReveal(startOffset, lineLength);
|
||||||
result = true;
|
result = true;
|
||||||
} catch (BadLocationException ex) {
|
} catch (BadLocationException ex) {
|
||||||
plugin.logError("Cannot position to line {0}.", new Object[] { String.valueOf(line) }, ex);
|
getPlugin().logError("Cannot position to line {0}.", new Object[] { String.valueOf(line) }, ex);
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -57,10 +57,8 @@ import com.wudsn.ide.base.common.MarkerUtility;
|
||||||
import com.wudsn.ide.base.common.NumberUtility;
|
import com.wudsn.ide.base.common.NumberUtility;
|
||||||
import com.wudsn.ide.base.common.ProcessWithLogs;
|
import com.wudsn.ide.base.common.ProcessWithLogs;
|
||||||
import com.wudsn.ide.base.common.StringUtility;
|
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.Hardware;
|
||||||
import com.wudsn.ide.lng.HardwareUtility;
|
import com.wudsn.ide.lng.HardwareUtility;
|
||||||
import com.wudsn.ide.lng.LanguageAnnotation;
|
|
||||||
import com.wudsn.ide.lng.LanguagePlugin;
|
import com.wudsn.ide.lng.LanguagePlugin;
|
||||||
import com.wudsn.ide.lng.LanguageUtility;
|
import com.wudsn.ide.lng.LanguageUtility;
|
||||||
import com.wudsn.ide.lng.Texts;
|
import com.wudsn.ide.lng.Texts;
|
||||||
|
@ -137,7 +135,7 @@ final class LanguageEditorCompileCommand {
|
||||||
*
|
*
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public static void execute(LanguageEditor languageEditor, CompilerFiles files, String commandId, String runnerId)
|
public static void execute(ILanguageEditor languageEditor, CompilerFiles files, String commandId, String runnerId)
|
||||||
throws RuntimeException {
|
throws RuntimeException {
|
||||||
|
|
||||||
if (languageEditor == null) {
|
if (languageEditor == null) {
|
||||||
|
@ -188,7 +186,7 @@ final class LanguageEditorCompileCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean executeInternal(LanguageEditor languageEditor, CompilerFiles files, String commandId,
|
private boolean executeInternal(ILanguageEditor languageEditor, CompilerFiles files, String commandId,
|
||||||
String runnerId) {
|
String runnerId) {
|
||||||
|
|
||||||
if (languageEditor == null) {
|
if (languageEditor == null) {
|
||||||
|
@ -461,7 +459,7 @@ final class LanguageEditorCompileCommand {
|
||||||
*
|
*
|
||||||
* @since 1.6.1
|
* @since 1.6.1
|
||||||
*/
|
*/
|
||||||
private void createBreakpointsFile(LanguageEditor languageEditor, CompilerFiles files, Runner runner) {
|
private void createBreakpointsFile(ILanguageEditor languageEditor, CompilerFiles files, Runner runner) {
|
||||||
if (languageEditor == null) {
|
if (languageEditor == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
||||||
}
|
}
|
||||||
|
@ -520,7 +518,7 @@ final class LanguageEditorCompileCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openOutputFile(LanguageEditor languageEditor, CompilerFiles files,
|
private void openOutputFile(ILanguageEditor languageEditor, CompilerFiles files,
|
||||||
CompilerRunPreferences compilerRunPreferences, CompilerConsole compilerConsole, String runnerId) {
|
CompilerRunPreferences compilerRunPreferences, CompilerConsole compilerConsole, String runnerId) {
|
||||||
|
|
||||||
if (languageEditor == null) {
|
if (languageEditor == null) {
|
||||||
|
@ -678,7 +676,7 @@ final class LanguageEditorCompileCommand {
|
||||||
return parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean parseLogs(LanguageEditor languageEditor, CompilerFiles files, ProcessWithLogs compileProcess) {
|
private boolean parseLogs(ILanguageEditor languageEditor, CompilerFiles files, ProcessWithLogs compileProcess) {
|
||||||
|
|
||||||
if (languageEditor == null) {
|
if (languageEditor == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
||||||
|
@ -738,7 +736,7 @@ final class LanguageEditorCompileCommand {
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
* @return <code>true</code> if an error was found.
|
* @return <code>true</code> if an error was found.
|
||||||
*/
|
*/
|
||||||
private boolean positionToFirstErrorOrWarning(LanguageEditor languageEditor, List<IMarker> markers) {
|
private boolean positionToFirstErrorOrWarning(ILanguageEditor languageEditor, List<IMarker> markers) {
|
||||||
|
|
||||||
if (languageEditor == null) {
|
if (languageEditor == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
||||||
|
@ -796,7 +794,7 @@ final class LanguageEditorCompileCommand {
|
||||||
return firstErrorMarker != null;
|
return firstErrorMarker != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseCompilerSymbols(LanguageEditor languageEditor, CompilerFiles files,
|
private void parseCompilerSymbols(ILanguageEditor languageEditor, CompilerFiles files,
|
||||||
CompilerProcessLogParser logParser) {
|
CompilerProcessLogParser logParser) {
|
||||||
|
|
||||||
if (languageEditor == null)
|
if (languageEditor == null)
|
||||||
|
|
|
@ -40,7 +40,7 @@ public final class LanguageEditorCompileCommandHandler extends LanguageEditorFil
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(ExecutionEvent event, LanguageEditor languageEditor, CompilerFiles files)
|
protected void execute(ExecutionEvent event, ILanguageEditor languageEditor, CompilerFiles files)
|
||||||
throws ExecutionException {
|
throws ExecutionException {
|
||||||
if (event == null) {
|
if (event == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'event' must not be null.");
|
throw new IllegalArgumentException("Parameter 'event' must not be null.");
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.core.commands.common.NotDefinedException;
|
import org.eclipse.core.commands.common.NotDefinedException;
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
import org.eclipse.ui.handlers.HandlerUtil;
|
||||||
|
|
||||||
import com.wudsn.ide.lng.LanguagePlugin;
|
import com.wudsn.ide.lng.LanguagePlugin;
|
||||||
|
@ -45,17 +44,121 @@ public abstract class LanguageEditorFilesCommandHandler extends AbstractHandler
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
IEditorPart editor;
|
var editor = HandlerUtil.getActiveEditorChecked(event);
|
||||||
editor = HandlerUtil.getActiveEditorChecked(event);
|
if (!(editor instanceof ILanguageEditor)) {
|
||||||
if (!(editor instanceof LanguageEditor)) {
|
if (!LanguageEditorPropertyTester.isPascalEditor(editor)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
// editor=new ILanguageEditor() {
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Gets the compiler id for this editor.
|
||||||
|
// *
|
||||||
|
// * @return The compiler id for this editor, not empty and not <code>null</code>.
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected final void initializeEditor() {
|
||||||
|
// super.initializeEditor();
|
||||||
|
//
|
||||||
|
// plugin = LanguagePlugin.getInstance();
|
||||||
|
// compiler = plugin.getCompilerRegistry().getCompilerByEditorClassName(getEditorClassName());
|
||||||
|
//
|
||||||
|
// setSourceViewerConfiguration(new LanguageSourceViewerConfiguration(this, getPreferenceStore()));
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // TODO
|
||||||
|
// protected String getEditorClassName() {
|
||||||
|
// return getClass().getName();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Gets the plugin this compiler instance belongs to.
|
||||||
|
// *
|
||||||
|
// * @return The plugin this compiler instance belongs to, not <code>null</code>.
|
||||||
|
// */
|
||||||
|
// public final LanguagePlugin getPlugin() {
|
||||||
|
// if (plugin == null) {
|
||||||
|
// throw new IllegalStateException("Field 'plugin' must not be null.");
|
||||||
|
// }
|
||||||
|
// return plugin;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Gets the language.
|
||||||
|
// *
|
||||||
|
// * @return The language, not <code>null</code>.
|
||||||
|
// */
|
||||||
|
// public final Language getLanguage() {
|
||||||
|
// return getCompilerDefinition().getLanguage();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Gets the language preferences.
|
||||||
|
// *
|
||||||
|
// * @return The language preferences, not <code>null</code>.
|
||||||
|
// */
|
||||||
|
// public final LanguagePreferences getLanguagePreferences() {
|
||||||
|
// return getPlugin().getLanguagePreferences(getLanguage());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Gets the compiler for this editor.
|
||||||
|
// *
|
||||||
|
// * @return The compiler for this editor, not <code>null</code>.
|
||||||
|
// */
|
||||||
|
// public final Compiler getCompiler() {
|
||||||
|
// if (compiler == null) {
|
||||||
|
// throw new IllegalStateException("Field 'compiler' must not be null.");
|
||||||
|
// }
|
||||||
|
// return compiler;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Gets the compiler definition for this editor.
|
||||||
|
// *
|
||||||
|
// * @return The compiler definition for this editor, not <code>null</code>.
|
||||||
|
// *
|
||||||
|
// * @sine 1.6.1
|
||||||
|
// */
|
||||||
|
// public final CompilerDefinition getCompilerDefinition() {
|
||||||
|
// if (compiler == null) {
|
||||||
|
// throw new IllegalStateException("Field 'compiler' must not be null.");
|
||||||
|
// }
|
||||||
|
// return compiler.getDefinition();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Gets the default hardware for this editor.
|
||||||
|
// *
|
||||||
|
// * @return The hardware for this editor, not <code>null</code>.
|
||||||
|
// *
|
||||||
|
// * @since 1.6.1
|
||||||
|
// */
|
||||||
|
// protected final Hardware getHardware() {
|
||||||
|
// if (hardware != null) {
|
||||||
|
// return hardware;
|
||||||
|
// }
|
||||||
|
// return getCompilerDefinition().getDefaultHardware();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Gets the compiler preferences.
|
||||||
|
// *
|
||||||
|
// * @return The compiler preferences, not <code>null</code>.
|
||||||
|
// */
|
||||||
|
// public final LanguageHardwareCompilerDefinitionPreferences getLanguageHardwareCompilerPreferences() {
|
||||||
|
// return getLanguagePreferences().getLanguageHardwareCompilerDefinitionPreferences(getHardware(),
|
||||||
|
// getCompilerDefinition());
|
||||||
|
// }
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
LanguageEditor languageEditor;
|
var languageEditor = (ILanguageEditor) editor;
|
||||||
languageEditor = (LanguageEditor) editor;
|
var files = LanguageEditorFilesLogic.createInstance(languageEditor).createCompilerFiles();
|
||||||
|
|
||||||
CompilerFiles files;
|
|
||||||
files = LanguageEditorFilesLogic.createInstance(languageEditor).createCompilerFiles();
|
|
||||||
|
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
execute(event, languageEditor, files);
|
execute(event, languageEditor, files);
|
||||||
|
@ -68,8 +171,10 @@ public abstract class LanguageEditorFilesCommandHandler extends AbstractHandler
|
||||||
} catch (NotDefinedException ignore) {
|
} catch (NotDefinedException ignore) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +187,7 @@ public abstract class LanguageEditorFilesCommandHandler extends AbstractHandler
|
||||||
* <code>null</code> .
|
* <code>null</code> .
|
||||||
* @throws ExecutionException if an exception occurred during execution.
|
* @throws ExecutionException if an exception occurred during execution.
|
||||||
*/
|
*/
|
||||||
protected abstract void execute(ExecutionEvent event, LanguageEditor languageEditor, CompilerFiles files)
|
protected abstract void execute(ExecutionEvent event, ILanguageEditor languageEditor, CompilerFiles files)
|
||||||
throws ExecutionException;
|
throws ExecutionException;
|
||||||
|
|
||||||
}
|
}
|
|
@ -30,17 +30,16 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.text.Document;
|
import org.eclipse.jface.text.Document;
|
||||||
import org.eclipse.jface.text.IDocument;
|
|
||||||
|
|
||||||
import com.wudsn.ide.base.common.FileUtility;
|
import com.wudsn.ide.base.common.FileUtility;
|
||||||
import com.wudsn.ide.base.common.MarkerUtility;
|
import com.wudsn.ide.base.common.MarkerUtility;
|
||||||
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.LanguagePlugin;
|
|
||||||
import com.wudsn.ide.lng.LanguageAnnotation;
|
import com.wudsn.ide.lng.LanguageAnnotation;
|
||||||
import com.wudsn.ide.lng.LanguageAnnotationValues;
|
import com.wudsn.ide.lng.LanguageAnnotationValues;
|
||||||
import com.wudsn.ide.lng.LanguageAnnotationValues.InvalidLanguageAnnotationException;
|
import com.wudsn.ide.lng.LanguageAnnotationValues.InvalidLanguageAnnotationException;
|
||||||
import com.wudsn.ide.lng.LanguageAnnotationValues.LanguageAnnotationValue;
|
import com.wudsn.ide.lng.LanguageAnnotationValues.LanguageAnnotationValue;
|
||||||
|
import com.wudsn.ide.lng.LanguagePlugin;
|
||||||
import com.wudsn.ide.lng.Texts;
|
import com.wudsn.ide.lng.Texts;
|
||||||
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||||
import com.wudsn.ide.lng.compiler.CompilerFiles;
|
import com.wudsn.ide.lng.compiler.CompilerFiles;
|
||||||
|
@ -56,7 +55,7 @@ import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
||||||
*/
|
*/
|
||||||
public final class LanguageEditorFilesLogic {
|
public final class LanguageEditorFilesLogic {
|
||||||
|
|
||||||
private LanguageEditor languageEditor;
|
private ILanguageEditor languageEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of the logic.
|
* Create a new instance of the logic.
|
||||||
|
@ -65,7 +64,7 @@ public final class LanguageEditorFilesLogic {
|
||||||
*
|
*
|
||||||
* @return The new instance, not <code>null</code>.
|
* @return The new instance, not <code>null</code>.
|
||||||
*/
|
*/
|
||||||
static LanguageEditorFilesLogic createInstance(LanguageEditor languageEditor) {
|
static LanguageEditorFilesLogic createInstance(ILanguageEditor languageEditor) {
|
||||||
if (languageEditor == null) {
|
if (languageEditor == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
throw new IllegalArgumentException("Parameter 'languageEditor' must not be null.");
|
||||||
}
|
}
|
||||||
|
@ -87,7 +86,7 @@ public final class LanguageEditorFilesLogic {
|
||||||
sourceIFile = languageEditor.getCurrentIFile();
|
sourceIFile = languageEditor.getCurrentIFile();
|
||||||
if (sourceIFile != null) {
|
if (sourceIFile != null) {
|
||||||
|
|
||||||
IDocument document = languageEditor.getDocumentProvider().getDocument(languageEditor.getEditorInput());
|
var document = languageEditor.getDocument();
|
||||||
LanguageAnnotationValues annotationValues = CompilerSourceParser.getAnnotationValues(document);
|
LanguageAnnotationValues annotationValues = CompilerSourceParser.getAnnotationValues(document);
|
||||||
|
|
||||||
IFile mainSourceIFile;
|
IFile mainSourceIFile;
|
||||||
|
|
|
@ -25,9 +25,7 @@ import java.util.List;
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
import org.eclipse.ui.handlers.HandlerUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,18 +39,16 @@ public final class LanguageEditorOpenDeclarationCommandHandler extends AbstractH
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
IEditorPart editor;
|
var editor = HandlerUtil.getActiveEditorChecked(event);
|
||||||
editor = HandlerUtil.getActiveEditorChecked(event);
|
if (!(editor instanceof ILanguageEditor)) {
|
||||||
if (!(editor instanceof LanguageEditor)) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
LanguageEditor languageEditor;
|
var languageEditor = (ILanguageEditor) editor;
|
||||||
languageEditor = (LanguageEditor) editor;
|
|
||||||
ITextSelection textSelection = (ITextSelection) languageEditor.getSite().getSelectionProvider().getSelection();
|
ITextSelection textSelection = (ITextSelection) languageEditor.getSite().getSelectionProvider().getSelection();
|
||||||
if (textSelection != null) {
|
if (textSelection != null) {
|
||||||
IDocument document = languageEditor.getDocumentProvider().getDocument(languageEditor.getEditorInput());
|
var document = languageEditor.getDocument();
|
||||||
int offset = textSelection.getOffset();
|
var offset = textSelection.getOffset();
|
||||||
List<LanguageHyperlink> hyperlinks = new ArrayList<LanguageHyperlink>();
|
List<LanguageHyperlink> hyperlinks = new ArrayList<LanguageHyperlink>();
|
||||||
LanguageHyperlinkDetector.detectHyperlinks(languageEditor, document, offset, false, hyperlinks);
|
LanguageHyperlinkDetector.detectHyperlinks(languageEditor, document, offset, false, hyperlinks);
|
||||||
if (!hyperlinks.isEmpty()) {
|
if (!hyperlinks.isEmpty()) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public final class LanguageEditorOpenFolderCommandHandler extends LanguageEditor
|
||||||
public static final String OPEN_OUTPUT_FOLDER = "com.wudsn.ide.lng.editor.LanguageEditorOpenOutputFolderCommand";
|
public static final String OPEN_OUTPUT_FOLDER = "com.wudsn.ide.lng.editor.LanguageEditorOpenOutputFolderCommand";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(ExecutionEvent event, LanguageEditor languageEditor, CompilerFiles files)
|
protected void execute(ExecutionEvent event, ILanguageEditor languageEditor, CompilerFiles files)
|
||||||
throws ExecutionException {
|
throws ExecutionException {
|
||||||
|
|
||||||
if (event == null) {
|
if (event == null) {
|
||||||
|
|
|
@ -23,10 +23,22 @@ import org.eclipse.core.expressions.PropertyTester;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.ui.editors.text.TextEditor;
|
import org.eclipse.ui.editors.text.TextEditor;
|
||||||
|
|
||||||
import com.wudsn.ide.lng.Language;
|
|
||||||
|
|
||||||
public class LanguageEditorPropertyTester extends PropertyTester {
|
public class LanguageEditorPropertyTester extends PropertyTester {
|
||||||
|
|
||||||
|
static boolean isPascalEditor(Object receiver) {
|
||||||
|
if (receiver instanceof TextEditor) {
|
||||||
|
|
||||||
|
var editor = (TextEditor) receiver;
|
||||||
|
var input = editor.getEditorInput();
|
||||||
|
var file = input.getAdapter(IFile.class);
|
||||||
|
if (file != null && file.getName().toLowerCase().endsWith(".pas")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public LanguageEditorPropertyTester() {
|
public LanguageEditorPropertyTester() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,18 +47,11 @@ public class LanguageEditorPropertyTester extends PropertyTester {
|
||||||
|
|
||||||
if (property.equals("IsLanguageEditor")) {
|
if (property.equals("IsLanguageEditor")) {
|
||||||
|
|
||||||
if (receiver instanceof LanguageEditor) {
|
if (receiver instanceof ILanguageEditor) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (receiver instanceof TextEditor) {
|
if (isPascalEditor(receiver)) {
|
||||||
|
return true;
|
||||||
var editor = (TextEditor) receiver;
|
|
||||||
var input = editor.getEditorInput();
|
|
||||||
var file = input.getAdapter(IFile.class);
|
|
||||||
if (file != null && file.getName().toLowerCase().endsWith(".pas")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -43,7 +43,7 @@ final class LanguageEditorToggleCommentAction extends TextEditorAction {
|
||||||
/**
|
/**
|
||||||
* The owning editor.
|
* The owning editor.
|
||||||
*/
|
*/
|
||||||
private final LanguageEditor editor;
|
private final ILanguageEditor editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The editor's source viewer.
|
* The editor's source viewer.
|
||||||
|
|
|
@ -170,8 +170,7 @@ final class LanguageHyperlink implements IHyperlink {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IEditorPart editorPart;
|
IEditorPart editorPart = null;
|
||||||
editorPart = null;
|
|
||||||
if (editorId.equals(DEFAULT_EDITOR)) {
|
if (editorId.equals(DEFAULT_EDITOR)) {
|
||||||
|
|
||||||
if (fileToOpen.exists() && fileToOpen.isFile()) {
|
if (fileToOpen.exists() && fileToOpen.isFile()) {
|
||||||
|
|
|
@ -41,7 +41,6 @@ import com.wudsn.ide.gfx.editor.GraphicsConversionEditor;
|
||||||
import com.wudsn.ide.hex.HexEditor;
|
import com.wudsn.ide.hex.HexEditor;
|
||||||
import com.wudsn.ide.lng.LanguageUtility;
|
import com.wudsn.ide.lng.LanguageUtility;
|
||||||
import com.wudsn.ide.lng.Texts;
|
import com.wudsn.ide.lng.Texts;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserFileReference;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserFileReference;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserFileReferenceType;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserFileReferenceType;
|
||||||
|
@ -124,7 +123,7 @@ public final class LanguageHyperlinkDetector extends AbstractHyperlinkDetector {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final static void detectHyperlinks(LanguageEditor languageEditor, IDocument document, int offset,
|
final static void detectHyperlinks(ILanguageEditor languageEditor, IDocument document, int offset,
|
||||||
boolean canShowMultipleHyperlinks, List<LanguageHyperlink> hyperlinks) {
|
boolean canShowMultipleHyperlinks, List<LanguageHyperlink> hyperlinks) {
|
||||||
IRegion lineInfo;
|
IRegion lineInfo;
|
||||||
int lineNumber;
|
int lineNumber;
|
||||||
|
@ -149,7 +148,7 @@ public final class LanguageHyperlinkDetector extends AbstractHyperlinkDetector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void detectInclude(LanguageEditor languageEditor, IRegion lineInfo, int lineNumber, String line,
|
private static void detectInclude(ILanguageEditor languageEditor, IRegion lineInfo, int lineNumber, String line,
|
||||||
int offsetInLine, boolean canShowMultipleHyperlinks, List<LanguageHyperlink> hyperlinks) {
|
int offsetInLine, boolean canShowMultipleHyperlinks, List<LanguageHyperlink> hyperlinks) {
|
||||||
// Try to detect binary or source includes
|
// Try to detect binary or source includes
|
||||||
CompilerSourceParser compilerSourceParser = languageEditor.createCompilerSourceParser();
|
CompilerSourceParser compilerSourceParser = languageEditor.createCompilerSourceParser();
|
||||||
|
@ -185,15 +184,14 @@ public final class LanguageHyperlinkDetector extends AbstractHyperlinkDetector {
|
||||||
|
|
||||||
// Perform resolution of relative paths and compiler specific
|
// Perform resolution of relative paths and compiler specific
|
||||||
// default extension.
|
// default extension.
|
||||||
File currentDirectory = languageEditor.getCurrentDirectory();
|
var currentDirectory = languageEditor.getCurrentDirectory();
|
||||||
String absoluteFilePath = compilerSourceParser.getIncludeAbsoluteFilePath(fileReference.getType(),
|
String absoluteFilePath = compilerSourceParser.getIncludeAbsoluteFilePath(fileReference.getType(),
|
||||||
currentDirectory, filePath);
|
currentDirectory, filePath);
|
||||||
if (absoluteFilePath == null) {
|
if (absoluteFilePath == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
URI uri;
|
var uri = new File(absoluteFilePath).toURI();
|
||||||
uri = new File(absoluteFilePath).toURI();
|
|
||||||
|
|
||||||
IRegion linkRegion = new Region(lineInfo.getOffset() + startQuoteOffset + 1, filePath.length());
|
IRegion linkRegion = new Region(lineInfo.getOffset() + startQuoteOffset + 1, filePath.length());
|
||||||
|
|
||||||
|
@ -233,10 +231,10 @@ public final class LanguageHyperlinkDetector extends AbstractHyperlinkDetector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void detectIdentifier(LanguageEditor languageEditor, IRegion lineInfo, int lineNumber, String line,
|
private static void detectIdentifier(ILanguageEditor languageEditor, IRegion lineInfo, int lineNumber, String line,
|
||||||
int offsetInLine, boolean canShowMultipleHyperlinks, List<LanguageHyperlink> hyperlinks) {
|
int offsetInLine, boolean canShowMultipleHyperlinks, List<LanguageHyperlink> hyperlinks) {
|
||||||
|
|
||||||
CompilerSyntax compilerSyntax = languageEditor.createCompilerSourceParser().getCompilerSyntax();
|
var compilerSyntax = languageEditor.createCompilerSourceParser().getCompilerSyntax();
|
||||||
|
|
||||||
int startIdentifierOffset = offsetInLine;
|
int startIdentifierOffset = offsetInLine;
|
||||||
int endIdentifierOffset = offsetInLine;
|
int endIdentifierOffset = offsetInLine;
|
||||||
|
@ -260,7 +258,8 @@ public final class LanguageHyperlinkDetector extends AbstractHyperlinkDetector {
|
||||||
endIdentifierOffset++;
|
endIdentifierOffset++;
|
||||||
}
|
}
|
||||||
String identifier = line.substring(startIdentifierOffset, endIdentifierOffset);
|
String identifier = line.substring(startIdentifierOffset, endIdentifierOffset);
|
||||||
CompilerSourceFile compilerSourceFile = languageEditor.getCompilerSourceFile();
|
// TODO: Hard cast to LanguageEditor
|
||||||
|
var compilerSourceFile = ((LanguageEditor) languageEditor).getCompilerSourceFile();
|
||||||
if (compilerSourceFile == null) {
|
if (compilerSourceFile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ import com.wudsn.ide.lng.compiler.syntax.InstructionType;
|
||||||
import com.wudsn.ide.lng.compiler.syntax.Opcode;
|
import com.wudsn.ide.lng.compiler.syntax.Opcode;
|
||||||
import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferencesConstants;
|
import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferencesConstants;
|
||||||
import com.wudsn.ide.lng.preferences.LanguagePreferences;
|
import com.wudsn.ide.lng.preferences.LanguagePreferences;
|
||||||
import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants;
|
|
||||||
import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants;
|
import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants;
|
||||||
import com.wudsn.ide.lng.preferences.TextAttributeConverter;
|
import com.wudsn.ide.lng.preferences.TextAttributeConverter;
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObject;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObject;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObjectLabelProvider;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObjectLabelProvider;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObjectType;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObjectType;
|
||||||
|
import com.wudsn.ide.lng.editor.ILanguageEditor;
|
||||||
import com.wudsn.ide.lng.editor.LanguageEditor;
|
import com.wudsn.ide.lng.editor.LanguageEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +77,7 @@ public final class LanguageOutlinePage extends ContentOutlinePage {
|
||||||
private static final class OutlineViewerSortAction extends Action {
|
private static final class OutlineViewerSortAction extends Action {
|
||||||
private static final QualifiedName CHECKED = new QualifiedName("OutlineViewerSortAction", "Checked");
|
private static final QualifiedName CHECKED = new QualifiedName("OutlineViewerSortAction", "Checked");
|
||||||
|
|
||||||
final LanguageEditor editor;
|
final ILanguageEditor editor;
|
||||||
final TreeViewer treeViewer;
|
final TreeViewer treeViewer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +87,7 @@ public final class LanguageOutlinePage extends ContentOutlinePage {
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
* @param treeViewer The tree viewer which displays the outline.
|
* @param treeViewer The tree viewer which displays the outline.
|
||||||
*/
|
*/
|
||||||
public OutlineViewerSortAction(LanguageEditor editor, TreeViewer treeViewer) {
|
public OutlineViewerSortAction(ILanguageEditor editor, TreeViewer treeViewer) {
|
||||||
super("", AS_CHECK_BOX);
|
super("", AS_CHECK_BOX);
|
||||||
if (editor == null) {
|
if (editor == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
||||||
|
@ -131,7 +132,7 @@ public final class LanguageOutlinePage extends ContentOutlinePage {
|
||||||
// Store the value.
|
// Store the value.
|
||||||
String checkedProperty = Boolean.toString(checked);
|
String checkedProperty = Boolean.toString(checked);
|
||||||
try {
|
try {
|
||||||
IFile iFile = editor.getCurrentIFile();
|
var iFile = editor.getCurrentIFile();
|
||||||
if (iFile != null) {
|
if (iFile != null) {
|
||||||
iFile.setPersistentProperty(CHECKED, checkedProperty);
|
iFile.setPersistentProperty(CHECKED, checkedProperty);
|
||||||
}
|
}
|
||||||
|
@ -550,9 +551,8 @@ public final class LanguageOutlinePage extends ContentOutlinePage {
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public final CompilerSourceFile getCompilerSourceFile() {
|
public final CompilerSourceFile getCompilerSourceFile() {
|
||||||
LanguageOutlineTreeContentProvider contentProvider;
|
var contentProvider = (LanguageOutlineTreeContentProvider) getTreeViewer().getContentProvider();
|
||||||
contentProvider = (LanguageOutlineTreeContentProvider) getTreeViewer().getContentProvider();
|
var compilerSourceFile = contentProvider.getCompilerSourceFile();
|
||||||
CompilerSourceFile compilerSourceFile = contentProvider.getCompilerSourceFile();
|
|
||||||
return compilerSourceFile;
|
return compilerSourceFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ package com.wudsn.ide.lng.outline;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jface.text.IDocument;
|
|
||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
|
@ -30,7 +29,6 @@ import com.wudsn.ide.base.common.Profiler;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
||||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObject;
|
import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObject;
|
||||||
import com.wudsn.ide.lng.editor.LanguageEditor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tree content provider to {@link LanguageOutlinePage}.
|
* Tree content provider to {@link LanguageOutlinePage}.
|
||||||
|
@ -159,8 +157,8 @@ final class LanguageOutlineTreeContentProvider implements ITreeContentProvider {
|
||||||
*/
|
*/
|
||||||
private void parse() {
|
private void parse() {
|
||||||
|
|
||||||
LanguageEditor editor = this.languageOutlinePage.editor;
|
var editor = this.languageOutlinePage.editor;
|
||||||
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
|
var document = editor.getDocument();
|
||||||
|
|
||||||
if (document != null) {
|
if (document != null) {
|
||||||
CompilerSourceParser parser = editor.createCompilerSourceParser();
|
CompilerSourceParser parser = editor.createCompilerSourceParser();
|
||||||
|
|
|
@ -68,8 +68,8 @@ import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||||
import com.wudsn.ide.lng.compiler.CompilerPaths;
|
import com.wudsn.ide.lng.compiler.CompilerPaths;
|
||||||
import com.wudsn.ide.lng.compiler.CompilerPaths.CompilerPath;
|
import com.wudsn.ide.lng.compiler.CompilerPaths.CompilerPath;
|
||||||
import com.wudsn.ide.lng.compiler.CompilerRegistry;
|
import com.wudsn.ide.lng.compiler.CompilerRegistry;
|
||||||
|
import com.wudsn.ide.lng.editor.ILanguageEditor;
|
||||||
import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase;
|
import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase;
|
||||||
import com.wudsn.ide.lng.editor.LanguageEditor;
|
|
||||||
import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode;
|
import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode;
|
||||||
import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants;
|
import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants;
|
||||||
|
|
||||||
|
@ -169,9 +169,8 @@ public abstract class LanguagePreferencesPage extends FieldEditorPreferencePage
|
||||||
@Override
|
@Override
|
||||||
public void init(IWorkbench workbench) {
|
public void init(IWorkbench workbench) {
|
||||||
IEditorPart editor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
|
IEditorPart editor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
|
||||||
if (editor instanceof LanguageEditor) {
|
if (editor instanceof ILanguageEditor) {
|
||||||
LanguageEditor languageEditor;
|
var languageEditor = (ILanguageEditor) editor;
|
||||||
languageEditor = (LanguageEditor) editor;
|
|
||||||
activeCompilerId = languageEditor.getCompilerDefinition().getId();
|
activeCompilerId = languageEditor.getCompilerDefinition().getId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@ package com.wudsn.ide.lng.preferences;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.TextAttribute;
|
import org.eclipse.jface.text.TextAttribute;
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||||
|
|
||||||
import com.wudsn.ide.base.common.AbstractIDEPlugin;
|
import com.wudsn.ide.base.common.AbstractIDEPlugin;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user