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


Java DebugUtil类代码示例

本文整理汇总了Java中com.intellij.psi.impl.DebugUtil的典型用法代码示例。如果您正苦于以下问题:Java DebugUtil类的具体用法?Java DebugUtil怎么用?Java DebugUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: PsiClassStubImpl

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
public PsiClassStubImpl(final JavaClassElementType type,
                        final StubElement parent,
                        final StringRef qualifiedName,
                        final StringRef name,
                        final StringRef baseRefText,
                        final byte flags) {
  super(parent, type);
  myQualifiedName = qualifiedName;
  myName = name;
  myBaseRefText = baseRefText;
  myFlags = flags;
  if (StubBasedPsiElementBase.ourTraceStubAstBinding) {
    String creationTrace = "Stub creation thread: " + Thread.currentThread() + "\n" + DebugUtil.currentStackTrace();
    putUserData(StubBasedPsiElementBase.CREATION_TRACE, creationTrace);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PsiClassStubImpl.java

示例2: addImportForItem

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
public static void addImportForItem(InsertionContext context, PsiClass aClass) {
  if (aClass.getQualifiedName() == null) return;
  PsiFile file = context.getFile();

  int startOffset = context.getStartOffset();
  int tail = context.getTailOffset();
  int newTail = JavaCompletionUtil.insertClassReference(aClass, file, startOffset, tail);
  if (newTail > context.getDocument().getTextLength() || newTail < 0) {
    LOG.error(LogMessageEx.createEvent("Invalid offset after insertion ",
                                       "offset=" + newTail + "\n" +
                                       "start=" + startOffset + "\n" +
                                       "tail=" + tail + "\n" +
                                       "file.length=" + file.getTextLength() + "\n" +
                                       "document=" + context.getDocument() + "\n" +
                                       DebugUtil.currentStackTrace(),
                                       AttachmentFactory.createAttachment(context.getDocument())));
    return;

  }
  context.setTailOffset(newTail);
  JavaCompletionUtil.shortenReference(file, context.getStartOffset());
  PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PsiTypeLookupItem.java

示例3: testSOEProof

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
public void testSOEProof() {
  final StringBuilder sb = new StringBuilder();
  final SecureRandom random = new SecureRandom();
  sb.append("class SOE_test {\n BigInteger BIG = new BigInteger(\n");
  int i;
  for (i = 0; i < 100000; i++) {
    sb.append("  \"").append(Math.abs(random.nextInt())).append("\" +\n");
  }
  sb.append("  \"\");\n}");

  final PsiJavaFile file = (PsiJavaFile)createLightFile("SOE_test.java", sb.toString());
  long t = System.currentTimeMillis();
  final StubElement tree = NEW_BUILDER.buildStubTree(file);
  t = System.currentTimeMillis() - t;
  assertEquals("PsiJavaFileStub []\n" +
               "  IMPORT_LIST:PsiImportListStub\n" +
               "  CLASS:PsiClassStub[name=SOE_test fqn=SOE_test]\n" +
               "    MODIFIER_LIST:PsiModifierListStub[mask=4096]\n" +
               "    TYPE_PARAMETER_LIST:PsiTypeParameterListStub\n" +
               "    EXTENDS_LIST:PsiRefListStub[EXTENDS_LIST:]\n" +
               "    IMPLEMENTS_LIST:PsiRefListStub[IMPLEMENTS_LIST:]\n" +
               "    FIELD:PsiFieldStub[BIG:BigInteger=;INITIALIZER_NOT_STORED;]\n" +
               "      MODIFIER_LIST:PsiModifierListStub[mask=4096]\n",
               DebugUtil.stubTreeToString(tree));
  System.out.println("SOE depth=" + i + ", time=" + t + "ms");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:continuationIndents_DoNotCount.java

示例4: testMergeWhenEmptyElementAfterWhitespaceIsLastChild

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
public void testMergeWhenEmptyElementAfterWhitespaceIsLastChild() throws Throwable {
  myBuilder = createBuilder(" foo bar");
  parseWhenEmptyElementAfterWhitespaceIsLastChild();
  final ASTNode tree = myBuilder.getTreeBuilt();
  new DummyHolder(getPsiManager(), (TreeElement)tree, null);

  myBuilder = createBuilder("  bar", tree);
  parseWhenEmptyElementAfterWhitespaceIsLastChild();
  DebugUtil.startPsiModification(null);
  try {
    myBuilder.getTreeBuilt();
    fail();
  }
  catch (BlockSupport.ReparsedSuccessfullyException e) {
    e.getDiffLog().performActualPsiChange(tree.getPsi().getContainingFile());
  }
  finally {
    DebugUtil.finishPsiModification();
  }

  assertEquals("  bar", tree.getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PsiBuilderTest.java

示例5: testSOEProof

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
public void testSOEProof() {
  StringBuilder sb = new StringBuilder();
  SecureRandom random = new SecureRandom();
  sb.append("class SOE_test {\n BigInteger BIG = new BigInteger(\n");
  int i;
  for (i = 0; i < 100000; i++) {
    sb.append("  \"").append(Math.abs(random.nextInt())).append("\" +\n");
  }
  sb.append("  \"\");\n}");

  PsiJavaFile file = (PsiJavaFile)createLightFile("SOE_test.java", sb.toString());
  long t = System.currentTimeMillis();
  StubElement tree = myBuilder.buildStubTree(file);
  t = System.currentTimeMillis() - t;
  assertEquals("PsiJavaFileStub []\n" +
               "  IMPORT_LIST:PsiImportListStub\n" +
               "  CLASS:PsiClassStub[name=SOE_test fqn=SOE_test]\n" +
               "    MODIFIER_LIST:PsiModifierListStub[mask=4096]\n" +
               "    TYPE_PARAMETER_LIST:PsiTypeParameterListStub\n" +
               "    EXTENDS_LIST:PsiRefListStub[EXTENDS_LIST:]\n" +
               "    IMPLEMENTS_LIST:PsiRefListStub[IMPLEMENTS_LIST:]\n" +
               "    FIELD:PsiFieldStub[BIG:BigInteger=;INITIALIZER_NOT_STORED;]\n" +
               "      MODIFIER_LIST:PsiModifierListStub[mask=4096]\n",
               DebugUtil.stubTreeToString(tree));
  System.out.println("SOE depth=" + i + ", time=" + t + "ms");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JavaStubBuilderTest.java

示例6: doTest

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
private void doTest(String source, String expected) {
  PsiJavaFile file = (PsiJavaFile)createLightFile("test.java", source);
  FileASTNode fileNode = file.getNode();
  assertNotNull(fileNode);
  assertFalse(fileNode.isParsed());

  StubElement lightTree = myBuilder.buildStubTree(file);
  assertFalse(fileNode.isParsed());

  file.getNode().getChildren(null); // force switch to AST
  StubElement astBasedTree = myBuilder.buildStubTree(file);
  assertTrue(fileNode.isParsed());

  assertEquals("light tree differs", expected, DebugUtil.stubTreeToString(lightTree));
  assertEquals("AST-based tree differs", expected, DebugUtil.stubTreeToString(astBasedTree));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaStubBuilderTest.java

示例7: getElementAtCaret

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
@Override
@NotNull
public PsiElement getElementAtCaret() {
  assertInitialized();
  Editor editor = getCompletionEditor();
  int findTargetFlags = TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED | TargetElementUtil.ELEMENT_NAME_ACCEPTED;
  PsiElement element = TargetElementUtil.findTargetElement(editor, findTargetFlags);

  // if no references found in injected fragment, try outer document
  if (element == null && editor instanceof EditorWindow) {
    element = TargetElementUtil.findTargetElement(((EditorWindow)editor).getDelegate(), findTargetFlags);
  }

  if (element == null) {
    Assert.fail("element not found in file " + myFile.getName() +
                " at caret position offset " + myEditor.getCaretModel().getOffset() +  "," +
                " psi structure:\n" + DebugUtil.psiToString(getFile(), true, true));
  }
  return element;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CodeInsightTestFixtureImpl.java

示例8: actionPerformed

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
  if (myLagging) {
    myLagging = false;
    myAlarm.cancelAllRequests();
  }
  else {
    myLagging = true;
    for (int i = 0; i < 100; i++) {
      new Runnable() {
        @Override
        public void run() {
          DebugUtil.sleep(5);
          ProgressManager.getInstance().runProcessWithProgressAsynchronously(new Task.Backgroundable(null, "lagging") {
            @Override
            public void run(@NotNull ProgressIndicator indicator) {
              DebugUtil.sleep(1);
            }
          }, new EmptyProgressIndicator());
          if (myLagging) {
            myAlarm.addRequest(this, 1);
          }
        }
      }.run();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ToggleLaggingModeAction.java

示例9: failedToBindStubToAst

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
private ASTNode failedToBindStubToAst(PsiFileImpl file, FileElement fileElement) {
  VirtualFile vFile = file.getVirtualFile();
  StubTree stubTree = file.getStubTree();
  String stubString = stubTree != null ? ((PsiFileStubImpl)stubTree.getRoot()).printTree() : "is null";
  String astString = DebugUtil.treeToString(fileElement, true);
  if (!ourTraceStubAstBinding) {
    stubString = StringUtil.trimLog(stubString, 1024);
    astString = StringUtil.trimLog(astString, 1024);
  }

  @NonNls String message = "Failed to bind stub to AST for element " + getClass() + " in " +
                           (vFile == null ? "<unknown file>" : vFile.getPath()) +
                           "\nFile:\n" + file + "@" + System.identityHashCode(file) +
                           "\nFile stub tree:\n" + stubString +
                           "\nLoaded file AST:\n" + astString;
  if (ourTraceStubAstBinding) {
    message += dumpCreationTraces(fileElement);
  }
  throw new IllegalArgumentException(message);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:StubBasedPsiElementBase.java

示例10: rawAddChildrenWithoutNotifications

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
public void rawAddChildrenWithoutNotifications(TreeElement first) {
  final TreeElement last = getLastChildNode();
  if (last == null){
    first.rawRemoveUpToWithoutNotifications(null, false);
    setFirstChildNode(first);
    while(true){
      final TreeElement treeNext = first.getTreeNext();
      first.setTreeParent(this);
      if(treeNext == null) break;
      first = treeNext;
    }
    setLastChildNode(first);
    first.setTreeParent(this);
  }
  else {
    last.rawInsertAfterMeWithoutNotifications(first);
  }

  DebugUtil.checkTreeStructure(this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CompositeElement.java

示例11: rawRemove

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
public void rawRemove() {
  final TreeElement next = getTreeNext();
  final CompositeElement parent = getTreeParent();
  final TreeElement prev = getTreePrev();

  if(prev != null){
    prev.setTreeNext(next);
  }
  else if(parent != null) {
    parent.setFirstChildNode(next);
  }

  if(next != null){
    next.setTreePrev(prev);
  }
  else if(parent != null) {
    parent.setLastChildNode(prev);
  }

  DebugUtil.checkTreeStructure(parent);
  DebugUtil.checkTreeStructure(prev);
  DebugUtil.checkTreeStructure(next);

  invalidate();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TreeElement.java

示例12: doActualPsiChange

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
@Override
void doActualPsiChange(@NotNull PsiFile file, @NotNull ASTDiffBuilder astDiffBuilder) {
  ASTNode child = myOldNode;
  ASTNode parent = myOldParent;

  PsiElement psiParent = parent.getPsi();
  PsiElement psiChild = file.isPhysical() ? child.getPsi() : null;

  if (psiParent != null && psiChild != null) {
    PsiTreeChangeEventImpl event = new PsiTreeChangeEventImpl(file.getManager());
    event.setParent(psiParent);
    event.setChild(psiChild);
    event.setFile(file);
    ((PsiManagerEx)file.getManager()).beforeChildRemoval(event);
  }

  astDiffBuilder.nodeDeleted(parent, child);

  ((TreeElement)child).rawRemove();
  ((CompositeElement)parent).subtreeChanged();

  DebugUtil.checkTreeStructure(parent);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DiffLog.java

示例13: watchTail

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
private void watchTail(int offset) {
  stopWatching();
  tailWatcher = (RangeMarkerEx)getDocument().createRangeMarker(offset, offset);
  if (!tailWatcher.isValid()) {
    throw new AssertionError(getDocument() + "; offset=" + offset);
  }
  tailWatcher.setGreedyToRight(true);
  spy = new RangeMarkerSpy(tailWatcher) {
    @Override
    protected void invalidated(DocumentEvent e) {
      if (ApplicationManager.getApplication().isUnitTestMode()) {
        LOG.error("Tail offset invalidated, say thanks to the "+ e);
      }

      if (invalidateTrace == null) {
        invalidateTrace = DebugUtil.currentStackTrace();
        killer = e;
      }
    }
  };
  getDocument().addDocumentListener(spy);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CompletionAssertions.java

示例14: createActions

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
@NotNull
@Override
protected Action[] createActions() {
  AbstractAction copyPsi = new AbstractAction("Cop&y PSI") {
    @Override
    public void actionPerformed(@NotNull ActionEvent e) {
      PsiElement element = parseText(myEditor.getDocument().getText());
      List<PsiElement> allToParse = new ArrayList<PsiElement>();
      if (element instanceof PsiFile) {
        allToParse.addAll(((PsiFile)element).getViewProvider().getAllFiles());
      }
      else if (element != null) {
        allToParse.add(element);
      }
      String data = "";
      for (PsiElement psiElement : allToParse) {
        data += DebugUtil.psiToString(psiElement, !myShowWhiteSpacesBox.isSelected(), true);
      }
      CopyPasteManager.getInstance().setContents(new StringSelection(data));
    }
  };
  return ArrayUtil.mergeArrays(new Action[]{copyPsi}, super.createActions());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PsiViewerDialog.java

示例15: stubTreeAndIndexDoNotMatch

import com.intellij.psi.impl.DebugUtil; //导入依赖的package包/类
@Override
protected Object stubTreeAndIndexDoNotMatch(@NotNull ObjectStubTree stubTree, PsiFileWithStubSupport psiFile) {
  final VirtualFile virtualFile = psiFile.getVirtualFile();
  StubTree stubTreeFromIndex = (StubTree)StubTreeLoader.getInstance().readFromVFile(psiFile.getProject(), virtualFile);
  String details = "Please report the problem to JetBrains with the file attached";
  details += StubTreeLoader.getInstance().getStubAstMismatchDiagnostics(virtualFile, psiFile, stubTree, null);
  details += "\n" + DebugUtil.currentStackTrace();
  String fileText = psiFile instanceof PsiCompiledElement ? "compiled" : psiFile.getText();
  return LogMessageEx.createEvent("PSI and index do not match",
                                  details,
                                  new Attachment(virtualFile.getPath() + "_file.txt", fileText),
                                  new Attachment("stubTree.txt", ((PsiFileStubImpl)stubTree.getRoot()).printTree()),
                                  new Attachment("stubTreeFromIndex.txt", stubTreeFromIndex == null
                                                                          ? "null"
                                                                          : ((PsiFileStubImpl)stubTreeFromIndex.getRoot()).printTree()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:StubProcessingHelper.java


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