Skip to content

Commit 79e4643

Browse files
committed
Minor change at tree content provider mechanism
- Input element null now handled by tree content provider as well
1 parent b7aa8d7 commit 79e4643

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

basheditor-plugin/src/main/java-eclipse/de/jcup/basheditor/outline/BashEditorTreeContentProvider.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class BashEditorTreeContentProvider implements ITreeContentProvider {
4040
@Override
4141
public Object[] getElements(Object inputElement) {
4242
synchronized (monitor) {
43-
if (!(inputElement instanceof BashScriptModel)) {
43+
if (inputElement!=null && !(inputElement instanceof BashScriptModel)) {
4444
return new Object[] { "Unsupported input element:"+inputElement };
4545
}
4646
if (items != null && items.length > 0) {
@@ -73,6 +73,7 @@ private Item[] createItems(BashScriptModel model) {
7373
item.type = ItemType.FUNCTION;
7474
item.offset = function.getPosition();
7575
item.length = function.getLengthToNameEnd();
76+
item.endOffset=function.getEnd();
7677
list.add(item);
7778
}
7879
if (list.isEmpty()) {
@@ -81,6 +82,7 @@ private Item[] createItems(BashScriptModel model) {
8182
item.type = ItemType.META_INFO;
8283
item.offset = 0;
8384
item.length = 0;
85+
item.endOffset=0;
8486
list.add(item);
8587
}
8688
if (model.hasErrors()) {
@@ -89,6 +91,7 @@ private Item[] createItems(BashScriptModel model) {
8991
item.type = ItemType.META_ERROR;
9092
item.offset = 0;
9193
item.length = 0;
94+
item.endOffset=0;
9295
list.add(0, item);
9396
}
9497
/* debug part*/
@@ -99,6 +102,7 @@ private Item[] createItems(BashScriptModel model) {
99102
item.type = ItemType.META_DEBUG;
100103
item.offset = token.getStart();
101104
item.length = token.getText().length();
105+
item.endOffset=token.getEnd();
102106
list.add(item);
103107
}
104108
}
@@ -127,7 +131,7 @@ public Item tryToFindByOffset(int offset) {
127131
}
128132
Item item = (Item) oitem;
129133
int itemStart = item.getOffset();
130-
int itemEnd = itemStart+item.getLength();
134+
int itemEnd = item.getEndOffset();// old: itemStart+item.getLength();
131135
if (offset >= itemStart && offset<=itemEnd ){
132136
return item;
133137
}

0 commit comments

Comments
 (0)