diff options
Diffstat (limited to 'python/openapi')
3 files changed, 17 insertions, 35 deletions
diff --git a/python/openapi/python-openapi.iml b/python/openapi/python-openapi.iml index 690468af6c04..9ac91c15af8f 100644 --- a/python/openapi/python-openapi.iml +++ b/python/openapi/python-openapi.iml @@ -12,7 +12,6 @@ <orderEntry type="module" module-name="lang-api" /> <orderEntry type="module" module-name="lang-impl" /> <orderEntry type="library" name="Guava" level="project" /> - <orderEntry type="module" module-name="webide-impl" exported="" /> </component> </module> diff --git a/python/openapi/src/com/jetbrains/python/psi/RootFileReferenceSet.java b/python/openapi/src/com/jetbrains/python/psi/RootFileReferenceSet.java index 36cf4d270278..8fd92a3b6fd9 100644 --- a/python/openapi/src/com/jetbrains/python/psi/RootFileReferenceSet.java +++ b/python/openapi/src/com/jetbrains/python/psi/RootFileReferenceSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,20 +15,20 @@ */ package com.jetbrains.python.psi; -import com.google.common.collect.Lists; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.*; +import com.intellij.openapi.vfs.newvfs.ManagingFS; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiFileSystemItem; +import com.intellij.psi.PsiReferenceProvider; import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; -import com.jetbrains.python.psi.PyStringLiteralExpression; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; -import java.util.Collections; /** * Resolves absolute paths from FS root, not content roots @@ -41,7 +41,8 @@ public class RootFileReferenceSet extends FileReferenceSet { int startInElement, PsiReferenceProvider provider, boolean caseSensitive, - boolean endingSlashNotAllowed, @Nullable FileType[] suitableFileTypes) { + boolean endingSlashNotAllowed, + @Nullable FileType[] suitableFileTypes) { super(str, element, startInElement, provider, caseSensitive, endingSlashNotAllowed, suitableFileTypes); } @@ -49,6 +50,7 @@ public class RootFileReferenceSet extends FileReferenceSet { super(s, element, offset, provider, sensitive); } + @Override public boolean isAbsolutePathReference() { if (!ApplicationManager.getApplication().isUnitTestMode()) { return FileUtil.isAbsolute(getPathString()); @@ -61,26 +63,13 @@ public class RootFileReferenceSet extends FileReferenceSet { @NotNull @Override public Collection<PsiFileSystemItem> computeDefaultContexts() { - final PsiFile file = getContainingFile(); - if (file != null) { + PsiFile file = getContainingFile(); + if (file == null) return ContainerUtil.emptyList(); - if (isAbsolutePathReference()) { - if (!ApplicationManager.getApplication().isUnitTestMode()) { - VirtualFile root = LocalFileSystem.getInstance().getRoot(); - PsiDirectory directory = file.getManager().findDirectory(root); - if (directory != null) { - return Lists.<PsiFileSystemItem>newArrayList(directory); - } - } - else { - return super.computeDefaultContexts(); - } - } - else { - return super.computeDefaultContexts(); - } + if (isAbsolutePathReference() && !ApplicationManager.getApplication().isUnitTestMode()) { + return toFileSystemItems(ManagingFS.getInstance().getLocalRoots()); } - return Collections.emptyList(); + return super.computeDefaultContexts(); } } diff --git a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReference.java b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReference.java index a7ea14704ed1..84760d87eed3 100644 --- a/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReference.java +++ b/python/openapi/src/com/jetbrains/python/templateLanguages/TemplateFileReference.java @@ -16,7 +16,6 @@ package com.jetbrains.python.templateLanguages; import com.intellij.lang.injection.InjectedLanguageManager; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtilCore; @@ -26,7 +25,6 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFileSystemItem; import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceHelper; -import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceHelperRegistrar; import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; import com.intellij.psi.impl.source.resolve.reference.impl.providers.PsiFileSystemItemUtil; import com.intellij.util.IncorrectOperationException; @@ -66,17 +64,13 @@ public class TemplateFileReference extends WeakFileReference { final VirtualFile curVFile = file.getVirtualFile(); if (curVFile == null) throw new IncorrectOperationException("Cannot bind from non-physical element:" + file); - final Project project = element.getProject(); - String newName; PsiFileSystemItem curItem = null; PsiFileSystemItem dstItem = null; - final FileReferenceHelper helper = FileReferenceHelperRegistrar.getNotNullHelper(file); - - PsiFileSystemItem _dstItem = helper.getPsiFileSystemItem(project, dstVFile); - PsiFileSystemItem _curItem = helper.getPsiFileSystemItem(project, curVFile); + PsiFileSystemItem _dstItem = FileReferenceHelper.getPsiFileSystemItem(file.getManager(), dstVFile); + PsiFileSystemItem _curItem = FileReferenceHelper.getPsiFileSystemItem(file.getManager(), curVFile); if (_dstItem != null && _curItem != null) { curItem = _curItem; dstItem = _dstItem; |