跨文件无法在VSCode中针对方法/函数“查找所有引用”

时间:2018-10-06 09:33:25

标签: visual-studio-code vscode-settings

Visual Studio代码版本1.27.2

Find all References仅列出current file中的引用。 我需要在项目中的文件中找到所有引用。

有可能吗?

类似find usages

如果右键单击symbol,然后选择“查找用法”。如果当前符号是function,则“查找用法”将搜索调用此函数的所有位置。如果当前符号是variable,则“查找用法”将搜索使用此变量的所有位置,等等。

3 个答案:

答案 0 :(得分:4)

右键单击该变量,然后选择 // determen if there are orders to display if(mysqli_num_rows($result2) > 0) { while($value2 = $result2->fetch_object()) { $key = $value2->soid.'-'.$value2->sdd; if(!isset($results[$key])) { $results[$key] = array( 'soid' => $value2->soid, 'sdd' => $value2->sdd, 'items' => array(), ); } $results[$key]['items'][] = $value2; } } ?> <table class="center table"> <thead> <tr> <th>Order Number</th> <th>Delivery Date</th> <th>QTY</th> <th>Food Type</th> </tr> </thead> <tbody> <tr> <td colspan="4"><b>Delivered orders :</b> (and orders delivered today...)</td> </tr> <?php foreach($results as $result) : ?> <?php if($result['sdd'] <= $datenow): ?> <tr> <td><?php echo($result['soid']); ?></td> <td><?php echo($result['sdd']); ?></td> <td></td> <td></td> </tr> <?php foreach($result['items'] as $item): ?> <tr> <td></td> <td></td> <td><?php echo($item->olq); ?></td> <td><?php echo($item->fft); ?></td> </tr> <?php endforeach; ?> <?php endif; ?> <?php endforeach; ?> </tbody> </table> This is how it looks in VSCode

我的Find All References

About Visual Studio Code Info

答案 1 :(得分:3)

Find all references等高级功能由每种语言扩展实现。

对于JavaScript,请尝试在工作区的根目录创建一个jsconfig.json,内容如下:

{
    "compilerOptions": {
        "target": "ES6"
    },
    "exclude": [
        "node_modules",
        "**/node_modules/*"
    ]
}

此文件告诉VS Code将您工作区中的所有JS文件都视为同一javascript项目的一部分。如果您的代码过于动态,Find all references可能仍无法在JavaScript中正常工作。它最适合使用import / exportclass和朋友的现代js

答案 2 :(得分:2)

在Visual Studio Code中,您可以先突出显示要搜索的文本,然后使用以下命令来执行此操作:CTRL + SHIFT + F(同时按下全部)。

CTRL + SHIFT + F只是访问VSCode左侧搜索选项卡的快捷方式。希望对涂鸦有帮助和道歉:)

enter image description here