use of com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet in project intellij-plugins by JetBrains.
the class VelocityStrutsResultContributor method createReferences.
public boolean createReferences(@NotNull final PsiElement psiElement, @NotNull final List<PsiReference> references, final boolean soft) {
final String namespace = getNamespace(psiElement);
if (namespace == null) {
return false;
}
final WebFacet webFacet = WebUtil.getWebFacet(psiElement);
if (webFacet == null) {
// setup error, web-facet must be present in current or dependent module
return false;
}
final FileReferenceSet set = FileReferenceSetHelper.createRestrictedByFileType(psiElement, VtlFileType.INSTANCE);
FileReferenceSetHelper.addWebDirectoryAndCurrentNamespaceAsRoots(psiElement, namespace, webFacet, set);
set.setEmptyPathAllowed(false);
Collections.addAll(references, set.getAllReferences());
return true;
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoImportReference method getQuickFixes.
@Override
public LocalQuickFix[] getQuickFixes() {
if (GoPackageUtil.isBuiltinPackage(resolve())) {
return new LocalQuickFix[] { new GoDeleteImportQuickFix() };
}
List<LocalQuickFix> result = ContainerUtil.newArrayList();
FileReferenceSet fileReferenceSet = getFileReferenceSet();
if (fileReferenceSet instanceof GoImportReferenceSet && !((GoImportReferenceSet) fileReferenceSet).isRelativeImport() && !fileReferenceSet.isAbsolutePathReference()) {
result.add(new GoGetPackageFix(fileReferenceSet.getPathString()));
}
String fileNameToCreate = getFileNameToCreate();
for (PsiFileSystemItem context : getContexts()) {
if (context instanceof PsiDirectory) {
try {
((PsiDirectory) context).checkCreateSubdirectory(fileNameToCreate);
String targetPath = context.getVirtualFile().getPath();
result.add(new CreateFileFix(true, fileNameToCreate, (PsiDirectory) context) {
@NotNull
@Override
public String getText() {
return "Create Directory " + fileNameToCreate + " at " + targetPath;
}
});
} catch (IncorrectOperationException ignore) {
}
}
}
return result.toArray(new LocalQuickFix[result.size()]);
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet in project intellij-plugins by JetBrains.
the class DartPackagePathReferenceProvider method getDartPackageReferences.
private static FileReference[] getDartPackageReferences(@NotNull final PsiElement psiElement, @NotNull final DartUrlResolver dartResolver) {
final TextRange textRange = ElementManipulators.getValueTextRange(psiElement);
final String referenceText = psiElement.getText().substring(textRange.getStartOffset(), textRange.getEndOffset());
final FileReferenceSet referenceSet = new FileReferenceSet(referenceText, psiElement, textRange.getStartOffset(), null, true) {
public FileReference createFileReference(final TextRange range, final int index, final String text) {
return new DartPackageAwareFileReference(this, range, index, text, dartResolver);
}
};
return referenceSet.getAllReferences();
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet in project intellij-community by JetBrains.
the class StaticPathReferenceProvider method createReferences.
@Override
public boolean createReferences(@NotNull final PsiElement psiElement, final int offset, final String text, @NotNull final List<PsiReference> references, final boolean soft) {
FileReferenceSet set = new FileReferenceSet(text, psiElement, offset, null, true, myEndingSlashNotAllowed, mySuitableFileTypes) {
@Override
protected boolean isUrlEncoded() {
return true;
}
@Override
protected boolean isSoft() {
return soft;
}
};
if (!myRelativePathsAllowed) {
set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
}
Collections.addAll(references, set.getAllReferences());
return true;
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet in project intellij-community by JetBrains.
the class JavaFxFileReferenceProvider method getReferences.
public static PsiReference[] getReferences(@NotNull PsiElement element, String value, final String acceptedExtension) {
final PsiDirectory directory = element.getContainingFile().getOriginalFile().getParent();
if (directory == null)
return PsiReference.EMPTY_ARRAY;
final boolean startsWithSlash = value.startsWith("/");
final VirtualFileSystem fs = directory.getVirtualFile().getFileSystem();
final FileReferenceSet fileReferenceSet = new FileReferenceSet(value, element, 1, null, fs.isCaseSensitive()) {
@NotNull
@Override
public Collection<PsiFileSystemItem> getDefaultContexts() {
if (startsWithSlash || !directory.isValid()) {
return super.getDefaultContexts();
}
return Collections.singletonList(directory);
}
@Override
protected Condition<PsiFileSystemItem> getReferenceCompletionFilter() {
return item -> {
if (item instanceof PsiDirectory)
return true;
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(item);
return virtualFile != null && acceptedExtension.equals(virtualFile.getExtension());
};
}
};
if (startsWithSlash) {
fileReferenceSet.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
}
return fileReferenceSet.getAllReferences();
}
Aggregations