Eclipse for C/C++的代码自动提示
第一步下载CDT插件
依次点击菜单:Help->Install New Software,在弹出的窗口中点击如下下拉框,选择CDT-http…,然后点击Next进行安装.
第二步下载Eclipse Plug-in插件
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6xiNkugN-1675420476581)(C:\Users\dell\AppData\Roaming\Typora\typora-user-images\image-20230202112542958.png)]
如果没有显示就是下载过了
注意这个如果报错就是上一个插件正在安装中,需要等待完成。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-P5T2zDXO-1675420476582)(C:\Users\dell\AppData\Roaming\Typora\typora-user-images\image-20230202112731418.png)]
安装完成后就重启
第三步:导入CDT插件源码
打开 window->show view,选择others。然后选择plug-in Development 下的plug-ins,再点击Open按钮。在弹出的在plugin-ins串口找到 org.eclipse.cdt.ui ,右键单击,选择import as -> source project,导入之后在你的 workspace就可以看到这个插件工程
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dAGFNdse-1675420476583)(C:\Users\dell\AppData\Roaming\Typora\typora-user-images\image-20230202142654685.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AGyBFK7U-1675420476583)(C:\Users\dell\AppData\Roaming\Typora\typora-user-images\image-20230202142959922.png)]
第四步:第四步修改CDT插件源码
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wJmjC6NU-1675420476584)(C:\Users\dell\AppData\Roaming\Typora\typora-user-images\image-20230202143437154.png)]
不会打开的看上图。之后找到路径
找到org.eclipse.cdt.ui/src/org.eclipse.cdt.internal.ui.text.contentassist/ContentAssistProcessor.java
修改public void setCompletionProposalAutoActivationCharacters(char[] activationSet)
public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
//fCompletionAutoActivationCharacters = activationSet;
String test = ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char[] triggers = test.toCharArray();
fCompletionAutoActivationCharacters = triggers;
}
找到
/org.eclipse.cdt.ui/src/org.eclipse.cdt.internal.ui.text.contentassist/CContentAssistProcessor.java
修改protected boolean verifyAutoActivation(ITextViewer viewer, int offset)
switch语句中增加了default分支.
protected boolean verifyAutoActivation(ITextViewer viewer, int offset) {
IDocument doc = viewer.getDocument();
if (doc == null) {
return false;
}
if (offset <= 0) {
return false;
}
try {
char activationChar = doc.getChar(--offset);
switch (activationChar) {
case ':':
return offset > 0 && doc.getChar(--offset) == ':';
case '>':
return offset > 0 && doc.getChar(--offset) == '-';
case '.':
// Avoid completion of float literals
CHeuristicScanner scanner = new CHeuristicScanner(doc);
int token = scanner.previousToken(--offset, Math.max(0, offset - 200));
// The scanner reports numbers as identifiers
if (token == Symbols.TokenIDENT
&& !Character.isJavaIdentifierStart(doc.getChar(scanner.getPosition() + 1))) {
// Not a valid identifier
return false;
}
return true;
//新增default
default:
return Character.isAlphabetic(activationChar) || activationChar=='_';
}
} catch (BadLocationException e) {
}
return false;
}
第五步:将修改后的CDT插件导出为jar文件
在工程上右键,然后点击Export按钮,选择Plug-in Development下的Deployable plug-ins and fragment,然后点击next。再选择路径后,点击finish就完成了
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eAvQeBnw-1675420476585)(C:\Users\dell\AppData\Roaming\Typora\typora-user-images\image-20230202151022948.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bjVfZVkH-1675420476585)(C:\Users\dell\AppData\Roaming\Typora\typora-user-images\image-20230202151211725.png)]
最后一步:替换
实际上jar插件只要放入插件目录中替代就行了,也就是将第五步产生的jar文件复制到C:\Users\dell.p2\pool\plugins目录下,将原来的替换。
参考原文
最后一步:替换
实际上jar插件只要放入插件目录中替代就行了,也就是将第五步产生的jar文件复制到C:\Users\dell.p2\pool\plugins目录下,将原来的替换。
参考原文
原文链接:https://blog.csdn.net/Ningjianwen/article/details/107955651