本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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());
}
示例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);
}