Merge remote-tracking branch 'origin/GT-3514-dragonmacher-find-uses-exception'

This commit is contained in:
ghidorahrex 2020-02-04 13:11:30 -05:00
commit c236edea6e
4 changed files with 28 additions and 20 deletions

View file

@ -24,6 +24,8 @@ import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import docking.widgets.fieldpanel.field.FieldElement; import docking.widgets.fieldpanel.field.FieldElement;
import docking.widgets.fieldpanel.support.FieldLocation; import docking.widgets.fieldpanel.support.FieldLocation;
import docking.widgets.fieldpanel.support.Highlight; import docking.widgets.fieldpanel.support.Highlight;
@ -450,16 +452,14 @@ public class ListingHighlightProvider
text = StringUtilities.findWord(text, pos, UNDERSCORE_AND_PERIOD_OK); text = StringUtilities.findWord(text, pos, UNDERSCORE_AND_PERIOD_OK);
} }
if (text != null) { if (StringUtils.isBlank(text)) {
text = text.trim();
if (text.length() == 0) {
text = null; text = null;
} }
} else {
text = text.trim();
if (text != null) {
currentHighlightPattern = Pattern.compile(text, Pattern.LITERAL); currentHighlightPattern = Pattern.compile(text, Pattern.LITERAL);
} }
return text; return text;
} }

View file

@ -125,7 +125,8 @@ public class LocationReferencesPlugin extends Plugin
private void displayProviderForLocation(ProgramLocation location, Navigatable navigatable) { private void displayProviderForLocation(ProgramLocation location, Navigatable navigatable) {
LocationDescriptor locationDescriptor = getLocationDescriptor(location); LocationDescriptor locationDescriptor = getLocationDescriptor(location);
if (locationDescriptor == null) { if (locationDescriptor == null) {
throw new IllegalArgumentException("Unable to display provider - unknown location"); throw new IllegalArgumentException(
"Unable to display provider - unknown location: " + location);
} }
LocationReferencesProvider provider = findProvider(locationDescriptor, navigatable); LocationReferencesProvider provider = findProvider(locationDescriptor, navigatable);

View file

@ -711,16 +711,9 @@ public final class ReferenceUtils {
return null; return null;
} }
List<Object> objects = variableOffset.getObjects();
Object object = objects.get((int) variableOffset.getOffset());
if (!(object instanceof LabelString)) {
return null;
}
Variable variable = variableOffset.getVariable(); Variable variable = variableOffset.getVariable();
DataType type = variable.getDataType(); DataType type = variable.getDataType();
LabelString label = (LabelString) object; String string = variableOffset.getDataTypeDisplayText();
String string = label.toString();
GenericDataTypeLocationDescriptor descriptor = GenericDataTypeLocationDescriptor descriptor =
createGenericDataTypeLocationDescriptor(program, type, string); createGenericDataTypeLocationDescriptor(program, type, string);
return descriptor; return descriptor;

View file

@ -120,16 +120,22 @@ public class VariableOffset {
} }
/** /**
* Get list of markup objects * Returns the data type access portion of this variable offset as a string
* @return list of markup objects * @return the text
*/ */
public List<Object> getObjects() { public String getDataTypeDisplayText() {
List<Object> objects = getObjects(false);
LabelString labelString = (LabelString) objects.get(0);
return labelString.toString();
}
private List<Object> getObjects(boolean showScalarAdjustment) {
DataType dt = variable.getDataType(); DataType dt = variable.getDataType();
StringBuffer name = new StringBuffer(variable.getName()); StringBuffer name = new StringBuffer(variable.getName());
long scalarAdjustment = 0; long scalarAdjustment = 0;
if (includeScalarAdjustment && (replacedElement instanceof Scalar)) { if (showScalarAdjustment && (replacedElement instanceof Scalar)) {
Scalar s = (Scalar) replacedElement; Scalar s = (Scalar) replacedElement;
scalarAdjustment = variable.isStackVariable() ? s.getSignedValue() : s.getValue(); scalarAdjustment = variable.isStackVariable() ? s.getSignedValue() : s.getValue();
scalarAdjustment -= offset; scalarAdjustment -= offset;
@ -214,6 +220,14 @@ public class VariableOffset {
return list; return list;
} }
/**
* Get list of markup objects
* @return list of markup objects
*/
public List<Object> getObjects() {
return getObjects(includeScalarAdjustment);
}
public Variable getVariable() { public Variable getVariable() {
return variable; return variable;
} }