Skip to content

Commit

Permalink
secure children calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Haehnchen committed Feb 27, 2024
1 parent 482db5b commit 856b5b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import org.jetbrains.vuejs.index.VueFrameworkHandlerKt;
import org.jetbrains.vuejs.lang.html.VueFile;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* @author Daniel Espendiller <[email protected]>
Expand Down Expand Up @@ -82,10 +79,12 @@ public static Map<String, List<String>> getSameDirectoryComponentsForIndex(@NotN

Map<String, String> directoryScope = new HashMap<>();

VirtualFile[] vueFiles = Arrays.stream(vueFile
.getVirtualFile()
.getParent()
.getChildren())
VirtualFile parent = vueFile.getVirtualFile().getParent();
if (parent == null) {
return Collections.emptyMap();
}

VirtualFile[] vueFiles = Arrays.stream(parent.getChildren())
.filter(v -> "vue".equalsIgnoreCase(v.getExtension()) && !v.getName().equalsIgnoreCase(vueFile.getName()))
.toArray(VirtualFile[]::new);

Expand Down
19 changes: 11 additions & 8 deletions src/main/java/de/espend/idea/vuejs/utils/VueJsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,18 @@ private void visitES6ImportedBinding(@NotNull String name, ES6ImportedBinding es


// current directory scope
for (VirtualFile child : containingFile.getVirtualFile().getParent().getChildren()) {
String name = child.getName();
if (!name.endsWith(".vue")) {
continue;
}
VirtualFile parent = containingFile.getVirtualFile().getParent();
if (parent != null) {
for (VirtualFile child : parent.getChildren()) {
String name = child.getName();
if (!name.endsWith(".vue")) {
continue;
}

String substring = name.substring(0, name.length() - 4);
components.putIfAbsent(substring, "./" + name);
components.putIfAbsent(VueJsUtil.convertToKebabCase(substring), "./" + name);
String substring = name.substring(0, name.length() - 4);
components.putIfAbsent(substring, "./" + name);
components.putIfAbsent(VueJsUtil.convertToKebabCase(substring), "./" + name);
}
}

return components;
Expand Down

0 comments on commit 856b5b5

Please sign in to comment.