Skip to content

Commit 98ab9b7

Browse files
committed
#7 Fix: null pointer on JSLiteralExpressionImpl.getValue
GoTo string paths like './dir/file', even if it does not end with '.js'
1 parent bbe91d2 commit 98ab9b7

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

resources/META-INF/plugin.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin>
22
<id>lv.midiana.misc.idea-plugins.deep-js-completion</id>
33
<name>deep-js-completion</name>
4-
<version>2018.10.18.001</version>
4+
<version>2018.10.25.001</version>
55
<vendor email="safronevev@gmail.com" url="http://midiana.lv/entry/deep-js-completion">Klesun</vendor>
66

77
<description><![CDATA[
@@ -26,7 +26,8 @@ This plugin will be highly inspired by my other plugin, <a href="https://plugins
2626
]]></description>
2727

2828
<change-notes><![CDATA[
29-
<li>Fix: null pointer on JSRootConfiguration.getInstance</li>
29+
<li>GoTo string paths like './dir/file', even if it does not end with '.js'</li>
30+
<li>Fix: null pointer on JSLiteralExpressionImpl.getValue</li>
3031
]]>
3132
</change-notes>
3233

src/org/klesun/deep_js_completion/entry/PathStrGoToDecl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ object PathStrGoToDecl {
1616
def getReferencedFile(relPath: String, caretFile: PsiFile): Option[PsiFile] = {
1717
Option(caretFile.getContainingDirectory)
1818
.flatMap(f => Option(f.getVirtualFile))
19-
.map(f => f.getPath + "/" + relPath)
19+
.map(f => f.getPath + "/" + relPath + (if (relPath.matches(".*\\.[a-zA-Z0-9]+$")) "" else ".js"))
2020
.flatMap(fullPath => Option(LocalFileSystem.getInstance.findFileByPath(fullPath)))
2121
.flatMap(f => Option(PsiManager.getInstance(caretFile.getProject).findFile(f)))
2222
}
2323

2424
def getReferencedFile(expr: JSExpression): Option[PsiFile] = {
2525
cast[JSLiteralExpressionImpl](expr)
2626
.flatMap(lit => {
27-
val relPath = lit.getValue.toString
27+
val relPath = Option(lit.getValue).map(_.toString).getOrElse("")
2828
if (relPath.startsWith("./") || relPath.startsWith("../")) {
2929
Option(lit.getContainingFile)
3030
.flatMap(f => getReferencedFile(relPath, f))

tests/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
let ssrLineNumbers = [];
44

55
var klesun = Klesun();
6-
klesun.requires('./Tls.js').then = Tls =>
6+
klesun.requires('./Tls').then = Tls =>
77
klesun.whenLoaded = () => (...ctorParams) => {
88
let tls = Tls();
99
// should suggest: opt, promise, http, mkDom, range, deepCopy

0 commit comments

Comments
 (0)