GT-2376: added new task monitor service

This commit is contained in:
adamopolous 2019-04-04 12:36:36 -04:00
parent 538cbc1226
commit f57af0b730
28 changed files with 1363 additions and 558 deletions

View file

@ -281,9 +281,11 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
throws IOException, VersionException, LanguageNotFoundException, CancelledException {
super(dbh, "Untitled", 500, 1000, consumer);
if (monitor == null) {
monitor = TaskMonitorAdapter.DUMMY_MONITOR;
monitor = TaskMonitorAdapter.DUMMY;
}
boolean success = false;
try {
int id = startTransaction("create program");
@ -294,6 +296,7 @@ public class ProgramDB extends DomainObjectAdapterDB implements Program, ChangeM
VersionException dbVersionExc = initializeDatabase(openMode);
VersionException languageVersionExc = null;
try {
language = DefaultLanguageService.getLanguageService().getLanguage(languageID);
languageVersionExc = checkLanguageVersion(openMode);

View file

@ -28,18 +28,19 @@ public interface LanguageProvider extends ExtensionPoint {
/**
* Returns the language with the given name or null if no language has that name
* @param name the name of the language to be retrieved
* @return the language with the given name
*
* @param languageId the name of the language to be retrieved
* @return the {@link Language} with the given name
*/
Language getLanguage(LanguageID languageId);
/**
* Returns a list of language descriptions provided by this provider
*/
LanguageDescription[] getLanguageDescriptions();
/**
* @return true if one of more laguages or language description failed to load
* @return true if one of more languages or language description failed to load
* properly.
*/
boolean hadLoadFailure();

View file

@ -27,12 +27,13 @@ import java.util.List;
public interface LanguageService {
/**
* Returns the language with the given language ID.
* @param languageID the ID of language to retrieve.
* @throws LanguageNotFoundException if no language can be found for the given ID.
* Returns the language with the given language ID
* @param languageID the ID of language to retrieve
* @return the {@link Language} matching the given ID
* @throws LanguageNotFoundException if no language can be found for the given ID
*/
Language getLanguage(LanguageID languageID) throws LanguageNotFoundException;
/**
* Returns the default Language to use for the given processor;
* @param processor the processor for which to get a language.
@ -59,13 +60,14 @@ public interface LanguageService {
/**
* Returns all known language descriptions which satisfy the criteria identify by the
* non-null parameters. A null value implies a don't-care wildcard value.
* @param processor
* @param endianess
* @param size
* @param variant
* @return
* @deprecated
* @param processor the processor for which to get a language
* @param endianess big or little
* @param size processor address space size (in bits)
* @param variant the processor version (usually 'default')
* @return the language descriptions that fit the parameters
* @deprecated use {@link #getLanguageDescriptions(Processor)} instead
*/
@Deprecated
List<LanguageDescription> getLanguageDescriptions(Processor processor, Endian endianess,
Integer size, String variant);

View file

@ -27,6 +27,8 @@ import generic.jar.ResourceFile;
import ghidra.app.plugin.processors.sleigh.SleighLanguageProvider;
import ghidra.program.model.lang.*;
import ghidra.util.classfinder.ClassSearcher;
import ghidra.util.task.TaskMonitor;
import ghidra.util.task.TaskMonitorService;
/**
* Default Language service used gather up all the languages that were found
@ -43,6 +45,7 @@ public class DefaultLanguageService implements LanguageService, ChangeListener {
/**
* Returns the single instance of the DefaultLanguageService.
* @return the language service
*/
public static synchronized LanguageService getLanguageService() {
if (languageService == null) {
@ -94,13 +97,23 @@ public class DefaultLanguageService implements LanguageService, ChangeListener {
*/
@Override
public Language getLanguage(LanguageID languageID) throws LanguageNotFoundException {
LanguageInfo info = languageMap.get(languageID);
if (info == null) {
throw new LanguageNotFoundException(languageID);
TaskMonitor monitor = TaskMonitorService.getMonitor();
monitor.setMessage("Retrieving language: " + languageID);
try {
LanguageInfo info = languageMap.get(languageID);
if (info == null) {
throw new LanguageNotFoundException(languageID);
}
Language lang = info.getLanguage();
return lang;
}
finally {
monitor.setMessage("");
}
return info.getLanguage();
}
/**
@ -161,8 +174,9 @@ public class DefaultLanguageService implements LanguageService, ChangeListener {
private static boolean languageMatchesExternalProcessor(LanguageDescription description,
String externalProcessorName, String externalTool) {
boolean result = false;
if (externalProcessorName == null)
if (externalProcessorName == null) {
result = true;
}
else if (externalTool != null) {
List<String> extNames = description.getExternalNames(externalTool);
if (extNames != null) {