Unreal 4.27 vscode 智能bug修复方法
The way to fix unreal 4.27 vscode intelligence bug
unreal engine 4.27 在 vscode 智能方面存在错误。
我已经找到解决方法并写出来了。
首先错误是 compileCommands_Default.json 和 compileCommands_LearnUE4.json是vscode智能的主要编译命令文件。
错误是每个“命令”字段都丢失了双引号。详情如下
[
{
"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"
}
]
查看命令字段
C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.29.30133\bin\HostX64\x64\cl.exe
应该改为
"C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.29.30133\bin\HostX64\x64\cl.exe"
在开头和结尾添加引号。
所以我写了一个脚本来解决这个问题。
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")
我的 VSCode 扩展修复了这个问题和其他问题。 https://github.com/boocs/ue4-intellisense-fixes
我的解决方案只是删除路径并保留 cl.exe
我不久前确实在错误报告中向 Epic 报告了它,并给了他们两种解决方案。但我认为报道只是一个很少起作用的黑洞。
unreal engine 4.27 在 vscode 智能方面存在错误。
我已经找到解决方法并写出来了。
首先错误是 compileCommands_Default.json 和 compileCommands_LearnUE4.json是vscode智能的主要编译命令文件。
错误是每个“命令”字段都丢失了双引号。详情如下
[
{
"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"
}
]
查看命令字段
C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.29.30133\bin\HostX64\x64\cl.exe
应该改为 "C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.29.30133\bin\HostX64\x64\cl.exe"
在开头和结尾添加引号。
所以我写了一个脚本来解决这个问题。
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")
我的 VSCode 扩展修复了这个问题和其他问题。 https://github.com/boocs/ue4-intellisense-fixes
我的解决方案只是删除路径并保留 cl.exe
我不久前确实在错误报告中向 Epic 报告了它,并给了他们两种解决方案。但我认为报道只是一个很少起作用的黑洞。