本文整理匯總了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);
}