当前位置: 首页>>代码示例>>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;未经允许,请勿转载。