The way to fix unreal 4.27 vscode intelligence bug

The unreal engine 4.27 has bug on vscode intelligence.

I have find out how to fix it and write it out.

First the bug is the compileCommands_Default.json and compileCommands_LearnUE4.json is the main compilecommand file for vscode intelligence.

The bug is every "command" fields lost a double quotation marks. details show below

[
    {
        "file": "D:\\\\unreal\\\\LearnUE4\\\\Source\\\\LearnUE4\\\\LearnUE4.Build.cs",
        "command": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe @\"D:\\unreal\\LearnUE4\\.vscode\\compileCommands_Default\\LearnUE4.210.rsp\"",
        "directory": "D:\\game\\UE_4.27\\Engine\\Source"
    }
]

Look at the command field

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe

which should change to "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe"

add a quotation at the begin and end.

2 answers

  • answered 2021-11-29 03:03 l0n0l

    So I write a script to fix this.

    import json
    import re
    from typing import List
    
    
    def fix_cmd(filepath):
        with open(filepath) as fp:
            d = json.load(fp)
            for item in d:
                cmd = item['command']
                m: List[re.Match] = re.findall("(C:.*cl.exe) (@.*)", cmd)
                m0 = m[0]
                cmd = f"\"{m0[0]}\" {m0[1]}"
                item['command'] = cmd
    
        with open(filepath, 'w') as fp:
            json.dump(d, fp, indent='\t')
    
    
    fix_cmd(".vscode/compileCommands_Default.json")
    fix_cmd(".vscode/compileCommands_LearnUE4.json")
    
    

  • answered 2021-11-29 18:41 boocs

    My VSCode extension fixes this and other problems. https://github.com/boocs/ue4-intellisense-fixes

    My solution was just to remove the path and just keep the cl.exe

    I did report it to Epic a while ago, in a bug report, and gave them both solutions. But I think reporting is just a black hole that rarely works.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum