bytedance / flutter_asset_literal_idea_plugin

GNU General Public License v2.0
36 stars 16 forks source link

error when use plugin #16

Open ayman-hub opened 1 year ago

ayman-hub commented 1 year ago

dear sir I am getting this error when using this plugin can you help me

java.lang.Throwable: filtered path list is empty at com.intellij.openapi.diagnostic.Logger.error(Logger.java:184) at com.ixigua.completion.contributor.AssetLiteralCompletionContributor.assetsForPrefix(AssetLiteralCompletionContributor.java:83) at com.ixigua.completion.contributor.AssetLiteralCompletionContributor$1.addCompletions(AssetLiteralCompletionContributor.java:47) at com.intellij.codeInsight.completion.CompletionProvider.addCompletionVariants(CompletionProvider.java:25) at com.intellij.codeInsight.completion.CompletionContributor.fillCompletionVariants(CompletionContributor.java:157) at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:76) at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:154) at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:146) at com.intellij.codeInsight.completion.CompletionResultSet.runRemainingContributors(CompletionResultSet.java:142) at com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor$1.addCompletions(LiveTemplateCompletionContributor.java:91) at com.intellij.codeInsight.completion.CompletionProvider.addCompletionVariants(CompletionProvider.java:25) at com.intellij.codeInsight.completion.CompletionContributor.fillCompletionVariants(CompletionContributor.java:157) at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:76) at com.intellij.codeInsight.completion.CompletionService.getVariantsFromContributors(CompletionService.java:59) at com.intellij.codeInsight.completion.CompletionService.performCompletion(CompletionService.java:132) at com.intellij.codeInsight.completion.BaseCompletionService.performCompletion(BaseCompletionService.java:43) at com.intellij.codeInsight.completion.CompletionProgressIndicator.lambda$calculateItems$11(CompletionProgressIndicator.java:870) at com.intellij.util.indexing.FileBasedIndex.lambda$ignoreDumbMode$0(FileBasedIndex.java:202) at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:114) at com.intellij.util.indexing.FileBasedIndexEx.ignoreDumbMode(FileBasedIndexEx.java:663) at com.intellij.util.indexing.FileBasedIndex.ignoreDumbMode(FileBasedIndex.java:201) at com.intellij.util.indexing.DumbModeAccessType.ignoreDumbMode(DumbModeAccessType.java:43) at com.intellij.codeInsight.completion.CompletionProgressIndicator.calculateItems(CompletionProgressIndicator.java:866) at com.intellij.codeInsight.completion.CompletionProgressIndicator.runContributors(CompletionProgressIndicator.java:854) at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lambda$startContributorThread$6(CodeCompletionHandlerBase.java:352) at com.intellij.codeInsight.completion.AsyncCompletion.lambda$tryReadOrCancel$5(CompletionThreading.java:172) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1154) at com.intellij.codeInsight.completion.AsyncCompletion.tryReadOrCancel(CompletionThreading.java:170) at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lambda$startContributorThread$7(CodeCompletionHandlerBase.java:344) at com.intellij.codeInsight.completion.AsyncCompletion.lambda$startThread$0(CompletionThreading.java:95) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:608) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:683) at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:639) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:607) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175) at com.intellij.codeInsight.completion.AsyncCompletion.lambda$startThread$1(CompletionThreading.java:91) at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:297) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699) at java.base/java.lang.Thread.run(Thread.java:833)

aJIEw commented 1 year ago

The reason for this error is that this plugin relies on '.package' file in the project's root to search all dependent packages, it seems flutter no longer uses this file to track packages, so we get this error.

You can find this under PubspecUtil.findAllDependentPubspecFiles()

VirtualFile packagesFile = pubspecYamlFile.getParent().findFileByRelativePath(".packages");

Before the project's owner fixes this, a temporary workaround is to remove search for all pubspec files, instead only searching assets in the current project.

public Map<String, CompletionContext> getChildren() {
    if (children == null) {
        children = new HashMap<>();
        // PubspecUtil.findAllDependentPubspecFiles(pubspec).forEach((s, virtualFile) -> {
        //     if (virtualFile == null) {
        //         return;
        //     }
        //     children.put(s, new CompletionContext(virtualFile, getPrefix()));
        // });

        children.put(getPackageName(), new CompletionContext(pubspec, getPrefix()));
    }
    return children;
}

If you don't want to build this yourself, you can use my build, but it only support IDEA 2022.2.

Related issue #9, and maybe #12 and #14.