Skip to content

Commit f669ff2

Browse files
author
angelozerr
committed
Select item after selection of quick outline + select item with Outline.
See #51 and #38
1 parent 2666e20 commit f669ff2

File tree

21 files changed

+535
-329
lines changed

21 files changed

+535
-329
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package ts.client;
2+
3+
public interface IKindProvider {
4+
5+
String getKind();
6+
7+
String getKindModifiers();
8+
}

core/ts.core/src/ts/client/Location.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
*/
1717
public class Location {
1818

19-
private final int line;
20-
private final int offset;
19+
private int line;
20+
private int offset;
21+
22+
public Location() {
23+
24+
}
2125

2226
public Location(int line, int offset) {
2327
this.line = line;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package ts.client.completions;
22

3-
public interface ICompletionEntry {
3+
import ts.client.IKindProvider;
4+
5+
public interface ICompletionEntry extends IKindProvider{
46

57
ICompletionEntry[] EMPTY_ENTRIES = new ICompletionEntry[0];
68

79
String getName();
810

9-
String getKind();
10-
11-
String getKindModifiers();
12-
1311
String getSortText();
1412
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package ts.client.navbar;
22

3-
public interface INavigationBarItem {
3+
import ts.client.IKindProvider;
4+
5+
public interface INavigationBarItem extends IKindProvider{
46

57
}

core/ts.core/src/ts/client/navbar/Location.java

-7
This file was deleted.

core/ts.core/src/ts/client/navbar/NavigationBarItem.java

+21-7
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,31 @@ public String getText() {
1414
return text;
1515
}
1616

17+
@Override
18+
public String getKind() {
19+
return kind;
20+
}
21+
22+
@Override
23+
public String getKindModifiers() {
24+
return kindModifiers;
25+
}
26+
1727
public void setText(String text) {
1828
this.text = text;
1929
}
2030

21-
// public void setSpansA(List<TextSpan> spans) {
22-
// this.spans = spans;
23-
// }
24-
//
25-
// public List<TextSpan> getSpansA() {
26-
// return spans;
27-
// }
31+
public void setSpans(List<TextSpan> spans) {
32+
this.spans = spans;
33+
}
34+
35+
public List<TextSpan> getSpans() {
36+
return spans;
37+
}
38+
39+
public boolean hasSpans() {
40+
return spans != null && spans.size() > 0;
41+
}
2842

2943
public List<NavigationBarItem> getChildItems() {
3044
return childItems;
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
package ts.client.navbar;
22

3+
import ts.client.Location;
4+
35
public class TextSpan {
46

5-
public Location start;
6-
public Location end;
7+
private Location start;
8+
private Location end;
9+
10+
public Location getStart() {
11+
return start;
12+
}
13+
14+
public void setStart(Location start) {
15+
this.start = start;
16+
}
17+
18+
public Location getEnd() {
19+
return end;
20+
}
21+
22+
public void setEnd(Location end) {
23+
this.end = end;
24+
}
725

826
}

core/ts.core/src/ts/resources/AbstractTypeScriptFile.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public int getPosition(int line, int offset) throws TypeScriptException {
7373
throw new UnsupportedOperationException();
7474
}
7575

76+
@Override
77+
public int getPosition(Location loc) throws TypeScriptException {
78+
return getPosition(loc.getLine(), loc.getOffset());
79+
}
80+
7681
@Override
7782
public void open() throws TypeScriptException {
7883
((TypeScriptProject) tsProject).openFile(this);
@@ -220,7 +225,7 @@ public void removeNavbarListener(INavbarListener listener) {
220225
public List<NavigationBarItem> getNavBar() {
221226
return navbar;
222227
}
223-
228+
224229
// @Override
225230
// public List<NavigationBarItem> getNavBar() throws TypeScriptException {
226231
// TypeScriptNavBarCollector c = new TypeScriptNavBarCollector();

core/ts.core/src/ts/resources/ITypeScriptFile.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ public interface ITypeScriptFile {
6464
String getPrefix(int position);
6565

6666
Location getLocation(int position) throws TypeScriptException;
67-
67+
6868
int getPosition(int line, int offset) throws TypeScriptException;
6969

70+
int getPosition(Location loc) throws TypeScriptException;
71+
7072
String getContents();
7173

7274
/**

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/plugin.properties

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ TypeScriptCompletionProposalCategory.name=TypeScript Proposals
1515
TypeScriptHyperLinkDetector=TypeScript Element
1616

1717
# Editor
18+
JavaScriptEditor.name=JavaScript (Salsa) Editor
1819
TypeScriptEditor.name=TypeScript Editor
1920

2021
# Hover

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/plugin.xml

+17
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,24 @@
2626
class="org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaDocumentSetupParticipant">
2727
</participant>
2828
</extension>
29+
30+
<!-- JavaScript Editor -->
31+
<extension
32+
point="org.eclipse.ui.editors">
33+
<editor
34+
name="%JavaScriptEditor.name"
35+
default="false"
36+
icon="$nl$/icons/full/obj16/ts.png"
37+
contributorClass="ts.eclipse.ide.jsdt.internal.ui.editor.TypeScriptEditorActionContributor"
38+
class="ts.eclipse.ide.jsdt.internal.ui.editor.TypeScriptEditor"
39+
symbolicFontName="org.eclipse.wst.jsdt.ui.editors.textfont"
40+
id="ts.eclipse.ide.jsdt.ui.editor.JavaScriptScriptEditor"
41+
extensions="js">
42+
<contentTypeBinding contentTypeId="org.eclipse.wst.jsdt.core.jsSource" />
43+
</editor>
44+
</extension>
2945

46+
<!-- TypeScript Editor -->
3047
<extension
3148
point="org.eclipse.ui.editors">
3249
<editor

eclipse/jsdt/ts.eclipse.ide.jsdt.ui/src/ts/eclipse/ide/jsdt/internal/ui/editor/JavaScriptLightWeightEditor.java

+49
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
import org.eclipse.jface.text.source.projection.ProjectionSupport;
3535
import org.eclipse.jface.text.source.projection.ProjectionViewer;
3636
import org.eclipse.jface.util.PropertyChangeEvent;
37+
import org.eclipse.jface.viewers.IPostSelectionProvider;
38+
import org.eclipse.jface.viewers.ISelectionChangedListener;
39+
import org.eclipse.jface.viewers.ISelectionProvider;
3740
import org.eclipse.swt.custom.StyledText;
3841
import org.eclipse.swt.graphics.Point;
3942
import org.eclipse.swt.widgets.Composite;
@@ -81,6 +84,52 @@ public class JavaScriptLightWeightEditor extends AbstractDecoratedTextEditor {
8184
/** The bracket inserter. */
8285
private BracketInserter fBracketInserter = new BracketInserter(this);
8386

87+
/**
88+
* Internal implementation class for a change listener.
89+
*
90+
*/
91+
protected abstract class AbstractSelectionChangedListener implements ISelectionChangedListener {
92+
93+
/**
94+
* Installs this selection changed listener with the given selection
95+
* provider. If the selection provider is a post selection provider,
96+
* post selection changed events are the preferred choice, otherwise
97+
* normal selection changed events are requested.
98+
*
99+
* @param selectionProvider
100+
*/
101+
public void install(ISelectionProvider selectionProvider) {
102+
if (selectionProvider == null)
103+
return;
104+
105+
if (selectionProvider instanceof IPostSelectionProvider) {
106+
IPostSelectionProvider provider = (IPostSelectionProvider) selectionProvider;
107+
provider.addPostSelectionChangedListener(this);
108+
} else {
109+
selectionProvider.addSelectionChangedListener(this);
110+
}
111+
}
112+
113+
/**
114+
* Removes this selection changed listener from the given selection
115+
* provider.
116+
*
117+
* @param selectionProvider
118+
* the selection provider
119+
*/
120+
public void uninstall(ISelectionProvider selectionProvider) {
121+
if (selectionProvider == null)
122+
return;
123+
124+
if (selectionProvider instanceof IPostSelectionProvider) {
125+
IPostSelectionProvider provider = (IPostSelectionProvider) selectionProvider;
126+
provider.removePostSelectionChangedListener(this);
127+
} else {
128+
selectionProvider.removeSelectionChangedListener(this);
129+
}
130+
}
131+
}
132+
84133
/**
85134
* This editor's projection support
86135
*

0 commit comments

Comments
 (0)