本文整理汇总了Java中com.intellij.openapi.util.text.StringUtil.replace方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtil.replace方法的具体用法?Java StringUtil.replace怎么用?Java StringUtil.replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.text.StringUtil
的用法示例。
在下文中一共展示了StringUtil.replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translate
import com.intellij.openapi.util.text.StringUtil; //导入方法依赖的package包/类
private void translate(AnActionEvent e, String sercet, String apiKey) {
Editor editor = e.getData(CommonDataKeys.EDITOR);
if (editor != null) {
String text = editor.getSelectionModel().getSelectedText();
if (text != null)
try {
text = StringUtil.replace(text, "*", "");
text = StringUtil.replace(text, "\n", "");
text = StringUtil.replace(text, "<tt>", "");
text = StringUtil.replace(text, "</tt>", "");
text = StringUtil.replace(text, "@link", "");
text = StringUtil.replace(text, "{", "");
text = StringUtil.replace(text, "}", "");
String result = HttpClientPool.getHttpClient().get(Constants.genUrl(sercet, apiKey, text));
ApiResult data = gson.fromJson(result, ApiResult.class);
if(data.getErrorCode().equals("202")){
Messages.showErrorDialog("请确认setting里面的ApiKey和ApiSecret是否正确","Api验证错误");
}else{
showPop(e, editor, resolveResult(text, data));
}
} catch (Exception exception) {
onParseError(exception);
// if(State.instance().isDebug()){
// Messages.showErrorDialog(exception.toString(),"发生了错误~~");
// }
exception.printStackTrace();
}
}
}
示例2: isValidFilePath
import com.intellij.openapi.util.text.StringUtil; //导入方法依赖的package包/类
protected String isValidFilePath(@NotNull String fullFilePath, @NotNull PsiDirectory baseDirectory) {
String filePath = StringUtil.replace(
fullFilePath,
File.separator,
"/"
);
if(filePath.length() == 0) {
return PhpBundle.message(
"validation.file.not.valid.name",
fullFilePath);
} else {
List<String> split = StringUtil.split(filePath, "/");
if(split.size() == 0) {
return PhpBundle.message(
"validation.file.not.valid.name",
fullFilePath);
} else {
for (String aSplit : split) {
if (!PhpNameUtil.isValidFileName(aSplit)) {
return PhpBundle.message(
"validation.file.not.valid.name",
fullFilePath);
}
}
VirtualFile baseDirectoryFile = baseDirectory.getVirtualFile();
VirtualFile fileByRelativePath = baseDirectoryFile.findFileByRelativePath(
PhpNameUtil.trimStart(
filePath,
'/')
);
if (fileByRelativePath != null) {
return PhpBundle.message(
"validation.file.already.exists",
fullFilePath);
} else {
return null;
}
}
}
}