Several Javascript files marked with X and yellow background

Answered

I have a project and today, I suddenly noticed that two Javascript files are suddenly marked with yellow backgrounds and an X in the top left corner. When refactoring, IntelliJ says those files are not part of the project, and the files have no syntax highlighting. I checked, and the files are definitely in Git, they're not being mistreated in the file types category, and there is no other evident exception I can find. Here's what it looks like:

The affected files are abstractUtxoCoin.js and baseCoin.js. Quite curiously, when marking any other file as plain text, the context menu shows the option to mark it as Javascript afterwards. With these files, however, there is only the option to mark them as plain text, which remains even after clicking it, which I did as part of some experimentation. Additionally, here's the dialog that appears when trying to rename either file:

What's going on, and how do I fix it? Thanks!

10 comments
Comment actions Permalink

This icon indicates non-project files - those that are excluded from indexing. Please check Excluded files list in the Project structure - do you have these files listed there? Also, does the issue persist after caches invalidation?

0
Comment actions Permalink

The file is definitely not being excluded using the project structure, and the issue does persist after cache invalidation and restart.

0
Comment actions Permalink

were these files created by hand, or generated?

0
Comment actions Permalink

I created them by hand many commits ago. This change in behavior was sudden.

0
Comment actions Permalink

does the issue persist if you copy these files in a new project?

0
Comment actions Permalink

No, it does not.

0
Comment actions Permalink

can you share a project that can be used to recreate the issue?

0
Comment actions Permalink

I'm afraid I cannot. However, I removed ./.idea/workspace.xml, reopened the project, and that appears to have fixed it.

0
Comment actions Permalink

I ran into a very similar problem and can provide a bit more context. I'm working on a shared React JS UI component library that generates a distribution bundle into a sub-directory named "dist". IntelliJ picked up the types declared in that bundle, so I added the "dist" folder to the exclusion list. That seems to have also automatically picked up the underlying original source files in the "src" folder.

My .idea/workspace.xml file contained the following configuration element:

<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
<option name="exactExcludedFiles">
<list>
<option value="$PROJECT_DIR$/src/SomeSourceFileA.js" />
 <option value="$PROJECT_DIR$/src/SomeSourceFileB.js" />
  <option value="$PROJECT_DIR$/src/SomeSourceFileC.js" />
... etc ...
</list>
</option>
</component>

Removing that block and restarting IntelliJ fixes the problem.

I'm not sure why the component name mentions TypeScript. At some point I toyed with converting all my source files to TypeScript but gave up and reverted the changes. It might have been caused by that.

1
Comment actions Permalink

the built-in TypeScript compiler, when enabled, auto-excludes the generated .js files from indexing by adding them to exactExcludedFiles list in workspace.xml. If your javascript files have the same names as generated files, this would mark them excluded. Removing the from the list manually should help

1

Please sign in to leave a comment.