当前位置: 首页>>代码示例>>Java>>正文


Java InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit方法代码示例

本文整理汇总了Java中com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit方法的典型用法代码示例。如果您正苦于以下问题:Java InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit方法的具体用法?Java InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit怎么用?Java InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil的用法示例。


在下文中一共展示了InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPsiElement

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Nullable
private static PsiElement getPsiElement(DataContext dataContext, Project project, Editor editor) {
  PsiElement psiElement = null;
  if (editor == null) {
    psiElement = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
  } else {
    final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
    final Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file);
    if (injectedEditor != null) {
      PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(injectedEditor, project);
      psiElement = psiFile != null ? psiFile.findElementAt(injectedEditor.getCaretModel().getOffset()) : null;
    }

    if (file != null && psiElement == null) {
      psiElement = file.findElementAt(editor.getCaretModel().getOffset());
    }
  }

  return psiElement;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ShowByteCodeAction.java

示例2: getData

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
public Object getData(String dataId) {
  if (PlatformDataKeys.EDITOR.is(dataId)) {
    return myEditor;
  }
  if (dataId.equals(AnActionEvent.injectedId(PlatformDataKeys.EDITOR.getName()))) {
    return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
  }
  if (LangDataKeys.PSI_FILE.is(dataId)) {
    return myFile;
  }
  if (dataId.equals(AnActionEvent.injectedId(LangDataKeys.PSI_FILE.getName()))) {
    Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
    return editor instanceof EditorWindow ? ((EditorWindow)editor).getInjectedFile() : getFile();
  }
  return super.getData(dataId);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:LightPlatformCodeInsightTestCase.java

示例3: getPsiElement

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Nullable
private static PsiElement getPsiElement(DataContext dataContext, Project project, Editor editor) {
  PsiElement psiElement = null;
  if (editor == null) {
    psiElement = LangDataKeys.PSI_ELEMENT.getData(dataContext);
  } else {
    final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
    final Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file);
    if (injectedEditor != null) {
      PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(injectedEditor, project);
      psiElement = psiFile != null ? psiFile.findElementAt(injectedEditor.getCaretModel().getOffset()) : null;
    }

    if (file != null && psiElement == null) {
      psiElement = file.findElementAt(editor.getCaretModel().getOffset());
    }
  }

  return psiElement;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:ShowByteCodeAction.java

示例4: getData

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
public Object getData(@Nonnull Key<?> dataId) {
  if (PlatformDataKeys.EDITOR == dataId) {
    return myEditor;
  }
  if (dataId == AnActionEvent.injectedId(PlatformDataKeys.EDITOR)) {
    return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
  }
  if (LangDataKeys.PSI_FILE == dataId) {
    return myFile;
  }
  if (dataId == AnActionEvent.injectedId(LangDataKeys.PSI_FILE)) {
    Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(getEditor(), getFile());
    return editor instanceof EditorWindow ? ((EditorWindow)editor).getInjectedFile() : getFile();
  }
  return super.getData(dataId);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:LightPlatformCodeInsightTestCase.java

示例5: getPsiElement

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Nullable
private static PsiElement getPsiElement(DataContext dataContext, Project project, Editor editor)
{
	PsiElement psiElement = null;
	if(editor == null)
	{
		psiElement = dataContext.getData(CommonDataKeys.PSI_ELEMENT);
	}
	else
	{
		final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project);
		final Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file);
		if(injectedEditor != null)
		{
			PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(injectedEditor, project);
			psiElement = psiFile != null ? psiFile.findElementAt(injectedEditor.getCaretModel().getOffset()) : null;
		}

		if(file != null && psiElement == null)
		{
			psiElement = file.findElementAt(editor.getCaretModel().getOffset());
		}
	}

	return psiElement;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:ShowByteCodeAction.java

示例6: setupEditorForInjectedLanguage

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private void setupEditorForInjectedLanguage() {
  Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, getFile());
  if (editor instanceof EditorWindow) {
    myFile = ((EditorWindow)editor).getInjectedFile().getViewProvider().getVirtualFile();
    myEditor = editor;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CodeInsightTestFixtureImpl.java

示例7: updateComponentInner

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private void updateComponentInner(@NotNull DataContext dataContext) {
  if (CommonDataKeys.PROJECT.getData(dataContext) != myProject) {
    return;
  }

  final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  if (editor == null) {
    PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
    if (element != null) {
      doUpdateComponent(element);
    }
    return;
  }

  PsiDocumentManager.getInstance(myProject).commitAllDocuments();
  final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, myProject);

  final Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file);
  if (injectedEditor != null) {
    final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(injectedEditor, myProject);
    if (psiFile != null) {
      doUpdateComponent(injectedEditor, psiFile);
      return;
    }
  }

  if (file != null) {
    doUpdateComponent(editor, file);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:DockablePopupManager.java

示例8: getInjectedEditor

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public static Editor getInjectedEditor(@NotNull Project project, final Editor editor, boolean commit) {
  Editor injectedEditor = editor;
  if (editor != null) {
    PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
    PsiFile psiFile = documentManager.getCachedPsiFile(editor.getDocument());
    if (psiFile != null) {
      if (commit) documentManager.commitAllDocuments();
      injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, psiFile);
    }
  }
  return injectedEditor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:BaseCodeInsightAction.java

示例9: invokeCompletion

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public static void invokeCompletion(@NotNull CompletionType completionType,
                                    boolean autopopup,
                                    Project project, Editor editor, int time, boolean restart) {
  if (editor.isDisposed()) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  // retrieve the injected file from scratch since our typing might have destroyed the old one completely
  Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
  PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(topLevelEditor.getDocument());
  if (file == null) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  PsiFile topLevelFile = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
  if (!PsiDocumentManager.getInstance(project).isCommitted(editor.getDocument())) {
    LOG.error("Non-committed document");
    PsiDocumentManager.getInstance(project).commitAllDocuments();
  }
  Editor newEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(topLevelEditor, topLevelFile);
  try {
    new CodeCompletionHandlerBase(completionType, false, autopopup, false).invokeCompletion(project, newEditor, time, false, restart);
  }
  catch (IndexNotReadyException ignored) {
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:CompletionAutoPopupHandler.java

示例10: CustomTemplateCallback

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public CustomTemplateCallback(@NotNull Editor editor, @NotNull PsiFile file) {
  myProject = file.getProject();
  myTemplateManager = TemplateManager.getInstance(myProject);

  myOffset = getOffset(editor);
  PsiElement element = InjectedLanguageUtil.findInjectedElementNoCommit(file, myOffset);
  myFile = element != null ? element.getContainingFile() : file;

  myInInjectedFragment = InjectedLanguageManager.getInstance(myProject).isInjectedFragment(myFile);
  myEditor = myInInjectedFragment ? InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file, myOffset) : editor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:CustomTemplateCallback.java

示例11: getOpenedEditor

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@Override
protected Editor getOpenedEditor(@NotNull final Editor editor, final boolean focusEditor) {
  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
  Document document = editor.getDocument();
  PsiFile psiFile = documentManager.getPsiFile(document);
  if (!focusEditor || documentManager.isUncommited(document)) {
    return editor;
  }

  return InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, psiFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PsiAwareFileEditorManagerImpl.java

示例12: setupEditorForInjectedLanguage

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static void setupEditorForInjectedLanguage() {
  Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, myFile);
  if (editor instanceof EditorWindow) {
    myFile = ((EditorWindow)editor).getInjectedFile();
    myEditor = editor;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:LightPlatformCodeInsightTestCase.java

示例13: updateComponent

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public void updateComponent() {
  if (myProject.isDisposed()) return;

  AsyncResult<DataContext> asyncResult = DataManager.getInstance().getDataContextFromFocus();
  DataContext dataContext = asyncResult.getResult();
  if (dataContext == null) {
    return;
  }

  if (PlatformDataKeys.PROJECT.getData(dataContext) != myProject) {
    return;
  }

  final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  if (editor == null) {
    PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
    if (element != null) {
      doUpdateComponent(element);
    }
    return;
  }

  final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, myProject);

  final Editor injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file);
  if (injectedEditor != null) {
    final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(injectedEditor, myProject);
    if (psiFile != null) {
      doUpdateComponent(injectedEditor, psiFile);
      return;
    }
  }

  if (file != null) {
    doUpdateComponent(editor, file);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:DockablePopupManager.java

示例14: invokeCompletion

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public static void invokeCompletion(CompletionType completionType,
                                    boolean autopopup,
                                    Project project, Editor editor, int time, boolean restart) {
  if (editor.isDisposed()) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  // retrieve the injected file from scratch since our typing might have destroyed the old one completely
  Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(editor);
  PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(topLevelEditor.getDocument());
  if (file == null) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
    return;
  }

  PsiFile topLevelFile = InjectedLanguageManager.getInstance(file.getProject()).getTopLevelFile(file);
  if (!PsiDocumentManager.getInstance(project).isCommitted(editor.getDocument())) {
    LOG.error("Non-committed document");
    PsiDocumentManager.getInstance(project).commitAllDocuments();
  }
  Editor newEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(topLevelEditor, topLevelFile);
  try {
    new CodeCompletionHandlerBase(completionType, false, autopopup, false).invokeCompletion(project, newEditor, time, false, restart);
  }
  catch (IndexNotReadyException ignored) {
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:CompletionAutoPopupHandler.java

示例15: CustomTemplateCallback

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
public CustomTemplateCallback(Editor editor, PsiFile file, boolean wrapping) {
  myProject = file.getProject();
  myTemplateManager = TemplateManager.getInstance(myProject);

  int offset = getOffset(wrapping, editor);
  PsiElement element = InjectedLanguageUtil.findInjectedElementNoCommit(file, offset);
  myFile = element != null ? element.getContainingFile() : file;

  myInInjectedFragment = InjectedLanguageManager.getInstance(myProject).isInjectedFragment(myFile);
  myEditor = myInInjectedFragment ? InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file, offset) : editor;

  fixInitialState(wrapping);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:CustomTemplateCallback.java


注:本文中的com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。