本文整理汇总了Java中org.jetbrains.builtInWebServer.BuiltInServerOptions类的典型用法代码示例。如果您正苦于以下问题:Java BuiltInServerOptions类的具体用法?Java BuiltInServerOptions怎么用?Java BuiltInServerOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BuiltInServerOptions类属于org.jetbrains.builtInWebServer包,在下文中一共展示了BuiltInServerOptions类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOAuthRedirectUrl
import org.jetbrains.builtInWebServer.BuiltInServerOptions; //导入依赖的package包/类
@NotNull
public static String getOAuthRedirectUrl() {
int port = BuiltInServerManager.getInstance().getPort();
// according to https://confluence.jetbrains.com/display/IDEADEV/Remote+communication
int defaultPort = BuiltInServerOptions.getInstance().builtInServerPort;
if (port >= defaultPort && port < (defaultPort + 20)) {
return "http://localhost:" + port + "/api/" + EduStepicNames.OAUTH_SERVICE_NAME;
}
return EduStepicNames.EXTERNAL_REDIRECT_URL;
}
示例2: isOnBuiltInWebServerByAuthority
import org.jetbrains.builtInWebServer.BuiltInServerOptions; //导入依赖的package包/类
public static boolean isOnBuiltInWebServerByAuthority(@Nonnull String authority) {
int portIndex = authority.indexOf(':');
if (portIndex < 0 || portIndex == authority.length() - 1) {
return false;
}
int port = StringUtil.parseInt(authority.substring(portIndex + 1), -1);
if (port == -1) {
return false;
}
BuiltInServerOptions options = BuiltInServerOptions.getInstance();
int idePort = BuiltInServerManager.getInstance().getPort();
if (options.builtInServerPort != port && idePort != port) {
return false;
}
String host = authority.substring(0, portIndex);
if (NetUtils.isLocalhost(host)) {
return true;
}
try {
InetAddress inetAddress = InetAddress.getByName(host);
return inetAddress.isLoopbackAddress() ||
inetAddress.isAnyLocalAddress() ||
(options.builtInServerAvailableExternally && idePort != port && NetworkInterface.getByInetAddress(inetAddress) != null);
}
catch (IOException e) {
return false;
}
}
示例3: getExternalDocInfoForElement
import org.jetbrains.builtInWebServer.BuiltInServerOptions; //导入依赖的package包/类
@Override
@Nullable
public String getExternalDocInfoForElement(@NotNull String docURL, final PsiElement element) throws Exception {
String externalDoc = null;
myElement = element;
String builtInServer = "http://localhost:" + BuiltInServerOptions.getInstance().getEffectiveBuiltInServerPort() + "/" + myProject.getName() + "/";
if (docURL.startsWith(builtInServer)) {
int refPosition = docURL.lastIndexOf('#');
VirtualFile file = WebServerPathToFileManager.getInstance(myProject).findVirtualFile(
docURL.substring(builtInServer.length(), refPosition < builtInServer.length() ? docURL.length() : refPosition)
);
if (file != null) {
InputStreamReader reader = new InputStreamReader(file.getInputStream(), CharsetToolkit.UTF8_CHARSET);
StringBuilder result = new StringBuilder();
try {
doBuildFromStream(docURL, reader, result);
}
finally {
reader.close();
}
externalDoc = correctDocText(docURL, result);
}
}
if (externalDoc == null) {
externalDoc = super.getExternalDocInfoForElement(docURL, element);
}
if (externalDoc == null) {
return null;
}
if (element instanceof PsiMethod) {
final String className = ApplicationManager.getApplication().runReadAction(
new NullableComputable<String>() {
@Override
@Nullable
public String compute() {
PsiClass aClass = ((PsiMethod)element).getContainingClass();
return aClass == null ? null : aClass.getQualifiedName();
}
}
);
Matcher matcher = ourMethodHeading.matcher(externalDoc);
StringBuilder buffer = new StringBuilder("<h3>");
DocumentationManager.createHyperlink(buffer, className, className, false);
return matcher.replaceFirst(buffer.append("</h3>").toString());
}
return externalDoc;
}