Skip to content

Commit 28f44e5

Browse files
committed
update to 1.1.0
1 parent 9a15cc6 commit 28f44e5

File tree

4 files changed

+34
-44
lines changed

4 files changed

+34
-44
lines changed

README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ intellij-idea-plugins
1717

1818
I have some website to learn. If you have good resource, please share to me. Thx ^_^
1919

20-
1. [http://bjorn.tipling.com/how-to-make-an-intellij-idea-plugin-in-30-minutes](http://bjorn.tipling.com/how-to-make-an-intellij-idea-plugin-in-30-minutes)
20+
1. [How to make an IntelliJ IDEA plugin in less than 30 minutes](http://bjorn.tipling.com/how-to-make-an-intellij-idea-plugin-in-30-minutes)
2121

22-
2. [https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Action+System](https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Action+System)
22+
2. [Action System](http://www.jetbrains.org/intellij/sdk/docs/basics/action_system.html)
2323

24-
3. [https://confluence.jetbrains.com/display/IDEADEV/Getting+Started+with+Plugin+Development](https://confluence.jetbrains.com/display/IDEADEV/Getting+Started+with+Plugin+Development)
24+
3. [Creating Your First Plugin](http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started.html)
2525

26-
4. [http://blog.csdn.net/dc_726/article/details/14139155](http://blog.csdn.net/dc_726/article/details/14139155) - chinese
26+
4. [Intellij IDEA插件开发入门](http://blog.csdn.net/dc_726/article/details/14139155) - chinese
27+
28+
5. [Plugin Compatibility with IntelliJ Platform Products](http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html)
2729

2830
<br />
2931
### Feedback
3032
3133
* QQ: 1321271684
32-
* blog: [blog.csdn.net/luonanqin](http://blog.csdn.net/luonanqin)
34+
* blog: [blog.csdn.net/luonanqin](http://blog.csdn.net/luonanqin)

ScrollFromSource/META-INF/plugin.xml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<idea-plugin version="2">
22
<id>luonq.ScrollFromSource</id>
33
<name>Scroll From Source</name>
4-
<version>1.0.1</version>
4+
<version>1.1.0</version>
55
<vendor email="[email protected]" url="https://github.com/luonanqin/intellij-idea-plugins/tree/master/ScrollFromSource">luonanqin</vendor>
6-
6+
<depends>com.intellij.modules.lang</depends>
77
<description><![CDATA[
88
Set the keyboard shortcut to the function of "Scroll From Source" in Project Panel.<br>
99
<br>
@@ -21,11 +21,16 @@
2121
<ul>
2222
<li>Fix bug to adapt Intellij idea 14</li>
2323
</ul>
24+
<p>1.1.0:</p>
25+
<ul>
26+
<li>Discard use reflecting to solve this problem</li>
27+
<li>Fix bug to adapt Intellij idea 15 & WebStorm 11</li>
28+
</ul>
2429
]]>
2530
</change-notes>
2631

2732
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
28-
<idea-version since-build="131.0"/>
33+
<idea-version since-build="143.0"/>
2934

3035
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
3136
on how to target different products -->

ScrollFromSource/ScrollFromSource.iml

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
<content url="file://$MODULE_DIR$">
77
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
88
</content>
9-
<orderEntry type="jdk" jdkName="IDEA IC-123.169" jdkType="IDEA JDK" />
9+
<orderEntry type="inheritedJdk" />
1010
<orderEntry type="sourceFolder" forTests="false" />
1111
</component>
12-
</module>
13-
12+
</module>
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package luonq;
22

33
import com.intellij.ide.projectView.ProjectView;
4-
import com.intellij.ide.projectView.impl.ProjectViewImpl;
54
import com.intellij.openapi.actionSystem.AnAction;
65
import com.intellij.openapi.actionSystem.AnActionEvent;
6+
import com.intellij.openapi.actionSystem.CommonDataKeys;
77
import com.intellij.openapi.diagnostic.Logger;
88
import com.intellij.openapi.project.Project;
9-
10-
import java.lang.reflect.Field;
11-
import java.lang.reflect.Method;
9+
import com.intellij.openapi.vfs.VirtualFile;
10+
import com.intellij.psi.PsiFileSystemItem;
11+
import com.intellij.psi.PsiManager;
1212

1313
/**
1414
* Created by Luonanqin on 11/13/14.
@@ -18,38 +18,22 @@ public class ScrollFromSource extends AnAction {
1818
private static final Logger LOG = Logger.getInstance(ScrollFromSource.class);
1919

2020
public void actionPerformed(AnActionEvent e) {
21-
try {
22-
Project project = e.getProject();
23-
ProjectViewImpl projectView = (ProjectViewImpl) ProjectView.getInstance(project);
24-
25-
Class<ProjectViewImpl> clazz = ProjectViewImpl.class;
26-
27-
Field[] fields = clazz.getDeclaredFields();
28-
Field myAutoScrollFromSourceHandlerField = null;
29-
for (int i = 0; i < fields.length; i++) {
30-
Field field = fields[i];
31-
// can't use field's name to find the variable of MyAutoScrollFromSourceHandler
32-
if ("MyAutoScrollFromSourceHandler".equals(field.getType().getSimpleName())) {
33-
myAutoScrollFromSourceHandlerField = field;
34-
}
35-
}
3621

37-
myAutoScrollFromSourceHandlerField.setAccessible(true);
38-
Object handler = myAutoScrollFromSourceHandlerField.get(projectView);
39-
40-
Class<?>[] clazzes = clazz.getDeclaredClasses();
41-
for (int i = 0; i < clazzes.length; i++) {
42-
Class<?> clazze = clazzes[i];
43-
String simpleName = clazze.getSimpleName();
44-
if ("MyAutoScrollFromSourceHandler".equals(simpleName)) {
45-
Method fromSource = clazze.getMethod("scrollFromSource");
46-
fromSource.setAccessible(true);
47-
fromSource.invoke(handler);
48-
return;
22+
Project project = e.getProject();
23+
VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
24+
25+
if (project != null && file != null) {
26+
VirtualFile target = file.getCanonicalFile();
27+
28+
if (target != null) {
29+
PsiManager psiManager = PsiManager.getInstance(project);
30+
PsiFileSystemItem psiFile = target.isDirectory() ? psiManager.findDirectory(target) : psiManager.findFile(target);
31+
32+
if (psiFile != null) {
33+
ProjectView.getInstance(project).select(psiFile, target, false);
34+
4935
}
5036
}
51-
} catch (Exception ex) {
52-
LOG.error("ScrollFromSource execute ERROR!", ex);
5337
}
5438
}
5539
}

0 commit comments

Comments
 (0)