mirror of
https://github.com/peterdell/wudsn-ide.git
synced 2024-06-03 06:29:35 +00:00
Complete source reformmted with profile JAC!
This commit is contained in:
parent
cf4ced650e
commit
cc3085752f
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -22,13 +22,13 @@ import com.wudsn.ide.asm.Hardware;
|
|||
import com.wudsn.ide.asm.preferences.AssemblerPreferencesCompilersPage;
|
||||
|
||||
/**
|
||||
* Visual editor page for the assembler preferences regarding arbitrary compilers.
|
||||
* Visual editor page for the assembler preferences regarding arbitrary
|
||||
* compilers.
|
||||
*
|
||||
* @author Peter Dell
|
||||
*
|
||||
*/
|
||||
public final class AssemblerPreferencesTestCompilersPage extends
|
||||
AssemblerPreferencesCompilersPage {
|
||||
public final class AssemblerPreferencesTestCompilersPage extends AssemblerPreferencesCompilersPage {
|
||||
|
||||
/**
|
||||
* Create is public. Used by extension point
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -85,8 +85,7 @@ final class KickAssCompilerProcessLogParser extends CompilerProcessLogParser {
|
|||
index = line.indexOf(',');
|
||||
if (index > 8) {
|
||||
|
||||
String lineNumberString = line.substring(8,
|
||||
index);
|
||||
String lineNumberString = line.substring(8, index);
|
||||
|
||||
try {
|
||||
lineNumber = Integer.parseInt(lineNumberString);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2016 <a href="http://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2016 <a href="http://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -96,85 +96,89 @@ final class Merlin32CompilerProcessLogParser extends CompilerProcessLogParser {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCompilerSymbols(List<CompilerSymbol> compilerSymbols) throws CoreException {
|
||||
if (compilerSymbols == null) {
|
||||
throw new IllegalArgumentException("Parameter 'compilerSymbols' must not be null.");
|
||||
}
|
||||
// String labelsFilePath = files.outputFilePathWithoutExtension + ".lab";
|
||||
// File labelsFile = new File(labelsFilePath);
|
||||
// if (labelsFile.exists()) {
|
||||
//
|
||||
// String labelsFileContent = FileUtility.readString(labelsFile, FileUtility.MAX_SIZE_UNLIMITED);
|
||||
// String[] lines = labelsFileContent.split("[\\r\\n]+");
|
||||
// if (lines.length > 2 || lines[0].toLowerCase().startsWith("mads")
|
||||
// || lines[1].toLowerCase().startsWith("label table:")) {
|
||||
// for (int i = 2; i < lines.length; i++) {
|
||||
// String[] parts = lines[i].split("\\t");
|
||||
// if (parts.length == 3) {
|
||||
// int type = CompilerSymbolType.LABEL_DEFINITION;
|
||||
// String bankString = parts[0];
|
||||
//
|
||||
// String name = parts[2];
|
||||
// String valueString = parts[1];
|
||||
// try {
|
||||
// long bank = Long.parseLong(bankString, 16);
|
||||
// int symbolBank;
|
||||
// if (bank >= 0 && bank < 0xfff9) {
|
||||
// symbolBank = (int) bank;
|
||||
// } else {
|
||||
// symbolBank = CompilerSymbol.UNDEFINED_BANK;
|
||||
// if (bank == 0xfff9) {
|
||||
// // Label for parameter in procedure defined
|
||||
// // by .PROC
|
||||
// // TODO: This would actually be a separate
|
||||
// // type
|
||||
// type = CompilerSymbolType.PROCEDURE_DEFINITION_SECTION;
|
||||
// } else if (bank == 0xfffa) {
|
||||
// // Label for array defined by .ARRAY
|
||||
// // TODO: This would actually be a separate
|
||||
// // type
|
||||
// type = CompilerSymbolType.LABEL_DEFINITION;
|
||||
// } else if (bank == 0xfffb) {
|
||||
// // Label for structured data defined by the
|
||||
// // pseudo-command DTA STRUCT_LABEL
|
||||
// type = CompilerSymbolType.STRUCTURE_DEFINITION_SECTION;
|
||||
// } else if (bank == 0xfffc) {
|
||||
// // Label for SpartaDOS X symbol defined by
|
||||
// // SMB
|
||||
// // TODO: This would actually be a separate
|
||||
// // type
|
||||
// type = CompilerSymbolType.LABEL_DEFINITION;
|
||||
// } else if (bank == 0xfffd) {
|
||||
// // Label for macro defined by .MACRO
|
||||
// // directive
|
||||
// // TODO: This would actually be a separate
|
||||
// // type
|
||||
// type = CompilerSymbolType.MACRO_DEFINITION_SECTION;
|
||||
// } else if (bank == 0xfffe) {
|
||||
// // Label for structure defined by .STRUCT
|
||||
// // directive
|
||||
// type = CompilerSymbolType.STRUCTURE_DEFINITION_SECTION;
|
||||
// } else if (bank == 0xffff) {
|
||||
// // Label for procedure defined by .PROC
|
||||
// // directive
|
||||
// type = CompilerSymbolType.PROCEDURE_DEFINITION_SECTION;
|
||||
// }
|
||||
// }
|
||||
// long value = Long.parseLong(valueString, 16);
|
||||
// CompilerSymbol compilerSymbol = CompilerSymbol.createNumberSymbol(type, name, symbolBank,
|
||||
// value);
|
||||
// compilerSymbols.add(compilerSymbol);
|
||||
// } catch (NumberFormatException ex) {
|
||||
// AssemblerPlugin.getInstance().logError("Cannot parse value {1} of symbol {0}.",
|
||||
// new Object[] { name, valueString }, ex);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// String labelsFilePath = files.outputFilePathWithoutExtension +
|
||||
// ".lab";
|
||||
// File labelsFile = new File(labelsFilePath);
|
||||
// if (labelsFile.exists()) {
|
||||
//
|
||||
// String labelsFileContent = FileUtility.readString(labelsFile,
|
||||
// FileUtility.MAX_SIZE_UNLIMITED);
|
||||
// String[] lines = labelsFileContent.split("[\\r\\n]+");
|
||||
// if (lines.length > 2 || lines[0].toLowerCase().startsWith("mads")
|
||||
// || lines[1].toLowerCase().startsWith("label table:")) {
|
||||
// for (int i = 2; i < lines.length; i++) {
|
||||
// String[] parts = lines[i].split("\\t");
|
||||
// if (parts.length == 3) {
|
||||
// int type = CompilerSymbolType.LABEL_DEFINITION;
|
||||
// String bankString = parts[0];
|
||||
//
|
||||
// String name = parts[2];
|
||||
// String valueString = parts[1];
|
||||
// try {
|
||||
// long bank = Long.parseLong(bankString, 16);
|
||||
// int symbolBank;
|
||||
// if (bank >= 0 && bank < 0xfff9) {
|
||||
// symbolBank = (int) bank;
|
||||
// } else {
|
||||
// symbolBank = CompilerSymbol.UNDEFINED_BANK;
|
||||
// if (bank == 0xfff9) {
|
||||
// // Label for parameter in procedure defined
|
||||
// // by .PROC
|
||||
// // TODO: This would actually be a separate
|
||||
// // type
|
||||
// type = CompilerSymbolType.PROCEDURE_DEFINITION_SECTION;
|
||||
// } else if (bank == 0xfffa) {
|
||||
// // Label for array defined by .ARRAY
|
||||
// // TODO: This would actually be a separate
|
||||
// // type
|
||||
// type = CompilerSymbolType.LABEL_DEFINITION;
|
||||
// } else if (bank == 0xfffb) {
|
||||
// // Label for structured data defined by the
|
||||
// // pseudo-command DTA STRUCT_LABEL
|
||||
// type = CompilerSymbolType.STRUCTURE_DEFINITION_SECTION;
|
||||
// } else if (bank == 0xfffc) {
|
||||
// // Label for SpartaDOS X symbol defined by
|
||||
// // SMB
|
||||
// // TODO: This would actually be a separate
|
||||
// // type
|
||||
// type = CompilerSymbolType.LABEL_DEFINITION;
|
||||
// } else if (bank == 0xfffd) {
|
||||
// // Label for macro defined by .MACRO
|
||||
// // directive
|
||||
// // TODO: This would actually be a separate
|
||||
// // type
|
||||
// type = CompilerSymbolType.MACRO_DEFINITION_SECTION;
|
||||
// } else if (bank == 0xfffe) {
|
||||
// // Label for structure defined by .STRUCT
|
||||
// // directive
|
||||
// type = CompilerSymbolType.STRUCTURE_DEFINITION_SECTION;
|
||||
// } else if (bank == 0xffff) {
|
||||
// // Label for procedure defined by .PROC
|
||||
// // directive
|
||||
// type = CompilerSymbolType.PROCEDURE_DEFINITION_SECTION;
|
||||
// }
|
||||
// }
|
||||
// long value = Long.parseLong(valueString, 16);
|
||||
// CompilerSymbol compilerSymbol =
|
||||
// CompilerSymbol.createNumberSymbol(type, name, symbolBank,
|
||||
// value);
|
||||
// compilerSymbols.add(compilerSymbol);
|
||||
// } catch (NumberFormatException ex) {
|
||||
// AssemblerPlugin.getInstance().logError("Cannot parse value {1} of symbol {0}.",
|
||||
// new Object[] { name, valueString }, ex);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
|
@ -44,12 +44,12 @@ final class Merlin32CompilerSourceParser extends CompilerSourceParser {
|
|||
} // Symbol not empty
|
||||
|
||||
// TODO Implement macro and Lup handling
|
||||
// if (instruction.equals("<<<<")) {
|
||||
// endMacroDefinition();
|
||||
// } else if (instruction.equals(">>>>")) {
|
||||
// // Same as "PMC"
|
||||
// } else if (instruction.equals("--^")) {
|
||||
// endRepeatSection();
|
||||
// }
|
||||
// if (instruction.equals("<<<<")) {
|
||||
// endMacroDefinition();
|
||||
// } else if (instruction.equals(">>>>")) {
|
||||
// // Same as "PMC"
|
||||
// } else if (instruction.equals("--^")) {
|
||||
// endRepeatSection();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -65,8 +65,7 @@ final class TassCompilerProcessLogParser extends CompilerProcessLogParser {
|
|||
includeFile = "";
|
||||
} else {
|
||||
include = true;
|
||||
includeFile = line.substring(3, matcher.end() - matcher.start()
|
||||
- 7);
|
||||
includeFile = line.substring(3, matcher.end() - matcher.start() - 7);
|
||||
}
|
||||
index = matcher.end();
|
||||
String lineNumberLine = errorLog.substring(index);
|
||||
|
@ -104,8 +103,7 @@ final class TassCompilerProcessLogParser extends CompilerProcessLogParser {
|
|||
|
||||
if (include) {
|
||||
if (lineNumber >= 0) {
|
||||
message = includeFile + " line " + lineNumber + ": "
|
||||
+ message;
|
||||
message = includeFile + " line " + lineNumber + ": " + message;
|
||||
} else {
|
||||
message = includeFile + ": " + message;
|
||||
}
|
||||
|
@ -114,8 +112,7 @@ final class TassCompilerProcessLogParser extends CompilerProcessLogParser {
|
|||
message = message.trim();
|
||||
|
||||
// Message mapping.
|
||||
if (severity == IMarker.SEVERITY_WARNING
|
||||
&& message.startsWith("Using bank")) {
|
||||
if (severity == IMarker.SEVERITY_WARNING && message.startsWith("Using bank")) {
|
||||
severity = IMarker.SEVERITY_INFO;
|
||||
}
|
||||
markerAvailable = true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -30,7 +30,6 @@ public final class AtasmEditor extends AssemblerEditor {
|
|||
public AtasmEditor() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCompilerId() {
|
||||
return CompilerId.ATASM;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -27,8 +27,7 @@ import com.wudsn.ide.asm.preferences.AssemblerPreferencesCompilersPage;
|
|||
* @author Peter Dell
|
||||
*
|
||||
*/
|
||||
public final class AssemblerPreferencesApple2CompilersPage extends
|
||||
AssemblerPreferencesCompilersPage {
|
||||
public final class AssemblerPreferencesApple2CompilersPage extends AssemblerPreferencesCompilersPage {
|
||||
|
||||
/**
|
||||
* Create is public. Used by extension point
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -27,8 +27,7 @@ import com.wudsn.ide.asm.preferences.AssemblerPreferencesCompilersPage;
|
|||
* @author Peter Dell
|
||||
*
|
||||
*/
|
||||
public final class AssemblerPreferencesAtari2600CompilersPage extends
|
||||
AssemblerPreferencesCompilersPage {
|
||||
public final class AssemblerPreferencesAtari2600CompilersPage extends AssemblerPreferencesCompilersPage {
|
||||
|
||||
/**
|
||||
* Create is public. Used by extension point
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -27,8 +27,7 @@ import com.wudsn.ide.asm.preferences.AssemblerPreferencesCompilersPage;
|
|||
* @author Peter Dell
|
||||
*
|
||||
*/
|
||||
public final class AssemblerPreferencesAtari7800CompilersPage extends
|
||||
AssemblerPreferencesCompilersPage {
|
||||
public final class AssemblerPreferencesAtari7800CompilersPage extends AssemblerPreferencesCompilersPage {
|
||||
|
||||
/**
|
||||
* Create is public. Used by extension point
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -28,8 +28,7 @@ import com.wudsn.ide.asm.preferences.AssemblerPreferencesCompilersPage;
|
|||
* @author Peter Dell
|
||||
*
|
||||
*/
|
||||
public final class AssemblerPreferencesAtari8CompilersPage extends
|
||||
AssemblerPreferencesCompilersPage {
|
||||
public final class AssemblerPreferencesAtari8CompilersPage extends AssemblerPreferencesCompilersPage {
|
||||
|
||||
/**
|
||||
* Create is public. Used by extension point
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -27,8 +27,7 @@ import com.wudsn.ide.asm.preferences.AssemblerPreferencesCompilersPage;
|
|||
* @author Peter Dell
|
||||
*
|
||||
*/
|
||||
public final class AssemblerPreferencesC64CompilersPage extends
|
||||
AssemblerPreferencesCompilersPage {
|
||||
public final class AssemblerPreferencesC64CompilersPage extends AssemblerPreferencesCompilersPage {
|
||||
|
||||
/**
|
||||
* Create is public. Used by extension point
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -27,8 +27,7 @@ import com.wudsn.ide.asm.preferences.AssemblerPreferencesCompilersPage;
|
|||
* @author Peter Dell
|
||||
*
|
||||
*/
|
||||
public final class AssemblerPreferencesNESCompilersPage extends
|
||||
AssemblerPreferencesCompilersPage {
|
||||
public final class AssemblerPreferencesNESCompilersPage extends AssemblerPreferencesCompilersPage {
|
||||
|
||||
/**
|
||||
* Create is public. Used by extension point
|
||||
|
|
|
@ -63,8 +63,8 @@ public final class Altirra extends Runner {
|
|||
AssemblerBreakpoint assemberBreakpoint = (AssemblerBreakpoint) breakpoint;
|
||||
IMarker marker = breakpoint.getMarker();
|
||||
String sourceFilePath = marker.getResource().getLocation().toOSString();
|
||||
breakpointBuilder
|
||||
.append("bp \"`" + sourceFilePath + ":" + assemberBreakpoint.getLineNumber() + "`\"\n");
|
||||
breakpointBuilder.append("bp \"`" + sourceFilePath + ":" + assemberBreakpoint.getLineNumber()
|
||||
+ "`\"\n");
|
||||
activeBreakpoints++;
|
||||
}
|
||||
} catch (CoreException ex) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -48,8 +48,7 @@ public final class HardwareUtility {
|
|||
*/
|
||||
public static String getDefaultFileExtension(Hardware hardware) {
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
switch (hardware) {
|
||||
case APPLE2:
|
||||
|
@ -90,8 +89,7 @@ public final class HardwareUtility {
|
|||
*/
|
||||
public static String getImagePath(Hardware hardware) {
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
String path;
|
||||
switch (hardware) {
|
||||
|
@ -120,8 +118,7 @@ public final class HardwareUtility {
|
|||
path = "hardware-test-16x16.gif";
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown hardware " + hardware
|
||||
+ ".");
|
||||
throw new IllegalArgumentException("Unknown hardware " + hardware + ".");
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
@ -136,12 +133,10 @@ public final class HardwareUtility {
|
|||
*/
|
||||
public static ImageDescriptor getImageDescriptor(Hardware hardware) {
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
ImageDescriptor result;
|
||||
result = AssemblerPlugin.getInstance().getImageDescriptor(
|
||||
getImagePath(hardware));
|
||||
result = AssemblerPlugin.getInstance().getImageDescriptor(getImagePath(hardware));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -156,8 +151,7 @@ public final class HardwareUtility {
|
|||
*/
|
||||
public static CompilerFileWriter getCompilerFileWriter(Hardware hardware) {
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
CompilerFileWriter compilerFileWriter;
|
||||
if (hardware.equals(Hardware.APPLE2)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -69,8 +69,7 @@ public final class CompilerConsole {
|
|||
|
||||
public void display(IConsoleView consoleView) {
|
||||
if (consoleView == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'consoleView' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'consoleView' must not be null.");
|
||||
}
|
||||
consoleView.display(console);
|
||||
|
||||
|
@ -84,8 +83,7 @@ public final class CompilerConsole {
|
|||
*/
|
||||
public void println(String message) {
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'message' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'message' must not be null.");
|
||||
}
|
||||
messageStream.println(message);
|
||||
}
|
||||
|
|
|
@ -23,16 +23,17 @@ public class CompilerFileWriter {
|
|||
/**
|
||||
* Creates or updates a disk image file with the output file.
|
||||
*
|
||||
* @param files The compiler files, not <code>null</code>.
|
||||
* @param files
|
||||
* The compiler files, not <code>null</code>.
|
||||
*
|
||||
* @return <code>true</code> if no disk image is required or it is required and has been updated.
|
||||
* @return <code>true</code> if no disk image is required or it is required
|
||||
* and has been updated.
|
||||
*
|
||||
* @since 1.6.3
|
||||
*/
|
||||
public boolean createOrUpdateDiskImage(CompilerFiles files) {
|
||||
if (files == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'outputFile' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'outputFile' must not be null.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -78,70 +78,52 @@ public final class CompilerRegistry {
|
|||
compilerMap = new TreeMap<String, Compiler>();
|
||||
|
||||
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint extensionPoint = extensionRegistry
|
||||
.getExtensionPoint(COMPILERS);
|
||||
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(COMPILERS);
|
||||
if (extensionPoint == null) {
|
||||
throw new IllegalStateException("Extension point '" + COMPILERS
|
||||
+ "' is not defined.");
|
||||
throw new IllegalStateException("Extension point '" + COMPILERS + "' is not defined.");
|
||||
}
|
||||
|
||||
IExtension[] extensions = extensionPoint.getExtensions();
|
||||
|
||||
for (IExtension extension : extensions) {
|
||||
IConfigurationElement[] configurationElements = extension
|
||||
.getConfigurationElements();
|
||||
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
|
||||
for (IConfigurationElement configurationElement : configurationElements) {
|
||||
|
||||
try {
|
||||
CompilerDefinition compilerDefinition;
|
||||
compilerDefinition = new CompilerDefinition();
|
||||
compilerDefinition.setId(configurationElement
|
||||
.getAttribute("id"));
|
||||
compilerDefinition.setName(configurationElement
|
||||
.getAttribute("name"));
|
||||
compilerDefinition.setClassName(configurationElement
|
||||
.getAttribute("class"));
|
||||
compilerDefinition.setHelpFilePaths(configurationElement
|
||||
.getAttribute("helpFilePaths"));
|
||||
compilerDefinition.setHomePageURL(configurationElement
|
||||
.getAttribute("homePageURL"));
|
||||
compilerDefinition
|
||||
.setDefaultParameters(configurationElement
|
||||
.getAttribute("defaultParameters"));
|
||||
compilerDefinition.setId(configurationElement.getAttribute("id"));
|
||||
compilerDefinition.setName(configurationElement.getAttribute("name"));
|
||||
compilerDefinition.setClassName(configurationElement.getAttribute("class"));
|
||||
compilerDefinition.setHelpFilePaths(configurationElement.getAttribute("helpFilePaths"));
|
||||
compilerDefinition.setHomePageURL(configurationElement.getAttribute("homePageURL"));
|
||||
compilerDefinition.setDefaultParameters(configurationElement.getAttribute("defaultParameters"));
|
||||
|
||||
configurationElement.getChildren("supportedCPU");
|
||||
IConfigurationElement[] supportedCPUArray;
|
||||
supportedCPUArray = configurationElement
|
||||
.getChildren("supportedCPU");
|
||||
List<CPU> supportedCPUs = new ArrayList<CPU>(
|
||||
supportedCPUArray.length);
|
||||
supportedCPUArray = configurationElement.getChildren("supportedCPU");
|
||||
List<CPU> supportedCPUs = new ArrayList<CPU>(supportedCPUArray.length);
|
||||
for (IConfigurationElement supportedCPU : supportedCPUArray) {
|
||||
supportedCPUs.add(CPU.valueOf(supportedCPU
|
||||
.getAttribute("cpu")));
|
||||
supportedCPUs.add(CPU.valueOf(supportedCPU.getAttribute("cpu")));
|
||||
}
|
||||
supportedCPUs = Collections.unmodifiableList(supportedCPUs);
|
||||
compilerDefinition.setSupportedCPUs(supportedCPUs);
|
||||
compilerDefinition.setDefaultHardware(Hardware
|
||||
.valueOf(configurationElement
|
||||
.getAttribute("defaultHardware")));
|
||||
compilerDefinition.setDefaultHardware(Hardware.valueOf(configurationElement
|
||||
.getAttribute("defaultHardware")));
|
||||
|
||||
compilerDefinitionList.add(compilerDefinition);
|
||||
|
||||
addCompiler(configurationElement, compilerDefinition);
|
||||
} catch (RuntimeException ex) {
|
||||
throw new RuntimeException(
|
||||
"Error during registration of compiler '"
|
||||
+ configurationElement.getAttribute("id")
|
||||
+ "'.", ex);
|
||||
throw new RuntimeException("Error during registration of compiler '"
|
||||
+ configurationElement.getAttribute("id") + "'.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
compilerDefinitionList = new ArrayList<CompilerDefinition>(
|
||||
compilerDefinitionList);
|
||||
compilerDefinitionList = new ArrayList<CompilerDefinition>(compilerDefinitionList);
|
||||
Collections.sort(compilerDefinitionList);
|
||||
compilerDefinitionList = Collections
|
||||
.unmodifiableList(compilerDefinitionList);
|
||||
compilerDefinitionList = Collections.unmodifiableList(compilerDefinitionList);
|
||||
compilerMap = Collections.unmodifiableMap(compilerMap);
|
||||
}
|
||||
|
||||
|
@ -155,26 +137,21 @@ public final class CompilerRegistry {
|
|||
* @param compilerDefinition
|
||||
* The compiler definition, not <code>null</code>.
|
||||
*/
|
||||
private void addCompiler(IConfigurationElement configurationElement,
|
||||
CompilerDefinition compilerDefinition) {
|
||||
private void addCompiler(IConfigurationElement configurationElement, CompilerDefinition compilerDefinition) {
|
||||
if (configurationElement == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'configurationElement' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'configurationElement' must not be null.");
|
||||
}
|
||||
if (compilerDefinition == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerDefinition' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null.");
|
||||
}
|
||||
|
||||
String id = compilerDefinition.getId();
|
||||
Compiler compiler;
|
||||
try {
|
||||
// The class loading must be delegated to the framework.
|
||||
compiler = (Compiler) configurationElement
|
||||
.createExecutableExtension("class");
|
||||
compiler = (Compiler) configurationElement.createExecutableExtension("class");
|
||||
} catch (CoreException ex) {
|
||||
throw new RuntimeException(
|
||||
"Cannot create compiler instance for id '" + id + "'.", ex);
|
||||
throw new RuntimeException("Cannot create compiler instance for id '" + id + "'.", ex);
|
||||
}
|
||||
|
||||
// Build the list of common and specific syntax definition files.
|
||||
|
@ -193,8 +170,7 @@ public final class CompilerRegistry {
|
|||
|
||||
compiler = compilerMap.put(id, compiler);
|
||||
if (compiler != null) {
|
||||
throw new RuntimeException("Compiler id '" + id
|
||||
+ "' is already registered to class '"
|
||||
throw new RuntimeException("Compiler id '" + id + "' is already registered to class '"
|
||||
+ compiler.getClass().getName() + "'.");
|
||||
}
|
||||
|
||||
|
@ -224,8 +200,7 @@ public final class CompilerRegistry {
|
|||
*/
|
||||
public Compiler getCompiler(String compilerId) {
|
||||
if (compilerId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be null.");
|
||||
}
|
||||
Compiler result;
|
||||
synchronized (compilerMap) {
|
||||
|
@ -234,8 +209,7 @@ public final class CompilerRegistry {
|
|||
}
|
||||
if (result == null) {
|
||||
|
||||
throw new IllegalArgumentException("Unknown compiler id '"
|
||||
+ compilerId + "'.");
|
||||
throw new IllegalArgumentException("Unknown compiler id '" + compilerId + "'.");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -41,31 +41,23 @@ public final class CompilerVariables {
|
|||
public static final String OUTPUT_FILE_NAME_WITHOUT_EXTENSION = "${outputFileNameWithoutExtension}";
|
||||
public static final String OUTPUT_FILE_NAME_SHORT_WITHOUT_EXTENSION = "${outputFileNameShortWithoutExtension}";
|
||||
|
||||
public static String replaceVariables(String parameter,
|
||||
CompilerFiles files) {
|
||||
public static String replaceVariables(String parameter, CompilerFiles files) {
|
||||
if (parameter == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'parameter' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'parameter' must not be null.");
|
||||
}
|
||||
if (files == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'files' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'files' must not be null.");
|
||||
}
|
||||
|
||||
// When referring to the source file and folder at compiler time,
|
||||
// this always means the main source file.
|
||||
parameter = parameter.replace(SOURCE_FOLDER_PATH,
|
||||
files.mainSourceFile.folderPath);
|
||||
parameter = parameter.replace(SOURCE_FILE_PATH,
|
||||
files.mainSourceFile.filePath);
|
||||
parameter = parameter.replace(OUTPUT_FOLDER_PATH,
|
||||
files.outputFolderPath);
|
||||
parameter = parameter.replace(SOURCE_FOLDER_PATH, files.mainSourceFile.folderPath);
|
||||
parameter = parameter.replace(SOURCE_FILE_PATH, files.mainSourceFile.filePath);
|
||||
parameter = parameter.replace(OUTPUT_FOLDER_PATH, files.outputFolderPath);
|
||||
parameter = parameter.replace(OUTPUT_FILE_PATH, files.outputFilePath);
|
||||
parameter = parameter.replace(OUTPUT_FILE_PATH_WITHOUT_EXTENSION,
|
||||
files.outputFilePathWithoutExtension);
|
||||
parameter = parameter.replace(OUTPUT_FILE_PATH_WITHOUT_EXTENSION, files.outputFilePathWithoutExtension);
|
||||
parameter = parameter.replace(OUTPUT_FILE_NAME, files.outputFileName);
|
||||
parameter = parameter.replace(OUTPUT_FILE_NAME_WITHOUT_EXTENSION,
|
||||
files.outputFileNameWithoutExtension);
|
||||
parameter = parameter.replace(OUTPUT_FILE_NAME_WITHOUT_EXTENSION, files.outputFileNameWithoutExtension);
|
||||
parameter = parameter.replace(OUTPUT_FILE_NAME_SHORT_WITHOUT_EXTENSION,
|
||||
files.outputFileNameShortWithoutExtension);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,71 +2,70 @@ package com.wudsn.ide.asm.compiler.parser;
|
|||
|
||||
public final class CompilerSourceParserFileReference {
|
||||
|
||||
private int type;
|
||||
private int directiveEndOffset;
|
||||
private int type;
|
||||
private int directiveEndOffset;
|
||||
|
||||
/**
|
||||
* Creation is public.
|
||||
*/
|
||||
public CompilerSourceParserFileReference() {
|
||||
type = CompilerSourceParserFileReferenceType.NONE;
|
||||
directiveEndOffset = 0;
|
||||
/**
|
||||
* Creation is public.
|
||||
*/
|
||||
public CompilerSourceParserFileReference() {
|
||||
type = CompilerSourceParserFileReferenceType.NONE;
|
||||
directiveEndOffset = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the include.
|
||||
*
|
||||
* @param type
|
||||
* The type of the include, see
|
||||
* {@link CompilerSourceParserFileReferenceType}.
|
||||
*/
|
||||
public void setType(int type) {
|
||||
switch (type) {
|
||||
case CompilerSourceParserFileReferenceType.SOURCE:
|
||||
case CompilerSourceParserFileReferenceType.BINARY:
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal include type " + type + ".");
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the include.
|
||||
*
|
||||
* @param type
|
||||
* The type of the include, see
|
||||
* {@link CompilerSourceParserFileReferenceType}.
|
||||
*/
|
||||
public void setType(int type) {
|
||||
switch (type) {
|
||||
case CompilerSourceParserFileReferenceType.SOURCE:
|
||||
case CompilerSourceParserFileReferenceType.BINARY:
|
||||
break;
|
||||
/**
|
||||
* Get the type of the include.
|
||||
*
|
||||
* @return The type of the include, see
|
||||
* {@link CompilerSourceParserFileReferenceType}.
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Illegal include type " + type
|
||||
+ ".");
|
||||
}
|
||||
this.type = type;
|
||||
/**
|
||||
* Sets the include directive end offset. The value must be the offset of
|
||||
* first character after the directive.
|
||||
*
|
||||
* @param directiveEndOffset
|
||||
* The include directive end offset, a non-negative integer.
|
||||
*/
|
||||
public void setDirectiveEndOffset(int directiveEndOffset) {
|
||||
if (directiveEndOffset < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'directiveEndOffset' must not be be negative. Specified value was " + directiveEndOffset
|
||||
+ ".");
|
||||
}
|
||||
this.directiveEndOffset = directiveEndOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the include.
|
||||
*
|
||||
* @return The type of the include, see
|
||||
* {@link CompilerSourceParserFileReferenceType}.
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the include directive end offset. The value must be the offset of
|
||||
* first character after the directive.
|
||||
*
|
||||
* @param directiveEndOffset
|
||||
* The include directive end offset, a non-negative integer.
|
||||
*/
|
||||
public void setDirectiveEndOffset(int directiveEndOffset) {
|
||||
if (directiveEndOffset < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'directiveEndOffset' must not be be negative. Specified value was "
|
||||
+ directiveEndOffset + ".");
|
||||
}
|
||||
this.directiveEndOffset = directiveEndOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the include directive end offset.
|
||||
*
|
||||
* @return The include directive end offset, a non-negative integer.
|
||||
*/
|
||||
public int getDirectiveEndOffset() {
|
||||
return directiveEndOffset;
|
||||
}
|
||||
/**
|
||||
* Gets the include directive end offset.
|
||||
*
|
||||
* @return The include directive end offset, a non-negative integer.
|
||||
*/
|
||||
public int getDirectiveEndOffset() {
|
||||
return directiveEndOffset;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -26,13 +26,13 @@ package com.wudsn.ide.asm.compiler.parser;
|
|||
*/
|
||||
public final class CompilerSourceParserFileReferenceType {
|
||||
|
||||
/**
|
||||
* Creation is private.
|
||||
*/
|
||||
private CompilerSourceParserFileReferenceType() {
|
||||
}
|
||||
/**
|
||||
* Creation is private.
|
||||
*/
|
||||
private CompilerSourceParserFileReferenceType() {
|
||||
}
|
||||
|
||||
public final static int NONE=1;
|
||||
public final static int SOURCE = 2;
|
||||
public final static int BINARY = 3;
|
||||
public final static int NONE = 1;
|
||||
public final static int SOURCE = 2;
|
||||
public final static int BINARY = 3;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -42,13 +42,11 @@ public abstract class CompilerSourceParserLineCallback {
|
|||
*/
|
||||
protected CompilerSourceParserLineCallback(String filePath, int lineNumber) {
|
||||
if (filePath == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'filePath' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'filePath' must not be null.");
|
||||
}
|
||||
if (lineNumber < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'lineNumber' must not be negative. Specified value is "
|
||||
+ lineNumber + ".");
|
||||
throw new IllegalArgumentException("Parameter 'lineNumber' must not be negative. Specified value is "
|
||||
+ lineNumber + ".");
|
||||
}
|
||||
this.filePath = filePath;
|
||||
this.lineNumber = lineNumber;
|
||||
|
@ -76,10 +74,8 @@ public abstract class CompilerSourceParserLineCallback {
|
|||
}
|
||||
|
||||
// Most of the parameters are currently not used by the consumer.
|
||||
public abstract void processLine(CompilerSourceParser compilerSourceParser,
|
||||
CompilerSourceFile compilerSourceFile, int lineNumber,
|
||||
int startOffset, int symbolOffset, boolean instructionFound,
|
||||
int instructionOffset, String instruction, int operandOffset,
|
||||
CompilerSourceParserTreeObject section);
|
||||
public abstract void processLine(CompilerSourceParser compilerSourceParser, CompilerSourceFile compilerSourceFile,
|
||||
int lineNumber, int startOffset, int symbolOffset, boolean instructionFound, int instructionOffset,
|
||||
String instruction, int operandOffset, CompilerSourceParserTreeObject section);
|
||||
|
||||
}
|
||||
|
|
|
@ -79,17 +79,14 @@ public final class CompilerSourceParserTreeObject {
|
|||
* @param description
|
||||
* The description of the tree object, not <code>null</code>.
|
||||
*/
|
||||
CompilerSourceParserTreeObject(CompilerSourceFile compilerSourceFile,
|
||||
int startOffset, int type, String name, String displayName,
|
||||
String description) {
|
||||
CompilerSourceParserTreeObject(CompilerSourceFile compilerSourceFile, int startOffset, int type, String name,
|
||||
String displayName, String description) {
|
||||
if (compilerSourceFile == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerSourceFile' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerSourceFile' must not be null.");
|
||||
}
|
||||
if (startOffset < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'startOffset' must not be negative. Specified value is "
|
||||
+ startOffset + ".");
|
||||
throw new IllegalArgumentException("Parameter 'startOffset' must not be negative. Specified value is "
|
||||
+ startOffset + ".");
|
||||
}
|
||||
this.compilerSourceFile = compilerSourceFile;
|
||||
this.startOffset = startOffset;
|
||||
|
@ -121,16 +118,13 @@ public final class CompilerSourceParserTreeObject {
|
|||
throw new IllegalArgumentException("Unknown type " + type + ".");
|
||||
}
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'name' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'name' must not be null.");
|
||||
}
|
||||
if (displayName == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'displayName' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'displayName' must not be null.");
|
||||
}
|
||||
if (description == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'description' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'description' must not be null.");
|
||||
}
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
|
@ -191,8 +185,8 @@ public final class CompilerSourceParserTreeObject {
|
|||
*/
|
||||
public String getCompoundName() {
|
||||
if (compoundName == null) {
|
||||
char identifierSeparatorCharacter = compilerSourceFile
|
||||
.getCompilerSyntax().getIdentifierSeparatorCharacter();
|
||||
char identifierSeparatorCharacter = compilerSourceFile.getCompilerSyntax()
|
||||
.getIdentifierSeparatorCharacter();
|
||||
switch (type) {
|
||||
case CompilerSourceParserTreeObjectType.DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.IMPLEMENTATION_SECTION:
|
||||
|
@ -236,13 +230,11 @@ public final class CompilerSourceParserTreeObject {
|
|||
&& namedParent.getType() != CompilerSourceParserTreeObjectType.PROCEDURE_DEFINITION_SECTION) {
|
||||
namedParent = namedParent.getParent();
|
||||
}
|
||||
if (namedParent != null
|
||||
&& StringUtility.isSpecified(compoundName)) {
|
||||
if (namedParent != null && StringUtility.isSpecified(compoundName)) {
|
||||
String parentCompoundName;
|
||||
parentCompoundName = parent.getCompoundName();
|
||||
if (StringUtility.isSpecified(parentCompoundName)) {
|
||||
compoundName = parentCompoundName
|
||||
+ identifierSeparatorCharacter + compoundName;
|
||||
compoundName = parentCompoundName + identifierSeparatorCharacter + compoundName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -350,12 +342,10 @@ public final class CompilerSourceParserTreeObject {
|
|||
*/
|
||||
final void addChild(CompilerSourceParserTreeObject child) {
|
||||
if (child == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'child' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'child' must not be null.");
|
||||
}
|
||||
if (child == this) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'child' must not be this: " + toString());
|
||||
throw new IllegalArgumentException("Parameter 'child' must not be this: " + toString());
|
||||
}
|
||||
children.add(child);
|
||||
child.setParent(this);
|
||||
|
@ -377,16 +367,13 @@ public final class CompilerSourceParserTreeObject {
|
|||
* @param includedCompilerSourceFile
|
||||
* The included compiler source file, may be <code>null</code>.
|
||||
*/
|
||||
final void setIncludedCompilerSourceFile(
|
||||
CompilerSourceFile includedCompilerSourceFile) {
|
||||
final void setIncludedCompilerSourceFile(CompilerSourceFile includedCompilerSourceFile) {
|
||||
if (type != CompilerSourceParserTreeObjectType.SOURCE_INCLUDE) {
|
||||
throw new IllegalStateException("The type of this tree object is "
|
||||
+ type + " and not SOURCE_INCLUDE");
|
||||
throw new IllegalStateException("The type of this tree object is " + type + " and not SOURCE_INCLUDE");
|
||||
}
|
||||
this.includedCompilerSourceFile = includedCompilerSourceFile;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -111,13 +111,13 @@ public final class CompilerSourceParserTreeObjectType {
|
|||
case BINARY_OUTPUT:
|
||||
result = Texts.COMPILER_SOURCE_PARSER_TREE_OBJECT_TYPE_BINARY_OUTPUT;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown type " + type + ".");
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines if instructions are allowed in the given type of section.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -42,8 +42,7 @@ import com.wudsn.ide.asm.editor.AssemblerEditor;
|
|||
* @author Peter Dell
|
||||
* @author Andy Reek
|
||||
*/
|
||||
public final class CompilerSourcePartitionScanner extends
|
||||
RuleBasedPartitionScanner {
|
||||
public final class CompilerSourcePartitionScanner extends RuleBasedPartitionScanner {
|
||||
|
||||
/**
|
||||
* Name for the single line comment partition.
|
||||
|
@ -72,46 +71,37 @@ public final class CompilerSourcePartitionScanner extends
|
|||
*/
|
||||
public CompilerSourcePartitionScanner(CompilerSyntax compilerSyntax) {
|
||||
if (compilerSyntax == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerSyntax' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerSyntax' must not be null.");
|
||||
}
|
||||
IToken commentSingleToken = new Token(PARTITION_COMMENT_SINGLE);
|
||||
IToken commentMultipleToken = new Token(PARTITION_COMMENT_MULTIPLE);
|
||||
IToken stringToken = new Token(PARTITION_STRING);
|
||||
|
||||
List<IRule> rules = new ArrayList<IRule>();
|
||||
for (String singleLineCommentDelimiter : compilerSyntax
|
||||
.getSingleLineCommentDelimiters()) {
|
||||
for (String singleLineCommentDelimiter : compilerSyntax.getSingleLineCommentDelimiters()) {
|
||||
|
||||
// A "*" is only a comment start token if it is followed by a space
|
||||
// or a tab.
|
||||
// It is allowed as part of an expression to refer to the program
|
||||
// counter.
|
||||
if (singleLineCommentDelimiter.equals("*")) {
|
||||
rules.add(new EndOfLineRule(singleLineCommentDelimiter + " ",
|
||||
commentSingleToken));
|
||||
rules.add(new EndOfLineRule(singleLineCommentDelimiter + "\t",
|
||||
commentSingleToken));
|
||||
rules.add(new EndOfLineRule(singleLineCommentDelimiter + " ", commentSingleToken));
|
||||
rules.add(new EndOfLineRule(singleLineCommentDelimiter + "\t", commentSingleToken));
|
||||
} else {
|
||||
rules.add(new EndOfLineRule(singleLineCommentDelimiter,
|
||||
commentSingleToken));
|
||||
rules.add(new EndOfLineRule(singleLineCommentDelimiter, commentSingleToken));
|
||||
}
|
||||
}
|
||||
List<String> multipleLinesCommentDelimiters = compilerSyntax
|
||||
.getMultipleLinesCommentDelimiters();
|
||||
List<String> multipleLinesCommentDelimiters = compilerSyntax.getMultipleLinesCommentDelimiters();
|
||||
for (int i = 0; i < multipleLinesCommentDelimiters.size();) {
|
||||
String startSequence = multipleLinesCommentDelimiters.get(i++);
|
||||
String endSequence = multipleLinesCommentDelimiters.get(i++);
|
||||
rules.add(new MultiLineRule(startSequence, endSequence,
|
||||
commentMultipleToken));
|
||||
rules.add(new MultiLineRule(startSequence, endSequence, commentMultipleToken));
|
||||
}
|
||||
|
||||
for (String stringDelimiter : compilerSyntax.getStringDelimiters()) {
|
||||
rules.add(new SingleLineRule(stringDelimiter, stringDelimiter,
|
||||
stringToken));
|
||||
rules.add(new SingleLineRule(stringDelimiter, stringDelimiter, stringToken));
|
||||
}
|
||||
|
||||
|
||||
IPredicateRule[] rulesArray = new IPredicateRule[rules.size()];
|
||||
rules.toArray(rulesArray);
|
||||
setPredicateRules(rulesArray);
|
||||
|
@ -127,8 +117,7 @@ public final class CompilerSourcePartitionScanner extends
|
|||
public void createDocumentPartitioner(IDocument document) {
|
||||
|
||||
if (document == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'document' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'document' must not be null.");
|
||||
}
|
||||
FastPartitioner partitioner = new FastPartitioner(this, new String[] {
|
||||
CompilerSourcePartitionScanner.PARTITION_COMMENT_SINGLE,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -46,8 +46,7 @@ public final class CompilerSyntaxUtility {
|
|||
*/
|
||||
public static String getTypeImagePath(Instruction instruction) {
|
||||
if (instruction == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'instruction' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'instruction' must not be null.");
|
||||
}
|
||||
String path;
|
||||
|
||||
|
@ -66,8 +65,7 @@ public final class CompilerSyntaxUtility {
|
|||
path = "instruction-type-pseudo-opcode-16x16.gif";
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown opcode type "
|
||||
+ opcode.getType() + ".");
|
||||
throw new IllegalStateException("Unknown opcode type " + opcode.getType() + ".");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -100,8 +98,7 @@ public final class CompilerSyntaxUtility {
|
|||
text = Texts.COMPILER_SYNTAX_PSEUDO_OPCODE;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown opcode type "
|
||||
+ opcode.getType() + ".");
|
||||
throw new IllegalStateException("Unknown opcode type " + opcode.getType() + ".");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ import com.wudsn.ide.asm.CPU;
|
|||
|
||||
public final class Directive extends Instruction {
|
||||
|
||||
Directive(Set<CPU> cpus, int type, boolean caseSensitive,
|
||||
String name, String title, String proposal) {
|
||||
Directive(Set<CPU> cpus, int type, boolean caseSensitive, String name, String title, String proposal) {
|
||||
super(cpus, type, caseSensitive, name, title, proposal);
|
||||
|
||||
switch (type) {
|
||||
|
@ -50,8 +49,7 @@ public final class Directive extends Instruction {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown type " + type
|
||||
+ " for directive '" + name + "'.");
|
||||
throw new IllegalArgumentException("Unknown type " + type + " for directive '" + name + "'.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,25 +42,18 @@ public abstract class Instruction implements Comparable<Instruction> {
|
|||
private int[] styledTitleOffsets;
|
||||
private String proposal;
|
||||
|
||||
protected Instruction(Set<CPU> cpus, int type, boolean caseSensitive,
|
||||
String name, String title, String proposal) {
|
||||
protected Instruction(Set<CPU> cpus, int type, boolean caseSensitive, String name, String title, String proposal) {
|
||||
if (cpus == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'cpus' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'cpus' must not be null.");
|
||||
}
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'name' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'name' must not be null.");
|
||||
}
|
||||
if (title == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'title' must not be null for instruction '"
|
||||
+ name + "'.");
|
||||
throw new IllegalArgumentException("Parameter 'title' must not be null for instruction '" + name + "'.");
|
||||
}
|
||||
if (proposal == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'proposal' must not be null for instruction '"
|
||||
+ name + "'.");
|
||||
throw new IllegalArgumentException("Parameter 'proposal' must not be null for instruction '" + name + "'.");
|
||||
}
|
||||
this.cpus = cpus;
|
||||
this.type = type;
|
||||
|
@ -85,14 +78,12 @@ public abstract class Instruction implements Comparable<Instruction> {
|
|||
if (c == '_') {
|
||||
i++;
|
||||
if (i >= title.length()) {
|
||||
throw new RuntimeException("Instruction '" + name
|
||||
+ "' has invalid title '" + title + "'.");
|
||||
throw new RuntimeException("Instruction '" + name + "' has invalid title '" + title + "'.");
|
||||
}
|
||||
c = title.charAt(i);
|
||||
fc = Character.toUpperCase(c);
|
||||
mnemonicBuilder.append(fc);
|
||||
styledTitleOffsetsList.add(NumberFactory
|
||||
.getInteger(styledTitleBuilder.length()));
|
||||
styledTitleOffsetsList.add(NumberFactory.getInteger(styledTitleBuilder.length()));
|
||||
} else {
|
||||
fc = c;
|
||||
}
|
||||
|
@ -104,20 +95,17 @@ public abstract class Instruction implements Comparable<Instruction> {
|
|||
int size = styledTitleOffsetsList.size();
|
||||
this.styledTitleOffsets = new int[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
this.styledTitleOffsets[i] = styledTitleOffsetsList.get(i)
|
||||
.intValue();
|
||||
this.styledTitleOffsets[i] = styledTitleOffsetsList.get(i).intValue();
|
||||
}
|
||||
|
||||
proposal = proposal.replace("\\n", "" + NEWLINE);
|
||||
if (!proposal.startsWith(name)) {
|
||||
throw new RuntimeException("Proposal '" + proposal
|
||||
+ "' of instruction '" + name + "' does not start with '"
|
||||
+ name + "'.");
|
||||
throw new RuntimeException("Proposal '" + proposal + "' of instruction '" + name
|
||||
+ "' does not start with '" + name + "'.");
|
||||
}
|
||||
if (proposal.indexOf(CURSOR) == -1) {
|
||||
|
||||
throw new RuntimeException("Proposal '" + proposal
|
||||
+ "' of instruction '" + name
|
||||
throw new RuntimeException("Proposal '" + proposal + "' of instruction '" + name
|
||||
+ "' does not contain cursor positioning via '_'.");
|
||||
}
|
||||
|
||||
|
@ -126,8 +114,7 @@ public abstract class Instruction implements Comparable<Instruction> {
|
|||
// Remove all special characters like
|
||||
StringBuilder mnemonicNameBuilder = new StringBuilder(upperCaseName);
|
||||
for (int i = 0; i < mnemonicNameBuilder.length(); i++) {
|
||||
if (!Character.isLetter(mnemonicNameBuilder.charAt(i))
|
||||
&& !Character.isDigit(mnemonicNameBuilder.charAt(i))) {
|
||||
if (!Character.isLetter(mnemonicNameBuilder.charAt(i)) && !Character.isDigit(mnemonicNameBuilder.charAt(i))) {
|
||||
mnemonicNameBuilder.deleteCharAt(i);
|
||||
}
|
||||
}
|
||||
|
@ -135,10 +122,8 @@ public abstract class Instruction implements Comparable<Instruction> {
|
|||
String mnemonic = mnemonicBuilder.toString();
|
||||
String mnemonicName = mnemonicNameBuilder.toString();
|
||||
if (!mnemonicName.equalsIgnoreCase(mnemonic)) {
|
||||
throw new RuntimeException("Menmonic '" + mnemonic
|
||||
+ "' derived from title '" + title
|
||||
+ "' with of instruction '" + name
|
||||
+ "' does match mnemonic '" + mnemonicName
|
||||
throw new RuntimeException("Menmonic '" + mnemonic + "' derived from title '" + title
|
||||
+ "' with of instruction '" + name + "' does match mnemonic '" + mnemonicName
|
||||
+ " derived from the name'.");
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -55,7 +55,6 @@ public final class InstructionType {
|
|||
public static final int BINARY_INCLUDE_DIRECTIVE = 121;
|
||||
public static final int BINARY_OUTPUT_DIRECTIVE = 122;
|
||||
|
||||
|
||||
// Types of opcodes.
|
||||
public static final int LEGAL_OPCODE = 200;
|
||||
public static final int ILLEGAL_OPCODE = 201;
|
||||
|
|
|
@ -38,8 +38,7 @@ import com.wudsn.ide.asm.Texts;
|
|||
* @author Peter Dell
|
||||
* @since 1.6.1
|
||||
*/
|
||||
public final class AssemblerBreakpointAdapterFactory implements
|
||||
IToggleBreakpointsTargetFactory {
|
||||
public final class AssemblerBreakpointAdapterFactory implements IToggleBreakpointsTargetFactory {
|
||||
|
||||
private String TARGET_ID = AssemblerBreakpointsTarget.class.getName();
|
||||
private Set<String> defaultSet;
|
||||
|
@ -50,8 +49,7 @@ public final class AssemblerBreakpointAdapterFactory implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToggleTargets(IWorkbenchPart part,
|
||||
ISelection selection) {
|
||||
public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) {
|
||||
if (part instanceof AssemblerEditor) {
|
||||
return defaultSet;
|
||||
}
|
||||
|
@ -59,8 +57,7 @@ public final class AssemblerBreakpointAdapterFactory implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultToggleTarget(IWorkbenchPart part,
|
||||
ISelection selection) {
|
||||
public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) {
|
||||
if (part instanceof AssemblerEditor) {
|
||||
return TARGET_ID;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public final class AssemblerBreakpointsTarget implements IToggleBreakpointsTarge
|
|||
AssemblerEditor assemblerEditor = getEditor(part);
|
||||
if (assemblerEditor != null) {
|
||||
IBreakpointManager breakPointManager = DebugPlugin.getDefault().getBreakpointManager();
|
||||
String editorId=assemblerEditor.getClass().getName();
|
||||
String editorId = assemblerEditor.getClass().getName();
|
||||
IEditorInput editorInput = assemblerEditor.getEditorInput();
|
||||
IResource resource = (IResource) editorInput.getAdapter(IResource.class);
|
||||
ITextSelection textSelection = (ITextSelection) selection;
|
||||
|
@ -85,7 +85,8 @@ public final class AssemblerBreakpointsTarget implements IToggleBreakpointsTarge
|
|||
if (StringUtility.isEmpty(description)) {
|
||||
return;
|
||||
}
|
||||
AssemblerBreakpoint breakpoint = new AssemblerBreakpoint(editorId, editorInput, resource, lineNumber + 1, description);
|
||||
AssemblerBreakpoint breakpoint = new AssemblerBreakpoint(editorId, editorInput, resource, lineNumber + 1,
|
||||
description);
|
||||
breakPointManager.addBreakpoint(breakpoint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,8 +94,7 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
private static final class SourceParserCallback extends
|
||||
CompilerSourceParserLineCallback {
|
||||
private static final class SourceParserCallback extends CompilerSourceParserLineCallback {
|
||||
private boolean instructionFound;
|
||||
private int instructionEndOffset;
|
||||
|
||||
|
@ -114,11 +113,9 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void processLine(CompilerSourceParser compilerSourceParser,
|
||||
CompilerSourceFile compilerSourceFile, int lineNumber,
|
||||
int startOffset, int symbolOffset, boolean instructionFound,
|
||||
int instructionOffset, String instruction, int operandOffset,
|
||||
CompilerSourceParserTreeObject section) {
|
||||
public void processLine(CompilerSourceParser compilerSourceParser, CompilerSourceFile compilerSourceFile,
|
||||
int lineNumber, int startOffset, int symbolOffset, boolean instructionFound, int instructionOffset,
|
||||
String instruction, int operandOffset, CompilerSourceParserTreeObject section) {
|
||||
|
||||
this.instructionFound = instructionFound;
|
||||
if (instructionFound) {
|
||||
|
@ -173,21 +170,16 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
*/
|
||||
AssemblerContentAssistProcessor(AssemblerEditor editor) {
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'editor' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
||||
}
|
||||
|
||||
this.editor = editor;
|
||||
|
||||
AssemblerPlugin plugin = editor.getPlugin();
|
||||
directiveImage = plugin
|
||||
.getImage("instruction-type-directive-16x16.gif");
|
||||
legalOpcodeImage = plugin
|
||||
.getImage("instruction-type-legal-opcode-16x16.gif");
|
||||
illegalOpcodeImage = plugin
|
||||
.getImage("instruction-type-illegal-opcode-16x16.gif");
|
||||
pseudoOpcodeImage = plugin
|
||||
.getImage("instruction-type-pseudo-opcode-16x16.gif");
|
||||
directiveImage = plugin.getImage("instruction-type-directive-16x16.gif");
|
||||
legalOpcodeImage = plugin.getImage("instruction-type-legal-opcode-16x16.gif");
|
||||
illegalOpcodeImage = plugin.getImage("instruction-type-illegal-opcode-16x16.gif");
|
||||
pseudoOpcodeImage = plugin.getImage("instruction-type-pseudo-opcode-16x16.gif");
|
||||
instructionStyler = new InstructionStyler();
|
||||
highlightStyler = new HighlightStyler();
|
||||
}
|
||||
|
@ -196,14 +188,11 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
|
||||
int offset) {
|
||||
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
|
||||
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();
|
||||
ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection();
|
||||
|
||||
int selectionOffset = offset;
|
||||
|
||||
|
@ -227,38 +216,27 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
// Parse the current assembler file and try to find the line in the
|
||||
// correct source file.
|
||||
CompilerFiles files = AssemblerEditorFilesLogic.createInstance(editor).createCompilerFiles();
|
||||
if (files==null){
|
||||
if (files == null) {
|
||||
return null;
|
||||
}
|
||||
SourceParserCallback compilerSourceCallback = new SourceParserCallback(
|
||||
files.sourceFile.filePath, lineNumber);
|
||||
CompilerSourceParser compilerSourceParser = editor
|
||||
.createCompilerSourceParser();
|
||||
CompilerSourceFile compilerSourceFile = compilerSourceParser
|
||||
.createCompilerSourceFile(files.sourceFile.file,
|
||||
viewer.getDocument());
|
||||
SourceParserCallback compilerSourceCallback = new SourceParserCallback(files.sourceFile.filePath, lineNumber);
|
||||
CompilerSourceParser compilerSourceParser = editor.createCompilerSourceParser();
|
||||
CompilerSourceFile compilerSourceFile = compilerSourceParser.createCompilerSourceFile(files.sourceFile.file,
|
||||
viewer.getDocument());
|
||||
compilerSourceParser.parse(compilerSourceFile, compilerSourceCallback);
|
||||
|
||||
// If there is no instruction in the line yet or the cursor is exactly
|
||||
// at the last character of that instruction, propose one.
|
||||
if (!compilerSourceCallback.wasInstructionFound()
|
||||
|| selectionOffset == lineOffset
|
||||
+ compilerSourceCallback.getInstructionEndOffset()) {
|
||||
String prefix = getPrefix(viewer,
|
||||
compilerSourceParser.getCompilerSyntax(), selectionOffset,
|
||||
false);
|
||||
Region region = new Region(selectionOffset - prefix.length(),
|
||||
prefix.length() + selection.getLength());
|
||||
|| selectionOffset == lineOffset + compilerSourceCallback.getInstructionEndOffset()) {
|
||||
String prefix = getPrefix(viewer, compilerSourceParser.getCompilerSyntax(), selectionOffset, false);
|
||||
Region region = new Region(selectionOffset - prefix.length(), prefix.length() + selection.getLength());
|
||||
addInstructionProposals(region, prefix, proposalList);
|
||||
} else {
|
||||
// Otherwise propose to use an identifier as operand.
|
||||
String prefix = getPrefix(viewer,
|
||||
compilerSourceParser.getCompilerSyntax(), selectionOffset,
|
||||
true);
|
||||
Region region = new Region(selectionOffset - prefix.length(),
|
||||
prefix.length() + selection.getLength());
|
||||
addIdentifierProposals(region, prefix, compilerSourceFile,
|
||||
proposalList);
|
||||
String prefix = getPrefix(viewer, compilerSourceParser.getCompilerSyntax(), selectionOffset, true);
|
||||
Region region = new Region(selectionOffset - prefix.length(), prefix.length() + selection.getLength());
|
||||
addIdentifierProposals(region, prefix, compilerSourceFile, proposalList);
|
||||
}
|
||||
|
||||
// If there is no proposal entry, return null instead of an empty array.
|
||||
|
@ -286,15 +264,12 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
*
|
||||
* @return The prefix, may be empty, not <code>null</code>.
|
||||
*/
|
||||
private String getPrefix(ITextViewer viewer, CompilerSyntax compilerSyntax,
|
||||
int offset, boolean onlyIdentifiers) {
|
||||
private String getPrefix(ITextViewer viewer, CompilerSyntax compilerSyntax, int offset, boolean onlyIdentifiers) {
|
||||
if (viewer == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'viewer' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'viewer' must not be null.");
|
||||
}
|
||||
if (compilerSyntax == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerSyntax' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerSyntax' must not be null.");
|
||||
}
|
||||
int i = offset;
|
||||
IDocument document = viewer.getDocument();
|
||||
|
@ -327,44 +302,34 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
private void addInstructionProposals(Region region, String prefix,
|
||||
List<ICompletionProposal> proposalList) {
|
||||
private void addInstructionProposals(Region region, String prefix, List<ICompletionProposal> proposalList) {
|
||||
if (region == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'region' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'region' must not be null.");
|
||||
}
|
||||
if (prefix == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'prefix' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'prefix' must not be null.");
|
||||
}
|
||||
if (proposalList == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'proposalList' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'proposalList' must not be null.");
|
||||
}
|
||||
AssemblerPreferences assemblerPreferences = editor.getPlugin()
|
||||
.getPreferences();
|
||||
AssemblerPreferences assemblerPreferences = editor.getPlugin().getPreferences();
|
||||
|
||||
int offset = region.getOffset();
|
||||
boolean lowerCase;
|
||||
|
||||
// Prefix is empty or prefix does not end with a letter but for
|
||||
// example "."
|
||||
if (StringUtility.isEmpty(prefix)
|
||||
|| !Character.isLetter(prefix.charAt(prefix.length() - 1))) {
|
||||
if (StringUtility.isEmpty(prefix) || !Character.isLetter(prefix.charAt(prefix.length() - 1))) {
|
||||
String defaultCase;
|
||||
defaultCase = assemblerPreferences
|
||||
.getEditorContentAssistProcessorDefaultCase();
|
||||
lowerCase = AssemblerContentAssistProcessorDefaultCase.LOWER_CASE
|
||||
.equals(defaultCase);
|
||||
defaultCase = assemblerPreferences.getEditorContentAssistProcessorDefaultCase();
|
||||
lowerCase = AssemblerContentAssistProcessorDefaultCase.LOWER_CASE.equals(defaultCase);
|
||||
} else {
|
||||
char lastchar = prefix.charAt(prefix.length() - 1);
|
||||
lowerCase = ((lastchar < 'a') || (lastchar > 'z')) ? false : true;
|
||||
}
|
||||
|
||||
CompilerSourceParser compilerSourceParser = editor
|
||||
.createCompilerSourceParser();
|
||||
InstructionSet instructionSet = compilerSourceParser
|
||||
.getInstructionSet();
|
||||
CompilerSourceParser compilerSourceParser = editor.createCompilerSourceParser();
|
||||
InstructionSet instructionSet = compilerSourceParser.getInstructionSet();
|
||||
|
||||
boolean caseSenstive = instructionSet.areInstructionsCaseSensitive();
|
||||
if (!caseSenstive) {
|
||||
|
@ -383,8 +348,7 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
} else {
|
||||
if (instruction.getUpperCaseName().indexOf(prefix) == 0) {
|
||||
|
||||
name = lowerCase ? instruction.getLowerCaseName()
|
||||
: instruction.getUpperCaseName();
|
||||
name = lowerCase ? instruction.getLowerCaseName() : instruction.getUpperCaseName();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,26 +371,22 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
image = pseudoOpcodeImage;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown opcode type "
|
||||
+ opcode.getType() + ".");
|
||||
throw new IllegalStateException("Unknown opcode type " + opcode.getType() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
String separator = " - ";
|
||||
String displayString = name + separator
|
||||
+ instruction.getTitle();
|
||||
String displayString = name + separator + instruction.getTitle();
|
||||
StyledString styledDisplayString = new StyledString();
|
||||
styledDisplayString.append(name);
|
||||
styledDisplayString.append(separator);
|
||||
int start = styledDisplayString.length();
|
||||
styledDisplayString.append(instruction.getStyledTitle());
|
||||
styledDisplayString.setStyle(0, name.length(),
|
||||
instructionStyler);
|
||||
styledDisplayString.setStyle(0, name.length(), instructionStyler);
|
||||
int[] offsets = instruction.getStyledTitleOffsets();
|
||||
|
||||
for (int j = 0; j < offsets.length; j++) {
|
||||
styledDisplayString.setStyle(start + offsets[j], 1,
|
||||
highlightStyler);
|
||||
styledDisplayString.setStyle(start + offsets[j], 1, highlightStyler);
|
||||
}
|
||||
|
||||
// Adapt proposal.
|
||||
|
@ -442,56 +402,47 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
proposal = proposal.replace("\n", "\n\t");
|
||||
newCursorOffset = offset + proposalIndex;
|
||||
|
||||
proposalList.add(new AssemblerInstructionCompletionProposal(
|
||||
proposal, offset, region.getLength(), newCursorOffset,
|
||||
image, displayString, styledDisplayString, null));
|
||||
proposalList.add(new AssemblerInstructionCompletionProposal(proposal, offset, region.getLength(),
|
||||
newCursorOffset, image, displayString, styledDisplayString, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Handle prefixes which contain "." or end with it.
|
||||
// TODO Handle identifier case sensitivity correctly
|
||||
private void addIdentifierProposals(Region region, String prefix,
|
||||
CompilerSourceFile compilerSourceFile,
|
||||
private void addIdentifierProposals(Region region, String prefix, CompilerSourceFile compilerSourceFile,
|
||||
List<ICompletionProposal> proposalList) {
|
||||
if (region == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'region' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'region' must not be null.");
|
||||
}
|
||||
if (prefix == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'prefix' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'prefix' must not be null.");
|
||||
}
|
||||
if (compilerSourceFile == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerSourceFile' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerSourceFile' must not be null.");
|
||||
}
|
||||
if (proposalList == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'proposalList' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'proposalList' must not be null.");
|
||||
}
|
||||
|
||||
CompilerSourceParserTreeObjectLabelProvider imageProvider = new CompilerSourceParserTreeObjectLabelProvider();
|
||||
IStyledLabelProvider styledStringProvider = imageProvider
|
||||
.getStyledStringProvider();
|
||||
IStyledLabelProvider styledStringProvider = imageProvider.getStyledStringProvider();
|
||||
int regionOffset = region.getOffset();
|
||||
int regionLength = region.getLength();
|
||||
String lowerCasePrefix = prefix.toLowerCase();
|
||||
|
||||
// Find last separator as basis for the prefix.
|
||||
char identifierSeparatorCharacter = editor.getCompilerDefinition()
|
||||
.getSyntax().getIdentifierSeparatorCharacter();
|
||||
char identifierSeparatorCharacter = editor.getCompilerDefinition().getSyntax()
|
||||
.getIdentifierSeparatorCharacter();
|
||||
if (identifierSeparatorCharacter != CompilerSyntax.NO_CHARACTER) {
|
||||
int index = lowerCasePrefix
|
||||
.lastIndexOf(identifierSeparatorCharacter);
|
||||
int index = lowerCasePrefix.lastIndexOf(identifierSeparatorCharacter);
|
||||
if (index >= 0) {
|
||||
regionOffset += index + 1;
|
||||
regionLength -= index + 1;
|
||||
lowerCasePrefix = lowerCasePrefix.substring(index + 1);
|
||||
lowerCasePrefix = lowerCasePrefix.substring(index + 1);
|
||||
}
|
||||
}
|
||||
List<CompilerSourceParserTreeObject> identifiers = compilerSourceFile
|
||||
.getIdentifiers();
|
||||
List<CompilerSourceParserTreeObject> identifiers = compilerSourceFile.getIdentifiers();
|
||||
String separator = " - ";
|
||||
for (int i = 0; i < identifiers.size(); i++) {
|
||||
CompilerSourceParserTreeObject element = identifiers.get(i);
|
||||
|
@ -510,14 +461,12 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
displayString = displayName;
|
||||
|
||||
}
|
||||
StyledString styledDisplayString = styledStringProvider
|
||||
.getStyledText(element);
|
||||
StyledString styledDisplayString = styledStringProvider.getStyledText(element);
|
||||
|
||||
int newCursorOffset = regionOffset + proposal.length();
|
||||
|
||||
proposalList.add(new AssemblerInstructionCompletionProposal(
|
||||
proposal, regionOffset, regionLength, newCursorOffset,
|
||||
image, displayString, styledDisplayString, null));
|
||||
proposalList.add(new AssemblerInstructionCompletionProposal(proposal, regionOffset, regionLength,
|
||||
newCursorOffset, image, displayString, styledDisplayString, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,8 +476,7 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public IContextInformation[] computeContextInformation(ITextViewer viewer,
|
||||
int offset) {
|
||||
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -537,10 +485,8 @@ final class AssemblerContentAssistProcessor implements IContentAssistProcessor {
|
|||
*/
|
||||
@Override
|
||||
public char[] getCompletionProposalAutoActivationCharacters() {
|
||||
CompilerSyntax compilerSyntax = editor.getCompilerDefinition()
|
||||
.getSyntax();
|
||||
char[] result = compilerSyntax
|
||||
.getCompletionProposalAutoActivationCharacters();
|
||||
CompilerSyntax compilerSyntax = editor.getCompilerDefinition().getSyntax();
|
||||
char[] result = compilerSyntax.getCompletionProposalAutoActivationCharacters();
|
||||
if (result.length == 0) {
|
||||
result = null;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -65,526 +65,491 @@ import com.wudsn.ide.base.common.RunnableWithLogging;
|
|||
*/
|
||||
final class AssemblerContentOutlinePage extends ContentOutlinePage {
|
||||
|
||||
/*
|
||||
* Toggle action to toggle the sorting in the outline tree. The state of the
|
||||
* action will be persisted along with the file in the editor. If there is
|
||||
* no state store yet along with in the file, the default is taken from the
|
||||
* last file which was opened.
|
||||
*/
|
||||
private static final class OutlineViewerSortAction extends Action {
|
||||
private static final QualifiedName CHECKED = new QualifiedName(
|
||||
"OutlineViewerSortAction", "Checked");
|
||||
/*
|
||||
* Toggle action to toggle the sorting in the outline tree. The state of the
|
||||
* action will be persisted along with the file in the editor. If there is
|
||||
* no state store yet along with in the file, the default is taken from the
|
||||
* last file which was opened.
|
||||
*/
|
||||
private static final class OutlineViewerSortAction extends Action {
|
||||
private static final QualifiedName CHECKED = new QualifiedName("OutlineViewerSortAction", "Checked");
|
||||
|
||||
final AssemblerEditor editor;
|
||||
final TreeViewer treeViewer;
|
||||
|
||||
/**
|
||||
* Creates a new sort action.
|
||||
*
|
||||
* @param editor
|
||||
* The editor which holds the respective file, not
|
||||
* <code>null</code>.
|
||||
* @param treeViewer
|
||||
* The tree viewer which displays the outline.
|
||||
*/
|
||||
public OutlineViewerSortAction(AssemblerEditor editor,
|
||||
TreeViewer treeViewer) {
|
||||
super("", AS_CHECK_BOX);
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'editor' must not be null.");
|
||||
}
|
||||
if (treeViewer == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'treeViewer' must not be null.");
|
||||
}
|
||||
setToolTipText(Texts.ASSEMBLER_CONTENT_OUTLINE_SORT_BUTTON_TOOL_TIP);
|
||||
ImageDescriptor imageDescriptor = AbstractUIPlugin
|
||||
.imageDescriptorFromPlugin(AssemblerPlugin.ID,
|
||||
"icons/outline-sort.gif");
|
||||
setImageDescriptor(imageDescriptor);
|
||||
this.editor = editor;
|
||||
this.treeViewer = treeViewer;
|
||||
|
||||
String checkedProperty;
|
||||
try {
|
||||
IFile iFile = editor.getCurrentIFile();
|
||||
if (iFile != null) {
|
||||
checkedProperty = iFile.getPersistentProperty(CHECKED);
|
||||
} else {
|
||||
checkedProperty = "";
|
||||
}
|
||||
} catch (CoreException ignore) {
|
||||
checkedProperty = null;
|
||||
}
|
||||
if (checkedProperty == null) {
|
||||
checkedProperty = editor.getPlugin().getProperty(CHECKED);
|
||||
}
|
||||
|
||||
boolean checked = Boolean.parseBoolean(checkedProperty);
|
||||
setChecked(checked);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// Get current state and update the UI.
|
||||
boolean checked = isChecked();
|
||||
setChecked(checked);
|
||||
|
||||
// Store the property.
|
||||
String checkedProperty = Boolean.toString(checked);
|
||||
try {
|
||||
IFile iFile = editor.getCurrentIFile();
|
||||
if (iFile != null) {
|
||||
iFile.setPersistentProperty(CHECKED, checkedProperty);
|
||||
}
|
||||
} catch (CoreException ex) {
|
||||
editor.getPlugin().logError("Cannot set property {0}",
|
||||
new Object[] { CHECKED }, ex);
|
||||
}
|
||||
editor.getPlugin().setProperty(CHECKED, checkedProperty);
|
||||
|
||||
// Refresh the tree viewer.
|
||||
BusyIndicator.showWhile(treeViewer.getControl().getDisplay(),
|
||||
new RunnableWithLogging() {
|
||||
@Override
|
||||
protected void runWithLogging() {
|
||||
treeViewer.refresh(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static final class OutlineViewerComparator extends ViewerComparator {
|
||||
private final OutlineViewerSortAction sortAction;
|
||||
|
||||
OutlineViewerComparator(OutlineViewerSortAction sortAction) {
|
||||
if (sortAction == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'sortAction' must not be null.");
|
||||
}
|
||||
this.sortAction = sortAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int category(Object element) {
|
||||
int result;
|
||||
CompilerSourceParserTreeObject object = (CompilerSourceParserTreeObject) element;
|
||||
|
||||
// Treat equate definition and label definition as equal.
|
||||
result = object.getType();
|
||||
|
||||
switch (object.getType()) {
|
||||
case CompilerSourceParserTreeObjectType.DEFAULT:
|
||||
case CompilerSourceParserTreeObjectType.DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.IMPLEMENTATION_SECTION:
|
||||
break;
|
||||
|
||||
case CompilerSourceParserTreeObjectType.EQUATE_DEFINITION:
|
||||
result = CompilerSourceParserTreeObjectType.EQUATE_DEFINITION;
|
||||
break;
|
||||
case CompilerSourceParserTreeObjectType.LABEL_DEFINITION:
|
||||
result = CompilerSourceParserTreeObjectType.EQUATE_DEFINITION;
|
||||
break;
|
||||
|
||||
case CompilerSourceParserTreeObjectType.ENUM_DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.STRUCTURE_DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.LOCAL_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.MACRO_DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.PAGES_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.PROCEDURE_DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.REPEAT_SECTION:
|
||||
break;
|
||||
|
||||
case CompilerSourceParserTreeObjectType.SOURCE_INCLUDE:
|
||||
case CompilerSourceParserTreeObjectType.BINARY_INCLUDE:
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Element '" + object.getName()
|
||||
+ "' has unknown type " + object.getType() + ".");
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||
|
||||
if (!sortAction.isChecked()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cat1 = category(e1);
|
||||
int cat2 = category(e2);
|
||||
|
||||
// Never sort definition or implementation sections.
|
||||
if (cat1 == CompilerSourceParserTreeObjectType.DEFINITION_SECTION
|
||||
&& cat2 == CompilerSourceParserTreeObjectType.DEFINITION_SECTION) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cat1 != cat2) {
|
||||
return cat1 - cat2;
|
||||
}
|
||||
|
||||
String name1;
|
||||
String name2;
|
||||
|
||||
if (viewer == null || !(viewer instanceof ContentViewer)) {
|
||||
name1 = e1.toString();
|
||||
name2 = e2.toString();
|
||||
} else {
|
||||
IBaseLabelProvider prov = ((ContentViewer) viewer)
|
||||
.getLabelProvider();
|
||||
if (prov instanceof ILabelProvider) {
|
||||
ILabelProvider lprov = (ILabelProvider) prov;
|
||||
name1 = lprov.getText(e1);
|
||||
name2 = lprov.getText(e2);
|
||||
} else {
|
||||
name1 = e1.toString();
|
||||
name2 = e2.toString();
|
||||
}
|
||||
}
|
||||
if (name1 == null) {
|
||||
name1 = "";//$NON-NLS-1$
|
||||
}
|
||||
if (name2 == null) {
|
||||
name2 = "";//$NON-NLS-1$
|
||||
}
|
||||
|
||||
// Use direct comparison as identified are ASCII only.
|
||||
return name1.compareTo(name2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor updater for selection changes in the content outline page.
|
||||
*/
|
||||
private final static class EditorUpdater extends RunnableWithLogging {
|
||||
private final Profiler profiler;
|
||||
|
||||
private final AssemblerEditor editor;
|
||||
private final AssemblerContentOutlinePage outlinePage;
|
||||
private final TreeViewer viewer;
|
||||
private final AssemblerContentOutlineTreeContentProvider contentProvider;
|
||||
|
||||
EditorUpdater(AssemblerEditor editor,
|
||||
AssemblerContentOutlinePage outlinePage, TreeViewer viewer) {
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'editor' must not be null.");
|
||||
}
|
||||
if (outlinePage == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'outlinePage' must not be null.");
|
||||
}
|
||||
if (viewer == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'viewer' must not be null.");
|
||||
}
|
||||
this.editor = editor;
|
||||
this.outlinePage = outlinePage;
|
||||
this.viewer = viewer;
|
||||
this.contentProvider = (AssemblerContentOutlineTreeContentProvider) viewer
|
||||
.getContentProvider();
|
||||
profiler = new Profiler(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a new
|
||||
* {@link AssemblerContentOutlineTreeContentProvider#parse} run and
|
||||
* updates the display.
|
||||
*/
|
||||
@Override
|
||||
protected void runWithLogging() {
|
||||
synchronized (outlinePage) {
|
||||
try {
|
||||
outlinePage.inputUpdateCounter++;
|
||||
runSynchronized();
|
||||
} finally {
|
||||
outlinePage.inputUpdateCounter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void runSynchronized() {
|
||||
// Stop drawing the control.
|
||||
Control control = viewer.getControl();
|
||||
|
||||
// Check if this call is caused by closing the editor.
|
||||
if (control.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
profiler.begin("runSynchronized");
|
||||
|
||||
profiler.begin("updateOutline");
|
||||
control.setRedraw(false);
|
||||
|
||||
// Remember the currently selected tree object in the content
|
||||
// outline tree viewer.
|
||||
ISelection selection = viewer.getSelection();
|
||||
Object[] expandedElements = viewer.getExpandedElements();
|
||||
|
||||
// Trigger the the new parse run.
|
||||
viewer.setInput(outlinePage.input);
|
||||
// viewer.refresh(); Not required?
|
||||
|
||||
profiler.begin("expandElements");
|
||||
if (expandedElements.length > 0) {
|
||||
viewer.setExpandedElements(expandedElements);
|
||||
} else {
|
||||
viewer.expandToLevel(2);
|
||||
}
|
||||
profiler.end("expandElements");
|
||||
|
||||
restoreSelection(selection);
|
||||
// Now that all changes are done, draw the control again.
|
||||
control.setRedraw(true);
|
||||
profiler.end("updateOutline");
|
||||
|
||||
// // Reselect the previous text selection in the editor.
|
||||
// editor.getSelectionProvider().setSelection(textSelection);
|
||||
|
||||
CompilerSourceFile compilerSourceFile;
|
||||
compilerSourceFile = contentProvider.getCompilerSourceFile();
|
||||
|
||||
// Update the identifiers to be highlighted
|
||||
profiler.begin("updateIdentifiers");
|
||||
editor.updateIdentifiers(compilerSourceFile);
|
||||
profiler.end("updateIdentifiers");
|
||||
|
||||
// Update the folding structure.
|
||||
profiler.begin("updateFoldingStructure");
|
||||
List<Position> foldingPositions;
|
||||
if (compilerSourceFile != null) {
|
||||
foldingPositions = compilerSourceFile.getFoldingPositions();
|
||||
} else {
|
||||
foldingPositions = Collections.emptyList();
|
||||
}
|
||||
editor.updateFoldingStructure(foldingPositions);
|
||||
|
||||
profiler.end("updateFoldingStructure");
|
||||
|
||||
profiler.end("runSynchronized");
|
||||
|
||||
}
|
||||
|
||||
private void restoreSelection(ISelection selection) {
|
||||
if (selection instanceof TreeSelection) {
|
||||
TreeSelection treeSelection = (TreeSelection) selection;
|
||||
TreePath[] selectedTreePaths = treeSelection.getPaths();
|
||||
List<TreePath> reselectedTreePaths = new ArrayList<TreePath>(
|
||||
selectedTreePaths.length);
|
||||
for (int i = 0; i < selectedTreePaths.length; i++) {
|
||||
TreePath treePath = selectedTreePaths[i];
|
||||
List<CompilerSourceParserTreeObject> treeObjects = contentProvider
|
||||
.getCompilerSourceFile().getSections();
|
||||
|
||||
List<Object> segments = new ArrayList<Object>(
|
||||
treePath.getSegmentCount());
|
||||
|
||||
for (int j = 0; j < treePath.getSegmentCount(); j++) {
|
||||
CompilerSourceParserTreeObject oldTreeObject;
|
||||
CompilerSourceParserTreeObject newTreeObject;
|
||||
oldTreeObject = (CompilerSourceParserTreeObject) treePath
|
||||
.getSegment(j);
|
||||
newTreeObject = null;
|
||||
|
||||
for (int k = 0; newTreeObject == null
|
||||
&& k < treeObjects.size(); k++) {
|
||||
if (treeObjects.get(k).getTreePath()
|
||||
.equals(oldTreeObject.getTreePath())) {
|
||||
newTreeObject = treeObjects.get(k);
|
||||
segments.add(newTreeObject);
|
||||
treeObjects = newTreeObject.getChildren();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!segments.isEmpty()) {
|
||||
reselectedTreePaths
|
||||
.add(new TreePath(segments.toArray()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TreePath[] reselectedTreePathsArray = new TreePath[reselectedTreePaths
|
||||
.size()];
|
||||
reselectedTreePaths.toArray(reselectedTreePathsArray);
|
||||
selection = new TreeSelection(reselectedTreePathsArray);
|
||||
|
||||
// Reselect the previously selected tree object in the
|
||||
// content outline tree viewer.
|
||||
viewer.setSelection(selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The owning editor.
|
||||
*/
|
||||
final AssemblerEditor editor;
|
||||
final TreeViewer treeViewer;
|
||||
|
||||
/**
|
||||
* The visual components.
|
||||
*/
|
||||
private OutlineViewerSortAction treeViewerSortAction;
|
||||
private OutlineViewerComparator treeViewerComparator;
|
||||
|
||||
/**
|
||||
* The current input.
|
||||
*/
|
||||
IEditorInput input;
|
||||
int inputUpdateCounter;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* Creates a new sort action.
|
||||
*
|
||||
* @param editor
|
||||
* The assembler editor, not <code>null</code>.
|
||||
* The editor which holds the respective file, not
|
||||
* <code>null</code>.
|
||||
* @param treeViewer
|
||||
* The tree viewer which displays the outline.
|
||||
*/
|
||||
AssemblerContentOutlinePage(AssemblerEditor editor) {
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'editor' must not be null.");
|
||||
}
|
||||
this.editor = editor;
|
||||
}
|
||||
public OutlineViewerSortAction(AssemblerEditor editor, TreeViewer treeViewer) {
|
||||
super("", AS_CHECK_BOX);
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
||||
}
|
||||
if (treeViewer == null) {
|
||||
throw new IllegalArgumentException("Parameter 'treeViewer' must not be null.");
|
||||
}
|
||||
setToolTipText(Texts.ASSEMBLER_CONTENT_OUTLINE_SORT_BUTTON_TOOL_TIP);
|
||||
ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(AssemblerPlugin.ID,
|
||||
"icons/outline-sort.gif");
|
||||
setImageDescriptor(imageDescriptor);
|
||||
this.editor = editor;
|
||||
this.treeViewer = treeViewer;
|
||||
|
||||
/**
|
||||
* Sets the input for the outline page.
|
||||
*
|
||||
* @param input
|
||||
* The new input, not <code>null</code>.
|
||||
*/
|
||||
final void setInput(IEditorInput input) {
|
||||
if (input == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'input' must not be null.");
|
||||
}
|
||||
this.input = input;
|
||||
|
||||
runEditorUpdater();
|
||||
}
|
||||
|
||||
private void runEditorUpdater() {
|
||||
final TreeViewer viewer = getTreeViewer();
|
||||
|
||||
if ((viewer != null) && (viewer.getContentProvider() != null)) {
|
||||
editor.getSite().getShell().getDisplay()
|
||||
.asyncExec(new EditorUpdater(editor, this, viewer));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the control and configures it. See code of
|
||||
* org.eclipse.jdt.internal.ui.text.JavaOutlineInformationControl for
|
||||
* similar use case.
|
||||
*
|
||||
* @param parent
|
||||
* ´The parent, not <code>null</code>.
|
||||
*/
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
super.createControl(parent);
|
||||
|
||||
TreeViewer treeViewer = getTreeViewer();
|
||||
|
||||
// Configure the toolbar.
|
||||
treeViewerSortAction = new OutlineViewerSortAction(editor, treeViewer);
|
||||
treeViewerComparator = new OutlineViewerComparator(treeViewerSortAction);
|
||||
IToolBarManager toolBarManager = getSite().getActionBars()
|
||||
.getToolBarManager();
|
||||
|
||||
// Configure the content.
|
||||
treeViewer
|
||||
.setContentProvider(new AssemblerContentOutlineTreeContentProvider(
|
||||
this));
|
||||
treeViewer
|
||||
.setLabelProvider(new CompilerSourceParserTreeObjectLabelProvider());
|
||||
treeViewer.setComparator(treeViewerComparator);
|
||||
treeViewer.addSelectionChangedListener(this);
|
||||
|
||||
toolBarManager.add(treeViewerSortAction);
|
||||
toolBarManager.update(true);
|
||||
|
||||
if (input != null) {
|
||||
runEditorUpdater();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
super.selectionChanged(event);
|
||||
|
||||
synchronized (this) {
|
||||
if (inputUpdateCounter > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ISelection selection = event.getSelection();
|
||||
|
||||
if (selection.isEmpty()) {
|
||||
editor.resetHighlightRange();
|
||||
String checkedProperty;
|
||||
try {
|
||||
IFile iFile = editor.getCurrentIFile();
|
||||
if (iFile != null) {
|
||||
checkedProperty = iFile.getPersistentProperty(CHECKED);
|
||||
} else {
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
Object object = ((IStructuredSelection) selection)
|
||||
.getFirstElement();
|
||||
|
||||
if (object instanceof CompilerSourceParserTreeObject) {
|
||||
|
||||
CompilerSourceParserTreeObject treeObject;
|
||||
AssemblerContentOutlineTreeContentProvider contentProvider;
|
||||
contentProvider = (AssemblerContentOutlineTreeContentProvider) getTreeViewer()
|
||||
.getContentProvider();
|
||||
treeObject = (CompilerSourceParserTreeObject) object;
|
||||
|
||||
// If this is the tree object from another (source
|
||||
// include) file, step off the tree to find the source
|
||||
// include statement.
|
||||
while (treeObject != null
|
||||
&& treeObject.getCompilerSourceFile() != contentProvider
|
||||
.getCompilerSourceFile()) {
|
||||
treeObject = treeObject.getParent();
|
||||
}
|
||||
if (treeObject != null) {
|
||||
try {
|
||||
editor.setHighlightRange(
|
||||
treeObject.getStartOffset(), 0, true);
|
||||
editor.getSelectionProvider().setSelection(
|
||||
new TextSelection(treeObject
|
||||
.getStartOffset(), 1));
|
||||
} catch (IllegalArgumentException x) {
|
||||
editor.resetHighlightRange();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
checkedProperty = "";
|
||||
}
|
||||
} catch (CoreException ignore) {
|
||||
checkedProperty = null;
|
||||
}
|
||||
if (checkedProperty == null) {
|
||||
checkedProperty = editor.getPlugin().getProperty(CHECKED);
|
||||
}
|
||||
|
||||
boolean checked = Boolean.parseBoolean(checkedProperty);
|
||||
setChecked(checked);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// Get current state and update the UI.
|
||||
boolean checked = isChecked();
|
||||
setChecked(checked);
|
||||
|
||||
// Store the property.
|
||||
String checkedProperty = Boolean.toString(checked);
|
||||
try {
|
||||
IFile iFile = editor.getCurrentIFile();
|
||||
if (iFile != null) {
|
||||
iFile.setPersistentProperty(CHECKED, checkedProperty);
|
||||
}
|
||||
} catch (CoreException ex) {
|
||||
editor.getPlugin().logError("Cannot set property {0}", new Object[] { CHECKED }, ex);
|
||||
}
|
||||
editor.getPlugin().setProperty(CHECKED, checkedProperty);
|
||||
|
||||
// Refresh the tree viewer.
|
||||
BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), new RunnableWithLogging() {
|
||||
@Override
|
||||
protected void runWithLogging() {
|
||||
treeViewer.refresh(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static final class OutlineViewerComparator extends ViewerComparator {
|
||||
private final OutlineViewerSortAction sortAction;
|
||||
|
||||
OutlineViewerComparator(OutlineViewerSortAction sortAction) {
|
||||
if (sortAction == null) {
|
||||
throw new IllegalArgumentException("Parameter 'sortAction' must not be null.");
|
||||
}
|
||||
this.sortAction = sortAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int category(Object element) {
|
||||
int result;
|
||||
CompilerSourceParserTreeObject object = (CompilerSourceParserTreeObject) element;
|
||||
|
||||
// Treat equate definition and label definition as equal.
|
||||
result = object.getType();
|
||||
|
||||
switch (object.getType()) {
|
||||
case CompilerSourceParserTreeObjectType.DEFAULT:
|
||||
case CompilerSourceParserTreeObjectType.DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.IMPLEMENTATION_SECTION:
|
||||
break;
|
||||
|
||||
case CompilerSourceParserTreeObjectType.EQUATE_DEFINITION:
|
||||
result = CompilerSourceParserTreeObjectType.EQUATE_DEFINITION;
|
||||
break;
|
||||
case CompilerSourceParserTreeObjectType.LABEL_DEFINITION:
|
||||
result = CompilerSourceParserTreeObjectType.EQUATE_DEFINITION;
|
||||
break;
|
||||
|
||||
case CompilerSourceParserTreeObjectType.ENUM_DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.STRUCTURE_DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.LOCAL_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.MACRO_DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.PAGES_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.PROCEDURE_DEFINITION_SECTION:
|
||||
case CompilerSourceParserTreeObjectType.REPEAT_SECTION:
|
||||
break;
|
||||
|
||||
case CompilerSourceParserTreeObjectType.SOURCE_INCLUDE:
|
||||
case CompilerSourceParserTreeObjectType.BINARY_INCLUDE:
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("Element '" + object.getName() + "' has unknown type " + object.getType()
|
||||
+ ".");
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||
|
||||
if (!sortAction.isChecked()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cat1 = category(e1);
|
||||
int cat2 = category(e2);
|
||||
|
||||
// Never sort definition or implementation sections.
|
||||
if (cat1 == CompilerSourceParserTreeObjectType.DEFINITION_SECTION
|
||||
&& cat2 == CompilerSourceParserTreeObjectType.DEFINITION_SECTION) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cat1 != cat2) {
|
||||
return cat1 - cat2;
|
||||
}
|
||||
|
||||
String name1;
|
||||
String name2;
|
||||
|
||||
if (viewer == null || !(viewer instanceof ContentViewer)) {
|
||||
name1 = e1.toString();
|
||||
name2 = e2.toString();
|
||||
} else {
|
||||
IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
|
||||
if (prov instanceof ILabelProvider) {
|
||||
ILabelProvider lprov = (ILabelProvider) prov;
|
||||
name1 = lprov.getText(e1);
|
||||
name2 = lprov.getText(e2);
|
||||
} else {
|
||||
name1 = e1.toString();
|
||||
name2 = e2.toString();
|
||||
}
|
||||
}
|
||||
if (name1 == null) {
|
||||
name1 = "";//$NON-NLS-1$
|
||||
}
|
||||
if (name2 == null) {
|
||||
name2 = "";//$NON-NLS-1$
|
||||
}
|
||||
|
||||
// Use direct comparison as identified are ASCII only.
|
||||
return name1.compareTo(name2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor updater for selection changes in the content outline page.
|
||||
*/
|
||||
private final static class EditorUpdater extends RunnableWithLogging {
|
||||
private final Profiler profiler;
|
||||
|
||||
private final AssemblerEditor editor;
|
||||
private final AssemblerContentOutlinePage outlinePage;
|
||||
private final TreeViewer viewer;
|
||||
private final AssemblerContentOutlineTreeContentProvider contentProvider;
|
||||
|
||||
EditorUpdater(AssemblerEditor editor, AssemblerContentOutlinePage outlinePage, TreeViewer viewer) {
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
||||
}
|
||||
if (outlinePage == null) {
|
||||
throw new IllegalArgumentException("Parameter 'outlinePage' must not be null.");
|
||||
}
|
||||
if (viewer == null) {
|
||||
throw new IllegalArgumentException("Parameter 'viewer' must not be null.");
|
||||
}
|
||||
this.editor = editor;
|
||||
this.outlinePage = outlinePage;
|
||||
this.viewer = viewer;
|
||||
this.contentProvider = (AssemblerContentOutlineTreeContentProvider) viewer.getContentProvider();
|
||||
profiler = new Profiler(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the compiler source file of the last parse process.
|
||||
*
|
||||
* @return The compiler source file of the last parse process or
|
||||
* <code>null</code>.
|
||||
* Triggers a new
|
||||
* {@link AssemblerContentOutlineTreeContentProvider#parse} run and
|
||||
* updates the display.
|
||||
*/
|
||||
final CompilerSourceFile getCompilerSourceFile() {
|
||||
AssemblerContentOutlineTreeContentProvider contentProvider;
|
||||
contentProvider = (AssemblerContentOutlineTreeContentProvider) getTreeViewer()
|
||||
.getContentProvider();
|
||||
CompilerSourceFile compilerSourceFile = contentProvider
|
||||
.getCompilerSourceFile();
|
||||
return compilerSourceFile;
|
||||
@Override
|
||||
protected void runWithLogging() {
|
||||
synchronized (outlinePage) {
|
||||
try {
|
||||
outlinePage.inputUpdateCounter++;
|
||||
runSynchronized();
|
||||
} finally {
|
||||
outlinePage.inputUpdateCounter--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void runSynchronized() {
|
||||
// Stop drawing the control.
|
||||
Control control = viewer.getControl();
|
||||
|
||||
// Check if this call is caused by closing the editor.
|
||||
if (control.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
profiler.begin("runSynchronized");
|
||||
|
||||
profiler.begin("updateOutline");
|
||||
control.setRedraw(false);
|
||||
|
||||
// Remember the currently selected tree object in the content
|
||||
// outline tree viewer.
|
||||
ISelection selection = viewer.getSelection();
|
||||
Object[] expandedElements = viewer.getExpandedElements();
|
||||
|
||||
// Trigger the the new parse run.
|
||||
viewer.setInput(outlinePage.input);
|
||||
// viewer.refresh(); Not required?
|
||||
|
||||
profiler.begin("expandElements");
|
||||
if (expandedElements.length > 0) {
|
||||
viewer.setExpandedElements(expandedElements);
|
||||
} else {
|
||||
viewer.expandToLevel(2);
|
||||
}
|
||||
profiler.end("expandElements");
|
||||
|
||||
restoreSelection(selection);
|
||||
// Now that all changes are done, draw the control again.
|
||||
control.setRedraw(true);
|
||||
profiler.end("updateOutline");
|
||||
|
||||
// // Reselect the previous text selection in the editor.
|
||||
// editor.getSelectionProvider().setSelection(textSelection);
|
||||
|
||||
CompilerSourceFile compilerSourceFile;
|
||||
compilerSourceFile = contentProvider.getCompilerSourceFile();
|
||||
|
||||
// Update the identifiers to be highlighted
|
||||
profiler.begin("updateIdentifiers");
|
||||
editor.updateIdentifiers(compilerSourceFile);
|
||||
profiler.end("updateIdentifiers");
|
||||
|
||||
// Update the folding structure.
|
||||
profiler.begin("updateFoldingStructure");
|
||||
List<Position> foldingPositions;
|
||||
if (compilerSourceFile != null) {
|
||||
foldingPositions = compilerSourceFile.getFoldingPositions();
|
||||
} else {
|
||||
foldingPositions = Collections.emptyList();
|
||||
}
|
||||
editor.updateFoldingStructure(foldingPositions);
|
||||
|
||||
profiler.end("updateFoldingStructure");
|
||||
|
||||
profiler.end("runSynchronized");
|
||||
|
||||
}
|
||||
|
||||
private void restoreSelection(ISelection selection) {
|
||||
if (selection instanceof TreeSelection) {
|
||||
TreeSelection treeSelection = (TreeSelection) selection;
|
||||
TreePath[] selectedTreePaths = treeSelection.getPaths();
|
||||
List<TreePath> reselectedTreePaths = new ArrayList<TreePath>(selectedTreePaths.length);
|
||||
for (int i = 0; i < selectedTreePaths.length; i++) {
|
||||
TreePath treePath = selectedTreePaths[i];
|
||||
List<CompilerSourceParserTreeObject> treeObjects = contentProvider.getCompilerSourceFile()
|
||||
.getSections();
|
||||
|
||||
List<Object> segments = new ArrayList<Object>(treePath.getSegmentCount());
|
||||
|
||||
for (int j = 0; j < treePath.getSegmentCount(); j++) {
|
||||
CompilerSourceParserTreeObject oldTreeObject;
|
||||
CompilerSourceParserTreeObject newTreeObject;
|
||||
oldTreeObject = (CompilerSourceParserTreeObject) treePath.getSegment(j);
|
||||
newTreeObject = null;
|
||||
|
||||
for (int k = 0; newTreeObject == null && k < treeObjects.size(); k++) {
|
||||
if (treeObjects.get(k).getTreePath().equals(oldTreeObject.getTreePath())) {
|
||||
newTreeObject = treeObjects.get(k);
|
||||
segments.add(newTreeObject);
|
||||
treeObjects = newTreeObject.getChildren();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!segments.isEmpty()) {
|
||||
reselectedTreePaths.add(new TreePath(segments.toArray()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TreePath[] reselectedTreePathsArray = new TreePath[reselectedTreePaths.size()];
|
||||
reselectedTreePaths.toArray(reselectedTreePathsArray);
|
||||
selection = new TreeSelection(reselectedTreePathsArray);
|
||||
|
||||
// Reselect the previously selected tree object in the
|
||||
// content outline tree viewer.
|
||||
viewer.setSelection(selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The owning editor.
|
||||
*/
|
||||
final AssemblerEditor editor;
|
||||
|
||||
/**
|
||||
* The visual components.
|
||||
*/
|
||||
private OutlineViewerSortAction treeViewerSortAction;
|
||||
private OutlineViewerComparator treeViewerComparator;
|
||||
|
||||
/**
|
||||
* The current input.
|
||||
*/
|
||||
IEditorInput input;
|
||||
int inputUpdateCounter;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
* @param editor
|
||||
* The assembler editor, not <code>null</code>.
|
||||
*/
|
||||
AssemblerContentOutlinePage(AssemblerEditor editor) {
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
||||
}
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the input for the outline page.
|
||||
*
|
||||
* @param input
|
||||
* The new input, not <code>null</code>.
|
||||
*/
|
||||
final void setInput(IEditorInput input) {
|
||||
if (input == null) {
|
||||
throw new IllegalArgumentException("Parameter 'input' must not be null.");
|
||||
}
|
||||
this.input = input;
|
||||
|
||||
runEditorUpdater();
|
||||
}
|
||||
|
||||
private void runEditorUpdater() {
|
||||
final TreeViewer viewer = getTreeViewer();
|
||||
|
||||
if ((viewer != null) && (viewer.getContentProvider() != null)) {
|
||||
editor.getSite().getShell().getDisplay().asyncExec(new EditorUpdater(editor, this, viewer));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the control and configures it. See code of
|
||||
* org.eclipse.jdt.internal.ui.text.JavaOutlineInformationControl for
|
||||
* similar use case.
|
||||
*
|
||||
* @param parent
|
||||
* ´The parent, not <code>null</code>.
|
||||
*/
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
super.createControl(parent);
|
||||
|
||||
TreeViewer treeViewer = getTreeViewer();
|
||||
|
||||
// Configure the toolbar.
|
||||
treeViewerSortAction = new OutlineViewerSortAction(editor, treeViewer);
|
||||
treeViewerComparator = new OutlineViewerComparator(treeViewerSortAction);
|
||||
IToolBarManager toolBarManager = getSite().getActionBars().getToolBarManager();
|
||||
|
||||
// Configure the content.
|
||||
treeViewer.setContentProvider(new AssemblerContentOutlineTreeContentProvider(this));
|
||||
treeViewer.setLabelProvider(new CompilerSourceParserTreeObjectLabelProvider());
|
||||
treeViewer.setComparator(treeViewerComparator);
|
||||
treeViewer.addSelectionChangedListener(this);
|
||||
|
||||
toolBarManager.add(treeViewerSortAction);
|
||||
toolBarManager.update(true);
|
||||
|
||||
if (input != null) {
|
||||
runEditorUpdater();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
super.selectionChanged(event);
|
||||
|
||||
synchronized (this) {
|
||||
if (inputUpdateCounter > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ISelection selection = event.getSelection();
|
||||
|
||||
if (selection.isEmpty()) {
|
||||
editor.resetHighlightRange();
|
||||
} else {
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
Object object = ((IStructuredSelection) selection).getFirstElement();
|
||||
|
||||
if (object instanceof CompilerSourceParserTreeObject) {
|
||||
|
||||
CompilerSourceParserTreeObject treeObject;
|
||||
AssemblerContentOutlineTreeContentProvider contentProvider;
|
||||
contentProvider = (AssemblerContentOutlineTreeContentProvider) getTreeViewer().getContentProvider();
|
||||
treeObject = (CompilerSourceParserTreeObject) object;
|
||||
|
||||
// If this is the tree object from another (source
|
||||
// include) file, step off the tree to find the source
|
||||
// include statement.
|
||||
while (treeObject != null
|
||||
&& treeObject.getCompilerSourceFile() != contentProvider.getCompilerSourceFile()) {
|
||||
treeObject = treeObject.getParent();
|
||||
}
|
||||
if (treeObject != null) {
|
||||
try {
|
||||
editor.setHighlightRange(treeObject.getStartOffset(), 0, true);
|
||||
editor.getSelectionProvider().setSelection(
|
||||
new TextSelection(treeObject.getStartOffset(), 1));
|
||||
} catch (IllegalArgumentException x) {
|
||||
editor.resetHighlightRange();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the compiler source file of the last parse process.
|
||||
*
|
||||
* @return The compiler source file of the last parse process or
|
||||
* <code>null</code>.
|
||||
*/
|
||||
final CompilerSourceFile getCompilerSourceFile() {
|
||||
AssemblerContentOutlineTreeContentProvider contentProvider;
|
||||
contentProvider = (AssemblerContentOutlineTreeContentProvider) getTreeViewer().getContentProvider();
|
||||
CompilerSourceFile compilerSourceFile = contentProvider.getCompilerSourceFile();
|
||||
return compilerSourceFile;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,146 +37,140 @@ import com.wudsn.ide.base.common.Profiler;
|
|||
* @author Peter Dell
|
||||
* @author Andy Reek
|
||||
*/
|
||||
final class AssemblerContentOutlineTreeContentProvider implements
|
||||
ITreeContentProvider {
|
||||
final class AssemblerContentOutlineTreeContentProvider implements ITreeContentProvider {
|
||||
|
||||
/**
|
||||
* The surrounding content outline page.
|
||||
*/
|
||||
private final AssemblerContentOutlinePage assemblerContentOutlinePage;
|
||||
/**
|
||||
* The surrounding content outline page.
|
||||
*/
|
||||
private final AssemblerContentOutlinePage assemblerContentOutlinePage;
|
||||
|
||||
/**
|
||||
* The last editor input which was parsed.
|
||||
*/
|
||||
private IEditorInput input;
|
||||
/**
|
||||
* The last editor input which was parsed.
|
||||
*/
|
||||
private IEditorInput input;
|
||||
|
||||
/**
|
||||
* The result of the last parse process.
|
||||
*/
|
||||
private CompilerSourceFile compilerSourceFile;
|
||||
/**
|
||||
* The result of the last parse process.
|
||||
*/
|
||||
private CompilerSourceFile compilerSourceFile;
|
||||
|
||||
/**
|
||||
* Called by
|
||||
* {@link AssemblerContentOutlinePage#createControl(org.eclipse.swt.widgets.Composite)}
|
||||
* .
|
||||
*
|
||||
* @param assemblerContentOutlinePage
|
||||
* The outline page, not <code>null</code>.
|
||||
*/
|
||||
AssemblerContentOutlineTreeContentProvider(
|
||||
AssemblerContentOutlinePage assemblerContentOutlinePage) {
|
||||
if (assemblerContentOutlinePage == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'assemblerContentOutlinePage' must not be null.");
|
||||
}
|
||||
this.assemblerContentOutlinePage = assemblerContentOutlinePage;
|
||||
/**
|
||||
* Called by
|
||||
* {@link AssemblerContentOutlinePage#createControl(org.eclipse.swt.widgets.Composite)}
|
||||
* .
|
||||
*
|
||||
* @param assemblerContentOutlinePage
|
||||
* The outline page, not <code>null</code>.
|
||||
*/
|
||||
AssemblerContentOutlineTreeContentProvider(AssemblerContentOutlinePage assemblerContentOutlinePage) {
|
||||
if (assemblerContentOutlinePage == null) {
|
||||
throw new IllegalArgumentException("Parameter 'assemblerContentOutlinePage' must not be null.");
|
||||
}
|
||||
this.assemblerContentOutlinePage = assemblerContentOutlinePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
if (element instanceof CompilerSourceParserTreeObject) {
|
||||
return ((CompilerSourceParserTreeObject) element).getParent();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
if (element instanceof CompilerSourceParserTreeObject) {
|
||||
return ((CompilerSourceParserTreeObject) element).getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
if (element instanceof CompilerSourceParserTreeObject) {
|
||||
return (((CompilerSourceParserTreeObject) element).hasChildren());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
if (element instanceof CompilerSourceParserTreeObject) {
|
||||
return (((CompilerSourceParserTreeObject) element).hasChildren());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
if (parentElement instanceof CompilerSourceParserTreeObject) {
|
||||
return ((CompilerSourceParserTreeObject) parentElement).getChildrenAsArray();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
Object[] result;
|
||||
if (inputElement == input && compilerSourceFile != null) {
|
||||
List<CompilerSourceParserTreeObject> sections;
|
||||
sections = compilerSourceFile.getSections();
|
||||
result = sections.toArray(new Object[sections.size()]);
|
||||
} else {
|
||||
result = new Object[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
if (parentElement instanceof CompilerSourceParserTreeObject) {
|
||||
return ((CompilerSourceParserTreeObject) parentElement)
|
||||
.getChildrenAsArray();
|
||||
}
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
input = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the compiler source file of the last parse process.
|
||||
*
|
||||
* @return The compiler source file of the last parse process or
|
||||
* <code>null</code>.
|
||||
*/
|
||||
CompilerSourceFile getCompilerSourceFile() {
|
||||
return compilerSourceFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
if (oldInput instanceof IEditorInput) {
|
||||
input = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
Object[] result;
|
||||
if (inputElement == input && compilerSourceFile != null) {
|
||||
List<CompilerSourceParserTreeObject> sections;
|
||||
sections = compilerSourceFile.getSections();
|
||||
result = sections.toArray(new Object[sections.size()]);
|
||||
} else {
|
||||
result = new Object[0];
|
||||
}
|
||||
if (newInput instanceof IEditorInput) {
|
||||
input = (IEditorInput) newInput;
|
||||
parse();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
/**
|
||||
* Parses the new input and builds up the parse tree.
|
||||
*/
|
||||
private void parse() {
|
||||
|
||||
AssemblerEditor editor = this.assemblerContentOutlinePage.editor;
|
||||
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
|
||||
|
||||
if (document != null) {
|
||||
CompilerSourceParser parser = editor.createCompilerSourceParser();
|
||||
compilerSourceFile = parser.createCompilerSourceFile(editor.getCurrentFile(), document);
|
||||
Profiler profiler = new Profiler(parser);
|
||||
profiler.begin("parse", editor.getTitle());
|
||||
parser.parse(compilerSourceFile, null);
|
||||
profiler.end("parse");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
input = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the compiler source file of the last parse process.
|
||||
*
|
||||
* @return The compiler source file of the last parse process or
|
||||
* <code>null</code>.
|
||||
*/
|
||||
CompilerSourceFile getCompilerSourceFile() {
|
||||
return compilerSourceFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
if (oldInput instanceof IEditorInput) {
|
||||
input = null;
|
||||
}
|
||||
|
||||
if (newInput instanceof IEditorInput) {
|
||||
input = (IEditorInput) newInput;
|
||||
parse();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the new input and builds up the parse tree.
|
||||
*/
|
||||
private void parse() {
|
||||
|
||||
AssemblerEditor editor = this.assemblerContentOutlinePage.editor;
|
||||
IDocument document = editor.getDocumentProvider().getDocument(
|
||||
editor.getEditorInput());
|
||||
|
||||
if (document != null) {
|
||||
CompilerSourceParser parser = editor.createCompilerSourceParser();
|
||||
compilerSourceFile = parser.createCompilerSourceFile(
|
||||
editor.getCurrentFile(), document);
|
||||
Profiler profiler = new Profiler(parser);
|
||||
profiler.begin("parse", editor.getTitle());
|
||||
parser.parse(compilerSourceFile, null);
|
||||
profiler.end("parse");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,34 +31,31 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
|
||||
|
||||
// TODO: Dynamic menu contribution is not working!
|
||||
public final class AssemblerEditorCompileAndRunCommandMenu extends
|
||||
WorkbenchWindowControlContribution {
|
||||
public final class AssemblerEditorCompileAndRunCommandMenu extends WorkbenchWindowControlContribution {
|
||||
|
||||
public AssemblerEditorCompileAndRunCommandMenu() {
|
||||
new Exception().printStackTrace();
|
||||
}
|
||||
public AssemblerEditorCompileAndRunCommandMenu() {
|
||||
new Exception().printStackTrace();
|
||||
}
|
||||
|
||||
public AssemblerEditorCompileAndRunCommandMenu(String id) {
|
||||
super(id);
|
||||
}
|
||||
public AssemblerEditorCompileAndRunCommandMenu(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@AboutToShow
|
||||
public void aboutToShow(List<MMenuElement> items) {
|
||||
MDirectMenuItem dynamicItem = MMenuFactory.INSTANCE
|
||||
.createDirectMenuItem();
|
||||
dynamicItem.setLabel("Dynamic Menu Item (" + new Date() + ")");
|
||||
dynamicItem
|
||||
.setContributorURI("platform:/plugin/at.descher.eclipse.bug389063");
|
||||
dynamicItem
|
||||
.setContributionURI("bundleclass://at.descher.eclipse.bug389063/at.descher.eclipse.bug389063.dynamic.DirectMenuItemAHandler");
|
||||
items.add(dynamicItem);
|
||||
@AboutToShow
|
||||
public void aboutToShow(List<MMenuElement> items) {
|
||||
MDirectMenuItem dynamicItem = MMenuFactory.INSTANCE.createDirectMenuItem();
|
||||
dynamicItem.setLabel("Dynamic Menu Item (" + new Date() + ")");
|
||||
dynamicItem.setContributorURI("platform:/plugin/at.descher.eclipse.bug389063");
|
||||
dynamicItem
|
||||
.setContributionURI("bundleclass://at.descher.eclipse.bug389063/at.descher.eclipse.bug389063.dynamic.DirectMenuItemAHandler");
|
||||
items.add(dynamicItem);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createControl(Composite parent) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected Control createControl(Composite parent) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -657,7 +657,8 @@ final class AssemblerEditorCompileCommand {
|
|||
List<IMarker> markers = new ArrayList<IMarker>();
|
||||
while (logParser.nextMarker()) {
|
||||
Marker markerProxy = logParser.getMarker();
|
||||
while (markerProxy != null) { // Loop to add main marker and its detail markers
|
||||
while (markerProxy != null) { // Loop to add main marker and its
|
||||
// detail markers
|
||||
if (!set.contains(markerProxy)) {
|
||||
set.add(markerProxy);
|
||||
try {
|
||||
|
|
|
@ -29,8 +29,7 @@ import com.wudsn.ide.asm.compiler.CompilerFiles;
|
|||
*
|
||||
* @author Peter Dell
|
||||
*/
|
||||
public final class AssemblerEditorCompileCommandHandler extends
|
||||
AssemblerEditorFilesCommandHandler {
|
||||
public final class AssemblerEditorCompileCommandHandler extends AssemblerEditorFilesCommandHandler {
|
||||
|
||||
/**
|
||||
* Creates a new instance. Called by the extension point
|
||||
|
@ -41,8 +40,7 @@ public final class AssemblerEditorCompileCommandHandler extends
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void execute(ExecutionEvent event,
|
||||
AssemblerEditor assemblerEditor, CompilerFiles files)
|
||||
protected void execute(ExecutionEvent event, AssemblerEditor assemblerEditor, CompilerFiles files)
|
||||
throws ExecutionException {
|
||||
if (event == null) {
|
||||
throw new IllegalArgumentException("Parameter 'event' must not be null.");
|
||||
|
@ -54,8 +52,7 @@ public final class AssemblerEditorCompileCommandHandler extends
|
|||
throw new IllegalArgumentException("Parameter 'files' must not be null.");
|
||||
}
|
||||
try {
|
||||
AssemblerEditorCompileCommand.execute(assemblerEditor, files, event
|
||||
.getCommand().getId(), null);
|
||||
AssemblerEditorCompileCommand.execute(assemblerEditor, files, event.getCommand().getId(), null);
|
||||
} catch (RuntimeException ex) {
|
||||
throw new ExecutionException("Cannot execute event " + event, ex);
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@ import com.wudsn.ide.asm.compiler.CompilerFiles;
|
|||
*
|
||||
* @author Peter Dell
|
||||
*/
|
||||
public abstract class AssemblerEditorFilesCommandHandler extends
|
||||
AbstractHandler {
|
||||
public abstract class AssemblerEditorFilesCommandHandler extends AbstractHandler {
|
||||
|
||||
public AssemblerEditorFilesCommandHandler() {
|
||||
super();
|
||||
|
@ -62,14 +61,11 @@ public abstract class AssemblerEditorFilesCommandHandler extends
|
|||
execute(event, assemblerEditor, files);
|
||||
} else {
|
||||
try {
|
||||
AssemblerPlugin
|
||||
.getInstance()
|
||||
.showError(
|
||||
assemblerEditor.getSite().getShell(),
|
||||
"Operation '"
|
||||
+ event.getCommand().getName()
|
||||
+ "' is not possible because the file in the editor is not located in the worksapce.",
|
||||
new Exception());
|
||||
AssemblerPlugin.getInstance().showError(
|
||||
assemblerEditor.getSite().getShell(),
|
||||
"Operation '" + event.getCommand().getName()
|
||||
+ "' is not possible because the file in the editor is not located in the worksapce.",
|
||||
new Exception());
|
||||
} catch (NotDefinedException ignore) {
|
||||
// Ignore
|
||||
}
|
||||
|
@ -86,13 +82,12 @@ public abstract class AssemblerEditorFilesCommandHandler extends
|
|||
* The assembler editor, not <code>null</code> and with current
|
||||
* files which are not <code>null</code>.
|
||||
* @param files
|
||||
* The current compiler files of the editor, not <code>null</code>
|
||||
* .
|
||||
* The current compiler files of the editor, not
|
||||
* <code>null</code> .
|
||||
* @throws ExecutionException
|
||||
* if an exception occurred during execution.
|
||||
*/
|
||||
protected abstract void execute(ExecutionEvent event,
|
||||
AssemblerEditor assemblerEditor, CompilerFiles files)
|
||||
protected abstract void execute(ExecutionEvent event, AssemblerEditor assemblerEditor, CompilerFiles files)
|
||||
throws ExecutionException;
|
||||
|
||||
}
|
|
@ -55,8 +55,8 @@ public final class AssemblerEditorOpenDeclarationCommandHandler extends Abstract
|
|||
int offset = textSelection.getOffset();
|
||||
List<AssemblerHyperlink> hyperlinks = new ArrayList<AssemblerHyperlink>();
|
||||
AssemblerHyperlinkDetector.detectHyperlinks(assemblerEditor, document, offset, false, hyperlinks);
|
||||
if (!hyperlinks.isEmpty()){
|
||||
AssemblerHyperlink hyperlink=hyperlinks.get(0);
|
||||
if (!hyperlinks.isEmpty()) {
|
||||
AssemblerHyperlink hyperlink = hyperlinks.get(0);
|
||||
hyperlink.open();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,28 +30,23 @@ import com.wudsn.ide.asm.compiler.CompilerFiles;
|
|||
*
|
||||
* @author Peter Dell
|
||||
*/
|
||||
public final class AssemblerEditorOpenFolderCommandHandler extends
|
||||
AssemblerEditorFilesCommandHandler {
|
||||
public final class AssemblerEditorOpenFolderCommandHandler extends AssemblerEditorFilesCommandHandler {
|
||||
|
||||
public static final String OPEN_SOURCE_FOLDER = "com.wudsn.ide.asm.editor.AssemblerEditorOpenSourceFolderCommand";
|
||||
public static final String OPEN_OUTPUT_FOLDER = "com.wudsn.ide.asm.editor.AssemblerEditorOpenOutputFolderCommand";
|
||||
|
||||
@Override
|
||||
protected void execute(ExecutionEvent event,
|
||||
AssemblerEditor assemblerEditor, CompilerFiles files)
|
||||
protected void execute(ExecutionEvent event, AssemblerEditor assemblerEditor, CompilerFiles files)
|
||||
throws ExecutionException {
|
||||
|
||||
if (event == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'event' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'event' must not be null.");
|
||||
}
|
||||
if (assemblerEditor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'assemblerEditor' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'assemblerEditor' must not be null.");
|
||||
}
|
||||
if (files == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'files' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'files' must not be null.");
|
||||
}
|
||||
|
||||
String folderPath;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -64,16 +64,14 @@ final class AssemblerEditorToggleCommentAction extends TextEditorAction {
|
|||
* The assembler editor's source viewer.
|
||||
*
|
||||
*/
|
||||
AssemblerEditorToggleCommentAction(ResourceBundle bundle, String prefix,
|
||||
AssemblerEditor editor, SourceViewer sourceViewer) {
|
||||
AssemblerEditorToggleCommentAction(ResourceBundle bundle, String prefix, AssemblerEditor editor,
|
||||
SourceViewer sourceViewer) {
|
||||
super(bundle, prefix, editor);
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'editor' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
||||
}
|
||||
if (sourceViewer == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'sourceViewer' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'sourceViewer' must not be null.");
|
||||
}
|
||||
this.editor = editor;
|
||||
this.sourceViewer = sourceViewer;
|
||||
|
@ -113,12 +111,10 @@ final class AssemblerEditorToggleCommentAction extends TextEditorAction {
|
|||
*/
|
||||
private boolean isCommented(IDocument document, TextSelection selection) {
|
||||
if (document == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'document' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'document' must not be null.");
|
||||
}
|
||||
if (selection == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'selection' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'selection' must not be null.");
|
||||
}
|
||||
try {
|
||||
int startLine = selection.getStartLine();
|
||||
|
@ -151,13 +147,11 @@ final class AssemblerEditorToggleCommentAction extends TextEditorAction {
|
|||
private boolean isCommented(String lineText) {
|
||||
|
||||
if (lineText == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'lineText' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'lineText' must not be null.");
|
||||
}
|
||||
|
||||
List<String> singleLineCommentDeliminters;
|
||||
singleLineCommentDeliminters = editor.getCompilerDefinition()
|
||||
.getSyntax().getSingleLineCommentDelimiters();
|
||||
singleLineCommentDeliminters = editor.getCompilerDefinition().getSyntax().getSingleLineCommentDelimiters();
|
||||
for (String delimiter : singleLineCommentDeliminters) {
|
||||
if (lineText.startsWith(delimiter)) {
|
||||
return true;
|
||||
|
|
|
@ -88,42 +88,33 @@ final class AssemblerHyperlink implements IHyperlink {
|
|||
* hyperlink for the same location, may be empty, not
|
||||
* <code>null</code>.
|
||||
*/
|
||||
AssemblerHyperlink(IRegion region, IWorkbenchPage workbenchPage,
|
||||
String absoluteFilePath, URI uri, String editorId, int lineNumber,
|
||||
String hyperlinkText) {
|
||||
AssemblerHyperlink(IRegion region, IWorkbenchPage workbenchPage, String absoluteFilePath, URI uri, String editorId,
|
||||
int lineNumber, String hyperlinkText) {
|
||||
if (region == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'region' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'region' must not be null.");
|
||||
}
|
||||
if (workbenchPage == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'workbenchPage' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'workbenchPage' must not be null.");
|
||||
}
|
||||
if (absoluteFilePath == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'absoluteFilePath' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'absoluteFilePath' must not be null.");
|
||||
}
|
||||
if (uri == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'uri' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'uri' must not be null.");
|
||||
}
|
||||
if (editorId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'editorId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'editorId' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(editorId)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'editorId' must not be empty.");
|
||||
throw new IllegalArgumentException("Parameter 'editorId' must not be empty.");
|
||||
}
|
||||
if (lineNumber < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'lineNumber' must not be negative. Specified value is "
|
||||
+ lineNumber + ".");
|
||||
throw new IllegalArgumentException("Parameter 'lineNumber' must not be negative. Specified value is "
|
||||
+ lineNumber + ".");
|
||||
}
|
||||
|
||||
if (hyperlinkText == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hyperlinkText' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hyperlinkText' must not be null.");
|
||||
}
|
||||
this.region = region;
|
||||
this.workbenchPage = workbenchPage;
|
||||
|
@ -167,22 +158,18 @@ final class AssemblerHyperlink implements IHyperlink {
|
|||
File fileToOpen = new File(absoluteFilePath);
|
||||
if (!fileToOpen.exists()) {
|
||||
String message = TextUtility.format(
|
||||
// ERROR: Target file '{0}' not exists. Do you
|
||||
// want to create the file now?
|
||||
Texts.ASSEMBLER_HYPERLINK_FILE_NOT_EXISTS,
|
||||
absoluteFilePath);
|
||||
boolean result = MessageDialog.openQuestion(workbenchPage
|
||||
.getWorkbenchWindow().getShell(),
|
||||
// ERROR: Target file '{0}' not exists. Do you
|
||||
// want to create the file now?
|
||||
Texts.ASSEMBLER_HYPERLINK_FILE_NOT_EXISTS, absoluteFilePath);
|
||||
boolean result = MessageDialog.openQuestion(workbenchPage.getWorkbenchWindow().getShell(),
|
||||
com.wudsn.ide.base.Texts.DIALOG_TITLE, message);
|
||||
// Try to create the file, if OK was pressed.
|
||||
if (result) {
|
||||
try {
|
||||
FileUtility.writeString(fileToOpen, "");
|
||||
} catch (CoreException ex) {
|
||||
ErrorDialog.openError(workbenchPage
|
||||
.getWorkbenchWindow().getShell(),
|
||||
com.wudsn.ide.base.Texts.DIALOG_TITLE, null, ex
|
||||
.getStatus());
|
||||
ErrorDialog.openError(workbenchPage.getWorkbenchWindow().getShell(),
|
||||
com.wudsn.ide.base.Texts.DIALOG_TITLE, null, ex.getStatus());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -194,16 +181,13 @@ final class AssemblerHyperlink implements IHyperlink {
|
|||
if (editorId.equals(DEFAULT_EDITOR)) {
|
||||
|
||||
if (fileToOpen.exists() && fileToOpen.isFile()) {
|
||||
IFileStore fileStore = EFS.getLocalFileSystem().getStore(
|
||||
fileToOpen.toURI());
|
||||
IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
|
||||
|
||||
try {
|
||||
editorPart = IDE.openEditorOnFileStore(workbenchPage,
|
||||
fileStore);
|
||||
editorPart = IDE.openEditorOnFileStore(workbenchPage, fileStore);
|
||||
} catch (PartInitException ex) {
|
||||
|
||||
AssemblerPlugin.getInstance().logError(
|
||||
"Cannot default editor editor for '{0}'.",
|
||||
AssemblerPlugin.getInstance().logError("Cannot default editor editor for '{0}'.",
|
||||
new Object[] { uri }, ex);
|
||||
|
||||
}
|
||||
|
@ -217,11 +201,9 @@ final class AssemblerHyperlink implements IHyperlink {
|
|||
|
||||
try {
|
||||
|
||||
editorPart = IDE.openEditor(workbenchPage, uri, editorId,
|
||||
true);
|
||||
editorPart = IDE.openEditor(workbenchPage, uri, editorId, true);
|
||||
} catch (PartInitException ex) {
|
||||
AssemblerPlugin.getInstance().logError(
|
||||
"Cannot system editor editor for '{0}'.",
|
||||
AssemblerPlugin.getInstance().logError("Cannot system editor editor for '{0}'.",
|
||||
new Object[] { uri }, ex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -35,8 +35,7 @@ import org.eclipse.swt.graphics.Point;
|
|||
*
|
||||
* @author Peter Dell
|
||||
*/
|
||||
final class AssemblerInstructionCompletionProposal implements
|
||||
ICompletionProposal, ICompletionProposalExtension6 {
|
||||
final class AssemblerInstructionCompletionProposal implements ICompletionProposal, ICompletionProposalExtension6 {
|
||||
|
||||
/** The string to be displayed in the completion proposal popup. */
|
||||
private String displayString;
|
||||
|
@ -48,15 +47,14 @@ final class AssemblerInstructionCompletionProposal implements
|
|||
private int replacementOffset;
|
||||
/** The replacement length. */
|
||||
private int replacementLength;
|
||||
/** The offset of the cursor after applying the replacement. */
|
||||
/** 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.
|
||||
|
@ -78,9 +76,8 @@ final class AssemblerInstructionCompletionProposal implements
|
|||
* @param contextInformation
|
||||
* The context information associated with this proposal.
|
||||
*/
|
||||
AssemblerInstructionCompletionProposal(String replacementString,
|
||||
int replacementOffset, int replacementLength, int cursorOffset, Image image,
|
||||
String displayString, StyledString styledDisplayString,
|
||||
AssemblerInstructionCompletionProposal(String replacementString, int replacementOffset, int replacementLength,
|
||||
int cursorOffset, Image image, String displayString, StyledString styledDisplayString,
|
||||
IContextInformation contextInformation) {
|
||||
Assert.isNotNull(replacementString);
|
||||
Assert.isNotNull(displayString);
|
||||
|
@ -91,7 +88,7 @@ final class AssemblerInstructionCompletionProposal implements
|
|||
this.replacementString = replacementString;
|
||||
this.replacementOffset = replacementOffset;
|
||||
this.replacementLength = replacementLength;
|
||||
this.cursorOffset=cursorOffset;
|
||||
this.cursorOffset = cursorOffset;
|
||||
this.image = image;
|
||||
this.displayString = displayString;
|
||||
this.styledDisplayString = styledDisplayString;
|
||||
|
@ -104,11 +101,9 @@ final class AssemblerInstructionCompletionProposal implements
|
|||
@Override
|
||||
public void apply(IDocument document) {
|
||||
try {
|
||||
document.replace(replacementOffset, replacementLength,
|
||||
replacementString);
|
||||
document.replace(replacementOffset, replacementLength, replacementString);
|
||||
} catch (BadLocationException ex) {
|
||||
throw new RuntimeException("Replacement offset "
|
||||
+ replacementOffset + " no valid", ex);
|
||||
throw new RuntimeException("Replacement offset " + replacementOffset + " no valid", ex);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -33,8 +33,7 @@ import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
|
|||
* @author Peter Dell
|
||||
* @author Andy Reek
|
||||
*/
|
||||
final class AssemblerReconcilingStategy implements IReconcilingStrategy,
|
||||
IReconcilingStrategyExtension {
|
||||
final class AssemblerReconcilingStategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
|
||||
|
||||
private final AssemblerEditor editor;
|
||||
private IDocument document;
|
||||
|
@ -48,8 +47,7 @@ final class AssemblerReconcilingStategy implements IReconcilingStrategy,
|
|||
*/
|
||||
AssemblerReconcilingStategy(AssemblerEditor editor) {
|
||||
if (editor == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'editor' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'editor' must not be null.");
|
||||
}
|
||||
this.editor = editor;
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ final class AssemblerSourceScanner extends RuleBasedScanner {
|
|||
}
|
||||
}
|
||||
}
|
||||
System.out.println(""+this+":"+state.identifierWordTokens.size());
|
||||
System.out.println("" + this + ":" + state.identifierWordTokens.size());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -25,7 +25,6 @@ import com.wudsn.ide.asm.AssemblerPlugin;
|
|||
import com.wudsn.ide.asm.compiler.CompilerSymbol;
|
||||
import com.wudsn.ide.asm.compiler.CompilerSymbolType;
|
||||
|
||||
|
||||
/**
|
||||
* LabelProvider for the {@link CompilerSymbol} instances in the compiler
|
||||
* symbols view.
|
||||
|
@ -55,7 +54,6 @@ final class CompilerSymbolLabelProvider {
|
|||
/** Outline procedure definition section image */
|
||||
private final Image procedureDefinitionSectionImage;
|
||||
|
||||
|
||||
CompilerSymbolLabelProvider() {
|
||||
AssemblerPlugin plugin;
|
||||
plugin = AssemblerPlugin.getInstance();
|
||||
|
|
|
@ -249,15 +249,15 @@ public final class CompilerSymbolsView extends ViewPart {
|
|||
text += " " + DateFormat.getTimeInstance().format(updateTimestamp);
|
||||
}
|
||||
sourceFileNameText.setText(text);
|
||||
String filterTextSequence = filterTextField.getText().toUpperCase();
|
||||
String filterTextSequence = filterTextField.getText().toUpperCase();
|
||||
|
||||
// A leading ! reverses the filter
|
||||
boolean matchTarget= true;
|
||||
if (filterTextSequence.startsWith("!")){
|
||||
filterTextSequence=filterTextSequence.substring(1);
|
||||
matchTarget=false;
|
||||
boolean matchTarget = true;
|
||||
if (filterTextSequence.startsWith("!")) {
|
||||
filterTextSequence = filterTextSequence.substring(1);
|
||||
matchTarget = false;
|
||||
}
|
||||
|
||||
|
||||
String[] filterTexts = filterTextSequence.split("[ ]+");
|
||||
List<CompilerSymbol> filteredCompilerSymbols = compilerSymbols;
|
||||
if (filterTexts.length > 0) {
|
||||
|
|
|
@ -56,359 +56,302 @@ import com.wudsn.ide.base.common.EnumUtility;
|
|||
*/
|
||||
public final class AssemblerTocProvider extends AbstractTocProvider {
|
||||
|
||||
private static final class Toc implements IToc {
|
||||
private ITopic[] topics;
|
||||
private static final class Toc implements IToc {
|
||||
private ITopic[] topics;
|
||||
|
||||
public Toc() {
|
||||
public Toc() {
|
||||
|
||||
topics = createTopics();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(IEvaluationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUAElement[] getChildren() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHref() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return Texts.TOC_WUDSN_IDE_LABEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITopic[] getTopics() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITopic getTopic(String href) {
|
||||
return topics[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TocContribution implements ITocContribution {
|
||||
|
||||
public TocContribution() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategoryId() {
|
||||
return "CategoryID";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContributorId() {
|
||||
return AssemblerPlugin.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getExtraDocuments() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "ID";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLinkTo() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IToc getToc() {
|
||||
return new Toc();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public AssemblerTocProvider() {
|
||||
topics = createTopics();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITocContribution[] getTocContributions(String locale) {
|
||||
return new ITocContribution[] { new TocContribution() };
|
||||
public boolean isEnabled(IEvaluationContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static ITopic createTopic(String href) {
|
||||
if (href == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'href' must not be null.");
|
||||
@Override
|
||||
public IUAElement[] getChildren() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHref() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return Texts.TOC_WUDSN_IDE_LABEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITopic[] getTopics() {
|
||||
return topics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITopic getTopic(String href) {
|
||||
return topics[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TocContribution implements ITocContribution {
|
||||
|
||||
public TocContribution() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategoryId() {
|
||||
return "CategoryID";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContributorId() {
|
||||
return AssemblerPlugin.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getExtraDocuments() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "ID";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLinkTo() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IToc getToc() {
|
||||
return new Toc();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrimary() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public AssemblerTocProvider() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITocContribution[] getTocContributions(String locale) {
|
||||
return new ITocContribution[] { new TocContribution() };
|
||||
}
|
||||
|
||||
private static ITopic createTopic(String href) {
|
||||
if (href == null) {
|
||||
throw new IllegalArgumentException("Parameter 'href' must not be null.");
|
||||
}
|
||||
|
||||
String label;
|
||||
String key = href;
|
||||
try {
|
||||
ResourceBundle resourceBundle;
|
||||
resourceBundle = ResourceBundle.getBundle("com/wudsn/ide/asm/help/AssemblerTocProvider",
|
||||
Locale.getDefault(), AssemblerTocProvider.class.getClassLoader());
|
||||
label = resourceBundle.getString(key);
|
||||
} catch (MissingResourceException ex) {
|
||||
label = href + " - Text missing";
|
||||
AssemblerPlugin.getInstance().logError("Resource for enum value {0} is missing.", new Object[] { key }, ex);
|
||||
}
|
||||
return createTopic("", label, href, null);
|
||||
}
|
||||
|
||||
// See[Bug 382599] Help: Icons not taken from IToc2/ITopic2 Implementations
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=382599
|
||||
@SuppressWarnings("restriction")
|
||||
private static ITopic createTopic(String icon, String label, String href, ITopic[] subtopics) {
|
||||
org.eclipse.help.internal.Topic result = new org.eclipse.help.internal.Topic();
|
||||
result.setAttribute(org.eclipse.help.internal.Topic.ATTRIBUTE_ICON, icon);
|
||||
result.setLabel(label);
|
||||
result.setHref(href);
|
||||
if (subtopics == null) {
|
||||
subtopics = new ITopic2[0];
|
||||
}
|
||||
result.appendChildren(subtopics);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static ITopic[] createTopicsArray(List<ITopic> topics) {
|
||||
if (topics == null) {
|
||||
throw new IllegalArgumentException("Parameter 'topics' must not be null.");
|
||||
}
|
||||
ITopic[] topicsArray;
|
||||
topicsArray = new ITopic[topics.size()];
|
||||
topics.toArray(topicsArray);
|
||||
return topicsArray;
|
||||
}
|
||||
|
||||
static ITopic[] createTopics() {
|
||||
AssemblerPlugin assemblerPlugin = AssemblerPlugin.getInstance();
|
||||
CompilerRegistry compilerRegistry = assemblerPlugin.getCompilerRegistry();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions();
|
||||
|
||||
List<ITopic> ideTopics = createIDETopics();
|
||||
List<ITopic> assemblerTopics = createAssemblerTopics(compilerDefinitions);
|
||||
List<ITopic> hardwareTopics = createHardwareTopics();
|
||||
List<ITopic> cpuTopics = createCPUTopics();
|
||||
|
||||
List<ITopic> topics = new ArrayList<ITopic>();
|
||||
|
||||
topics.add(createTopic("", Texts.TOC_IDE_TOPIC_LABEL, "", createTopicsArray(ideTopics)));
|
||||
topics.add(createTopic("", Texts.TOC_ASSEMBLERS_TOPIC_LABEL, "", createTopicsArray(assemblerTopics)));
|
||||
topics.add(createTopic("", Texts.TOC_HARDWARES_TOPIC_LABEL, "", createTopicsArray(hardwareTopics)));
|
||||
topics.add(createTopic("", Texts.TOC_CPUS_TOPIC_LABEL, "", createTopicsArray(cpuTopics)));
|
||||
|
||||
return createTopicsArray(topics);
|
||||
}
|
||||
|
||||
private static List<ITopic> createIDETopics() {
|
||||
List<ITopic> topics = new ArrayList<ITopic>();
|
||||
|
||||
topics.add(createTopic("help/ide-tutorials.section.html"));
|
||||
topics.add(createTopic("help/ide-features.section.html"));
|
||||
topics.add(createTopic("help/ide-installation.section.html"));
|
||||
topics.add(createTopic("help/ide-releases.section.html"));
|
||||
topics.add(createTopic("help/ide-faq.section.html"));
|
||||
topics.add(createTopic("help/ide-credits.section.html"));
|
||||
return topics;
|
||||
}
|
||||
|
||||
private static List<ITopic> createAssemblerTopics(List<CompilerDefinition> compilerDefinitions) {
|
||||
if (compilerDefinitions == null) {
|
||||
throw new IllegalArgumentException("Parameter 'compilerDefinitions' must not be null.");
|
||||
}
|
||||
int size = compilerDefinitions.size();
|
||||
List<ITopic> assemblerTopics = new ArrayList<ITopic>(size);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
CompilerDefinition compilerDefinition = compilerDefinitions.get(i);
|
||||
|
||||
String href = AssemblerHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getId() + "/"
|
||||
+ AssemblerHelpContentProducer.SECTION_GENERAL + AssemblerHelpContentProducer.EXTENSION;
|
||||
|
||||
ITopic generalTopic = createTopic("", Texts.TOC_ASSEMBLER_GENERAL_TOPIC_LABEL, href, null);
|
||||
|
||||
href = AssemblerHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getId() + "/"
|
||||
+ AssemblerHelpContentProducer.SECTION_INSTRUCTIONS + AssemblerHelpContentProducer.EXTENSION;
|
||||
ITopic opcodesTopic = createTopic("", Texts.TOC_ASSEMBLER_INSTRUCTIONS_TOPIC_LABEL, href, null);
|
||||
|
||||
AssemblerPreferences assemblerPreferences = AssemblerPlugin.getInstance().getPreferences();
|
||||
String compilerExecutablePath = assemblerPreferences.getCompilerExecutablePath(compilerDefinition.getId());
|
||||
|
||||
String icon = "";
|
||||
List<ITopic> manualTopics = new ArrayList<ITopic>();
|
||||
try {
|
||||
File file = compilerDefinition.getHelpFile(compilerExecutablePath);
|
||||
|
||||
// Appending the help file path with the correct file
|
||||
// extension allows in-place display for example for ".html"
|
||||
// files.
|
||||
String extension = file.getPath();
|
||||
int index = extension.lastIndexOf('.');
|
||||
if (index > 0) {
|
||||
extension = extension.substring(index);
|
||||
if (extension.equalsIgnoreCase(".pdf")) {
|
||||
icon = "pdf";
|
||||
}
|
||||
} else {
|
||||
extension = ".html";
|
||||
}
|
||||
|
||||
String label;
|
||||
String key = href;
|
||||
try {
|
||||
ResourceBundle resourceBundle;
|
||||
resourceBundle = ResourceBundle.getBundle(
|
||||
"com/wudsn/ide/asm/help/AssemblerTocProvider",
|
||||
Locale.getDefault(),
|
||||
AssemblerTocProvider.class.getClassLoader());
|
||||
label = resourceBundle.getString(key);
|
||||
} catch (MissingResourceException ex) {
|
||||
label = href + " - Text missing";
|
||||
AssemblerPlugin.getInstance().logError(
|
||||
"Resource for enum value {0} is missing.",
|
||||
new Object[] { key }, ex);
|
||||
}
|
||||
return createTopic("", label, href, null);
|
||||
}
|
||||
href = AssemblerHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getId() + "/"
|
||||
+ AssemblerHelpContentProducer.SECTION_MANUAL + extension;
|
||||
|
||||
// See[Bug 382599] Help: Icons not taken from IToc2/ITopic2 Implementations
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=382599
|
||||
@SuppressWarnings("restriction")
|
||||
private static ITopic createTopic(String icon, String label, String href,
|
||||
ITopic[] subtopics) {
|
||||
org.eclipse.help.internal.Topic result = new org.eclipse.help.internal.Topic();
|
||||
result.setAttribute(org.eclipse.help.internal.Topic.ATTRIBUTE_ICON,
|
||||
icon);
|
||||
result.setLabel(label);
|
||||
result.setHref(href);
|
||||
if (subtopics == null) {
|
||||
subtopics = new ITopic2[0];
|
||||
}
|
||||
result.appendChildren(subtopics);
|
||||
return result;
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
if (files != null) {
|
||||
for (File file2 : files) {
|
||||
String encodedPath;
|
||||
try {
|
||||
encodedPath = URLEncoder.encode(file2.getName(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new IllegalArgumentException("Cannot encode file name '" + file2.getName() + "'");
|
||||
}
|
||||
|
||||
private static ITopic[] createTopicsArray(List<ITopic> topics) {
|
||||
if (topics == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'topics' must not be null.");
|
||||
}
|
||||
ITopic[] topicsArray;
|
||||
topicsArray = new ITopic[topics.size()];
|
||||
topics.toArray(topicsArray);
|
||||
return topicsArray;
|
||||
}
|
||||
|
||||
static ITopic[] createTopics() {
|
||||
AssemblerPlugin assemblerPlugin = AssemblerPlugin.getInstance();
|
||||
CompilerRegistry compilerRegistry = assemblerPlugin
|
||||
.getCompilerRegistry();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry
|
||||
.getCompilerDefinitions();
|
||||
|
||||
List<ITopic> ideTopics = createIDETopics();
|
||||
List<ITopic> assemblerTopics = createAssemblerTopics(compilerDefinitions);
|
||||
List<ITopic> hardwareTopics = createHardwareTopics();
|
||||
List<ITopic> cpuTopics = createCPUTopics();
|
||||
|
||||
List<ITopic> topics = new ArrayList<ITopic>();
|
||||
|
||||
topics.add(createTopic("", Texts.TOC_IDE_TOPIC_LABEL, "",
|
||||
createTopicsArray(ideTopics)));
|
||||
topics.add(createTopic("", Texts.TOC_ASSEMBLERS_TOPIC_LABEL, "",
|
||||
createTopicsArray(assemblerTopics)));
|
||||
topics.add(createTopic("", Texts.TOC_HARDWARES_TOPIC_LABEL, "",
|
||||
createTopicsArray(hardwareTopics)));
|
||||
topics.add(createTopic("", Texts.TOC_CPUS_TOPIC_LABEL, "",
|
||||
createTopicsArray(cpuTopics)));
|
||||
|
||||
return createTopicsArray(topics);
|
||||
}
|
||||
|
||||
private static List<ITopic> createIDETopics() {
|
||||
List<ITopic> topics = new ArrayList<ITopic>();
|
||||
|
||||
topics.add(createTopic("help/ide-tutorials.section.html"));
|
||||
topics.add(createTopic("help/ide-features.section.html"));
|
||||
topics.add(createTopic("help/ide-installation.section.html"));
|
||||
topics.add(createTopic("help/ide-releases.section.html"));
|
||||
topics.add(createTopic("help/ide-faq.section.html"));
|
||||
topics.add(createTopic("help/ide-credits.section.html"));
|
||||
return topics;
|
||||
}
|
||||
|
||||
private static List<ITopic> createAssemblerTopics(
|
||||
List<CompilerDefinition> compilerDefinitions) {
|
||||
if (compilerDefinitions == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerDefinitions' must not be null.");
|
||||
}
|
||||
int size = compilerDefinitions.size();
|
||||
List<ITopic> assemblerTopics = new ArrayList<ITopic>(size);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
CompilerDefinition compilerDefinition = compilerDefinitions.get(i);
|
||||
|
||||
String href = AssemblerHelpContentProducer.SCHEMA_COMPILER
|
||||
+ compilerDefinition.getId() + "/"
|
||||
+ AssemblerHelpContentProducer.SECTION_GENERAL
|
||||
+ AssemblerHelpContentProducer.EXTENSION;
|
||||
|
||||
ITopic generalTopic = createTopic("",
|
||||
Texts.TOC_ASSEMBLER_GENERAL_TOPIC_LABEL, href, null);
|
||||
|
||||
href = AssemblerHelpContentProducer.SCHEMA_COMPILER
|
||||
+ compilerDefinition.getId() + "/"
|
||||
+ AssemblerHelpContentProducer.SECTION_INSTRUCTIONS
|
||||
+ AssemblerHelpContentProducer.EXTENSION;
|
||||
ITopic opcodesTopic = createTopic("",
|
||||
Texts.TOC_ASSEMBLER_INSTRUCTIONS_TOPIC_LABEL, href, null);
|
||||
|
||||
AssemblerPreferences assemblerPreferences = AssemblerPlugin
|
||||
.getInstance().getPreferences();
|
||||
String compilerExecutablePath = assemblerPreferences
|
||||
.getCompilerExecutablePath(compilerDefinition.getId());
|
||||
|
||||
String icon = "";
|
||||
List<ITopic> manualTopics = new ArrayList<ITopic>();
|
||||
try {
|
||||
File file = compilerDefinition
|
||||
.getHelpFile(compilerExecutablePath);
|
||||
|
||||
// Appending the help file path with the correct file
|
||||
// extension allows in-place display for example for ".html"
|
||||
// files.
|
||||
String extension = file.getPath();
|
||||
int index = extension.lastIndexOf('.');
|
||||
if (index > 0) {
|
||||
extension = extension.substring(index);
|
||||
if (extension.equalsIgnoreCase(".pdf")) {
|
||||
icon = "pdf";
|
||||
}
|
||||
} else {
|
||||
extension = ".html";
|
||||
}
|
||||
|
||||
href = AssemblerHelpContentProducer.SCHEMA_COMPILER
|
||||
+ compilerDefinition.getId() + "/"
|
||||
+ AssemblerHelpContentProducer.SECTION_MANUAL
|
||||
+ extension;
|
||||
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
if (files != null) {
|
||||
for (File file2 : files) {
|
||||
String encodedPath;
|
||||
try {
|
||||
encodedPath = URLEncoder.encode(
|
||||
file2.getName(), "UTF-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot encode file name '"
|
||||
+ file2.getName() + "'");
|
||||
}
|
||||
|
||||
manualTopics
|
||||
.add(createTopic(
|
||||
"",
|
||||
file2.getName(),
|
||||
href
|
||||
+ "?"
|
||||
+ AssemblerHelpContentProducer.SECTION_MANUAL_FILE
|
||||
+ "=" + encodedPath, null));
|
||||
}
|
||||
}
|
||||
// if the file is folder, the manual does not have own
|
||||
// content but only sub-topics
|
||||
href = "";
|
||||
}
|
||||
} catch (CoreException ex) {
|
||||
href = AssemblerHelpContentProducer.SCHEMA_COMPILER
|
||||
+ compilerDefinition.getId() + "/"
|
||||
+ AssemblerHelpContentProducer.SECTION_MANUAL + ".html";
|
||||
manualTopics.add(createTopic("", file2.getName(), href + "?"
|
||||
+ AssemblerHelpContentProducer.SECTION_MANUAL_FILE + "=" + encodedPath, null));
|
||||
}
|
||||
|
||||
ITopic manualTopic = createTopic(icon,
|
||||
Texts.TOC_ASSEMBLER_MANUAL_TOPIC_LABEL, href,
|
||||
createTopicsArray(manualTopics));
|
||||
|
||||
assemblerTopics.add(createTopic("", compilerDefinition.getName(),
|
||||
"",
|
||||
new ITopic[] { generalTopic, opcodesTopic, manualTopic }));
|
||||
}
|
||||
// if the file is folder, the manual does not have own
|
||||
// content but only sub-topics
|
||||
href = "";
|
||||
}
|
||||
return assemblerTopics;
|
||||
} catch (CoreException ex) {
|
||||
href = AssemblerHelpContentProducer.SCHEMA_COMPILER + compilerDefinition.getId() + "/"
|
||||
+ AssemblerHelpContentProducer.SECTION_MANUAL + ".html";
|
||||
}
|
||||
|
||||
ITopic manualTopic = createTopic(icon, Texts.TOC_ASSEMBLER_MANUAL_TOPIC_LABEL, href,
|
||||
createTopicsArray(manualTopics));
|
||||
|
||||
assemblerTopics.add(createTopic("", compilerDefinition.getName(), "", new ITopic[] { generalTopic,
|
||||
opcodesTopic, manualTopic }));
|
||||
}
|
||||
return assemblerTopics;
|
||||
}
|
||||
|
||||
private static List<ITopic> createHardwareTopics() {
|
||||
// Build hardware topics
|
||||
List<ITopic> hardwareTopics = new ArrayList<ITopic>(
|
||||
Hardware.values().length - 1);
|
||||
for (Hardware hardware : Hardware.values()) {
|
||||
if (hardware.equals(Hardware.GENERIC)) {
|
||||
continue;
|
||||
}
|
||||
List<ITopic> chipTopics = new ArrayList<ITopic>();
|
||||
switch (hardware) {
|
||||
private static List<ITopic> createHardwareTopics() {
|
||||
// Build hardware topics
|
||||
List<ITopic> hardwareTopics = new ArrayList<ITopic>(Hardware.values().length - 1);
|
||||
for (Hardware hardware : Hardware.values()) {
|
||||
if (hardware.equals(Hardware.GENERIC)) {
|
||||
continue;
|
||||
}
|
||||
List<ITopic> chipTopics = new ArrayList<ITopic>();
|
||||
switch (hardware) {
|
||||
|
||||
case ATARI2600:
|
||||
chipTopics
|
||||
.add(createTopic("help/www.qotile.net/minidig/docs/sizes.txt"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.qotile.net/minidig/docs/2600_mem_map.txt"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.qotile.net/minidig/docs/stella.pdf"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.qotile.net/minidig/docs/2600_advanced_prog_guide.txt"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.qotile.net/minidig/docs/tia_color.html"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.qotile.net/minidig/docs/2600_tia_map.txt"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.qotile.net/minidig/docs/2600_riot_map.txt"));
|
||||
break;
|
||||
case ATARI2600:
|
||||
chipTopics.add(createTopic("help/www.qotile.net/minidig/docs/sizes.txt"));
|
||||
chipTopics.add(createTopic("help/www.qotile.net/minidig/docs/2600_mem_map.txt"));
|
||||
chipTopics.add(createTopic("help/www.qotile.net/minidig/docs/stella.pdf"));
|
||||
chipTopics.add(createTopic("help/www.qotile.net/minidig/docs/2600_advanced_prog_guide.txt"));
|
||||
chipTopics.add(createTopic("help/www.qotile.net/minidig/docs/tia_color.html"));
|
||||
chipTopics.add(createTopic("help/www.qotile.net/minidig/docs/2600_tia_map.txt"));
|
||||
chipTopics.add(createTopic("help/www.qotile.net/minidig/docs/2600_riot_map.txt"));
|
||||
break;
|
||||
|
||||
case ATARI8BIT:
|
||||
chipTopics
|
||||
.add(createTopic("help/www.oxyron.de/html/registers_antic.html"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.oxyron.de/html/registers_gtia.html"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.oxyron.de/html/registers_pokey.html"));
|
||||
break;
|
||||
case C64:
|
||||
chipTopics
|
||||
.add(createTopic("help/www.oxyron.de/html/registers_rec.html"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.oxyron.de/html/registers_sid.html"));
|
||||
chipTopics
|
||||
.add(createTopic("help/www.oxyron.de/html/registers_vic2.html"));
|
||||
break;
|
||||
default:
|
||||
// Nothing available.
|
||||
case ATARI8BIT:
|
||||
chipTopics.add(createTopic("help/www.oxyron.de/html/registers_antic.html"));
|
||||
chipTopics.add(createTopic("help/www.oxyron.de/html/registers_gtia.html"));
|
||||
chipTopics.add(createTopic("help/www.oxyron.de/html/registers_pokey.html"));
|
||||
break;
|
||||
case C64:
|
||||
chipTopics.add(createTopic("help/www.oxyron.de/html/registers_rec.html"));
|
||||
chipTopics.add(createTopic("help/www.oxyron.de/html/registers_sid.html"));
|
||||
chipTopics.add(createTopic("help/www.oxyron.de/html/registers_vic2.html"));
|
||||
break;
|
||||
default:
|
||||
// Nothing available.
|
||||
|
||||
}
|
||||
String href = AssemblerHelpContentProducer.SCHEMA_HARDWARE
|
||||
+ hardware.name().toLowerCase()
|
||||
+ AssemblerHelpContentProducer.EXTENSION;
|
||||
hardwareTopics.add(createTopic("", EnumUtility.getText(hardware),
|
||||
href, createTopicsArray(chipTopics)));
|
||||
}
|
||||
return hardwareTopics;
|
||||
}
|
||||
String href = AssemblerHelpContentProducer.SCHEMA_HARDWARE + hardware.name().toLowerCase()
|
||||
+ AssemblerHelpContentProducer.EXTENSION;
|
||||
hardwareTopics.add(createTopic("", EnumUtility.getText(hardware), href, createTopicsArray(chipTopics)));
|
||||
}
|
||||
return hardwareTopics;
|
||||
}
|
||||
|
||||
private static List<ITopic> createCPUTopics() {
|
||||
List<ITopic> cpuTopics = new ArrayList<ITopic>(CPU.values().length - 1);
|
||||
for (CPU cpu : CPU.values()) {
|
||||
String href = AssemblerHelpContentProducer.SCHEMA_CPU
|
||||
+ cpu.name().toLowerCase()
|
||||
+ AssemblerHelpContentProducer.EXTENSION;
|
||||
cpuTopics
|
||||
.add(createTopic("", EnumUtility.getText(cpu), href, null));
|
||||
}
|
||||
return cpuTopics;
|
||||
private static List<ITopic> createCPUTopics() {
|
||||
List<ITopic> cpuTopics = new ArrayList<ITopic>(CPU.values().length - 1);
|
||||
for (CPU cpu : CPU.values()) {
|
||||
String href = AssemblerHelpContentProducer.SCHEMA_CPU + cpu.name().toLowerCase()
|
||||
+ AssemblerHelpContentProducer.EXTENSION;
|
||||
cpuTopics.add(createTopic("", EnumUtility.getText(cpu), href, null));
|
||||
}
|
||||
return cpuTopics;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,16 +30,13 @@ final class HTMLConstants {
|
|||
|
||||
private static final String NL = "\n";
|
||||
private static final String DOC_TYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
|
||||
private static final String CONTENT_TYPE = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset="
|
||||
+ UTF8 + "\" />";
|
||||
private static final String CONTENT_TYPE = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + UTF8
|
||||
+ "\" />";
|
||||
private static final String STYLE_SHEETS = "<link rel=\"STYLESHEET\" href=\"/help/content/org.eclipse.platform/book.css\" type=\"text/css\" />"
|
||||
+ NL
|
||||
+ "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"stylesheets/ide.css\"/>";
|
||||
+ NL + "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"stylesheets/ide.css\"/>";
|
||||
|
||||
public static final String PREFIX = DOC_TYPE + NL
|
||||
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + NL + "<head>"
|
||||
+ NL + HTMLConstants.CONTENT_TYPE + NL + HTMLConstants.STYLE_SHEETS
|
||||
+ NL + "</head><body>";
|
||||
public static final String PREFIX = DOC_TYPE + NL + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + NL + "<head>"
|
||||
+ NL + HTMLConstants.CONTENT_TYPE + NL + HTMLConstants.STYLE_SHEETS + NL + "</head><body>";
|
||||
public static final String SUFFIX = "</body>" + NL + "</html>";
|
||||
|
||||
}
|
||||
|
|
|
@ -37,28 +37,22 @@ final class HTMLWrapperInputStream extends InputStream {
|
|||
private InputStream innerInputStream;
|
||||
private InputStream suffixInputStream;
|
||||
|
||||
public HTMLWrapperInputStream(String prefix, String suffix,
|
||||
InputStream inputStream) {
|
||||
public HTMLWrapperInputStream(String prefix, String suffix, InputStream inputStream) {
|
||||
if (prefix == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'prefix' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'prefix' must not be null.");
|
||||
}
|
||||
if (suffix == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'suffix' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'suffix' must not be null.");
|
||||
}
|
||||
if (inputStream == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'inputStream' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'inputStream' must not be null.");
|
||||
}
|
||||
|
||||
try {
|
||||
prefixInputStream = new ByteArrayInputStream(
|
||||
prefix.getBytes("UTF-8"));
|
||||
prefixInputStream = new ByteArrayInputStream(prefix.getBytes("UTF-8"));
|
||||
|
||||
innerInputStream = inputStream;
|
||||
suffixInputStream = new ByteArrayInputStream(
|
||||
suffix.getBytes("UTF-8"));
|
||||
suffixInputStream = new ByteArrayInputStream(suffix.getBytes("UTF-8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
@ -72,7 +66,7 @@ final class HTMLWrapperInputStream extends InputStream {
|
|||
if (prefixInputStream != null) {
|
||||
result = prefixInputStream.read();
|
||||
if (result != -1) {
|
||||
// System.out.print((char)result);
|
||||
// System.out.print((char)result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -82,7 +76,7 @@ final class HTMLWrapperInputStream extends InputStream {
|
|||
if (innerInputStream != null) {
|
||||
result = innerInputStream.read();
|
||||
if (result != -1) {
|
||||
// System.out.print((char)result);
|
||||
// System.out.print((char)result);
|
||||
return result;
|
||||
}
|
||||
innerInputStream = null;
|
||||
|
@ -91,7 +85,7 @@ final class HTMLWrapperInputStream extends InputStream {
|
|||
if (suffixInputStream != null) {
|
||||
result = suffixInputStream.read();
|
||||
if (result != -1) {
|
||||
// System.out.print((char)result);
|
||||
// System.out.print((char)result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ public final class AssemblerPreferences {
|
|||
*/
|
||||
public AssemblerPreferences(IPreferenceStore preferenceStore) {
|
||||
if (preferenceStore == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'preferenceStore' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'preferenceStore' must not be null.");
|
||||
}
|
||||
this.preferenceStore = preferenceStore;
|
||||
}
|
||||
|
@ -65,11 +64,9 @@ public final class AssemblerPreferences {
|
|||
*/
|
||||
public TextAttribute getEditorTextAttribute(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'name' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'name' must not be null.");
|
||||
}
|
||||
return TextAttributeConverter.fromString(preferenceStore
|
||||
.getString(name));
|
||||
return TextAttributeConverter.fromString(preferenceStore.getString(name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,15 +102,12 @@ public final class AssemblerPreferences {
|
|||
*/
|
||||
public String getCompilerExecutablePath(String compilerId) {
|
||||
if (compilerId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(compilerId)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerId' must not be empty.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be empty.");
|
||||
}
|
||||
return getString(AssemblerPreferencesConstants
|
||||
.getCompilerExecutablePathName(compilerId));
|
||||
return getString(AssemblerPreferencesConstants.getCompilerExecutablePathName(compilerId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,19 +121,15 @@ public final class AssemblerPreferences {
|
|||
*
|
||||
* @return The compiler preferences, not <code>null</code>.
|
||||
*/
|
||||
public CompilerPreferences getCompilerPreferences(String compilerId,
|
||||
Hardware hardware) {
|
||||
public CompilerPreferences getCompilerPreferences(String compilerId, Hardware hardware) {
|
||||
if (compilerId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(compilerId)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerId' must not be empty.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be empty.");
|
||||
}
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
return new CompilerPreferences(this, compilerId, hardware);
|
||||
|
||||
|
@ -157,8 +147,7 @@ public final class AssemblerPreferences {
|
|||
*/
|
||||
String getString(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
String result;
|
||||
result = preferenceStore.getString(name);
|
||||
|
@ -183,8 +172,7 @@ public final class AssemblerPreferences {
|
|||
*/
|
||||
boolean getBoolean(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
return preferenceStore.getBoolean(name);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public interface AssemblerPreferencesChangeListener {
|
|||
|
||||
/**
|
||||
* Notify of changed properties.
|
||||
*
|
||||
* @param preferences
|
||||
* The assembler preferences containing the new values, not
|
||||
* <code>null</code>.
|
||||
|
|
|
@ -43,8 +43,7 @@ import com.wudsn.ide.asm.runner.RunnerId;
|
|||
*
|
||||
* @author Peter Dell
|
||||
*/
|
||||
public final class AssemblerPreferencesInitializer extends
|
||||
AbstractPreferenceInitializer {
|
||||
public final class AssemblerPreferencesInitializer extends AbstractPreferenceInitializer {
|
||||
|
||||
/**
|
||||
* Creation must be public default.
|
||||
|
@ -54,8 +53,7 @@ public final class AssemblerPreferencesInitializer extends
|
|||
|
||||
@Override
|
||||
public void initializeDefaultPreferences() {
|
||||
IPreferenceStore store = AssemblerPlugin.getInstance()
|
||||
.getPreferenceStore();
|
||||
IPreferenceStore store = AssemblerPlugin.getInstance().getPreferenceStore();
|
||||
|
||||
initializeEditorPreferences(store);
|
||||
|
||||
|
@ -66,76 +64,56 @@ public final class AssemblerPreferencesInitializer extends
|
|||
|
||||
private void initializeEditorPreferences(IPreferenceStore store) {
|
||||
if (store == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'store' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'store' must not be null.");
|
||||
}
|
||||
// Editor.
|
||||
Display display = Display.getCurrent();
|
||||
|
||||
TextAttribute textAttribute = new TextAttribute(new Color(display, 0,
|
||||
128, 0), null, SWT.ITALIC);
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT,
|
||||
TextAttribute textAttribute = new TextAttribute(new Color(display, 0, 128, 0), null, SWT.ITALIC);
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT,
|
||||
TextAttributeConverter.toString(textAttribute));
|
||||
|
||||
textAttribute = new TextAttribute(new Color(display, 0, 0, 255), null,
|
||||
SWT.NORMAL);
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_STRING,
|
||||
textAttribute = new TextAttribute(new Color(display, 0, 0, 255), null, SWT.NORMAL);
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_STRING,
|
||||
TextAttributeConverter.toString(textAttribute));
|
||||
|
||||
textAttribute = new TextAttribute(new Color(display, 0, 0, 255), null,
|
||||
SWT.BOLD);
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_NUMBER,
|
||||
textAttribute = new TextAttribute(new Color(display, 0, 0, 255), null, SWT.BOLD);
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_NUMBER,
|
||||
TextAttributeConverter.toString(textAttribute));
|
||||
|
||||
textAttribute = new TextAttribute(new Color(display, 128, 64, 0), null,
|
||||
SWT.BOLD);
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_DIRECTVE,
|
||||
textAttribute = new TextAttribute(new Color(display, 128, 64, 0), null, SWT.BOLD);
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_DIRECTVE,
|
||||
TextAttributeConverter.toString(textAttribute));
|
||||
|
||||
textAttribute = new TextAttribute(new Color(display, 0, 0, 128), null,
|
||||
SWT.BOLD);
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL,
|
||||
textAttribute = new TextAttribute(new Color(display, 0, 0, 128), null, SWT.BOLD);
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL,
|
||||
TextAttributeConverter.toString(textAttribute));
|
||||
|
||||
textAttribute = new TextAttribute(new Color(display, 255, 32, 32),
|
||||
null, SWT.BOLD);
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL,
|
||||
textAttribute = new TextAttribute(new Color(display, 255, 32, 32), null, SWT.BOLD);
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL,
|
||||
TextAttributeConverter.toString(textAttribute));
|
||||
|
||||
textAttribute = new TextAttribute(new Color(display, 32, 128, 32),
|
||||
null, SWT.BOLD);
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO,
|
||||
textAttribute = new TextAttribute(new Color(display, 32, 128, 32), null, SWT.BOLD);
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO,
|
||||
TextAttributeConverter.toString(textAttribute));
|
||||
|
||||
// Content assist.
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE,
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE,
|
||||
AssemblerContentAssistProcessorDefaultCase.LOWER_CASE);
|
||||
|
||||
// Compiling.
|
||||
store.setDefault(
|
||||
AssemblerPreferencesConstants.EDITOR_COMPILE_COMMAND_POSITIONING_MODE,
|
||||
store.setDefault(AssemblerPreferencesConstants.EDITOR_COMPILE_COMMAND_POSITIONING_MODE,
|
||||
AssemblerEditorCompileCommandPositioningMode.FIRST_ERROR_OR_WARNING);
|
||||
}
|
||||
|
||||
private void initializeCompilerPreferences(IPreferenceStore store) {
|
||||
if (store == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'store' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'store' must not be null.");
|
||||
}
|
||||
|
||||
CompilerRegistry compilerRegistry = AssemblerPlugin.getInstance()
|
||||
.getCompilerRegistry();
|
||||
CompilerRegistry compilerRegistry = AssemblerPlugin.getInstance().getCompilerRegistry();
|
||||
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry
|
||||
.getCompilerDefinitions();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions();
|
||||
for (CompilerDefinition compilerDefinition : compilerDefinitions) {
|
||||
String compilerId;
|
||||
String name;
|
||||
|
@ -145,24 +123,16 @@ public final class AssemblerPreferencesInitializer extends
|
|||
if (hardware.equals(Hardware.GENERIC)) {
|
||||
continue;
|
||||
}
|
||||
store.setDefault(AssemblerPreferencesConstants
|
||||
.getCompilerCPUName(compilerId, hardware),
|
||||
store.setDefault(AssemblerPreferencesConstants.getCompilerCPUName(compilerId, hardware),
|
||||
compilerDefinition.getSupportedCPUs().get(0).toString());
|
||||
|
||||
name = AssemblerPreferencesConstants.getCompilerParametersName(
|
||||
compilerId, hardware);
|
||||
store.setDefault(name,
|
||||
compilerDefinition.getDefaultParameters());
|
||||
name = AssemblerPreferencesConstants
|
||||
.getCompilerOutputFolderModeName(compilerId, hardware);
|
||||
name = AssemblerPreferencesConstants.getCompilerParametersName(compilerId, hardware);
|
||||
store.setDefault(name, compilerDefinition.getDefaultParameters());
|
||||
name = AssemblerPreferencesConstants.getCompilerOutputFolderModeName(compilerId, hardware);
|
||||
store.setDefault(name, CompilerOutputFolderMode.TEMP_FOLDER);
|
||||
name = AssemblerPreferencesConstants
|
||||
.getCompilerOutputFileExtensionName(compilerId,
|
||||
hardware);
|
||||
store.setDefault(name,
|
||||
HardwareUtility.getDefaultFileExtension(hardware));
|
||||
name = AssemblerPreferencesConstants.getCompilerRunnerIdName(
|
||||
compilerId, hardware);
|
||||
name = AssemblerPreferencesConstants.getCompilerOutputFileExtensionName(compilerId, hardware);
|
||||
store.setDefault(name, HardwareUtility.getDefaultFileExtension(hardware));
|
||||
name = AssemblerPreferencesConstants.getCompilerRunnerIdName(compilerId, hardware);
|
||||
store.setDefault(name, RunnerId.DEFAULT_APPLICATION);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ import com.wudsn.ide.base.gui.SWTFactory;
|
|||
public final class AssemblerPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
private abstract class TextAttributeSelectionListener implements SelectionListener {
|
||||
|
||||
|
||||
/**
|
||||
* Creation is public.
|
||||
*/
|
||||
|
|
|
@ -37,24 +37,19 @@ public final class CompilerPreferences {
|
|||
private Hardware hardware;
|
||||
private String compilerId;
|
||||
|
||||
CompilerPreferences(AssemblerPreferences assemblerPreferences,
|
||||
String compilerId, Hardware hardware) {
|
||||
CompilerPreferences(AssemblerPreferences assemblerPreferences, String compilerId, Hardware hardware) {
|
||||
if (assemblerPreferences == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'assemblerPreferences' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'assemblerPreferences' must not be null.");
|
||||
}
|
||||
|
||||
if (compilerId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(compilerId)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'compilerId' must not be empty.");
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be empty.");
|
||||
}
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
this.assemblerPreferences = assemblerPreferences;
|
||||
this.compilerId = compilerId;
|
||||
|
@ -91,9 +86,8 @@ public final class CompilerPreferences {
|
|||
*/
|
||||
public CPU getCPU() {
|
||||
CPU result;
|
||||
String cpuString = assemblerPreferences
|
||||
.getString(AssemblerPreferencesConstants.getCompilerCPUName(
|
||||
compilerId, hardware));
|
||||
String cpuString = assemblerPreferences.getString(AssemblerPreferencesConstants.getCompilerCPUName(compilerId,
|
||||
hardware));
|
||||
|
||||
if (StringUtility.isEmpty(cpuString)) {
|
||||
result = CPU.MOS6502;
|
||||
|
@ -130,8 +124,8 @@ public final class CompilerPreferences {
|
|||
* <code>null</code>.
|
||||
*/
|
||||
public String getParameters() {
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants
|
||||
.getCompilerParametersName(compilerId, hardware));
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants.getCompilerParametersName(compilerId,
|
||||
hardware));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,8 +137,8 @@ public final class CompilerPreferences {
|
|||
*/
|
||||
public String getOutputFolderMode() {
|
||||
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants
|
||||
.getCompilerOutputFolderModeName(compilerId, hardware));
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants.getCompilerOutputFolderModeName(compilerId,
|
||||
hardware));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,8 +151,8 @@ public final class CompilerPreferences {
|
|||
*/
|
||||
public String getOutputFolderPath() {
|
||||
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants
|
||||
.getCompilerOutputFolderPathName(compilerId, hardware));
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants.getCompilerOutputFolderPathName(compilerId,
|
||||
hardware));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,8 +162,8 @@ public final class CompilerPreferences {
|
|||
*/
|
||||
public String getOutputFileExtension() {
|
||||
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants
|
||||
.getCompilerOutputFileExtensionName(compilerId, hardware));
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants.getCompilerOutputFileExtensionName(
|
||||
compilerId, hardware));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,9 +173,8 @@ public final class CompilerPreferences {
|
|||
* <code>null</code>.
|
||||
*/
|
||||
public String getRunnerId() {
|
||||
String result = assemblerPreferences
|
||||
.getString(AssemblerPreferencesConstants
|
||||
.getCompilerRunnerIdName(compilerId, hardware));
|
||||
String result = assemblerPreferences.getString(AssemblerPreferencesConstants.getCompilerRunnerIdName(
|
||||
compilerId, hardware));
|
||||
if (StringUtility.isEmpty(result)) {
|
||||
result = RunnerId.DEFAULT_APPLICATION;
|
||||
}
|
||||
|
@ -199,16 +192,13 @@ public final class CompilerPreferences {
|
|||
*/
|
||||
public String getRunnerExecutablePath(String runnerId) {
|
||||
if (runnerId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'runnerId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'runnerId' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(runnerId)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'runnerId' must not be empty.");
|
||||
throw new IllegalArgumentException("Parameter 'runnerId' must not be empty.");
|
||||
}
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants
|
||||
.getCompilerRunnerExecutablePathName(compilerId, hardware,
|
||||
runnerId));
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants.getCompilerRunnerExecutablePathName(
|
||||
compilerId, hardware, runnerId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,16 +212,13 @@ public final class CompilerPreferences {
|
|||
*/
|
||||
public String getRunnerCommandLine(String runnerId) {
|
||||
if (runnerId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'runnerId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'runnerId' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(runnerId)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'runnerId' must not be empty.");
|
||||
throw new IllegalArgumentException("Parameter 'runnerId' must not be empty.");
|
||||
}
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants
|
||||
.getCompilerRunnerCommandLineName(compilerId, hardware,
|
||||
runnerId));
|
||||
return assemblerPreferences.getString(AssemblerPreferencesConstants.getCompilerRunnerCommandLineName(
|
||||
compilerId, hardware, runnerId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -247,16 +234,13 @@ public final class CompilerPreferences {
|
|||
*/
|
||||
public boolean isRunnerWaitForCompletion(String runnerId) {
|
||||
if (runnerId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'runnerId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'runnerId' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(runnerId)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'runnerId' must not be empty.");
|
||||
throw new IllegalArgumentException("Parameter 'runnerId' must not be empty.");
|
||||
}
|
||||
return assemblerPreferences.getBoolean(AssemblerPreferencesConstants
|
||||
.getCompilerRunnerWaitForCompletionName(compilerId, hardware,
|
||||
runnerId));
|
||||
return assemblerPreferences.getBoolean(AssemblerPreferencesConstants.getCompilerRunnerWaitForCompletionName(
|
||||
compilerId, hardware, runnerId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public final class CompilerRunPreferences {
|
|||
throw new IllegalArgumentException("Parameter 'properties' must not be null.");
|
||||
}
|
||||
this.compilerPreferences = compilerPreferences;
|
||||
this.mainSourceFileProperties=mainSourceFileProperties;
|
||||
this.mainSourceFileProperties = mainSourceFileProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -43,8 +43,7 @@ final class DirectoryFieldDownloadEditor extends DirectoryFieldEditor {
|
|||
|
||||
Link link;
|
||||
|
||||
public DirectoryFieldDownloadEditor(String name, String labelText,
|
||||
Composite parent) {
|
||||
public DirectoryFieldDownloadEditor(String name, String labelText, Composite parent) {
|
||||
super(name, labelText, parent);
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,8 @@ final class DirectoryFieldDownloadEditor extends DirectoryFieldEditor {
|
|||
}
|
||||
|
||||
/**
|
||||
* Do not check input as file to allow selecting ".app" directories on MacOS X.
|
||||
* Do not check input as file to allow selecting ".app" directories on MacOS
|
||||
* X.
|
||||
*
|
||||
* @return <code>true</code> in all cases.
|
||||
*/
|
||||
|
@ -115,19 +115,15 @@ final class DirectoryFieldDownloadEditor extends DirectoryFieldEditor {
|
|||
*/
|
||||
public void setLinkURL(String url) {
|
||||
if (link == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'link' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'link' must not be null.");
|
||||
}
|
||||
if (url == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'url' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'url' must not be null.");
|
||||
}
|
||||
|
||||
if (url.length() > 0) {
|
||||
link.setText("<a href=\"" + url + "\">"
|
||||
+ Texts.PREFERENCES_DOWNLOAD_LINK + "</a>");
|
||||
link.setToolTipText(TextUtility.format(
|
||||
Texts.PREFERENCES_DOWNLOAD_LINK_TOOL_TIP, url));
|
||||
link.setText("<a href=\"" + url + "\">" + Texts.PREFERENCES_DOWNLOAD_LINK + "</a>");
|
||||
link.setToolTipText(TextUtility.format(Texts.PREFERENCES_DOWNLOAD_LINK_TOOL_TIP, url));
|
||||
|
||||
} else {
|
||||
link.setText("");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -43,8 +43,7 @@ final class FileFieldDownloadEditor extends FileFieldEditor {
|
|||
|
||||
Link link;
|
||||
|
||||
public FileFieldDownloadEditor(String name, String labelText,
|
||||
Composite parent) {
|
||||
public FileFieldDownloadEditor(String name, String labelText, Composite parent) {
|
||||
super(name, labelText, parent);
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,8 @@ final class FileFieldDownloadEditor extends FileFieldEditor {
|
|||
}
|
||||
|
||||
/**
|
||||
* Do not check input as file to allow selecting ".app" directories on MacOS X.
|
||||
* Do not check input as file to allow selecting ".app" directories on MacOS
|
||||
* X.
|
||||
*
|
||||
* @return <code>true</code> in all cases.
|
||||
*/
|
||||
|
@ -115,19 +115,15 @@ final class FileFieldDownloadEditor extends FileFieldEditor {
|
|||
*/
|
||||
public void setLinkURL(String url) {
|
||||
if (link == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'link' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'link' must not be null.");
|
||||
}
|
||||
if (url == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'url' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'url' must not be null.");
|
||||
}
|
||||
|
||||
if (url.length() > 0) {
|
||||
link.setText("<a href=\"" + url + "\">"
|
||||
+ Texts.PREFERENCES_DOWNLOAD_LINK + "</a>");
|
||||
link.setToolTipText(TextUtility.format(
|
||||
Texts.PREFERENCES_DOWNLOAD_LINK_TOOL_TIP, url));
|
||||
link.setText("<a href=\"" + url + "\">" + Texts.PREFERENCES_DOWNLOAD_LINK + "</a>");
|
||||
link.setToolTipText(TextUtility.format(Texts.PREFERENCES_DOWNLOAD_LINK_TOOL_TIP, url));
|
||||
|
||||
} else {
|
||||
link.setText("");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -92,8 +92,7 @@ public final class TextAttributeConverter {
|
|||
FontData fontData = font.getFontData()[0];
|
||||
fontData = new FontData(fontData.getName(), fontData.getHeight(), style);
|
||||
font = new Font(display, fontData);
|
||||
result = new TextAttribute(foregroundColor, backgroundColor, style,
|
||||
font);
|
||||
result = new TextAttribute(foregroundColor, backgroundColor, style, font);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -106,13 +105,11 @@ public final class TextAttributeConverter {
|
|||
*/
|
||||
public static String toString(TextAttribute textAttribute) {
|
||||
if (textAttribute == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'textAttribute' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'textAttribute' must not be null.");
|
||||
}
|
||||
|
||||
String result;
|
||||
result = toString(textAttribute.getForeground()) + ","
|
||||
+ toString(textAttribute.getBackground()) + ","
|
||||
result = toString(textAttribute.getForeground()) + "," + toString(textAttribute.getBackground()) + ","
|
||||
+ Integer.toString(textAttribute.getStyle());
|
||||
return result;
|
||||
}
|
||||
|
@ -138,12 +135,13 @@ public final class TextAttributeConverter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Dispose the colors and the font of the text attribute created by this class.
|
||||
* Dispose the colors and the font of the text attribute created by this
|
||||
* class.
|
||||
*
|
||||
* @param textAttribute
|
||||
* The text attribute or <code>null</code>.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public static void dispose(TextAttribute textAttribute) {
|
||||
if (textAttribute != null) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -28,8 +28,7 @@ import java.util.List;
|
|||
*
|
||||
* @author Peter Dell
|
||||
*/
|
||||
final class TextAttributeListContentProvider implements
|
||||
IStructuredContentProvider {
|
||||
final class TextAttributeListContentProvider implements IStructuredContentProvider {
|
||||
|
||||
TextAttributeListContentProvider() {
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -39,12 +39,10 @@ final class TextAttributeListItem {
|
|||
|
||||
TextAttributeListItem(String displayName, String preferencesKey) {
|
||||
if (displayName == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'displayName' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'displayName' must not be null.");
|
||||
}
|
||||
if (preferencesKey == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'preferencesKey' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null.");
|
||||
}
|
||||
this.displayName = displayName;
|
||||
this.preferencesKey = preferencesKey;
|
||||
|
@ -77,8 +75,7 @@ final class TextAttributeListItem {
|
|||
*/
|
||||
public void setTextAttribute(TextAttribute textAttribute) {
|
||||
if (textAttribute == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'textAttribute' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'textAttribute' must not be null.");
|
||||
}
|
||||
this.textAttribute = textAttribute;
|
||||
}
|
||||
|
@ -90,8 +87,7 @@ final class TextAttributeListItem {
|
|||
*/
|
||||
public TextAttribute getTextAttribute() {
|
||||
if (textAttribute == null) {
|
||||
throw new IllegalStateException(
|
||||
"Field 'textAttribute' must not be null.");
|
||||
throw new IllegalStateException("Field 'textAttribute' must not be null.");
|
||||
}
|
||||
return textAttribute;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -30,8 +30,7 @@ import org.eclipse.swt.graphics.Font;
|
|||
*
|
||||
* @author Peter Dell
|
||||
*/
|
||||
final class TextAttributeListItemProvider extends LabelProvider implements
|
||||
IColorProvider, IFontProvider {
|
||||
final class TextAttributeListItemProvider extends LabelProvider implements IColorProvider, IFontProvider {
|
||||
|
||||
TextAttributeListItemProvider() {
|
||||
|
||||
|
@ -47,8 +46,7 @@ final class TextAttributeListItemProvider extends LabelProvider implements
|
|||
*/
|
||||
@Override
|
||||
public Color getForeground(Object element) {
|
||||
return ((TextAttributeListItem) element).getTextAttribute()
|
||||
.getForeground();
|
||||
return ((TextAttributeListItem) element).getTextAttribute().getForeground();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,8 +54,7 @@ final class TextAttributeListItemProvider extends LabelProvider implements
|
|||
*/
|
||||
@Override
|
||||
public Color getBackground(Object element) {
|
||||
return ((TextAttributeListItem) element).getTextAttribute()
|
||||
.getBackground();
|
||||
return ((TextAttributeListItem) element).getTextAttribute().getBackground();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,7 +65,6 @@ public class Runner {
|
|||
return definition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the {@link File} object for the breakpoints file.
|
||||
*
|
||||
|
|
|
@ -63,8 +63,7 @@ public final class RunnerDefinition implements Comparable<RunnerDefinition> {
|
|||
*/
|
||||
final void setHardware(Hardware hardware) {
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
this.hardware = hardware;
|
||||
}
|
||||
|
@ -76,8 +75,7 @@ public final class RunnerDefinition implements Comparable<RunnerDefinition> {
|
|||
*/
|
||||
public final Hardware getHardware() {
|
||||
if (hardware == null) {
|
||||
throw new IllegalStateException(
|
||||
"Field 'hardware' must not be null.");
|
||||
throw new IllegalStateException("Field 'hardware' must not be null.");
|
||||
}
|
||||
return hardware;
|
||||
}
|
||||
|
@ -92,8 +90,7 @@ public final class RunnerDefinition implements Comparable<RunnerDefinition> {
|
|||
*/
|
||||
final void setId(String id) {
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'id' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'id' must not be null.");
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -118,8 +115,7 @@ public final class RunnerDefinition implements Comparable<RunnerDefinition> {
|
|||
*/
|
||||
final void setName(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'name' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'name' must not be null.");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -146,8 +142,7 @@ public final class RunnerDefinition implements Comparable<RunnerDefinition> {
|
|||
public final boolean isRunnerExecutablePathPossible() {
|
||||
boolean result;
|
||||
|
||||
result = id.equals(RunnerId.USER_DEFINED_APPLICATION)
|
||||
|| defaultCommandLine.contains(RUNNER_EXECUTABLE_PATH);
|
||||
result = id.equals(RunnerId.USER_DEFINED_APPLICATION) || defaultCommandLine.contains(RUNNER_EXECUTABLE_PATH);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -175,8 +170,7 @@ public final class RunnerDefinition implements Comparable<RunnerDefinition> {
|
|||
*/
|
||||
public final String getHomePageURL() {
|
||||
if (homePageURL == null) {
|
||||
throw new IllegalStateException(
|
||||
"Field 'homePageURL' must not be null.");
|
||||
throw new IllegalStateException("Field 'homePageURL' must not be null.");
|
||||
}
|
||||
return homePageURL;
|
||||
}
|
||||
|
@ -203,8 +197,7 @@ public final class RunnerDefinition implements Comparable<RunnerDefinition> {
|
|||
*/
|
||||
public final String getDefaultCommandLine() {
|
||||
if (defaultCommandLine == null) {
|
||||
throw new IllegalStateException(
|
||||
"Field 'defaultCommandLine' must not be null.");
|
||||
throw new IllegalStateException("Field 'defaultCommandLine' must not be null.");
|
||||
}
|
||||
return defaultCommandLine;
|
||||
}
|
||||
|
@ -218,12 +211,10 @@ public final class RunnerDefinition implements Comparable<RunnerDefinition> {
|
|||
@Override
|
||||
public final int compareTo(RunnerDefinition o) {
|
||||
if (o == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'o' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'o' must not be null.");
|
||||
}
|
||||
if (name == null || o.name == null) {
|
||||
throw new IllegalStateException(
|
||||
"Field 'name' must not be null for this or for argument.");
|
||||
throw new IllegalStateException("Field 'name' must not be null for this or for argument.");
|
||||
|
||||
}
|
||||
int result = id.compareTo(o.id);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -76,27 +76,20 @@ public final class RunnerRegistry {
|
|||
runnerMap = new TreeMap<String, Runner>();
|
||||
|
||||
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint extensionPoint = extensionRegistry
|
||||
.getExtensionPoint(RUNNERS);
|
||||
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(RUNNERS);
|
||||
IExtension[] extensions = extensionPoint.getExtensions();
|
||||
|
||||
for (IExtension extension : extensions) {
|
||||
IConfigurationElement[] configurationElements = extension
|
||||
.getConfigurationElements();
|
||||
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
|
||||
for (IConfigurationElement configurationElement : configurationElements) {
|
||||
|
||||
RunnerDefinition runnerDefinition;
|
||||
runnerDefinition = new RunnerDefinition();
|
||||
runnerDefinition.setId(configurationElement.getAttribute("id"));
|
||||
runnerDefinition
|
||||
.setHardware(Hardware.valueOf(configurationElement
|
||||
.getAttribute("hardware")));
|
||||
runnerDefinition.setName(configurationElement
|
||||
.getAttribute("name"));
|
||||
runnerDefinition.setHomePageURL(configurationElement
|
||||
.getAttribute("homePageURL"));
|
||||
runnerDefinition.setDefaultCommandLine(configurationElement
|
||||
.getAttribute("defaultCommandLine"));
|
||||
runnerDefinition.setHardware(Hardware.valueOf(configurationElement.getAttribute("hardware")));
|
||||
runnerDefinition.setName(configurationElement.getAttribute("name"));
|
||||
runnerDefinition.setHomePageURL(configurationElement.getAttribute("homePageURL"));
|
||||
runnerDefinition.setDefaultCommandLine(configurationElement.getAttribute("defaultCommandLine"));
|
||||
|
||||
runnerDefinitionList.add(runnerDefinition);
|
||||
|
||||
|
@ -104,11 +97,9 @@ public final class RunnerRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
runnerDefinitionList = new ArrayList<RunnerDefinition>(
|
||||
runnerDefinitionList);
|
||||
runnerDefinitionList = new ArrayList<RunnerDefinition>(runnerDefinitionList);
|
||||
Collections.sort(runnerDefinitionList);
|
||||
runnerDefinitionList = Collections
|
||||
.unmodifiableList(runnerDefinitionList);
|
||||
runnerDefinitionList = Collections.unmodifiableList(runnerDefinitionList);
|
||||
runnerMap = Collections.unmodifiableMap(runnerMap);
|
||||
}
|
||||
|
||||
|
@ -122,31 +113,24 @@ public final class RunnerRegistry {
|
|||
* @param runnerDefinition
|
||||
* The runner definition, not <code>null</code>.
|
||||
*/
|
||||
private void addRunner(IConfigurationElement configurationElement,
|
||||
RunnerDefinition runnerDefinition) {
|
||||
private void addRunner(IConfigurationElement configurationElement, RunnerDefinition runnerDefinition) {
|
||||
if (configurationElement == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'configurationElement' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'configurationElement' must not be null.");
|
||||
}
|
||||
if (runnerDefinition == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'runnerDefinition' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'runnerDefinition' must not be null.");
|
||||
}
|
||||
|
||||
String id = runnerDefinition.getHardware().toString().toLowerCase()
|
||||
+ "." + runnerDefinition.getId();
|
||||
String id = runnerDefinition.getHardware().toString().toLowerCase() + "." + runnerDefinition.getId();
|
||||
|
||||
// Optionally use a specific runner implementation class.
|
||||
Runner runner;
|
||||
if (configurationElement.getAttribute("class") != null) {
|
||||
try {
|
||||
// The class loading must be delegated to the framework.
|
||||
runner = (Runner) configurationElement
|
||||
.createExecutableExtension("class");
|
||||
runner = (Runner) configurationElement.createExecutableExtension("class");
|
||||
} catch (CoreException ex) {
|
||||
throw new RuntimeException(
|
||||
"Cannot create runner instance for id '" + id + "'.",
|
||||
ex);
|
||||
throw new RuntimeException("Cannot create runner instance for id '" + id + "'.", ex);
|
||||
}
|
||||
} else {
|
||||
runner = new Runner();
|
||||
|
@ -155,10 +139,8 @@ public final class RunnerRegistry {
|
|||
runner.setDefinition(runnerDefinition);
|
||||
runner = runnerMap.put(id, runner);
|
||||
if (runner != null) {
|
||||
throw new RuntimeException("Runner with id '"
|
||||
+ runnerDefinition.getId() + "' for hardware '"
|
||||
+ runnerDefinition.getHardware().toString()
|
||||
+ "' is already registered to class '"
|
||||
throw new RuntimeException("Runner with id '" + runnerDefinition.getId() + "' for hardware '"
|
||||
+ runnerDefinition.getHardware().toString() + "' is already registered to class '"
|
||||
+ runner.getClass().getName() + "'.");
|
||||
}
|
||||
|
||||
|
@ -176,12 +158,10 @@ public final class RunnerRegistry {
|
|||
*/
|
||||
public List<RunnerDefinition> getDefinitions(Hardware hardware) {
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
|
||||
List<RunnerDefinition> result = new ArrayList<RunnerDefinition>(
|
||||
runnerDefinitionList.size());
|
||||
List<RunnerDefinition> result = new ArrayList<RunnerDefinition>(runnerDefinitionList.size());
|
||||
for (RunnerDefinition runnerDefinition : runnerDefinitionList) {
|
||||
if (runnerDefinition.getHardware().equals(hardware)
|
||||
|| runnerDefinition.getHardware().equals(Hardware.GENERIC)) {
|
||||
|
@ -205,27 +185,23 @@ public final class RunnerRegistry {
|
|||
*/
|
||||
public Runner getRunner(Hardware hardware, String runnerId) {
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'hardware' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
if (runnerId == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'runnerId' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'runnerId' must not be null.");
|
||||
}
|
||||
Runner result;
|
||||
synchronized (runnerMap) {
|
||||
|
||||
result = runnerMap.get(hardware.toString().toLowerCase() + "."
|
||||
+ runnerId);
|
||||
result = runnerMap.get(hardware.toString().toLowerCase() + "." + runnerId);
|
||||
if (result == null) {
|
||||
result = runnerMap.get(Hardware.GENERIC.toString()
|
||||
.toLowerCase() + "." + runnerId);
|
||||
result = runnerMap.get(Hardware.GENERIC.toString().toLowerCase() + "." + runnerId);
|
||||
}
|
||||
}
|
||||
if (result == null) {
|
||||
|
||||
throw new IllegalArgumentException("Unknown runner id '" + runnerId
|
||||
+ "' for hardware '" + hardware.toString() + "'.");
|
||||
throw new IllegalArgumentException("Unknown runner id '" + runnerId + "' for hardware '"
|
||||
+ hardware.toString() + "'.");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -78,7 +78,7 @@ public final class Texts extends NLS {
|
|||
public static String HEX_EDITOR_FILE_CONTENT_MODE_FIELD_LABEL;
|
||||
public static String HEX_EDITOR_CHARACTER_SET_TYPE_FIELD_LABEL;
|
||||
public static String HEX_EDITOR_BYTES_PER_ROW_FIELD_LABEL;
|
||||
|
||||
|
||||
public static String HEX_EDITOR_SAVE_SELECTION_AS_DIALOG_TITLE;
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,247 +47,226 @@ import com.wudsn.ide.base.Texts;
|
|||
*/
|
||||
public abstract class AbstractIDEPlugin extends AbstractUIPlugin {
|
||||
|
||||
private Map<String, Image> images;
|
||||
private Map<String, Image> images;
|
||||
|
||||
/**
|
||||
* Creates a new instance. Must be public for dynamic instantiation.
|
||||
*/
|
||||
protected AbstractIDEPlugin() {
|
||||
images = new HashMap<String, Image>();
|
||||
/**
|
||||
* Creates a new instance. Must be public for dynamic instantiation.
|
||||
*/
|
||||
protected AbstractIDEPlugin() {
|
||||
images = new HashMap<String, Image>();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin id.
|
||||
*
|
||||
* @return The plugin id, not empty and not <code>null</code>.
|
||||
*/
|
||||
protected abstract String getPluginId();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an info message to the plugin log and the standard output stream.
|
||||
*
|
||||
* @param message
|
||||
* The message, not <code>null</code>.
|
||||
* @param parameters
|
||||
* The message parameters, may be empty or <code>null</code>.
|
||||
*/
|
||||
public final void log(String message, Object[] parameters) {
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException("Parameter 'message' must not be null.");
|
||||
}
|
||||
message = format(message, parameters);
|
||||
getLog().log(new Status(IStatus.INFO, getPluginId(), IStatus.OK, message, null));
|
||||
// System.out.println(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error message and an exception to the plugin log and the standard
|
||||
* error stream.
|
||||
*
|
||||
* @param message
|
||||
* The message, not <code>null</code>.
|
||||
* @param parameters
|
||||
* The message parameters, may be empty or <code>null</code>.
|
||||
* @param th
|
||||
* The throwable or <code>null</code>.
|
||||
*/
|
||||
public final void logError(String message, Object[] parameters, Throwable th) {
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException("Parameter 'message' must not be null.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin id.
|
||||
*
|
||||
* @return The plugin id, not empty and not <code>null</code>.
|
||||
*/
|
||||
protected abstract String getPluginId();
|
||||
message = format(message, parameters);
|
||||
if (th != null) {
|
||||
message = message + "\n" + th.getMessage();
|
||||
}
|
||||
getLog().log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, th));
|
||||
// System.err.println(message);
|
||||
// if (th != null) {
|
||||
// th.printStackTrace(System.err);
|
||||
// }
|
||||
// System.err.flush();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
}
|
||||
|
||||
private String format(String message, Object... parameters) {
|
||||
if (parameters == null) {
|
||||
parameters = new String[0];
|
||||
}
|
||||
String[] stringParameters = new String[parameters.length];
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
Object parameter = parameters[i];
|
||||
String stringParameter;
|
||||
if (parameter == null) {
|
||||
stringParameter = "null";
|
||||
} else {
|
||||
stringParameter = parameter.toString();
|
||||
}
|
||||
stringParameters[i] = stringParameter;
|
||||
}
|
||||
message = TextUtility.format(message, stringParameters);
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows error message and an exception as error dialog and logs them to the
|
||||
* plugin log and the standard error stream.
|
||||
*
|
||||
* @param shell
|
||||
* The shell, not <code>null</code>.
|
||||
*
|
||||
* @param message
|
||||
* The message, not <code>null</code>.
|
||||
* @param th
|
||||
* The throwable, not <code>null</code>.
|
||||
*/
|
||||
public final void showError(Shell shell, String message, Throwable th) {
|
||||
if (shell == null) {
|
||||
throw new IllegalArgumentException("Parameter 'shell' must not be null.");
|
||||
}
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException("Parameter 'message' must not be null.");
|
||||
}
|
||||
if (th == null) {
|
||||
throw new IllegalArgumentException("Parameter 'th' must not be null.");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
super.stop(context);
|
||||
Status status = new Status(IStatus.ERROR, getPluginId(), message);
|
||||
|
||||
ErrorDialog.openError(shell, Texts.DIALOG_TITLE, th.getClass().getName() + ": " + th.getMessage()
|
||||
+ "\nCheck the .log file in the .metadata folder of the workspace for details.", status);
|
||||
logError(message, null, th);
|
||||
}
|
||||
|
||||
public final void savePreferences() {
|
||||
String pluginId;
|
||||
pluginId = getPluginId();
|
||||
try {
|
||||
InstanceScope.INSTANCE.getNode(pluginId).flush();
|
||||
} catch (BackingStoreException ex) {
|
||||
|
||||
throw new RuntimeException("Cannot store preferences for plugin '" + pluginId + "'", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an info message to the plugin log and the standard output stream.
|
||||
*
|
||||
* @param message
|
||||
* The message, not <code>null</code>.
|
||||
* @param parameters
|
||||
* The message parameters, may be empty or <code>null</code>.
|
||||
*/
|
||||
public final void log(String message, Object[] parameters) {
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'message' must not be null.");
|
||||
}
|
||||
message = format(message, parameters);
|
||||
getLog().log(
|
||||
new Status(IStatus.INFO, getPluginId(), IStatus.OK, message,
|
||||
null));
|
||||
// System.out.println(message);
|
||||
/**
|
||||
* Gets the image for the specified plug-in relative path.
|
||||
*
|
||||
* @param path
|
||||
* The plug-in relative path, not <code>null</code>.
|
||||
*
|
||||
* @return The image, not <code>null</code>.
|
||||
*/
|
||||
public final Image getImage(String path) {
|
||||
if (path == null) {
|
||||
throw new IllegalArgumentException("Parameter 'path' must not be null.");
|
||||
}
|
||||
Image result;
|
||||
synchronized (images) {
|
||||
result = images.get(path);
|
||||
if (result == null) {
|
||||
|
||||
/**
|
||||
* Logs an error message and an exception to the plugin log and the standard
|
||||
* error stream.
|
||||
*
|
||||
* @param message
|
||||
* The message, not <code>null</code>.
|
||||
* @param parameters
|
||||
* The message parameters, may be empty or <code>null</code>.
|
||||
* @param th
|
||||
* The throwable or <code>null</code>.
|
||||
*/
|
||||
public final void logError(String message, Object[] parameters, Throwable th) {
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'message' must not be null.");
|
||||
}
|
||||
|
||||
message = format(message, parameters);
|
||||
if (th != null) {
|
||||
message = message + "\n" + th.getMessage();
|
||||
}
|
||||
getLog().log(
|
||||
new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR,
|
||||
message, th));
|
||||
// System.err.println(message);
|
||||
// if (th != null) {
|
||||
// th.printStackTrace(System.err);
|
||||
// }
|
||||
// System.err.flush();
|
||||
|
||||
}
|
||||
|
||||
private String format(String message, Object... parameters) {
|
||||
if (parameters == null) {
|
||||
parameters = new String[0];
|
||||
}
|
||||
String[] stringParameters = new String[parameters.length];
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
Object parameter = parameters[i];
|
||||
String stringParameter;
|
||||
if (parameter == null) {
|
||||
stringParameter = "null";
|
||||
} else {
|
||||
stringParameter = parameter.toString();
|
||||
}
|
||||
stringParameters[i] = stringParameter;
|
||||
}
|
||||
message = TextUtility.format(message, stringParameters);
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows error message and an exception as error dialog and logs them to the
|
||||
* plugin log and the standard error stream.
|
||||
*
|
||||
* @param shell
|
||||
* The shell, not <code>null</code>.
|
||||
*
|
||||
* @param message
|
||||
* The message, not <code>null</code>.
|
||||
* @param th
|
||||
* The throwable, not <code>null</code>.
|
||||
*/
|
||||
public final void showError(Shell shell, String message, Throwable th) {
|
||||
if (shell == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'shell' must not be null.");
|
||||
}
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'message' must not be null.");
|
||||
}
|
||||
if (th == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'th' must not be null.");
|
||||
}
|
||||
|
||||
Status status = new Status(IStatus.ERROR, getPluginId(), message);
|
||||
|
||||
ErrorDialog
|
||||
.openError(
|
||||
shell,
|
||||
Texts.DIALOG_TITLE,
|
||||
th.getClass().getName()
|
||||
+ ": "
|
||||
+ th.getMessage()
|
||||
+ "\nCheck the .log file in the .metadata folder of the workspace for details.",
|
||||
status);
|
||||
logError(message, null, th);
|
||||
}
|
||||
|
||||
public final void savePreferences() {
|
||||
String pluginId;
|
||||
pluginId = getPluginId();
|
||||
try {
|
||||
InstanceScope.INSTANCE.getNode(pluginId).flush();
|
||||
} catch (BackingStoreException ex) {
|
||||
|
||||
throw new RuntimeException("Cannot store preferences for plugin '"
|
||||
+ pluginId + "'", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the image for the specified plug-in relative path.
|
||||
*
|
||||
* @param path
|
||||
* The plug-in relative path, not <code>null</code>.
|
||||
*
|
||||
* @return The image, not <code>null</code>.
|
||||
*/
|
||||
public final Image getImage(String path) {
|
||||
if (path == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'path' must not be null.");
|
||||
}
|
||||
Image result;
|
||||
synchronized (images) {
|
||||
result = images.get(path);
|
||||
if (result == null) {
|
||||
|
||||
ImageDescriptor imageDescriptor;
|
||||
imageDescriptor = getImageDescriptor(path);
|
||||
if (imageDescriptor == null) {
|
||||
throw new RuntimeException("Image '" + path
|
||||
+ "' not found.");
|
||||
}
|
||||
result = imageDescriptor.createImage();
|
||||
images.put(path, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the image for the specified plug-in relative path.
|
||||
*
|
||||
* @param path
|
||||
* The plug-in relative path, not <code>null</code>.
|
||||
*
|
||||
* @return The image descriptor or <code>null</code> if no image resource
|
||||
* was found.
|
||||
*/
|
||||
public final ImageDescriptor getImageDescriptor(String path) {
|
||||
ImageDescriptor imageDescriptor;
|
||||
imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
|
||||
getPluginId(), "icons/" + path);
|
||||
return imageDescriptor;
|
||||
imageDescriptor = getImageDescriptor(path);
|
||||
if (imageDescriptor == null) {
|
||||
throw new RuntimeException("Image '" + path + "' not found.");
|
||||
}
|
||||
result = imageDescriptor.createImage();
|
||||
images.put(path, result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the absolute path of a entry from the plugin's directory.
|
||||
*
|
||||
* @param fileName
|
||||
* The name of a file or directory, no compound name like
|
||||
* "dir1\dir2" or "dir1\file1", not <code>null</code>.
|
||||
*
|
||||
* @return The absolute path of the file or directory in the plugin's
|
||||
* directory, may be empty, not <code>null</code>.
|
||||
*/
|
||||
public final String getFilePathFromPlugin(String fileName) {
|
||||
if (fileName == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'entry' must not be null.");
|
||||
}
|
||||
URL url = null;
|
||||
IPath path = null;
|
||||
String result = "";
|
||||
return result;
|
||||
|
||||
Enumeration<URL> enu = getBundle().findEntries("/", fileName, true);
|
||||
if (enu != null && enu.hasMoreElements()) {
|
||||
url = enu.nextElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (url == null) {
|
||||
return "";
|
||||
}
|
||||
/**
|
||||
* Gets the image for the specified plug-in relative path.
|
||||
*
|
||||
* @param path
|
||||
* The plug-in relative path, not <code>null</code>.
|
||||
*
|
||||
* @return The image descriptor or <code>null</code> if no image resource
|
||||
* was found.
|
||||
*/
|
||||
public final ImageDescriptor getImageDescriptor(String path) {
|
||||
ImageDescriptor imageDescriptor;
|
||||
imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(getPluginId(), "icons/" + path);
|
||||
return imageDescriptor;
|
||||
}
|
||||
|
||||
try {
|
||||
path = new Path(FileLocator.toFileURL(url).getPath());
|
||||
result = path.makeAbsolute().toOSString();
|
||||
} catch (Exception ex) {
|
||||
result = "";
|
||||
}
|
||||
|
||||
return result;
|
||||
/**
|
||||
* Gets the absolute path of a entry from the plugin's directory.
|
||||
*
|
||||
* @param fileName
|
||||
* The name of a file or directory, no compound name like
|
||||
* "dir1\dir2" or "dir1\file1", not <code>null</code>.
|
||||
*
|
||||
* @return The absolute path of the file or directory in the plugin's
|
||||
* directory, may be empty, not <code>null</code>.
|
||||
*/
|
||||
public final String getFilePathFromPlugin(String fileName) {
|
||||
if (fileName == null) {
|
||||
throw new IllegalArgumentException("Parameter 'entry' must not be null.");
|
||||
}
|
||||
URL url = null;
|
||||
IPath path = null;
|
||||
String result = "";
|
||||
|
||||
Enumeration<URL> enu = getBundle().findEntries("/", fileName, true);
|
||||
if (enu != null && enu.hasMoreElements()) {
|
||||
url = enu.nextElement();
|
||||
}
|
||||
|
||||
if (url == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
path = new Path(FileLocator.toFileURL(url).getPath());
|
||||
result = path.makeAbsolute().toOSString();
|
||||
} catch (Exception ex) {
|
||||
result = "";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,37 +33,33 @@ import com.wudsn.ide.base.BasePlugin;
|
|||
|
||||
public final class EnumUtility {
|
||||
|
||||
/**
|
||||
* Gets the localized text for an enum value.
|
||||
*
|
||||
* @param enumValue
|
||||
* The enum value, not <code>null</code>.
|
||||
* @return The localized text, may be empty, not <code>null</code>.
|
||||
*/
|
||||
public static String getText(Enum<?> enumValue) {
|
||||
if (enumValue == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'enumValue' must not be null.");
|
||||
}
|
||||
|
||||
String result;
|
||||
|
||||
Class<?> enumClass = enumValue.getClass();
|
||||
|
||||
String key = enumClass.getName() + "." + enumValue.name();
|
||||
try {
|
||||
ResourceBundle resourceBundle;
|
||||
|
||||
resourceBundle = ResourceBundle.getBundle("plugin",
|
||||
Locale.getDefault(), enumClass.getClassLoader());
|
||||
result = resourceBundle.getString(key);
|
||||
} catch (MissingResourceException ex) {
|
||||
result = enumValue.name() + " - Text missing";
|
||||
BasePlugin.getInstance().logError(
|
||||
"Resource for enum value {0} is missing.",
|
||||
new Object[] { key }, ex);
|
||||
}
|
||||
return result;
|
||||
/**
|
||||
* Gets the localized text for an enum value.
|
||||
*
|
||||
* @param enumValue
|
||||
* The enum value, not <code>null</code>.
|
||||
* @return The localized text, may be empty, not <code>null</code>.
|
||||
*/
|
||||
public static String getText(Enum<?> enumValue) {
|
||||
if (enumValue == null) {
|
||||
throw new IllegalArgumentException("Parameter 'enumValue' must not be null.");
|
||||
}
|
||||
|
||||
String result;
|
||||
|
||||
Class<?> enumClass = enumValue.getClass();
|
||||
|
||||
String key = enumClass.getName() + "." + enumValue.name();
|
||||
try {
|
||||
ResourceBundle resourceBundle;
|
||||
|
||||
resourceBundle = ResourceBundle.getBundle("plugin", Locale.getDefault(), enumClass.getClassLoader());
|
||||
result = resourceBundle.getString(key);
|
||||
} catch (MissingResourceException ex) {
|
||||
result = enumValue.name() + " - Text missing";
|
||||
BasePlugin.getInstance().logError("Resource for enum value {0} is missing.", new Object[] { key }, ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -63,8 +63,7 @@ public final class HexUtility {
|
|||
*/
|
||||
public static String getByteValueHexString(int byteValue) {
|
||||
if (byteValue < 0 || byteValue > 255) {
|
||||
throw new IllegalArgumentException("Integer value " + byteValue
|
||||
+ " is no byte value.");
|
||||
throw new IllegalArgumentException("Integer value " + byteValue + " is no byte value.");
|
||||
}
|
||||
return hexStrings[byteValue];
|
||||
}
|
||||
|
@ -80,9 +79,8 @@ public final class HexUtility {
|
|||
*/
|
||||
public static int getLongValueHexLength(long longValue) {
|
||||
if (longValue < 0) {
|
||||
throw new RuntimeException(
|
||||
"Parameter 'longValue' must not be negative. Specified value is "
|
||||
+ longValue + ".");
|
||||
throw new RuntimeException("Parameter 'longValue' must not be negative. Specified value is " + longValue
|
||||
+ ".");
|
||||
}
|
||||
int result = Long.toHexString(longValue).length();
|
||||
if ((result & 1) == 1) {
|
||||
|
@ -99,8 +97,7 @@ public final class HexUtility {
|
|||
* @return The string, not empty and not <code>null</code>.
|
||||
*/
|
||||
public static String getLongValueHexString(long longValue) {
|
||||
return getLongValueHexString(longValue,
|
||||
getLongValueHexLength(longValue));
|
||||
return getLongValueHexString(longValue, getLongValueHexLength(longValue));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,14 +113,12 @@ public final class HexUtility {
|
|||
*/
|
||||
public static String getLongValueHexString(long longValue, int length) {
|
||||
if (longValue < 0) {
|
||||
throw new RuntimeException(
|
||||
"Parameter 'longValue' must not be negative. Specified value is "
|
||||
+ longValue + ".");
|
||||
throw new RuntimeException("Parameter 'longValue' must not be negative. Specified value is " + longValue
|
||||
+ ".");
|
||||
}
|
||||
if (length < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'length' must not be negative. Specified value is "
|
||||
+ length + ".");
|
||||
throw new IllegalArgumentException("Parameter 'length' must not be negative. Specified value is " + length
|
||||
+ ".");
|
||||
}
|
||||
String result = Long.toHexString(longValue).toUpperCase();
|
||||
if (length > AUTOMATIC_LENGTH) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -36,33 +36,27 @@ public final class IPathUtility {
|
|||
|
||||
public static IPath makeRelative(IPath filePath, IPath filePathPrefix) {
|
||||
if (filePath == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'filePath' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'filePath' must not be null.");
|
||||
}
|
||||
if (filePathPrefix == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'filePathPrefix' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'filePathPrefix' must not be null.");
|
||||
}
|
||||
if (filePath.isAbsolute() && !filePathPrefix.isEmpty()) {
|
||||
if (filePathPrefix.isPrefixOf(filePath)) {
|
||||
filePath = filePath.removeFirstSegments(filePathPrefix
|
||||
.segmentCount());
|
||||
filePath = filePath.removeFirstSegments(filePathPrefix.segmentCount());
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public static IPath makeAbsolute(IPath filePath, IPath filePathPrefix,
|
||||
boolean forcePrefix) {
|
||||
public static IPath makeAbsolute(IPath filePath, IPath filePathPrefix, boolean forcePrefix) {
|
||||
if (filePath == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'filePath' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'filePath' must not be null.");
|
||||
}
|
||||
if (filePathPrefix == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'filePathPrefix' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'filePathPrefix' must not be null.");
|
||||
}
|
||||
|
||||
|
||||
// If the file path is empty, the prefix is omitted by default.
|
||||
// Only if forcePrefix is true, it is added.
|
||||
if (!filePath.isEmpty() || forcePrefix) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -68,8 +68,7 @@ final class InputStreamMonitor {
|
|||
*/
|
||||
public InputStreamMonitor(OutputStream outputStream) {
|
||||
if (outputStream == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'outputStream' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'outputStream' must not be null.");
|
||||
}
|
||||
this.outputStream = outputStream;
|
||||
outputQueue = new ArrayList<String>();
|
||||
|
@ -128,8 +127,7 @@ final class InputStreamMonitor {
|
|||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException ex) {
|
||||
BasePlugin.getInstance().logError("IOException during write()",
|
||||
null, ex);
|
||||
BasePlugin.getInstance().logError("IOException during write()", null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,8 +143,7 @@ final class InputStreamMonitor {
|
|||
outputStream.write(text.getBytes());
|
||||
outputStream.flush();
|
||||
} catch (IOException ex) {
|
||||
BasePlugin.getInstance().logError(
|
||||
"IOException during writeNext()", null, ex);
|
||||
BasePlugin.getInstance().logError("IOException during writeNext()", null, ex);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -62,19 +62,15 @@ public final class MarkerUtility {
|
|||
*
|
||||
* @return The marker representing the message, not <code>null</code>.
|
||||
*/
|
||||
public static IMarker createMarker(IFile file, int lineNumber,
|
||||
int severity, String message, String... parameters) {
|
||||
public static IMarker createMarker(IFile file, int lineNumber, int severity, String message, String... parameters) {
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'file' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'file' must not be null.");
|
||||
}
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'message' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'message' must not be null.");
|
||||
}
|
||||
if (parameters == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'parameters' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'parameters' must not be null.");
|
||||
}
|
||||
|
||||
message = TextUtility.format(message, parameters);
|
||||
|
@ -107,8 +103,7 @@ public final class MarkerUtility {
|
|||
*/
|
||||
public static void gotoMarker(IEditorPart editor, IMarker marker) {
|
||||
if (marker == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'marker' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'marker' must not be null.");
|
||||
}
|
||||
try {
|
||||
IFile iFile = (IFile) marker.getResource();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
|
|
@ -36,192 +36,178 @@ import com.wudsn.ide.base.BasePlugin;
|
|||
*/
|
||||
public final class ProcessWithLogs {
|
||||
|
||||
private final String[] commandArray;
|
||||
private final File workingDirectory;
|
||||
private int exitValue;
|
||||
private String outputLog;
|
||||
private String errorLog;
|
||||
private final String[] commandArray;
|
||||
private final File workingDirectory;
|
||||
private int exitValue;
|
||||
private String outputLog;
|
||||
private String errorLog;
|
||||
|
||||
public static final String[] getExecutableExtensions() {
|
||||
public static final String[] getExecutableExtensions() {
|
||||
|
||||
String[] extensions;
|
||||
String os = Platform.getOS();
|
||||
if (os.equals(Platform.OS_WIN32)) {
|
||||
// Default to ".exe" for Windows
|
||||
extensions = new String[] { "*.exe", "*.jar", "*.*" };
|
||||
} else if (os.equals(Platform.OS_MACOSX)) {
|
||||
// No restrictions for MacOS X since "*.app" is not always a good
|
||||
// choice.
|
||||
extensions = new String[0];
|
||||
} else {
|
||||
// No restrictions for all other operating systems.
|
||||
extensions = new String[0];
|
||||
}
|
||||
return extensions;
|
||||
String[] extensions;
|
||||
String os = Platform.getOS();
|
||||
if (os.equals(Platform.OS_WIN32)) {
|
||||
// Default to ".exe" for Windows
|
||||
extensions = new String[] { "*.exe", "*.jar", "*.*" };
|
||||
} else if (os.equals(Platform.OS_MACOSX)) {
|
||||
// No restrictions for MacOS X since "*.app" is not always a good
|
||||
// choice.
|
||||
extensions = new String[0];
|
||||
} else {
|
||||
// No restrictions for all other operating systems.
|
||||
extensions = new String[0];
|
||||
}
|
||||
return extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new process.
|
||||
*
|
||||
* @param commandArray
|
||||
* The command array, not empty and not <code>null</code>.
|
||||
* @param workingDirectory
|
||||
* The working directory, not <code>null</code>.
|
||||
*/
|
||||
public ProcessWithLogs(String[] commandArray, File workingDirectory) {
|
||||
if (commandArray == null) {
|
||||
throw new IllegalArgumentException("Parameter 'fullCommandArray' must not be null.");
|
||||
}
|
||||
if (commandArray.length == 0) {
|
||||
throw new IllegalArgumentException("Parameter 'fullCommandArray.length' must not be empty.");
|
||||
}
|
||||
for (int i = 0; i < commandArray.length; i++) {
|
||||
if (commandArray[i] == null) {
|
||||
throw new IllegalArgumentException("Parameter 'commandArray' must contain null at positition " + i
|
||||
+ ".");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new process.
|
||||
*
|
||||
* @param commandArray
|
||||
* The command array, not empty and not <code>null</code>.
|
||||
* @param workingDirectory
|
||||
* The working directory, not <code>null</code>.
|
||||
*/
|
||||
public ProcessWithLogs(String[] commandArray, File workingDirectory) {
|
||||
if (commandArray == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'fullCommandArray' must not be null.");
|
||||
}
|
||||
if (commandArray.length == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'fullCommandArray.length' must not be empty.");
|
||||
}
|
||||
for (int i = 0; i < commandArray.length; i++) {
|
||||
if (commandArray[i] == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'commandArray' must contain null at positition "
|
||||
+ i + ".");
|
||||
}
|
||||
}
|
||||
|
||||
if (workingDirectory == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'workingDirectory' must not be null.");
|
||||
}
|
||||
|
||||
this.commandArray = commandArray;
|
||||
this.workingDirectory = FileUtility.getCanonicalFile(workingDirectory);
|
||||
exitValue = 0;
|
||||
outputLog = "";
|
||||
errorLog = "";
|
||||
if (workingDirectory == null) {
|
||||
throw new IllegalArgumentException("Parameter 'workingDirectory' must not be null.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the compiler.
|
||||
*
|
||||
* @param out
|
||||
* The print stream for the output output, see {@link System#out}
|
||||
* .
|
||||
* @param err
|
||||
* The print stream for the error output, see {@link System#err}.
|
||||
* @param wait
|
||||
* <code>true</code> to wait for the process to terminate and
|
||||
* collect the output.
|
||||
*
|
||||
* @throws IOException
|
||||
* The the creation of the process fails.
|
||||
*/
|
||||
public void exec(PrintStream out, PrintStream err, boolean wait)
|
||||
throws IOException {
|
||||
this.commandArray = commandArray;
|
||||
this.workingDirectory = FileUtility.getCanonicalFile(workingDirectory);
|
||||
exitValue = 0;
|
||||
outputLog = "";
|
||||
errorLog = "";
|
||||
}
|
||||
|
||||
if (out == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'out' must not be null.");
|
||||
}
|
||||
if (err == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'err' must not be null.");
|
||||
}
|
||||
Process process = null;
|
||||
exitValue = 0;
|
||||
outputLog = "";
|
||||
errorLog = "";
|
||||
Profiler profiler = new Profiler(this);
|
||||
profiler.begin("exec");
|
||||
try {
|
||||
BasePlugin.getInstance().log(
|
||||
"Executing process '{0}' in working directory '{1}'.",
|
||||
new Object[] { getCommandArrayString(),
|
||||
workingDirectory.getPath() });
|
||||
/**
|
||||
* Executes the compiler.
|
||||
*
|
||||
* @param out
|
||||
* The print stream for the output output, see {@link System#out}
|
||||
* .
|
||||
* @param err
|
||||
* The print stream for the error output, see {@link System#err}.
|
||||
* @param wait
|
||||
* <code>true</code> to wait for the process to terminate and
|
||||
* collect the output.
|
||||
*
|
||||
* @throws IOException
|
||||
* The the creation of the process fails.
|
||||
*/
|
||||
public void exec(PrintStream out, PrintStream err, boolean wait) throws IOException {
|
||||
|
||||
process = Runtime.getRuntime().exec(commandArray, null,
|
||||
workingDirectory);
|
||||
} catch (IOException ex) {
|
||||
BasePlugin.getInstance().logError(
|
||||
"Cannot execute process '{0}' in working directory '{1}'.",
|
||||
new Object[] { getCommandArrayString(),
|
||||
workingDirectory.getPath() }, ex);
|
||||
throw ex;
|
||||
} finally {
|
||||
profiler.end("exec");
|
||||
}
|
||||
if (wait) {
|
||||
String encoding = null;
|
||||
StreamsProxy streamsProxy = new StreamsProxy(process, encoding,
|
||||
out, err);
|
||||
try {
|
||||
profiler.begin("waitFor");
|
||||
process.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
BasePlugin.getInstance().logError("Process interrupted", null,
|
||||
ex);
|
||||
throw new IOException(ex.getMessage());
|
||||
} finally {
|
||||
profiler.end("waitFor");
|
||||
process.destroy();
|
||||
}
|
||||
if (out == null) {
|
||||
throw new IllegalArgumentException("Parameter 'out' must not be null.");
|
||||
}
|
||||
if (err == null) {
|
||||
throw new IllegalArgumentException("Parameter 'err' must not be null.");
|
||||
}
|
||||
Process process = null;
|
||||
exitValue = 0;
|
||||
outputLog = "";
|
||||
errorLog = "";
|
||||
Profiler profiler = new Profiler(this);
|
||||
profiler.begin("exec");
|
||||
try {
|
||||
BasePlugin.getInstance().log("Executing process '{0}' in working directory '{1}'.",
|
||||
new Object[] { getCommandArrayString(), workingDirectory.getPath() });
|
||||
|
||||
streamsProxy.close();
|
||||
exitValue = process.exitValue();
|
||||
outputLog = streamsProxy.getOutputStreamMonitor().getContents();
|
||||
errorLog = streamsProxy.getErrorStreamMonitor().getContents();
|
||||
}
|
||||
process = Runtime.getRuntime().exec(commandArray, null, workingDirectory);
|
||||
} catch (IOException ex) {
|
||||
BasePlugin.getInstance().logError("Cannot execute process '{0}' in working directory '{1}'.",
|
||||
new Object[] { getCommandArrayString(), workingDirectory.getPath() }, ex);
|
||||
throw ex;
|
||||
} finally {
|
||||
profiler.end("exec");
|
||||
}
|
||||
if (wait) {
|
||||
String encoding = null;
|
||||
StreamsProxy streamsProxy = new StreamsProxy(process, encoding, out, err);
|
||||
try {
|
||||
profiler.begin("waitFor");
|
||||
process.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
BasePlugin.getInstance().logError("Process interrupted", null, ex);
|
||||
throw new IOException(ex.getMessage());
|
||||
} finally {
|
||||
profiler.end("waitFor");
|
||||
process.destroy();
|
||||
}
|
||||
|
||||
streamsProxy.close();
|
||||
exitValue = process.exitValue();
|
||||
outputLog = streamsProxy.getOutputStreamMonitor().getContents();
|
||||
errorLog = streamsProxy.getErrorStreamMonitor().getContents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command array to be as string.
|
||||
*
|
||||
* @return The command array as string, may be empty, not <code>null</code>
|
||||
* ..
|
||||
*/
|
||||
public String getCommandArrayString() {
|
||||
StringBuilder result;
|
||||
result = new StringBuilder();
|
||||
for (int i = 0; i < commandArray.length; i++) {
|
||||
result.append(commandArray[i]);
|
||||
if (i < commandArray.length - 1) {
|
||||
result.append(" ");
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the working directory.
|
||||
*
|
||||
* @return The working directory, not <code>null</code>.
|
||||
*/
|
||||
public File getWorkingDirectory() {
|
||||
return workingDirectory;
|
||||
/**
|
||||
* Gets the command array to be as string.
|
||||
*
|
||||
* @return The command array as string, may be empty, not <code>null</code>
|
||||
* ..
|
||||
*/
|
||||
public String getCommandArrayString() {
|
||||
StringBuilder result;
|
||||
result = new StringBuilder();
|
||||
for (int i = 0; i < commandArray.length; i++) {
|
||||
result.append(commandArray[i]);
|
||||
if (i < commandArray.length - 1) {
|
||||
result.append(" ");
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exit value of the process.
|
||||
*
|
||||
* @return The exit value of the process.
|
||||
*/
|
||||
public int getExitValue() {
|
||||
return exitValue;
|
||||
}
|
||||
/**
|
||||
* Gets the working directory.
|
||||
*
|
||||
* @return The working directory, not <code>null</code>.
|
||||
*/
|
||||
public File getWorkingDirectory() {
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output log captured from {@link System#out}.
|
||||
*
|
||||
* @return The output log, maybe empty, not <code>null</code>.
|
||||
*/
|
||||
public String getOutputLog() {
|
||||
return outputLog;
|
||||
}
|
||||
/**
|
||||
* Gets the exit value of the process.
|
||||
*
|
||||
* @return The exit value of the process.
|
||||
*/
|
||||
public int getExitValue() {
|
||||
return exitValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the error log captured from {@link System#out}.
|
||||
*
|
||||
* @return The output log, maybe empty, not <code>null</code>.
|
||||
*/
|
||||
public String getErrorLog() {
|
||||
return errorLog;
|
||||
}
|
||||
/**
|
||||
* Gets the output log captured from {@link System#out}.
|
||||
*
|
||||
* @return The output log, maybe empty, not <code>null</code>.
|
||||
*/
|
||||
public String getOutputLog() {
|
||||
return outputLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the error log captured from {@link System#out}.
|
||||
*
|
||||
* @return The output log, maybe empty, not <code>null</code>.
|
||||
*/
|
||||
public String getErrorLog() {
|
||||
return errorLog;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,63 +26,57 @@ import com.wudsn.ide.base.BasePlugin;
|
|||
|
||||
public final class Profiler {
|
||||
|
||||
public static final String PROPERTY_NAME = "com.wudsn.ide.common.base.Profiler";
|
||||
public static final String PROPERTY_NAME = "com.wudsn.ide.common.base.Profiler";
|
||||
|
||||
private static final class Entry {
|
||||
private static final class Entry {
|
||||
|
||||
public final long startTimeMillis;
|
||||
public final String description;
|
||||
public final long startTimeMillis;
|
||||
public final String description;
|
||||
|
||||
public Entry(String description) {
|
||||
if (description == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'description' must not be null.");
|
||||
}
|
||||
startTimeMillis = System.currentTimeMillis();
|
||||
this.description = description;
|
||||
}
|
||||
public Entry(String description) {
|
||||
if (description == null) {
|
||||
throw new IllegalArgumentException("Parameter 'description' must not be null.");
|
||||
}
|
||||
startTimeMillis = System.currentTimeMillis();
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
private Object owner;
|
||||
private Map<String, Entry> statistics;
|
||||
|
||||
public Profiler(Object owner) {
|
||||
if (owner == null) {
|
||||
throw new IllegalArgumentException("Parameter 'owner' must not be null.");
|
||||
}
|
||||
this.owner = owner;
|
||||
statistics = new HashMap<String, Entry>();
|
||||
}
|
||||
|
||||
public void end(String key) {
|
||||
Entry entry = statistics.get(key);
|
||||
if (entry == null) {
|
||||
throw new IllegalStateException("No begin for key '" + key + "'.");
|
||||
}
|
||||
|
||||
private Object owner;
|
||||
private Map<String, Entry> statistics;
|
||||
|
||||
public Profiler(Object owner) {
|
||||
if (owner == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'owner' must not be null.");
|
||||
}
|
||||
this.owner = owner;
|
||||
statistics = new HashMap<String, Entry>();
|
||||
if (Boolean.getBoolean(PROPERTY_NAME)) {
|
||||
Long duration = new Long((System.currentTimeMillis() - entry.startTimeMillis));
|
||||
if (entry.description.isEmpty()) {
|
||||
BasePlugin.getInstance().log("Time for '{0}:{1}' is {2}ms", new Object[] { owner, key, duration });
|
||||
} else {
|
||||
BasePlugin.getInstance().log("Time for '{0}:{1}' of {2} is {3}ms",
|
||||
new Object[] { owner, key, entry.description, duration });
|
||||
}
|
||||
}
|
||||
|
||||
public void end(String key) {
|
||||
Entry entry = statistics.get(key);
|
||||
if (entry == null) {
|
||||
throw new IllegalStateException("No begin for key '" + key + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.getBoolean(PROPERTY_NAME)) {
|
||||
Long duration = new Long(
|
||||
(System.currentTimeMillis() - entry.startTimeMillis));
|
||||
if (entry.description.isEmpty()) {
|
||||
BasePlugin.getInstance().log("Time for '{0}:{1}' is {2}ms",
|
||||
new Object[] { owner, key, duration });
|
||||
} else {
|
||||
BasePlugin.getInstance()
|
||||
.log("Time for '{0}:{1}' of {2} is {3}ms",
|
||||
new Object[] { owner, key, entry.description,
|
||||
duration });
|
||||
}
|
||||
}
|
||||
public void begin(String key) {
|
||||
begin(key, "");
|
||||
}
|
||||
|
||||
}
|
||||
public void begin(String key, String description) {
|
||||
statistics.put(key, new Entry(description));
|
||||
|
||||
public void begin(String key) {
|
||||
begin(key, "");
|
||||
}
|
||||
|
||||
public void begin(String key, String description) {
|
||||
statistics.put(key, new Entry(description));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -46,12 +46,10 @@ public class PropertiesSerializer {
|
|||
|
||||
protected final void setProperty(String key, String value) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'value' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'value' must not be null.");
|
||||
}
|
||||
|
||||
properties.put(key, value);
|
||||
|
@ -60,12 +58,10 @@ public class PropertiesSerializer {
|
|||
public final String readString(String key, String defaultValue) {
|
||||
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
if (defaultValue == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'defaultValue' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'defaultValue' must not be null.");
|
||||
}
|
||||
String result;
|
||||
result = properties.getProperty(key);
|
||||
|
@ -79,20 +75,17 @@ public class PropertiesSerializer {
|
|||
public final void writeString(String key, String value) {
|
||||
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'value' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'value' must not be null.");
|
||||
}
|
||||
setProperty(key, value);
|
||||
}
|
||||
|
||||
public boolean readBoolean(String key, boolean defaultValue) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
|
||||
}
|
||||
boolean result;
|
||||
|
@ -106,25 +99,20 @@ public class PropertiesSerializer {
|
|||
|
||||
public final void writeBoolean(String key, boolean value) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
properties.setProperty(key, Boolean.toString(value));
|
||||
}
|
||||
|
||||
public final <T extends Enum<?>> T readEnum(String key, T defaultValue,
|
||||
Class<T> enumClass) {
|
||||
public final <T extends Enum<?>> T readEnum(String key, T defaultValue, Class<T> enumClass) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
if (defaultValue == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'defaultValue' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'defaultValue' must not be null.");
|
||||
}
|
||||
if (enumClass == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'enumClass' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'enumClass' must not be null.");
|
||||
}
|
||||
T result;
|
||||
result = defaultValue;
|
||||
|
@ -146,12 +134,10 @@ public class PropertiesSerializer {
|
|||
|
||||
public final <T extends Enum<?>> void writeEnum(String key, T value) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'value' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'value' must not be null.");
|
||||
}
|
||||
setProperty(key, value.name());
|
||||
}
|
||||
|
@ -159,8 +145,7 @@ public class PropertiesSerializer {
|
|||
public final int readInteger(String key, int defaultValue) {
|
||||
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
|
||||
int result;
|
||||
|
@ -181,8 +166,7 @@ public class PropertiesSerializer {
|
|||
public final void writeInteger(String key, int value) {
|
||||
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
|
||||
setProperty(key, String.valueOf(value));
|
||||
|
@ -190,12 +174,10 @@ public class PropertiesSerializer {
|
|||
|
||||
public final void readProperties(String key, PropertiesSerializer value) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'value' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'value' must not be null.");
|
||||
}
|
||||
String prefix = key + ".";
|
||||
Properties valueProperties = value.getProperties();
|
||||
|
@ -204,29 +186,24 @@ public class PropertiesSerializer {
|
|||
while (i.hasMoreElements()) {
|
||||
String valueKey = (String) i.nextElement();
|
||||
if (valueKey.startsWith(prefix)) {
|
||||
valueProperties.setProperty(
|
||||
valueKey.substring(prefix.length()),
|
||||
properties.getProperty(valueKey));
|
||||
valueProperties.setProperty(valueKey.substring(prefix.length()), properties.getProperty(valueKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void writeProperties(String key, PropertiesSerializer value) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'key' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Parameter 'value' must not be null.");
|
||||
throw new IllegalArgumentException("Parameter 'value' must not be null.");
|
||||
}
|
||||
String prefix = key + ".";
|
||||
Properties valueProperties = value.getProperties();
|
||||
Enumeration<Object> i = valueProperties.keys();
|
||||
while (i.hasMoreElements()) {
|
||||
String valueKey = (String) i.nextElement();
|
||||
setProperty(prefix + valueKey,
|
||||
valueProperties.getProperty(valueKey));
|
||||
setProperty(prefix + valueKey, valueProperties.getProperty(valueKey));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
* Copyright (C) 2009 - 2019 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
|
@ -34,8 +34,7 @@ public abstract class RunnableWithLogging implements Runnable {
|
|||
runWithLogging();
|
||||
|
||||
} catch (Throwable th) {
|
||||
BasePlugin.getInstance().logError(
|
||||
"Runnable '{0}' ended with exception.",
|
||||
BasePlugin.getInstance().logError("Runnable '{0}' ended with exception.",
|
||||
new Object[] { getClass().getName() }, th);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user