boocs / ue4-intellisense-fixes

Automatically fixes VSCode/Unreal Engine Intellisense Config bugs on startup
MIT License
162 stars 9 forks source link

Couldn't find UE source file Version.h problem #12

Closed heptaspirit closed 2 years ago

heptaspirit commented 2 years ago

My UE is version v4.27.2, in Windows 10 This problem didn't appear every time, but it does give me annoying trouble. Every time after I add new c++ class and reopen VS Code, extension didn't work and output:

Searching for *.uproject file...
Extension "UE Intellisense Fixes" is now active!

** Error **: Couldn't find UE source file Version.h
** Error **: Couldn't parse Unreal Engine version.
** Error **: No fixable project could be created.

Extension is done.

And every time when I met this problem, I had to close extension and reopen it. After restart extension, it does work and output. Please neglect this below output has my project repaired because I just reopen extension twice.

Searching for *.uproject file...
Extension "UE Intellisense Fixes" is now active!

Found Unreal Engine v4.27.2

Fixing compiler path in c_cpp_properties.json.
Cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Extension compiler path isn't set. Will not force compiler path in c_cpp_properties. (Not an error)
If the extension's compiler path setting was previously set you should reset your UE project to get back the c_cpp_properties default path.

Fixing compiler paths in compile commands.
Will not override compiler path in compile commands file. (Not an error)
Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe" @"G:\SelfProject\UE\ToonTanks\.vscode\compileCommands_ToonTanks\ToonTanks.210.rsp"
Compile Command Object wasn't modifed. Will not write file.
Below is the compile commands first entry command. (WARNING) If getting errors and the compiler path is unexpected reset your UE project.
command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe" @"G:\SelfProject\UE\ToonTanks\.vscode\compileCommands_Default\ToonTanks.210.rsp"
Compile Command Object wasn't modifed. Will not write file.
Done fixing compiler paths.

Fixing invalid paths in response files.
No invalid paths returned. No fixes needed.
No invalid paths returned. No fixes needed.
End fixing invalid paths in response files.

Fixing missing compile command files.
No missing file paths found. No fixes needed.
No missing file paths found. No fixes needed.
End fix missing compile commands.

Attempting to fix UE workspace(Add empty tag parser).
UE's tag parser includes are set to empty array for performance.
The setting limitSymbolsToIncludedHeaders is already set to true.
End fix UE workspace(Add empty tag parser).

Attempting to fix wrong cppStandard.
Extension's cppStandard setting was set to empty string.
Intellisense will use cpptools cppStandard setting instead of this extension's setting.
End fix wrong cppStandard.

Fixing launch.json.
launch.json didn't need to be changed.
End fix launch.json.

Start fix wrong intellisense mode
Cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Intellisense mode doesn't need to be fixed.
End fix wrong intellisense mode.

Attempting to fix UE workspace optimization.
Current Main workspace file's forced includes are already fixed.
End fix UE optimization.

No need to write ToonTanks CCppProperties. It was unchanged.
No need to write UE4 CCppProperties. It was unchanged.

Extension is done.

This problem happens every time I create new class and reopen VS Code, and fixed by reopen extension. I wonder if this problem can be fixed, automated.

boocs commented 2 years ago

I've had this happen occasionally but haven't figured out the cause.

That being said, when you create a new class you'll always have to restart VSCode(I do show the log with a message saying this). This is because the class files have to be added to the compile command file when the extension runs on startup.

heptaspirit commented 2 years ago

I've had this happen occasionally but haven't figured out the cause.

That being said, when you create a new class you'll always have to restart VSCode(I do show the log with a message saying this). This is because the class files have to be added to the compile command file when the extension runs on startup.

Yeah, I see the log (tell me to restart vsc) and restart vsc, then extension doesn't work. That makes me have to restart extension. After disable extension, restart vsc and then reopen the extension all things done.

heptaspirit commented 2 years ago

Well, I just make a more wired bug.

Repeated this procedure five times, two times got fixed, three times fell. I just did not change ANYTHING in this project, just reopen vscode.

The only difference I find is vscode extension activation time

boocs commented 2 years ago

Thanks for the additional info. I'll definitely look into it again.

It could just be a simple fix of bypassing VSCode API code with node code. We'll see!

boocs commented 2 years ago

I put out a 2.5.1 beta release. If you can please test and let me know if it fixes the problems. Thanks!

heptaspirit commented 2 years ago

I put out a 2.5.1 beta release. If you can please test and let me know if it fixes the problems. Thanks!

I just try as before, things do changed. "Version.h" error has disappeared, but I find new problem and here is output.

Searching for *.uproject file...
*.uproject file was found!
Extension "UE Intellisense Fixes" is now active!

Found Unreal Engine v4.27.2

** Error **: No uproject files found.
** Error **: This fixable project hasn't been initialized properly and is invalid.

I repeat reopen vscode 5 times and this error appear twice.

boocs commented 2 years ago

We're getting closer! I should be able to put 1 more test release out later tonight/morning and see if I can fix the rest tomorrow.

Thanks for the help!

boocs commented 2 years ago

I released another test version 2.5.2.

