类com.intellij.psi.text.BlockSupport源码实例Demo

下面列出了怎么用com.intellij.psi.text.BlockSupport的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: glsl4idea   文件: GLSLParser.java
@Override
@NotNull
public ASTNode parse(@NotNull IElementType root, @NotNull PsiBuilder builder) {
    try {
        parseLight(root, builder);
        return builder.getTreeBuilt();
    } catch (ProcessCanceledException | BlockSupport.ReparsedSuccessfullyException expected) {
        // Not a problem
        throw expected;
    } catch (Exception ex) {
        crashing = true;
        Logger.getLogger("GLSLParser").log(Level.WARNING, "Crashed while trying to parse "+root, ex);
        throw ex;
    }
}
 
源代码2 项目: consulo   文件: PomModelImpl.java
@Nullable
private Runnable reparseFile(@Nonnull final PsiFile file, @Nonnull FileElement treeElement, @Nonnull CharSequence newText) {
  TextRange changedPsiRange = ChangedPsiRangeUtil.getChangedPsiRange(file, treeElement, newText);
  if (changedPsiRange == null) return null;

  final DiffLog log = BlockSupport.getInstance(myProject).reparseRange(file, treeElement, changedPsiRange, newText, new EmptyProgressIndicator(), treeElement.getText());
  return () -> runTransaction(new PomTransactionBase(file, getModelAspect(TreeAspect.class)) {
    @Override
    public PomModelEvent runInner() throws IncorrectOperationException {
      return new TreeAspectEvent(PomModelImpl.this, log.performActualPsiChange(file));
    }
  });
}
 
源代码3 项目: consulo   文件: PsiBuilderImpl.java
public PsiBuilderImpl(@Nonnull Project project,
                      @Nonnull ParserDefinition parserDefinition,
                      @Nonnull LanguageVersion languageVersion,
                      @Nonnull Lexer lexer,
                      @Nonnull ASTNode chameleon,
                      @Nonnull CharSequence text) {
  this(project, SharedImplUtil.getContainingFile(chameleon), languageVersion, parserDefinition, lexer, SharedImplUtil.findCharTableByTree(chameleon), text,
       Pair.getFirst(chameleon.getUserData(BlockSupport.TREE_TO_BE_REPARSED)), Pair.getSecond(chameleon.getUserData(BlockSupport.TREE_TO_BE_REPARSED)), null,
       chameleon);
}
 
源代码4 项目: consulo   文件: PsiBuilderImpl.java
private void checkTreeDepth(final int maxDepth, final boolean isFileRoot) {
  if (myFile == null) return;
  final PsiFile file = myFile.getOriginalFile();
  final Boolean flag = file.getUserData(BlockSupport.TREE_DEPTH_LIMIT_EXCEEDED);
  if (maxDepth > BlockSupport.INCREMENTAL_REPARSE_DEPTH_LIMIT) {
    if (!Boolean.TRUE.equals(flag)) {
      file.putUserData(BlockSupport.TREE_DEPTH_LIMIT_EXCEEDED, Boolean.TRUE);
    }
  }
  else if (isFileRoot && flag != null) {
    file.putUserData(BlockSupport.TREE_DEPTH_LIMIT_EXCEEDED, null);
  }
}
 
源代码5 项目: consulo   文件: DocumentCommitThread.java
private static void assertAfterCommit(@Nonnull Document document, @Nonnull final PsiFile file, @Nonnull FileElement oldFileNode) {
  if (oldFileNode.getTextLength() != document.getTextLength()) {
    final String documentText = document.getText();
    String fileText = file.getText();
    boolean sameText = Comparing.equal(fileText, documentText);
    String errorMessage = "commitDocument() left PSI inconsistent: " +
                          DebugUtil.diagnosePsiDocumentInconsistency(file, document) +
                          "; node.length=" +
                          oldFileNode.getTextLength() +
                          "; doc.text" +
                          (sameText ? "==" : "!=") +
                          "file.text" +
                          "; file name:" +
                          file.getName() +
                          "; type:" +
                          file.getFileType() +
                          "; lang:" +
                          file.getLanguage();
    //PluginException.logPluginError(LOG, errorMessage, null, file.getLanguage().getClass());
    LOG.error(errorMessage);

    file.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, Boolean.TRUE);
    try {
      BlockSupport blockSupport = BlockSupport.getInstance(file.getProject());
      final DiffLog diffLog = blockSupport.reparseRange(file, file.getNode(), new TextRange(0, documentText.length()), documentText, createProgressIndicator(), oldFileNode.getText());
      diffLog.doActualPsiChange(file);

      if (oldFileNode.getTextLength() != document.getTextLength()) {
        LOG.error("PSI is broken beyond repair in: " + file);
        //PluginException.logPluginError(LOG, "PSI is broken beyond repair in: " + file, null, file.getLanguage().getClass());
      }
    }
    finally {
      file.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, null);
    }
  }
}
 
源代码6 项目: consulo   文件: PsiDocumentManagerBase.java
@Override
public void bulkUpdateStarting(@Nonnull Document document) {
  document.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, Boolean.TRUE);
}
 
 类所在包
 类方法
 同包方法