本文整理匯總了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;
}
}
}
}