Skip to content

Commit 0fdafd6

Browse files
committed
Fix #131
1 parent 564f3da commit 0fdafd6

File tree

6 files changed

+82
-7
lines changed

6 files changed

+82
-7
lines changed

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/TypeScriptUIMessages.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ public class TypeScriptUIMessages extends NLS {
138138
public static String AbstractAnnotationHover_message_singleQuickFix;
139139
public static String AbstractAnnotationHover_message_multipleQuickFix;
140140

141+
// Implementation
142+
public static String TypeScriptImplementationLabelProvider_text;
143+
141144
public static ResourceBundle getResourceBundle() {
142145
try {
143146
if (fResourceBundle == null)

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/internal/ui/TypeScriptUIMessages.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,7 @@ Launch_MainTab_Not_a_directory=The specified location is not a directory
113113

114114
# Hover
115115
AbstractAnnotationHover_message_singleQuickFix= 1 quick fix available:
116-
AbstractAnnotationHover_message_multipleQuickFix= {0} quick fixes available:
116+
AbstractAnnotationHover_message_multipleQuickFix= {0} quick fixes available:
117+
118+
# Implementation
119+
TypeScriptImplementationLabelProvider_text=''{0}''.

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/implementation/TypeScriptImplementationContentProvider.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* Copyright (c) 2015-2017 Angelo ZERR.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Angelo Zerr <[email protected]> - initial API and implementation
10+
*/
111
package ts.eclipse.ide.ui.implementation;
212

313
import java.util.List;
@@ -8,7 +18,6 @@ public class TypeScriptImplementationContentProvider implements ITreeContentProv
818

919
@Override
1020
public Object[] getChildren(Object arg0) {
11-
// TODO Auto-generated method stub
1221
return null;
1322
}
1423

@@ -28,7 +37,6 @@ public Object getParent(Object arg0) {
2837

2938
@Override
3039
public boolean hasChildren(Object arg0) {
31-
// TODO Auto-generated method stub
3240
return false;
3341
}
3442

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/implementation/TypeScriptImplementationDialog.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* Copyright (c) 2015-2017 Angelo ZERR.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Angelo Zerr <[email protected]> - initial API and implementation
10+
*/
111
package ts.eclipse.ide.ui.implementation;
212

313
import java.util.ArrayList;
@@ -14,6 +24,10 @@
1424
import ts.eclipse.ide.ui.TypeScriptUIPlugin;
1525
import ts.resources.ITypeScriptFile;
1626

27+
/**
28+
* Popiup dialog which shows implementation for a given text selection.
29+
*
30+
*/
1731
public class TypeScriptImplementationDialog extends AbstractInformationControl {
1832

1933
public TypeScriptImplementationDialog(Shell parent, int shellStyle, ITypeScriptFile tsFile) {
@@ -27,12 +41,11 @@ public void setInput(Object input) {
2741
try {
2842
final TreeViewer treeViewer = getTreeViewer();
2943
tsFile.implementation(selection.getOffset()).thenAccept(spans -> {
30-
if (treeViewer != null) {
44+
if (treeViewer != null && spans != null && spans.size() > 0) {
3145
treeViewer.getTree().getDisplay().asyncExec(new Runnable() {
3246

3347
@Override
3448
public void run() {
35-
System.err.println("refresh");
3649
treeViewer.setInput(spans);
3750
}
3851
});
Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,65 @@
1+
/**
2+
* Copyright (c) 2015-2017 Angelo ZERR.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Angelo Zerr <[email protected]> - initial API and implementation
10+
*/
111
package ts.eclipse.ide.ui.implementation;
212

13+
import org.eclipse.core.resources.IFile;
314
import org.eclipse.jface.viewers.LabelProvider;
15+
import org.eclipse.osgi.util.NLS;
16+
import org.eclipse.swt.graphics.Image;
17+
import org.eclipse.ui.model.WorkbenchLabelProvider;
418

519
import ts.client.FileSpan;
20+
import ts.eclipse.ide.core.utils.WorkbenchResourceUtil;
21+
import ts.eclipse.ide.internal.ui.TypeScriptUIMessages;
622

23+
/**
24+
* TypeScript implementation label provider.
25+
*
26+
*/
727
public class TypeScriptImplementationLabelProvider extends LabelProvider {
828

29+
private static final WorkbenchLabelProvider INSTANCE = new WorkbenchLabelProvider();
30+
931
@Override
1032
public String getText(Object element) {
1133
if (element instanceof FileSpan) {
12-
34+
String filename = getFilename(((FileSpan) element));
35+
return NLS.bind(TypeScriptUIMessages.TypeScriptImplementationLabelProvider_text, filename);
1336
}
1437
return super.getText(element);
1538
}
39+
40+
private String getFilename(FileSpan span) {
41+
IFile file = getEclipseFile(span);
42+
return file != null ? file.getFullPath().toString() : span.getFile();
43+
}
44+
45+
private IFile getEclipseFile(FileSpan span) {
46+
String filename = span.getFile();
47+
IFile file = WorkbenchResourceUtil.findFileFromWorkspace(filename);
48+
if (file != null) {
49+
return file;
50+
}
51+
return null;
52+
}
53+
54+
@Override
55+
public Image getImage(Object element) {
56+
if (element instanceof FileSpan) {
57+
IFile file = getEclipseFile((FileSpan) element);
58+
if (file != null) {
59+
return INSTANCE.getImage(file);
60+
}
61+
}
62+
return super.getImage(element);
63+
}
64+
1665
}

eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/search/TypeScriptSearchQuery.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
8686
ReferencesResponseBody references = tsFile.references(offset).get(20000, TimeUnit.MILLISECONDS);
8787
for (ReferencesResponseItem reference : references.getRefs()) {
8888
addRef(reference, tsResult);
89-
9089
}
9190
}
9291
} finally {

0 commit comments

Comments
 (0)