heptaspirit commented 2 years ago

I released another test version 2.5.2.

It is really strange I can still meet this:

Searching for *.uproject file...
*.uproject file was found!
Extension "UE Intellisense Fixes" is now active!

Found Unreal Engine v4.27.2

** Error **: No uproject files found.
** Error **: This fixable project hasn't been initialized properly and is invalid.

But the frequency is much lower than v2.5.1, I tried for 7 times and only see once. Only if I tried many times, I may even neglect this.

boocs commented 2 years ago

It must be the VSCode API's findFiles function acting weird for some reason. A findFiles bug kind of sucks since I do use it a lot.

To make sure, I can create a node Glob version, for that one spot, and see if you get any false not finding files bugs.

heptaspirit commented 2 years ago

It must be the VSCode API's findFiles function acting weird for some reason. A findFiles bug kind of sucks since I do use it a lot.

To make sure, I can create a node Glob version, for that one spot, and see if you get any false not finding files bugs.

Maybe we can report this bug to VSCode because it may refer to some VS Code FindFile bug.

boocs commented 2 years ago

Yeah, I probably will but there's still on off chance I'm missing something in my code. It isn't the best written and has no tests...

I did go through my code and search for any missing awaits yesterday but it still could be this or something else that's poorly designed.

I'll try to get the Glob version done so you can test it.

boocs commented 2 years ago

It'll have to wait for tomorrow. Getting weird behavior with the new function so need to test more.

boocs commented 2 years ago

I released 2.5.3 to test.

This uses node fast-glob which unfortunately causes a big increase in file size. I've realized I've been dumb and don't really need this find files code and can do it the same way I used to fixed the Unreal Version.h check. I'll probably change that and do a full 2.6.0 release with that version.

I also removed the progress bar code. The weirdness did seem like async issues and the progress bar wraps my extension in convoluted async code. The extension runs decently fast that it's unneeded anyway.

So maybe findFiles wasn't the reason? Maybe...

heptaspirit commented 2 years ago

I released 2.5.3 to test.

This uses node fast-glob which unfortunately causes a big increase in file size. I've realized I've been dumb and don't really need this find files code and can do it the same way I used to fixed the Unreal Version.h check. I'll probably change that and do a full 2.6.0 release with that version.

I also removed the progress bar code. The weirdness did seem like async issues and the progress bar wraps my extension in convoluted async code. The extension runs decently fast that it's unneeded anyway.

So maybe findFiles wasn't the reason? Maybe...

Thanks for your patient effort on improving this extension, without your help people like me who try to use VSCode to edit UE C++ would face these annoying problem every day.

I just test 2.5.3 on my project and it outputs new problem

Searching for *.uproject file...
*.uproject file was found!
Extension "UE Intellisense Fixes" is now active!

Found Unreal Engine v4.27.2

Couldn't find files in ToonTanks workspace's .vscode folder with glob: .vscode/c_cpp_properties.json
** Error **: No files found for getCCppConfigCopy().
** Error **: The main cCppProperties wasn't enabled at construction setup.
** Error **: This fixable project hasn't been initialized properly and is invalid.

Extension is done.

Maybe you are right, it is not problem about findfile...

boocs commented 2 years ago

Well... It is findFiles because that error is because findFiles didn't find something it should have. We're basically fixing one findFiles and then it errs on the next one. I do use it a bit. I do believe I could fix this so it happens rarely since I believe the exclude parameter I'm not setting is what makes this happen so often for you. When I set that parameter previously, you've tested it and it only happened 1 out of 7 times. Probably better not to use findFiles though.

Actually I thought of something. Maybe that 1 out of 7 times was an anomaly and it really is fixed. The first "*.uproject file was found" message is from the fixed findFiles call so that does seem to be working. Maybe I'll try to fix all findFiles with the exclude setting set and see if you run into any errors.

I've been away today so I'll be working on it tomorrow.

boocs commented 2 years ago

I released 2.5.4.

I removed fast-glob, for now, and made sure all findFiles didn't exclude anywhere automatically.

heptaspirit commented 2 years ago

This time I try more times and find these

Searching for *.uproject file...
*.uproject file was found!
Extension "UE Intellisense Fixes" is now active!

Found Unreal Engine v4.27.2

** Error **: No uproject files found!
** Error **: This fixable project hasn't been initialized properly and is invalid.

Extension is done.

and

Searching for *.uproject file...
*.uproject file was found!
Extension "UE Intellisense Fixes" is now active!

Found Unreal Engine v4.27.2

Couldn't find files in ToonTanks workspace's .vscode folder with glob: .vscode/c_cpp_properties.json
** Error **: No files found for getCCppConfigCopy().
** Error **: The main cCppProperties wasn't enabled at construction setup.
** Error **: This fixable project hasn't been initialized properly and is invalid.

Extension is done.

They are much rare than before.

boocs commented 2 years ago

Still could be some weird async issue but more than likely there is a findFiles bug. I did try looking for findFiles on their issues tracker github and didn't find anything. That is kind of worrying that it could still be my code.

