com.intellij.psi.impl.source.tree.injected.Place Java Examples
The following examples show how to use
com.intellij.psi.impl.source.tree.injected.Place.
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: ShaderLabCGCompletionContributor.java From consulo-unity3d with Apache License 2.0 | 6 votes |
public ShaderLabCGCompletionContributor() { extend(CompletionType.BASIC, StandardPatterns.psiElement().withLanguage(CGLanguage.INSTANCE), new CompletionProvider() { @RequiredReadAction @Override public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull final CompletionResultSet result) { Place shreds = InjectedLanguageUtil.getShreds(parameters.getOriginalFile()); for(PsiLanguageInjectionHost.Shred shred : shreds) { PsiLanguageInjectionHost host = shred.getHost(); if(host instanceof ShaderCGScript) { ShaderLabFile containingFile = (ShaderLabFile) host.getContainingFile(); ShaderReference.consumeProperties(containingFile, result::addElement); } } } }); }
Example #2
Source File: QuickEditHandler.java From consulo with Apache License 2.0 | 6 votes |
public void initMarkers(Place shreds) { SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject); int curOffset = -1; for (PsiLanguageInjectionHost.Shred shred : shreds) { final RangeMarker rangeMarker = myNewDocument.createRangeMarker( shred.getRange().getStartOffset() + shred.getPrefix().length(), shred.getRange().getEndOffset() - shred.getSuffix().length()); final TextRange rangeInsideHost = shred.getRangeInsideHost(); PsiLanguageInjectionHost host = shred.getHost(); RangeMarker origMarker = myOrigDocument.createRangeMarker(rangeInsideHost.shiftRight(host.getTextRange().getStartOffset())); SmartPsiElementPointer<PsiLanguageInjectionHost> elementPointer = smartPointerManager.createSmartPsiElementPointer(host); Trinity<RangeMarker, RangeMarker, SmartPsiElementPointer> markers = Trinity.<RangeMarker, RangeMarker, SmartPsiElementPointer>create(origMarker, rangeMarker, elementPointer); myMarkers.add(markers); origMarker.setGreedyToRight(true); rangeMarker.setGreedyToRight(true); if (origMarker.getStartOffset() > curOffset) { origMarker.setGreedyToLeft(true); rangeMarker.setGreedyToLeft(true); } curOffset = origMarker.getEndOffset(); } initGuardedBlocks(shreds); }
Example #3
Source File: QuickEditAction.java From consulo with Apache License 2.0 | 5 votes |
public static QuickEditHandler getExistingHandler(@Nonnull PsiFile injectedFile) { Place shreds = InjectedLanguageUtil.getShreds(injectedFile); DocumentWindow documentWindow = InjectedLanguageUtil.getDocumentWindow(injectedFile); if (shreds == null || documentWindow == null) return null; TextRange hostRange = TextRange.create(shreds.get(0).getHostRangeMarker().getStartOffset(), shreds.get(shreds.size() - 1).getHostRangeMarker().getEndOffset()); for (Editor editor : EditorFactory.getInstance().getAllEditors()) { if (editor.getDocument() != documentWindow.getDelegate()) continue; QuickEditHandler handler = editor.getUserData(QUICK_EDIT_HANDLER); if (handler != null && handler.changesRange(hostRange)) return handler; } return null; }