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


Java InjectedLanguageUtil.findInjectedElementNoCommit方法代码示例

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


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

示例1: shouldSkipAutoPopup

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static boolean shouldSkipAutoPopup(Editor editor, PsiFile psiFile) {
  int offset = editor.getCaretModel().getOffset();
  int psiOffset = Math.max(0, offset - 1);

  PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(psiFile, psiOffset);
  if (elementAt == null) {
    elementAt = psiFile.findElementAt(psiOffset);
  }
  if (elementAt == null) return true;

  Language language = PsiUtilCore.findLanguageFromElement(elementAt);

  for (CompletionConfidence confidence : CompletionConfidenceEP.forLanguage(language)) {
    final ThreeState result = confidence.shouldSkipAutopopup(elementAt, psiFile, offset);
    if (result != ThreeState.UNSURE) {
      LOG.debug(confidence + " has returned shouldSkipAutopopup=" + result);
      return result == ThreeState.YES;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CodeCompletionHandlerBase.java

示例2: getContext

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
public static PsiElement getContext(@NotNull PsiFile file, int offset, boolean searchInInjectedFragment) {
  PsiElement element = null;
  if (searchInInjectedFragment && !InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file)) {
    PsiDocumentManager documentManager = PsiDocumentManager.getInstance(file.getProject());
    Document document = documentManager.getDocument(file);
    if (document != null && !documentManager.isCommitted(document)) {
      LOGGER.error("Trying to access to injected template context on uncommited document, offset = " + offset,
                   AttachmentFactory.createAttachment(file.getVirtualFile()));
    }
    else {
      element = InjectedLanguageUtil.findInjectedElementNoCommit(file, offset);
    }
  }
  if (element == null) {
    element = PsiUtilCore.getElementAtOffset(file, offset);
  }
  return element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:CustomTemplateCallback.java

示例3: doFindWhiteSpaceNode

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
private static Pair<PsiElement, CharTable> doFindWhiteSpaceNode(@NotNull PsiFile file, int offset) {
  ASTNode astNode = SourceTreeToPsiMap.psiElementToTree(file);
  if (!(astNode instanceof FileElement)) {
    return new Pair<PsiElement, CharTable>(null, null);
  }
  PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(file, offset);
  final CharTable charTable = ((FileElement)astNode).getCharTable();
  if (elementAt == null) {
    elementAt = findElementInTreeWithFormatterEnabled(file, offset);
  }

  if( elementAt == null) {
    return new Pair<PsiElement, CharTable>(null, charTable);
  }
  ASTNode node = elementAt.getNode();
  if (node == null || node.getElementType() != TokenType.WHITE_SPACE) {
    return new Pair<PsiElement, CharTable>(null, charTable);
  }
  return Pair.create(elementAt, charTable);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CodeStyleManagerImpl.java

示例4: shouldSkipAutoPopup

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
private static boolean shouldSkipAutoPopup(Editor editor, PsiFile psiFile) {
  int offset = editor.getCaretModel().getOffset();
  int psiOffset = Math.max(0, offset - 1);

  PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(psiFile, psiOffset);
  if (elementAt == null) {
    elementAt = psiFile.findElementAt(psiOffset);
  }
  if (elementAt == null) return true;

  Language language = PsiUtilBase.findLanguageFromElement(elementAt);

  for (CompletionConfidence confidence : CompletionConfidenceEP.forLanguage(language)) {
    final ThreeState result = confidence.shouldSkipAutopopup(elementAt, psiFile, offset);
    if (result != ThreeState.UNSURE) {
      LOG.debug(confidence + " has returned shouldSkipAutopopup=" + result);
      return result == ThreeState.YES;
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:CodeCompletionHandlerBase.java

示例5: getInjectedFileIfAny

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
private static PsiFile getInjectedFileIfAny(@NotNull final Editor editor, @NotNull final Project project, int offset, @NotNull PsiFile psiFile, @NotNull final Alarm alarm) {
  Document document = editor.getDocument();
  // when document is committed, try to highlight braces in injected lang - it's fast
  if (!PsiDocumentManager.getInstance(project).isUncommited(document)) {
    final PsiElement injectedElement = InjectedLanguageUtil.findInjectedElementNoCommit(psiFile, offset);
    if (injectedElement != null /*&& !(injectedElement instanceof PsiWhiteSpace)*/) {
      final PsiFile injected = injectedElement.getContainingFile();
      if (injected != null) {
        return injected;
      }
    }
  }
  else {
    PsiDocumentManager.getInstance(project).performForCommittedDocument(document, new Runnable() {
      @Override
      public void run() {
        if (!project.isDisposed() && !editor.isDisposed()) {
          BraceHighlighter.updateBraces(editor, alarm);
        }
      }
    });
  }
  return psiFile;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:BraceHighlightingHandler.java

示例6: doFindWhiteSpaceNode

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
private static Pair<PsiElement, CharTable> doFindWhiteSpaceNode(@NotNull PsiFile file, int offset) {
  ASTNode astNode = SourceTreeToPsiMap.psiElementToTree(file);
  if (!(astNode instanceof FileElement)) {
    return new Pair<PsiElement, CharTable>(null, null);
  }
  PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(file, offset);
  final CharTable charTable = ((FileElement)astNode).getCharTable();
  if (elementAt == null) {
    elementAt = findElementInTreeWithFormatterEnabled(file, offset);
  }

  if( elementAt == null) {
    return new Pair<PsiElement, CharTable>(null, charTable);
  }
  ASTNode node = elementAt.getNode();
  if (node == null || node.getElementType() != TokenType.WHITE_SPACE) {
    return new Pair<PsiElement, CharTable>(null, charTable);
  }
  return new Pair<PsiElement, CharTable>(elementAt, charTable);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:CodeStyleManagerImpl.java

示例7: getInjectedFileIfAny

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
private static PsiFile getInjectedFileIfAny(@NotNull final Editor editor,
                                            @NotNull final Project project,
                                            int offset,
                                            @NotNull PsiFile psiFile,
                                            @NotNull final Alarm alarm) {
  Document document = editor.getDocument();
  // when document is committed, try to highlight braces in injected lang - it's fast
  if (PsiDocumentManager.getInstance(project).isCommitted(document)) {
    final PsiElement injectedElement = InjectedLanguageUtil.findInjectedElementNoCommit(psiFile, offset);
    if (injectedElement != null /*&& !(injectedElement instanceof PsiWhiteSpace)*/) {
      final PsiFile injected = injectedElement.getContainingFile();
      if (injected != null) {
        return injected;
      }
    }
  }
  else {
    PsiDocumentManager.getInstance(project).performForCommittedDocument(document, new Runnable() {
      @Override
      public void run() {
        if (!project.isDisposed() && !editor.isDisposed()) {
          BraceHighlighter.updateBraces(editor, alarm);
        }
      }
    });
  }
  return psiFile;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:BraceHighlightingHandler.java

示例8: 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

示例9: 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

示例10: getContext

import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; //导入方法依赖的package包/类
@NotNull
public static PsiElement getContext(@NotNull PsiFile file, int offset) {
  PsiElement element = null;
  if (!InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file)) {
    element = InjectedLanguageUtil.findInjectedElementNoCommit(file, offset);
  }
  if (element == null) {
    element = file.findElementAt(offset);
    if (element == null) {
      element = file;
    }
  }
  return element;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:CustomTemplateCallback.java


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