com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference Java Examples
The following examples show how to use
com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSharpClassesMoveProcessor.java From consulo-csharp with Apache License 2.0 | 5 votes |
@RequiredWriteAction public static NonCodeUsageInfo[] retargetUsages(UsageInfo[] usages) { final List<NonCodeUsageInfo> nonCodeUsages = new ArrayList<>(); for(UsageInfo usageInfo : usages) { if(usageInfo instanceof MyUsageInfo) { MyUsageInfo info = (MyUsageInfo) usageInfo; DotNetNamedElement declaration = info.myDeclarationAndResolveTargetCouple.getFirst(); if(info.getReference() instanceof FileReference || info.getReference() instanceof PsiDynaReference) { final PsiElement usageElement = info.getElement(); if(usageElement != null) { final PsiFile usageFile = usageElement.getContainingFile(); final PsiFile psiFile = usageFile.getViewProvider().getPsi(usageFile.getViewProvider().getBaseLanguage()); if(psiFile != null && psiFile.equals(declaration.getContainingFile())) { continue; // already processed in MoveFilesOrDirectoriesUtil.doMoveFile } } } final PsiElement refElement = info.myReference.getElement(); if(refElement != null && refElement.isValid()) { info.myReference.bindToElement(info.myDeclarationAndResolveTargetCouple.getFirst()); } } else if(usageInfo instanceof NonCodeUsageInfo) { nonCodeUsages.add((NonCodeUsageInfo) usageInfo); } } return nonCodeUsages.toArray(new NonCodeUsageInfo[nonCodeUsages.size()]); }
Example #2
Source File: IgnoreReferenceSet.java From idea-gitignore with MIT License | 5 votes |
/** * Returns last reference of the current element's references. * * @return last {@link FileReference} */ @Nullable public FileReference getLastReference() { FileReference lastReference = super.getLastReference(); if (lastReference != null && lastReference.getCanonicalText().endsWith(getSeparatorString())) { return this.myReferences != null && this.myReferences.length > 1 ? this.myReferences[this.myReferences.length - 2] : null; } return lastReference; }
Example #3
Source File: PsiDynaReference.java From consulo with Apache License 2.0 | 5 votes |
@Override public PsiElement bindToElement(@Nonnull PsiElement element) throws IncorrectOperationException { for (PsiReference reference : myReferences) { if (reference instanceof FileReference) { return reference.bindToElement(element); } } return myElement; }
Example #4
Source File: MoveFilesOrDirectoriesProcessor.java From consulo with Apache License 2.0 | 5 votes |
protected void retargetUsages(UsageInfo[] usages, Map<PsiElement, PsiElement> oldToNewMap) { final List<NonCodeUsageInfo> nonCodeUsages = new ArrayList<>(); for (UsageInfo usageInfo : usages) { if (usageInfo instanceof MyUsageInfo) { final MyUsageInfo info = (MyUsageInfo)usageInfo; final PsiElement element = myElementsToMove[info.myIndex]; if (info.getReference() instanceof FileReference || info.getReference() instanceof PsiDynaReference) { final PsiElement usageElement = info.getElement(); if (usageElement != null) { final PsiFile usageFile = usageElement.getContainingFile(); final PsiFile psiFile = usageFile.getViewProvider().getPsi(usageFile.getViewProvider().getBaseLanguage()); if (psiFile != null && psiFile.equals(element)) { continue; // already processed in MoveFilesOrDirectoriesUtil.doMoveFile } } } final PsiElement refElement = info.myReference.getElement(); if (refElement != null && refElement.isValid()) { info.myReference.bindToElement(element); } } else if (usageInfo instanceof NonCodeUsageInfo) { nonCodeUsages.add((NonCodeUsageInfo)usageInfo); } } for (PsiFile movedFile : myFoundUsages.keySet()) { MoveFileHandler.forElement(movedFile).retargetUsages(myFoundUsages.get(movedFile), oldToNewMap); } myNonCodeUsages = nonCodeUsages.toArray(new NonCodeUsageInfo[nonCodeUsages.size()]); }
Example #5
Source File: IgnoreReferenceSet.java From idea-gitignore with MIT License | 4 votes |
/** * Parses entry, searches for file references and stores them in {@link #myReferences}. */ @Override protected void reparse() { ProgressManager.checkCanceled(); String str = StringUtil.trimEnd(getPathString(), getSeparatorString()); final List<FileReference> referencesList = new ArrayList<>(); String separatorString = getSeparatorString(); // separator's length can be more then 1 char int sepLen = separatorString.length(); int currentSlash = -sepLen; int startInElement = getStartInElement(); // skip white space while (currentSlash + sepLen < str.length() && Character.isWhitespace(str.charAt(currentSlash + sepLen))) { currentSlash++; } if (currentSlash + sepLen + sepLen < str.length() && str.substring(currentSlash + sepLen, currentSlash + sepLen + sepLen).equals(separatorString)) { currentSlash += sepLen; } int index = 0; if (str.equals(separatorString)) { final FileReference fileReference = createFileReference( new TextRange(startInElement, startInElement + sepLen), index++, separatorString ); referencesList.add(fileReference); } while (true) { ProgressManager.checkCanceled(); final int nextSlash = str.indexOf(separatorString, currentSlash + sepLen); final String subReferenceText = nextSlash > 0 ? str.substring(0, nextSlash) : str; TextRange range = new TextRange(startInElement + currentSlash + sepLen, startInElement + (nextSlash > 0 ? nextSlash : str.length())); final FileReference ref = createFileReference(range, index++, subReferenceText); referencesList.add(ref); if ((currentSlash = nextSlash) < 0) { break; } } myReferences = referencesList.toArray(new FileReference[0]); }
Example #6
Source File: FileReferenceQuickFixProvider.java From consulo with Apache License 2.0 | 4 votes |
public MyCreateFileFix(boolean isdirectory, String newFileName, PsiDirectory directory, FileReference reference) { super(isdirectory, newFileName, directory); isDirectory = isdirectory; myNewFileTemplateName = isDirectory ? null : reference.getNewFileTemplateName(); }
Example #7
Source File: RenameFileReferenceIntentionAction.java From consulo with Apache License 2.0 | 4 votes |
public RenameFileReferenceIntentionAction(final String existingElementName, final FileReference fileReference) { myExistingElementName = existingElementName; myFileReference = fileReference; }
Example #8
Source File: IgnoreReferenceSet.java From idea-gitignore with MIT License | 2 votes |
/** * Creates {@link IgnoreReference} instance basing on passed text value. * * @param range text range * @param index start index * @param text string text * @return file reference */ @Override public FileReference createFileReference(TextRange range, int index, String text) { return new IgnoreReference(this, range, index, text); }