I'll create a pure fast-glob version and see how often it happens but will keep the pure findFiles alive so it can still be referenced.

I'll create the issue after this test.

boocs commented 2 years ago

I released 2.5.5 that replaces all findFiles with fast-glob.

I kind of screwed up and should've been saving these as branches in git. Still getting used to it. Oh well.

heptaspirit commented 2 years ago

Still could be some weird async issue but more than likely there is a findFiles bug. I did try looking for findFiles on their issues tracker github and didn't find anything. That is kind of worrying that it could still be my code.

I'll create a pure fast-glob version and see how often it happens but will keep the pure findFiles alive so it can still be referenced.

I'll create the issue after this test.

After multiple times try, I only meet this

Searching for *.uproject file...
*.uproject file was found!
Extension "UE Intellisense Fixes" is now active!

Found Unreal Engine v4.27.2

Couldn't find files in UE4 workspace's .vscode folder with glob: .vscode/c_cpp_properties.json
** Error **: No files found for getCCppConfigCopy().
** Error **: The main cCppProperties wasn't enabled at construction setup.
** Error **: This fixable project hasn't been initialized properly and is invalid.

Extension is done.

This is the only one I meet.

boocs commented 2 years ago

Can you open your project's ProjectName.code-workspace file in a text editor?

You should see something like this in the file:

{
    "name": "UE4",
    "path": "K:\\Program Files\\Epic Games\\UE_4.27"
}

Go to the UE path specified in your file and see if it really doesn't have a .vscode folder with a c_cpp_properties.json inside.

heptaspirit commented 2 years ago

Can you open your project's ProjectName.code-workspace file in a text editor?

You should see something like this in the file:

{
  "name": "UE4",
  "path": "K:\\Program Files\\Epic Games\\UE_4.27"
}

Go to the UE path specified in your file and see if it really doesn't have a .vscode folder with a c_cpp_properties.json inside.

I find this in ProjectName.code-workspace

"folders": [
        {
            "name": "ToonTanks",
            "path": "."
        },
        {
            "name": "UE4",
            "path": "G:\\Engine\\UE_4.27"
        }
    ],

and in c_cpp_properties.json

{
    "configurations": [
        {
            "name": "ToonTanksEditor Editor Win64 Development (ToonTanks)",
            "intelliSenseMode": "msvc-x64",
            "compileCommands": "G:\\SelfProject\\UE\\ToonTanks\\.vscode\\compileCommands_ToonTanks.json",
            "cStandard": "c17",
            "cppStandard": "c++17"
        },
        {
            "name": "Win32",
            "intelliSenseMode": "msvc-x64",
            "compileCommands": "G:\\SelfProject\\UE\\ToonTanks\\.vscode\\compileCommands_Default.json",
            "cStandard": "c17",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

It seems everything in folder is okay.

boocs commented 2 years ago

Just to be sure, can you post a picture of your G:\Engine\UE_4.27 folder?

heptaspirit commented 2 years ago

Just to be sure, can you post a picture of your G:\Engine\UE_4.27 folder?

图片

and inside .vscode folder there is 图片

boocs commented 2 years ago

Added 3.0.0 beta!

I added a bunch of log comments for when it's searching to try to understand what's going on.

Will suck if fast-glob is causing issues as well.

heptaspirit commented 2 years ago

Added 3.0.0 beta!

I added a bunch of log comments for when it's searching to try to understand what's going on.

Will suck if fast-glob is causing issues as well.

After reopen project for 10 times I think you finally fix this bug. There has a long output and for every time I can see

Attempting to fix UE workspace(Add empty tag parser).
UE's tag parser includes are set to empty array for performance.
The setting limitSymbolsToIncludedHeaders is already set to true.
End fix UE workspace(Add empty tag parser).

Attempting to fix wrong cppStandard.
This extension set main workspace c_cpp_properties.json's cppStandard to c++17
This extension set main workspace c_cpp_properties.json's cppStandard to c++17
This extension set ue4 workspace c_cpp_properties.json's cppStandard to c++17
This extension set ue4 workspace c_cpp_properties.json's cppStandard to c++17
End fix wrong cppStandard.

Fixing launch.json.
launch.json didn't need to be changed.
End fix launch.json.

Start fix wrong intellisense mode
Cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Intellisense mode doesn't need to be fixed.
End fix wrong intellisense mode.

Attempting to fix UE workspace optimization.
Current Main workspace file's forced includes are already fixed.
End fix UE optimization.

No need to write ToonTanks CCppProperties. It was unchanged.
No need to write UE4 CCppProperties. It was unchanged.

Extension is done.

This mean extension works every time I try.

boocs commented 2 years ago

Cool. Thanks again for all your help!

Hopefully the release version still works as good. I'm only removing/changing some log messages.

boocs commented 2 years ago

I released 3.0.1. Let me know how it goes and you can close this if it's working good.

heptaspirit commented 2 years ago

I released 3.0.1. Let me know how it goes and you can close this if it's working good.

After testing 3.0.1 for many times, there is no difference with 3.0.0 beta. Seems like this bug is finally done.

boocs commented 2 years ago

Cool, thanks again for testing!