本文整理汇总了Java中com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.findInjectedPsiNoCommit方法的典型用法代码示例。如果您正苦于以下问题:Java InjectedLanguageUtil.findInjectedPsiNoCommit方法的具体用法?Java InjectedLanguageUtil.findInjectedPsiNoCommit怎么用?Java InjectedLanguageUtil.findInjectedPsiNoCommit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil
的用法示例。
在下文中一共展示了InjectedLanguageUtil.findInjectedPsiNoCommit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCompletionContext
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static CompletionContext createCompletionContext(PsiFile hostCopy,
int hostStartOffset,
OffsetMap hostMap, PsiFile originalFile) {
CompletionAssertions.assertHostInfo(hostCopy, hostMap);
InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(hostCopy.getProject());
CompletionContext context;
PsiFile injected = InjectedLanguageUtil.findInjectedPsiNoCommit(hostCopy, hostStartOffset);
if (injected != null) {
if (injected instanceof PsiFileImpl) {
((PsiFileImpl)injected).setOriginalFile(originalFile);
}
DocumentWindow documentWindow = InjectedLanguageUtil.getDocumentWindow(injected);
CompletionAssertions.assertInjectedOffsets(hostStartOffset, injectedLanguageManager, injected, documentWindow);
context = new CompletionContext(injected, translateOffsetMapToInjected(hostMap, documentWindow));
} else {
context = new CompletionContext(hostCopy, hostMap);
}
CompletionAssertions.assertFinalOffsets(originalFile, context, injected);
return context;
}
示例2: chooseBetweenHostAndInjected
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Nullable
public static Pair<PsiFile,Editor> chooseBetweenHostAndInjected(@NotNull PsiFile hostFile, @NotNull Editor hostEditor, @NotNull PairProcessor<PsiFile, Editor> predicate) {
Editor editorToApply = null;
PsiFile fileToApply = null;
int offset = hostEditor.getCaretModel().getOffset();
PsiFile injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(hostFile, offset);
if (injectedFile != null) {
Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(hostEditor, injectedFile);
if (predicate.process(injectedFile, injectedEditor)) {
editorToApply = injectedEditor;
fileToApply = injectedFile;
}
}
if (editorToApply == null && predicate.process(hostFile, hostEditor)) {
editorToApply = hostEditor;
fileToApply = hostFile;
}
if (editorToApply == null) return null;
return Pair.create(fileToApply, editorToApply);
}
示例3: invokeImpl
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void invokeImpl(Project project, Editor editor, PsiFile file) {
final PsiFile psiFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, editor.getCaretModel().getOffset());
if (psiFile == null) return;
final PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(project).getInjectionHost(psiFile);
if (host == null) return;
final LanguageInjectionSupport support = psiFile.getUserData(LanguageInjectionSupport.SETTINGS_EDITOR);
if (support == null) return;
try {
if (!support.editInjectionInPlace(host)) {
ShowSettingsUtil.getInstance().editConfigurable(project, new InjectionsSettingsUI(project, Configuration.getProjectInstance(project)));
}
}
finally {
FileContentUtil.reparseFiles(project, Collections.<VirtualFile>emptyList(), true);
}
}
示例4: createCompletionContext
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static CompletionContext createCompletionContext(PsiFile hostCopy,
int hostStartOffset,
OffsetMap hostMap, PsiFile originalFile) {
CompletionAssertions.assertHostInfo(hostCopy, hostMap);
InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(hostCopy.getProject());
CompletionContext context;
PsiFile injected = InjectedLanguageUtil.findInjectedPsiNoCommit(hostCopy, hostStartOffset);
if (injected != null) {
if (injected instanceof PsiFileImpl && injectedLanguageManager.isInjectedFragment(originalFile)) {
((PsiFileImpl)injected).setOriginalFile(originalFile);
}
DocumentWindow documentWindow = InjectedLanguageUtil.getDocumentWindow(injected);
CompletionAssertions.assertInjectedOffsets(hostStartOffset, injectedLanguageManager, injected, documentWindow);
context = new CompletionContext(injected, translateOffsetMapToInjected(hostMap, documentWindow));
} else {
context = new CompletionContext(hostCopy, hostMap);
}
CompletionAssertions.assertFinalOffsets(originalFile, context, injected);
return context;
}
示例5: chooseBetweenHostAndInjected
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Nullable
public static Pair<PsiFile, Editor> chooseBetweenHostAndInjected(@Nonnull PsiFile hostFile,
@Nonnull Editor hostEditor,
@Nonnull PairProcessor<PsiFile, Editor> predicate) {
Editor editorToApply = null;
PsiFile fileToApply = null;
int offset = hostEditor.getCaretModel().getOffset();
PsiFile injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(hostFile, offset);
if (injectedFile != null) {
Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(hostEditor, injectedFile);
if (predicate.process(injectedFile, injectedEditor)) {
editorToApply = injectedEditor;
fileToApply = injectedFile;
}
}
if (editorToApply == null && predicate.process(hostFile, hostEditor)) {
editorToApply = hostEditor;
fileToApply = hostFile;
}
if (editorToApply == null) return null;
return Pair.create(fileToApply, editorToApply);
}
示例6: isAvailable
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
final int offset = editor.getCaretModel().getOffset();
final PsiFile psiFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
if (psiFile == null) return false;
final LanguageInjectionSupport support = psiFile.getUserData(LanguageInjectionSupport.SETTINGS_EDITOR);
return support != null;
}
示例7: isAvailable
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
final int offset = editor.getCaretModel().getOffset();
PsiElement element = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
if (element == null) {
return InjectedReferencesContributor.isInjected(file.findReferenceAt(offset));
}
return element.getUserData(LanguageInjectionSupport.INJECTOR_SUPPORT) != null;
}
示例8: doExtractFunction
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private void doExtractFunction() throws Throwable {
myFixture.configureByFile(getTestFileName() + ".xsl");
final Editor editor = myFixture.getEditor();
assertTrue("Selection required", editor.getSelectionModel().hasSelection());
editor.getCaretModel().moveToOffset(editor.getSelectionModel().getSelectionStart());
final XsltExtractFunctionAction action = new XsltExtractFunctionAction() {
@Override
protected RefactoringOptions getSettings(XPathExpression expression, Set<XPathExpression> matchingExpressions) {
return new RefactoringOptions() {
@Override
public boolean isCanceled() {
return false;
}
@Override
public String getName() {
return "f:foo";
}
};
}
};
final PsiFile file = InjectedLanguageUtil.findInjectedPsiNoCommit(myFixture.getFile(), editor.getCaretModel().getOffset());
final Editor editorWindow = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, file);
assertTrue(editorWindow instanceof EditorWindow);
action.invoke(myFixture.getProject(), editorWindow, file, null);
myFixture.checkResultByFile(getTestFileName() + "_after.xsl");
}
示例9: addAvailableActionsForGroups
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void addAvailableActionsForGroups(@NotNull HighlightInfo info,
@NotNull Editor editor,
@NotNull PsiFile file,
@NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
int group,
int offset) {
if (info.quickFixActionMarkers == null) return;
if (group != -1 && group != info.getGroup()) return;
Editor injectedEditor = null;
PsiFile injectedFile = null;
for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) {
HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
RangeMarker range = pair.second;
if (!range.isValid()) continue;
int start = range.getStartOffset();
int end = range.getEndOffset();
final Project project = file.getProject();
if (start > offset || offset > end) {
continue;
}
Editor editorToUse;
PsiFile fileToUse;
if (info.isFromInjection()) {
if (injectedEditor == null) {
injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
}
editorToUse = injectedEditor;
fileToUse = injectedFile;
}
else {
editorToUse = editor;
fileToUse = file;
}
if (actionInGroup.getAction().isAvailable(project, editorToUse, fileToUse)) {
outList.add(actionInGroup);
}
}
}
示例10: addAvailableActionsForGroups
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void addAvailableActionsForGroups(@NotNull HighlightInfo info,
@NotNull Editor editor,
@NotNull PsiFile file,
@NotNull List<HighlightInfo.IntentionActionDescriptor> outList,
int group,
int offset) {
if (info.quickFixActionMarkers == null) return;
if (group != -1 && group != info.getGroup()) return;
boolean fixRangeIsNotEmpty = !info.getFixTextRange().isEmpty();
Editor injectedEditor = null;
PsiFile injectedFile = null;
for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) {
HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
RangeMarker range = pair.second;
if (!range.isValid() || fixRangeIsNotEmpty && isEmpty(range)) continue;
if (DumbService.isDumb(file.getProject()) && !DumbService.isDumbAware(actionInGroup.getAction())) {
continue;
}
int start = range.getStartOffset();
int end = range.getEndOffset();
final Project project = file.getProject();
if (start > offset || offset > end) {
continue;
}
Editor editorToUse;
PsiFile fileToUse;
if (info.isFromInjection()) {
if (injectedEditor == null) {
injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
}
editorToUse = injectedEditor;
fileToUse = injectedFile;
}
else {
editorToUse = editor;
fileToUse = file;
}
if (actionInGroup.getAction().isAvailable(project, editorToUse, fileToUse)) {
outList.add(actionInGroup);
}
}
}
示例11: addAvailableFixesForGroups
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void addAvailableFixesForGroups(@Nonnull HighlightInfo info,
@Nonnull Editor editor,
@Nonnull PsiFile file,
@Nonnull List<HighlightInfo.IntentionActionDescriptor> outList,
int group,
int offset) {
if (info.quickFixActionMarkers == null) return;
if (group != -1 && group != info.getGroup()) return;
boolean fixRangeIsNotEmpty = !info.getFixTextRange().isEmpty();
Editor injectedEditor = null;
PsiFile injectedFile = null;
for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) {
HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
RangeMarker range = pair.second;
if (!range.isValid() || fixRangeIsNotEmpty && isEmpty(range)) continue;
if (DumbService.isDumb(file.getProject()) && !DumbService.isDumbAware(actionInGroup.getAction())) {
continue;
}
int start = range.getStartOffset();
int end = range.getEndOffset();
final Project project = file.getProject();
if (start > offset || offset > end) {
continue;
}
Editor editorToUse;
PsiFile fileToUse;
if (info.isFromInjection()) {
if (injectedEditor == null) {
injectedFile = InjectedLanguageUtil.findInjectedPsiNoCommit(file, offset);
injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
}
editorToUse = injectedEditor;
fileToUse = injectedFile;
}
else {
editorToUse = editor;
fileToUse = file;
}
if (actionInGroup.getAction().isAvailable(project, editorToUse, fileToUse)) {
outList.add(actionInGroup);
}
}
}