Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLangParser is attempting to parse *.d files related to DTrace for things like Python installations and Android sdk #867

Open
SingingBush opened this issue May 31, 2023 · 3 comments

Comments

@SingingBush
Copy link
Member

There's a few times that reports have come in via sentry

ava.lang.IllegalArgumentException: Could not find single match for token: 'floatLiteral'. 0 matches found
    at io.github.intellij.dlanguage.parser.DLangParser.tok(DLangParser.java:9465)
    at io.github.intellij.dlanguage.parser.DLangParser.<init>(DLangParser.java:135)
    at io.github.intellij.dlanguage.parser.ParserWrapper.parseLight(ParserWrapper.java:23)
    at io.github.intellij.dlanguage.parser.ParserWrapper.parse(ParserWrapper.java:448)

It seems that for some reason Intellij is scanning the content of the users python installation. There are numerous files with a .d extension such as

  • test/dtracedata/assert_usable.d
  • test/dtracedata/call_stack.d
  • test/dtracedata/gc.d
  • test/dtracedata/line.d

which the IDE then treats as D source. This example was from Intellij IDEA Ultimate 2023.1.2 on Linux:

com.intellij.diagnostic.PluginException: Failed to build index 'DModuleIndex' for file file:///usr/lib/python3.10/test/dtracedata/line.d (id = 2365) (file type = D file) [Plugin: net.masterthought.dlanguage]
    at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
    at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:89)
    at com.intellij.util.indexing.diagnostic.BrokenIndexingDiagnostics$DefaultListener.onFileIndexMappingFailed(BrokenIndexingDiagnostics.kt:47)
    at com.intellij.util.indexing.FileBasedIndexImpl.createSingleIndexValueApplier(FileBasedIndexImpl.java:1690)
    at com.intellij.util.indexing.FileBasedIndexImpl.lambda$doIndexFileContent$26(FileBasedIndexImpl.java:1546)
    at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.freezeFileTypeTemporarilyWithProvidedValueIn(FileTypeManagerImpl.java:675)
    at com.intellij.util.indexing.FileBasedIndexImpl.doIndexFileContent(FileBasedIndexImpl.java:1494)
    at com.intellij.util.indexing.FileBasedIndexImpl.indexFileContent(FileBasedIndexImpl.java:1467)

The plugin should only be treating *.d or *.di files as D source if it's files within the project under content roots or modules that have been added as D dependencies via dub.

@SingingBush
Copy link
Member Author

got a similar error reported for method_compile_stat.d which is was related to dtrace files in Android source code

@SingingBush SingingBush changed the title DLangParser is attempting to parse *.d files in python installation DLangParser is attempting to parse *.d files related to DTrace for things like Python installations and Android sdk Jul 15, 2023
@SingingBush
Copy link
Member Author

and another for DynamicAny.idl.d which is related to Java. I suspect that resolving this issue could close most of the parser related issues

@SingingBush
Copy link
Member Author

I've made a change for this on a local branch where I amend DlangVirtualFileVisitor's isExcluded method to do the following:

        @Nullable final Project project = ProjectUtil.guessProjectForFile(srcFile);
        if(project != null) {
            final ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
            @Nullable final Sdk sdk = rootManager.getProjectSdk();

            boolean notDlangSdk = !(sdk != null && (sdk.getSdkType() instanceof DlangSdkType));

            if(notDlangSdk) {
                log.debug(String.format("Visited file '%s' but excluding as project sdk is not a D lang SDK", srcFile.getName()));
            }
        }

I just need to do some testing before pushing the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant