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


Java PsiElement.getLastChild方法代碼示例

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


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

示例1: findPropsNameListInPropTypeObject

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
@NotNull
List<PropTypeBean> findPropsNameListInPropTypeObject(PsiElement expression){
  List<PropTypeBean> paramList = new ArrayList<>();
  if(expression!=null && expression.getLastChild() != null &&  expression.getLastChild() instanceof JSObjectLiteralExpression){
    JSObjectLiteralExpression literalExpression = (JSObjectLiteralExpression) expression.getLastChild();
    JSProperty[] properties = literalExpression.getProperties();
    for (JSProperty property : properties) {
      if(property.getLastChild().getText().contains("PropTypes")){
        Pattern p = Pattern.compile("(React)?\\s*\\.?\\s*PropTypes\\s*\\.\\s*(any|string|object|bool|func|number|array|symbol)\\s*\\.?\\s*(isRequired)?");
        Matcher m = p.matcher(property.getLastChild().getText());
        if(m.matches()){
          String type = m.group(2)==null?"any":m.group(2);
          boolean isRequired = m.group(3) != null;
          paramList.add(new PropTypeBean(property.getName(),type, isRequired));
        }
      }
    }
  }
  return  paramList;
}
 
開發者ID:dpzxsm,項目名稱:ReactPropTypes-Plugin,代碼行數:21,代碼來源:CommonAction.java

示例2: getArrayCreationByFieldRef

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
@Nullable
static ArrayCreationExpression getArrayCreationByFieldRef(FieldReference value) {
    ArrayCreationExpression arrayCreation = null;
    PsiElement arrayDecl = null;
    arrayDecl = value.resolve();
    if (arrayDecl != null && arrayDecl.getParent() != null && arrayDecl.getParent().getChildren().length > 1 ) {
        PsiElement psiElement = arrayDecl.getLastChild();
        if (psiElement instanceof ArrayCreationExpression)
            arrayCreation = (ArrayCreationExpression)psiElement;
        else
            return null;
    } else
        return null;
    return arrayCreation;
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:16,代碼來源:ObjectFactoryUtils.java

示例3: getLastMeaningChild

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
@Nullable
public static PsiElement getLastMeaningChild(PsiElement element) {
  PsiElement last = element.getLastChild();
  return last instanceof PsiWhiteSpace || last instanceof PsiComment
      ? getPrevMeaningSibling(last)
      : last;
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:8,代碼來源:WhitespaceUtils.java

示例4: findPropsNameListInDefaultPropsElement

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
@NotNull
List<DefaultPropType> findPropsNameListInDefaultPropsElement(PsiElement expression){
  List<DefaultPropType> paramList = new ArrayList<>();
  if(expression!=null && expression.getLastChild() != null &&  expression.getLastChild() instanceof JSObjectLiteralExpression){
    JSObjectLiteralExpression literalExpression = (JSObjectLiteralExpression) expression.getLastChild();
    JSProperty[] properties = literalExpression.getProperties();
    for (JSProperty property : properties) {
      String name = property.getName();
      String value = property.getValue()!=null?property.getValue().getText():"";
      DefaultPropType defaultPropType = new DefaultPropType(name, value,PropTypesHelper.getPropTypeByValue(value));
      paramList.add(defaultPropType);
    }
  }
  return  paramList;
}
 
開發者ID:dpzxsm,項目名稱:ReactPropTypes-Plugin,代碼行數:16,代碼來源:CommonAction.java

示例5: quoteAll

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
public static void quoteAll(@NotNull Project project, @NotNull PsiFile psiFile) {
    try {
        Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
        List<Integer> quotePositions = new ArrayList<>();
        Collection<PsiElement> fields = getAllFields(psiFile);
        PsiElement separator;
        for (PsiElement field : fields) {
            if (field.getFirstChild() == null || getElementType(field.getFirstChild()) != CsvTypes.QUOTE) {
                separator = getPreviousSeparator(field);
                if (separator == null) {
                    quotePositions.add(field.getParent().getTextOffset());
                } else {
                    quotePositions.add(separator.getTextOffset() + separator.getTextLength());
                }
            }
            if (field.getLastChild() == null || getElementType(field.getLastChild()) != CsvTypes.QUOTE) {
                separator = getNextSeparator(field);
                if (separator == null) {
                    quotePositions.add(field.getParent().getTextOffset() + field.getParent().getTextLength());
                } else {
                    quotePositions.add(separator.getTextOffset());
                }
            }
        }
        String text = addQuotes(document.getText(), quotePositions);
        document.setText(text);
    } catch (IncorrectOperationException e) {
        LOG.error(e);
    }
}
 
開發者ID:SeeSharpSoft,項目名稱:intellij-csv-validator,代碼行數:31,代碼來源:CsvIntentionHelper.java

示例6: getOpeningQuotePosition

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
public static int getOpeningQuotePosition(PsiElement errorElement) {
    PsiElement lastFieldElement = errorElement;
    while(getElementType(lastFieldElement) != CsvTypes.RECORD) {
        lastFieldElement = lastFieldElement.getPrevSibling();
    }
    lastFieldElement = lastFieldElement.getLastChild();
    if (getElementType(lastFieldElement) != CsvTypes.FIELD) {
        throw new RuntimeException("Field element expected");
    }
    return getOpeningQuotePosition(lastFieldElement.getFirstChild(), lastFieldElement.getLastChild());

}
 
開發者ID:SeeSharpSoft,項目名稱:intellij-csv-validator,代碼行數:13,代碼來源:CsvIntentionHelper.java

示例7: findLastDescendantOfType

import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
private static <T> T findLastDescendantOfType(PsiElement el, Class<T> clazz) {
  while (el != null && !clazz.isInstance(el)) {
    el = el.getLastChild();
  }
  return clazz.cast(el);
}
 
開發者ID:google,項目名稱:bamboo-soy,代碼行數:7,代碼來源:SoyBlock.java


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