本文整理汇总了Java中com.intellij.util.Url类的典型用法代码示例。如果您正苦于以下问题:Java Url类的具体用法?Java Url怎么用?Java Url使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Url类属于com.intellij.util包,在下文中一共展示了Url类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: canonicalizePath
import com.intellij.util.Url; //导入依赖的package包/类
public static String canonicalizePath(@NotNull String url, @NotNull Url baseUrl, boolean baseUrlIsFile) {
String path = url;
if (url.charAt(0) != '/') {
String basePath = baseUrl.getPath();
if (baseUrlIsFile) {
int lastSlashIndex = basePath.lastIndexOf('/');
StringBuilder pathBuilder = new StringBuilder();
if (lastSlashIndex == -1) {
pathBuilder.append('/');
}
else {
pathBuilder.append(basePath, 0, lastSlashIndex + 1);
}
path = pathBuilder.append(url).toString();
}
else {
path = basePath + '/' + url;
}
}
path = FileUtil.toCanonicalPath(path, '/');
return path;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:SourceResolver.java
示例2: findMappings
import com.intellij.util.Url; //导入依赖的package包/类
@Nullable
public MappingList findMappings(@NotNull List<Url> sourceUrls, @NotNull SourceMap sourceMap, @Nullable VirtualFile sourceFile) {
for (Url sourceUrl : sourceUrls) {
int index = canonicalizedSourcesMap.get(sourceUrl);
if (index != -1) {
return sourceMap.sourceIndexToMappings[index];
}
}
if (sourceFile != null) {
MappingList mappings = findByFile(sourceMap, sourceFile);
if (mappings != null) {
return mappings;
}
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SourceResolver.java
示例3: getUrls
import com.intellij.util.Url; //导入依赖的package包/类
@NotNull
public static List<Url> getUrls(@NotNull VirtualFile file, @NotNull Project project, @Nullable String currentAuthority) {
if (currentAuthority != null && !compareAuthority(currentAuthority)) {
return Collections.emptyList();
}
String path = WebServerPathToFileManager.getInstance(project).getPath(file);
if (path == null) {
return Collections.emptyList();
}
int effectiveBuiltInServerPort = BuiltInServerOptions.getInstance().getEffectiveBuiltInServerPort();
Url url = Urls.newHttpUrl(currentAuthority == null ? "localhost:" + effectiveBuiltInServerPort : currentAuthority, '/' + project.getName() + '/' + path);
int defaultPort = BuiltInServerManager.getInstance().getPort();
if (currentAuthority != null || defaultPort == effectiveBuiltInServerPort) {
return Collections.singletonList(url);
}
return Arrays.asList(url, Urls.newHttpUrl("localhost:" + defaultPort, '/' + project.getName() + '/' + path));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:BuiltInWebBrowserUrlProvider.java
示例4: getOrCreateFile
import com.intellij.util.Url; //导入依赖的package包/类
public synchronized HttpVirtualFileImpl getOrCreateFile(@Nullable HttpVirtualFileImpl parent, @NotNull Url url, @NotNull String path, final boolean directory) {
Map<Url, HttpVirtualFileImpl> cache = directory ? remoteDirectories : remoteFiles;
HttpVirtualFileImpl file = cache.get(url);
if (file == null) {
if (directory) {
file = new HttpVirtualFileImpl(getHttpFileSystem(url), parent, path, null);
}
else {
RemoteFileInfoImpl fileInfo = new RemoteFileInfoImpl(url, this);
file = new HttpVirtualFileImpl(getHttpFileSystem(url), parent, path, fileInfo);
fileInfo.addDownloadingListener(new MyDownloadingListener(file));
}
cache.put(url, file);
}
return file;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RemoteFileManagerImpl.java
示例5: setupUrlField
import com.intellij.util.Url; //导入依赖的package包/类
public static void setupUrlField(@NotNull TextFieldWithBrowseButton field, @NotNull final Project project) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
return HtmlUtil.isHtmlFile(file) || virtualFileToUrl(file, project) != null;
}
};
descriptor.setTitle(XmlBundle.message("javascript.debugger.settings.choose.file.title"));
descriptor.setDescription(XmlBundle.message("javascript.debugger.settings.choose.file.subtitle"));
descriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
field.addBrowseFolderListener(new TextBrowseFolderListener(descriptor, project) {
@NotNull
@Override
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
if (chosenFile.isDirectory()) {
return chosenFile.getPath();
}
Url url = virtualFileToUrl(chosenFile, project);
return url == null ? chosenFile.getUrl() : url.toDecodedForm();
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:StartBrowserPanel.java
示例6: getUrlsToOpen
import com.intellij.util.Url; //导入依赖的package包/类
@NotNull
@Override
public Collection<Url> getUrlsToOpen(@NotNull OpenInBrowserRequest request, boolean preferLocalUrl) throws WebBrowserUrlProvider.BrowserException {
boolean isHtmlOrXml = isHtmlOrXmlFile(request.getFile().getViewProvider().getBaseLanguage());
if (!preferLocalUrl || !isHtmlOrXml) {
DumbService dumbService = DumbService.getInstance(request.getProject());
for (WebBrowserUrlProvider urlProvider : WebBrowserUrlProvider.EP_NAME.getExtensions()) {
if ((!dumbService.isDumb() || DumbService.isDumbAware(urlProvider)) && urlProvider.canHandleElement(request)) {
Collection<Url> urls = getUrls(urlProvider, request);
if (!urls.isEmpty()) {
return urls;
}
}
}
if (!isHtmlOrXml) {
return Collections.emptyList();
}
}
VirtualFile file = request.getVirtualFile();
return file instanceof LightVirtualFile || !request.getFile().getViewProvider().isPhysical()
? Collections.<Url>emptyList()
: Collections.singletonList(Urls.newFromVirtualFile(file));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:WebBrowserServiceImpl.java
示例7: getUrls
import com.intellij.util.Url; //导入依赖的package包/类
@NotNull
private static Collection<Url> getUrls(@Nullable WebBrowserUrlProvider provider, @NotNull OpenInBrowserRequest request) throws WebBrowserUrlProvider.BrowserException {
if (provider != null) {
if (request.getResult() != null) {
return request.getResult();
}
try {
return provider.getUrls(request);
}
catch (WebBrowserUrlProvider.BrowserException e) {
if (!HtmlUtil.isHtmlFile(request.getFile())) {
throw e;
}
}
}
return Collections.emptyList();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:WebBrowserServiceImpl.java
示例8: previewUrl
import com.intellij.util.Url; //导入依赖的package包/类
@Nullable
private Url previewUrl(OpenInBrowserRequest request, VirtualFile virtualFile, GaugeSettingsModel settings) throws IOException, InterruptedException {
ProcessBuilder builder = new ProcessBuilder(settings.getGaugePath(), Constants.DOCS, Spectacle.NAME, virtualFile.getPath());
String projectName = request.getProject().getName();
builder.environment().put("spectacle_out_dir", createOrGetTempDirectory(projectName).getPath() + "/docs");
builder.directory(GaugeUtil.moduleDir(GaugeUtil.moduleForPsiElement(request.getFile())));
GaugeUtil.setGaugeEnvironmentsTo(builder, settings);
Process docsProcess = builder.start();
int exitCode = docsProcess.waitFor();
if (exitCode != 0) {
String docsOutput = String.format("<pre>%s</pre>", GaugeUtil.getOutput(docsProcess.getInputStream(), " ").replace("<", "<").replace(">", ">"));
Notifications.Bus.notify(new Notification("Specification Preview", "Error: Specification Preview", docsOutput, NotificationType.ERROR));
return null;
}
return new UrlImpl(FileUtil.join(createOrGetTempDirectory(projectName).getPath(), "docs/html/specs/" + virtualFile.getNameWithoutExtension() + ".html"));
}
开发者ID:getgauge,项目名称:Intellij-Plugin,代码行数:17,代码来源:GaugeWebBrowserPreview.java
示例9: parseAndCheckIsLocalHost
import com.intellij.util.Url; //导入依赖的package包/类
public static boolean parseAndCheckIsLocalHost(String uri, boolean onlyAnyOrLoopback, boolean hostsOnly) {
if (uri == null || uri.equals("about:blank")) {
return true;
}
try {
Url parsedUri = Urls.parse(uri, false);
if (parsedUri == null) {
return false;
}
String host = getHost(parsedUri);
return host != null && (isTrustedChromeExtension(parsedUri) || isLocalHost(host, onlyAnyOrLoopback, hostsOnly));
}
catch (Exception ignored) {
}
return false;
}
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:NettyKt.java
示例10: get
import com.intellij.util.Url; //导入依赖的package包/类
@Override
public Image get(Object key) {
if (myManager == null || key == null) return null;
PsiElement element = getElement();
if (element == null) return null;
URL url = (URL)key;
Image inMemory = myManager.getElementImage(element, url.toExternalForm());
if (inMemory != null) {
return inMemory;
}
Url parsedUrl = Urls.parseEncoded(url.toExternalForm());
BuiltInServerManager builtInServerManager = BuiltInServerManager.getInstance();
if (parsedUrl != null && builtInServerManager.isOnBuiltInWebServer(parsedUrl)) {
try {
url = new URL(builtInServerManager.addAuthToken(parsedUrl).toExternalForm());
}
catch (MalformedURLException e) {
LOG.warn(e);
}
}
return Toolkit.getDefaultToolkit().createImage(url);
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:DocumentationComponent.java
示例11: canHandleElement
import com.intellij.util.Url; //导入依赖的package包/类
public boolean canHandleElement(@NotNull OpenInBrowserRequest request)
{
try
{
Collection<Url> urls = getUrls(request);
if(!urls.isEmpty())
{
request.setResult(urls);
return true;
}
}
catch(BrowserException ignored)
{
}
return false;
}
开发者ID:consulo,项目名称:consulo-xml,代码行数:18,代码来源:WebBrowserUrlProvider.java
示例12: getUrlForContext
import com.intellij.util.Url; //导入依赖的package包/类
@Nullable
public static Url getUrlForContext(@NotNull PsiElement sourceElement)
{
Url url;
try
{
Collection<Url> urls = WebBrowserService.getInstance().getUrlsToOpen(sourceElement, false);
url = ContainerUtil.getFirstItem(urls);
if(url == null)
{
return null;
}
}
catch(WebBrowserUrlProvider.BrowserException ignored)
{
return null;
}
VirtualFile virtualFile = sourceElement.getContainingFile().getVirtualFile();
if(virtualFile == null)
{
return null;
}
return !url.isInLocalFileSystem() || HtmlUtil.isHtmlFile(virtualFile) ? url : null;
}
开发者ID:consulo,项目名称:consulo-xml,代码行数:27,代码来源:WebBrowserServiceImpl.java
示例13: getUrl
import com.intellij.util.Url; //导入依赖的package包/类
@Nullable
@Override
protected Url getUrl(@NotNull OpenInBrowserRequest request, @NotNull VirtualFile file) throws BrowserException {
SwaggerFileService swaggerFileService = ServiceManager.getService(SwaggerFileService.class);
Optional<Path> swaggerHTMLFolder = swaggerFileService.convertSwaggerToHtml(request.getFile());
return swaggerHTMLFolder
.map(SwaggerFilesUtils::convertSwaggerLocationToUrl)
.orElse(null);
}
开发者ID:zalando,项目名称:intellij-swagger,代码行数:11,代码来源:SwaggerUiUrlProvider.java
示例14: test
import com.intellij.util.Url; //导入依赖的package包/类
@Test
public void test() throws IOException {
Path path = Files.createTempDirectory("");
Url url = SwaggerFilesUtils.convertSwaggerLocationToUrl(path);
Assert.assertEquals(url.getPath(), path.toString() + File.separator + "index.html");
}
开发者ID:zalando,项目名称:intellij-swagger,代码行数:8,代码来源:SwaggerFilesUtilsTest.java
示例15: ScriptBase
import com.intellij.util.Url; //导入依赖的package包/类
protected ScriptBase(@NotNull Type type, @NotNull Url url, int line, int column, int endLine) {
this.type = type;
this.url = url;
this.line = line;
this.column = column;
this.endLine = endLine;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:ScriptBase.java
示例16: findMappingList
import com.intellij.util.Url; //导入依赖的package包/类
@Nullable
public MappingList findMappingList(@NotNull List<Url> sourceUrls, @Nullable VirtualFile sourceFile, @Nullable NullableLazyValue<SourceResolver.Resolver> resolver) {
MappingList mappings = sourceResolver.findMappings(sourceUrls, this, sourceFile);
if (mappings == null && resolver != null) {
SourceResolver.Resolver resolverValue = resolver.getValue();
if (resolverValue != null) {
mappings = sourceResolver.findMappings(sourceFile, this, resolverValue);
}
}
return mappings;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:SourceMap.java
示例17: processMappingsInLine
import com.intellij.util.Url; //导入依赖的package包/类
public boolean processMappingsInLine(@NotNull List<Url> sourceUrls,
int sourceLine,
@NotNull MappingList.MappingsProcessorInLine mappingProcessor,
@Nullable VirtualFile sourceFile,
@Nullable NullableLazyValue<SourceResolver.Resolver> resolver) {
MappingList mappings = findMappingList(sourceUrls, sourceFile, resolver);
return mappings != null && mappings.processMappingsInLine(sourceLine, mappingProcessor);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:SourceMap.java
示例18: SourceResolver
import com.intellij.util.Url; //导入依赖的package包/类
public SourceResolver(@NotNull List<String> sourceUrls, boolean trimFileScheme, @Nullable Url baseFileUrl, boolean baseUrlIsFile, @Nullable List<String> sourceContents) {
rawSources = sourceUrls;
this.sourceContents = sourceContents;
canonicalizedSources = new Url[sourceUrls.size()];
canonicalizedSourcesMap = SystemInfo.isFileSystemCaseSensitive
? new ObjectIntHashMap<Url>(canonicalizedSources.length)
: new ObjectIntHashMap<Url>(canonicalizedSources.length, Urls.getCaseInsensitiveUrlHashingStrategy());
for (int i = 0; i < sourceUrls.size(); i++) {
String rawSource = sourceUrls.get(i);
Url url = canonicalizeUrl(rawSource, baseFileUrl, trimFileScheme, i, baseUrlIsFile);
canonicalizedSources[i] = url;
canonicalizedSourcesMap.put(url, i);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:SourceResolver.java
示例19: canonicalizeUrl
import com.intellij.util.Url; //导入依赖的package包/类
protected Url canonicalizeUrl(@NotNull String url, @Nullable Url baseUrl, boolean trimFileScheme, int sourceIndex, boolean baseUrlIsFile) {
if (trimFileScheme && url.startsWith(StandardFileSystems.FILE_PROTOCOL_PREFIX)) {
return Urls.newLocalFileUrl(FileUtil.toCanonicalPath(VfsUtilCore.toIdeaUrl(url, true).substring(StandardFileSystems.FILE_PROTOCOL_PREFIX.length()), '/'));
}
else if (baseUrl == null || url.contains(URLUtil.SCHEME_SEPARATOR) || url.startsWith("data:") || url.startsWith("blob:") || url.startsWith("javascript:")) {
return Urls.parseEncoded(url);
}
String path = canonicalizePath(url, baseUrl, baseUrlIsFile);
if (baseUrl.getScheme() == null && baseUrl.isInLocalFileSystem()) {
return Urls.newLocalFileUrl(path);
}
// browserify produces absolute path in the local filesystem
if (isAbsolute(path)) {
VirtualFile file = LocalFileFinder.findFile(path);
if (file != null) {
if (absoluteLocalPathToSourceIndex == null) {
// must be linked, on iterate original path must be first
absoluteLocalPathToSourceIndex = createStringIntMap(rawSources.size());
sourceIndexToAbsoluteLocalPath = new String[rawSources.size()];
}
absoluteLocalPathToSourceIndex.put(path, sourceIndex);
sourceIndexToAbsoluteLocalPath[sourceIndex] = path;
String canonicalPath = file.getCanonicalPath();
if (canonicalPath != null && !canonicalPath.equals(path)) {
absoluteLocalPathToSourceIndex.put(canonicalPath, sourceIndex);
}
return Urls.newLocalFileUrl(path);
}
}
return new UrlImpl(baseUrl.getScheme(), baseUrl.getAuthority(), path, null);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:SourceResolver.java
示例20: findByFile
import com.intellij.util.Url; //导入依赖的package包/类
@Nullable
private MappingList findByFile(@NotNull SourceMap sourceMap, @NotNull VirtualFile sourceFile) {
MappingList mappings = null;
if (absoluteLocalPathToSourceIndex != null && sourceFile.isInLocalFileSystem()) {
mappings = getMappingsBySource(sourceMap, absoluteLocalPathToSourceIndex.get(sourceFile.getPath()));
if (mappings == null) {
String sourceFileCanonicalPath = sourceFile.getCanonicalPath();
if (sourceFileCanonicalPath != null) {
mappings = getMappingsBySource(sourceMap, absoluteLocalPathToSourceIndex.get(sourceFileCanonicalPath));
}
}
}
if (mappings == null) {
int index = canonicalizedSourcesMap.get(Urls.newFromVirtualFile(sourceFile).trimParameters());
if (index != -1) {
return sourceMap.sourceIndexToMappings[index];
}
for (int i = 0; i < canonicalizedSources.length; i++) {
Url url = canonicalizedSources[i];
if (Urls.equalsIgnoreParameters(url, sourceFile)) {
return sourceMap.sourceIndexToMappings[i];
}
VirtualFile canonicalFile = sourceFile.getCanonicalFile();
if (canonicalFile != null && !canonicalFile.equals(sourceFile) && Urls.equalsIgnoreParameters(url, canonicalFile)) {
return sourceMap.sourceIndexToMappings[i];
}
}
}
return mappings;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:SourceResolver.java
注:本文中的com.intellij.util.Url类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论