當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiFile.getChildren方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiFile.getChildren方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiFile.getChildren方法的具體用法?Java PsiFile.getChildren怎麽用?Java PsiFile.getChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiFile的用法示例。


在下文中一共展示了PsiFile.getChildren方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: EmojiCheckinHandler

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
public EmojiCheckinHandler(CheckinProjectPanel checkinProjectPanel) {
	JPanel emojiPanel = new JPanel();
	emojiPanel.setLayout(new VerticalFlowLayout());
	VirtualFile emojirc = checkinProjectPanel.getProject().getBaseDir().findChild(".emojirc");
	if (emojirc == null) return;
	PsiFile psiFile = PsiManager.getInstance(checkinProjectPanel.getProject()).findFile(emojirc);
	if (psiFile == null) return;
	for (PsiElement psiElement : psiFile.getChildren()) {
		if (!(psiElement instanceof EmojiResourceProperty)) continue;
		emojiPanel.add(createEmojiButton(psiElement.getFirstChild().getText(), psiElement.getLastChild().getText(), false, buttonGroup));
	}
	emojiPanel.add(createEmojiButton(null, NO_EMOJI, true, buttonGroup));
	Splitter splitter = (Splitter) checkinProjectPanel.getComponent();
	CommitMessage commitMessage = (CommitMessage) splitter.getSecondComponent();
	JComponent component = (JComponent) commitMessage.getComponent(1);
	JBScrollPane scrollPane = new JBScrollPane(emojiPanel);
	scrollPane.setBorder(null);
	Splitter commitSplitter = new Splitter();
	commitSplitter.setFirstComponent(scrollPane);
	commitSplitter.setSecondComponent((JComponent) commitMessage.getComponent(0));
	commitMessage.add(commitSplitter, 0);
	for (EmojiPanelFactory factory : factories) {
		factory.createPanel(commitMessage);
	}
	this.checkinProjectPanel = checkinProjectPanel;
}
 
開發者ID:syuchan1005,項目名稱:EmojiPrefix,代碼行數:27,代碼來源:EmojiCheckinHandler.java

示例2: findFirstImportIndex

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
int findFirstImportIndex(PsiFile file){
  PsiElement[] children = file.getChildren();
  for (PsiElement aChildren : children) {
    if (aChildren instanceof PsiWhiteSpace) {
      continue;
    }
    if (aChildren instanceof PsiComment) {
      continue;
    }
    return aChildren.getTextRange().getStartOffset();
  }
  return 0;
}
 
開發者ID:dpzxsm,項目名稱:ReactPropTypes-Plugin,代碼行數:14,代碼來源:CommonAction.java

示例3: handleInsert

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Override
public void handleInsert(InsertionContext context)
{
    // Remove the text the user typed.
    context
        .getDocument()
        .deleteString(context.getStartOffset(), context.getTailOffset());

    context.commitDocument();

    // Grab the deepest property available for insertion... hø hø hø!
    JSProperty targetProperty = getTargetProperty(context.getFile());
    // Generate the remaining jsNotation.
    String quote = JSCodeStyleSettings.getQuote(targetProperty);
    String jsNotation = setting.toRelativeJsNotation(targetProperty, quote);

    // Create a new file to initiate all lexers, parsers grumpkins and snarks...
    PsiFile psiContainer = PsiFileFactory
        .getInstance(context.getProject())
        .createFileFromText(targetProperty.getLanguage(), jsNotation);

    JSExpression value = targetProperty.getValue();

    if (value == null)
    {
        return;
    }

    PsiElement[] childrenForInsertion = psiContainer.getChildren();
    // Insert in reverse order. Probably an easier way, but this works just fine...
    ArrayUtils.reverse(childrenForInsertion);

    // Grab all created elements in the temporary file and insert them into the document.
    for (PsiElement completion : childrenForInsertion)
    {
        value.addAfter(completion, value.getFirstChild());
    }

    PsiElement formattedValue = CodeStyleManager
        .getInstance(context.getProject())
        .reformat(value);

    value.replace(formattedValue);

    List<LookupElement> subCompletions = setting.getSubCompletionVariants();
    // User does not need to edit bools or enums with single value.
    if (setting.getType().equals("Boolean") || subCompletions.size() == 1)
    {
        return;
    }

    context.commitDocument();
    moveCursor(context);

    if (subCompletions.size() > 1)
    {
        AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(context.getEditor());
    }
}
 
開發者ID:whitefire,項目名稱:roc-completion,代碼行數:60,代碼來源:SettingLookupElement.java


注:本文中的com.intellij.psi.PsiFile.getChildren方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。