本文整理匯總了Java中com.intellij.psi.impl.source.tree.LeafPsiElement類的典型用法代碼示例。如果您正苦於以下問題:Java LeafPsiElement類的具體用法?Java LeafPsiElement怎麽用?Java LeafPsiElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LeafPsiElement類屬於com.intellij.psi.impl.source.tree包,在下文中一共展示了LeafPsiElement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invokeAutoPopup
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@Override
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
MethodReference reference = PsiTreeUtil.getParentOfType(position, MethodReference.class);
if (reference != null && ArrayUtil.contains(reference.getName(), ViewsUtil.renderMethods)) {
if (typeChar == '\'' || typeChar == '"') {
if (position instanceof LeafPsiElement && position.getText().equals("$view")) {
return true;
}
if (position.getNextSibling() instanceof ParameterList) {
return true;
}
}
}
return false;
}
示例2: findPropsNameListWithIdentityReference
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@NotNull
private List<PropTypeBean> findPropsNameListWithIdentityReference(String identity, PsiElement psiElement){
return PsiTreeUtil.findChildrenOfType(psiElement, LeafPsiElement.class)
.stream()
.filter(o -> o.getText().equals(identity))
.filter(o -> o.getElementType().toString().equals("JS:IDENTIFIER"))
.filter(o -> {
if(o.getParent() instanceof JSReferenceExpressionImpl){
JSReferenceExpressionImpl parent = (JSReferenceExpressionImpl) o.getParent();
if(parent.getTreeNext()!=null && parent.getTreeNext().getElementType().toString().equals("JS:DOT")
&&parent.getTreeNext().getTreeNext()!=null){
return true;
}
}
return false;
})
.map(o -> ((JSReferenceExpressionImpl)o.getParent()).getTreeNext().getTreeNext().getText())
.distinct()
.map(o -> new PropTypeBean(o,"any", false))
.collect(Collectors.toList());
}
示例3: invokeAutoPopup
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@Override
public boolean invokeAutoPopup(@NotNull PsiElement position, char typeChar) {
MethodReference reference = PsiTreeUtil.getParentOfType(position, MethodReference.class);
if (reference != null && reference.getName() != null && reference.getName().equals("t") && reference.getClassReference() instanceof ClassReference) {
ClassReference classReference = (ClassReference) reference.getClassReference();
if (classReference == null || classReference.getName() == null || !classReference.getName().equals("Yii")) {
return false;
}
if (typeChar == '\'' || typeChar == '"') {
if (position instanceof LeafPsiElement && (position.getText().equals("$category") || position.getText().equals("$message"))) {
return true;
}
if (position.getNextSibling() instanceof ParameterList) {
return true;
}
}
}
return false;
}
示例4: calculateEndOffsetReductor
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
private static int calculateEndOffsetReductor(
@NotNull final PsiElement directive,
final boolean isDefinitivelyClosing
) {
if (!isDefinitivelyClosing) {
final PsiElement directiveWhitespace = directive.getPrevSibling();
if (directiveWhitespace instanceof LeafPsiElement) {
final String directiveWhitespaceText = directiveWhitespace.getText();
final int lastBreakline = directiveWhitespaceText.lastIndexOf('\n');
if (lastBreakline != -1) {
return directiveWhitespaceText.length() - lastBreakline;
}
}
}
return 0;
}
示例5: checkPsiElement
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
/**
* @param psiElement checking element
* @return true if this is process.env.*** variable
*/
public static boolean checkPsiElement(@NotNull PsiElement psiElement) {
if(!(psiElement instanceof LeafPsiElement)) {
return false;
}
IElementType elementType = ((LeafPsiElement) psiElement).getElementType();
if(!elementType.toString().equals("JS:IDENTIFIER")) {
return false;
}
PsiElement parent = psiElement.getParent();
if(!(parent instanceof JSReferenceExpression)) {
return false;
}
return ((JSReferenceExpression) parent).getCanonicalText().startsWith("process.env");
}
示例6: annotate
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof LeafPsiElement) {
final LeafPsiElement psiElement = (LeafPsiElement) element;
if (psiElement.getElementType().equals(CptTypes.CLASS_NAME)) {
final String className = element.getText();
SupportedLanguages.getCptLang(element).ifPresent(lang -> {
final CptLangAnnotator annotator = lang.getAnnotator();
if (!annotator.isMatchingType(psiElement, className)) {
holder.createErrorAnnotation(element.getTextRange(), "Class not found");
}
});
}
}
}
示例7: getGotoDeclarationTarget
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@Nullable
@Override
public PsiElement getGotoDeclarationTarget(final PsiElement sourceElement, final Editor editor) {
if (!(sourceElement instanceof LeafPsiElement)
|| !(((LeafPsiElement) sourceElement)
.getElementType().equals(ImpexTypes.MACRO_USAGE))) {
return null;
}
final PsiFile originalFile = sourceElement.getContainingFile();
final Collection<ImpexMacroDeclaration> macroDeclarations =
PsiTreeUtil.findChildrenOfType(
originalFile,
ImpexMacroDeclaration.class
);
if (!macroDeclarations.isEmpty()) {
for (final ImpexMacroDeclaration declaration : macroDeclarations) {
if (sourceElement.textMatches(declaration.getFirstChild())) {
return declaration.getFirstChild();
}
}
}
return null;
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:27,代碼來源:ImpexMacrosGoToDeclarationHandler.java
示例8: applyFix
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
PsiElement element = problemDescriptor.getPsiElement();
if ( ! (element instanceof PhpClass)) {
return;
}
PsiFile containingFile = element.getContainingFile();
PsiDocumentManager manager = PsiDocumentManager.getInstance(project);
Document document = manager.getDocument(containingFile);
PhpClass phpClass = (PhpClass) element;
PsiElement abstractKeyword = PhpPsiElementFactory.createFromText(project, LeafPsiElement.class, "abstract");
if (abstractKeyword == null) {
return;
}
phpClass.addBefore(abstractKeyword, phpClass.getFirstChild());
if (document != null) {
manager.doPostponedOperationsAndUnblockDocument(document);
TextRange reformatRange = abstractKeyword.getTextRange();
CodeStyleManager.getInstance(project).reformatText(containingFile, reformatRange.getStartOffset(), reformatRange.getEndOffset());
}
}
示例9: insertItemIntoListRemoveRedundantCommas
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@Override
@NotNull
public PsiElement insertItemIntoListRemoveRedundantCommas(
@NotNull final PyElement list,
@Nullable final PyExpression afterThis,
@NotNull final PyExpression toInsert) {
// TODO: #insertItemIntoList is probably buggy. In such case, fix it and get rid of this method
final PsiElement result = insertItemIntoList(list, afterThis, toInsert);
final LeafPsiElement[] leafs = PsiTreeUtil.getChildrenOfType(list, LeafPsiElement.class);
if (leafs != null) {
final Deque<LeafPsiElement> commas = Queues.newArrayDeque(Collections2.filter(Arrays.asList(leafs), COMMAS_ONLY));
if (!commas.isEmpty()) {
final LeafPsiElement lastComma = commas.getLast();
if (PsiTreeUtil.getNextSiblingOfType(lastComma, PyExpression.class) == null) { //Comma has no expression after it
lastComma.delete();
}
}
}
return result;
}
示例10: reformatClosure
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
/**
* Automatically reformats all the Groovy code inside the given closure.
*/
static void reformatClosure(@NotNull GrStatementOwner closure) {
new ReformatCodeProcessor(closure.getProject(), closure.getContainingFile(), closure.getParent().getTextRange(), false)
.runWithoutProgress();
// Now strip out any blank lines. They tend to accumulate otherwise. To do this, we iterate through our elements and find those that
// consist only of whitespace, and eliminate all double-newline occurrences.
for (PsiElement psiElement : closure.getChildren()) {
if (psiElement instanceof LeafPsiElement) {
String text = psiElement.getText();
if (StringUtil.isEmptyOrSpaces(text)) {
String newText = text;
while (newText.contains("\n\n")) {
newText = newText.replaceAll("\n\n", "\n");
}
if (!newText.equals(text)) {
((LeafPsiElement)psiElement).replaceWithText(newText);
}
}
}
}
}
示例11: visitElement
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@Override
public void visitElement(final @NotNull PsiElement element) {
PsiElement e = element;
while (e.getParent() != null) {
myString.append(" ");
e = e.getParent();
}
myString.append(element.getClass().getName());
myString.append(": ");
myString.append(element.toString());
if (element instanceof LeafPsiElement) {
myString.append(" ");
myString.append(element.getText());
}
myString.append("\n");
super.visitElement(element);
}
示例12: namedArgumentLabel
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
public static GroovyElementPattern.Capture<GrArgumentLabel> namedArgumentLabel(@Nullable final ElementPattern<? extends String> namePattern) {
return new GroovyElementPattern.Capture<GrArgumentLabel>(new InitialPatternCondition<GrArgumentLabel>(GrArgumentLabel.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
if (o instanceof GrArgumentLabel) {
PsiElement nameElement = ((GrArgumentLabel)o).getNameElement();
if (nameElement instanceof LeafPsiElement) {
IElementType elementType = ((LeafPsiElement)nameElement).getElementType();
if (elementType == GroovyTokenTypes.mIDENT ||
CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getBoxedTypeName(elementType))) {
return namePattern == null || namePattern.accepts(((GrArgumentLabel)o).getName());
}
}
}
return false;
}
});
}
示例13: processImports
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
private static void processImports(final List<FoldingDescriptor> descriptors, GrImportStatement[] imports) {
if (imports.length < 2) return;
PsiElement first = imports[0];
while (first != null) {
PsiElement marker = first;
PsiElement next = first.getNextSibling();
while (next instanceof GrImportStatement || next instanceof LeafPsiElement) {
if (next instanceof GrImportStatement) marker = next;
next = next.getNextSibling();
}
if (marker != first) {
int start = first.getTextRange().getStartOffset();
int end = marker.getTextRange().getEndOffset();
int tail = "import ".length();
if (start + tail < end && !JavaFoldingBuilderBase.hasErrorElementsNearby(first.getContainingFile(), start, end)) {
descriptors.add(new FoldingDescriptor(first.getNode(), new TextRange(start + tail, end)));
}
}
while (!(next instanceof GrImportStatement) && next != null) next = next.getNextSibling();
first = next;
}
}
示例14: alignSpockTable
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
private void alignSpockTable(List<GrStatement> group) {
if (group.size() < 2) {
return;
}
GrStatement inner = group.get(0);
boolean embedded = inner != null && isTablePart(inner);
GrStatement first = embedded ? inner : group.get(1);
List<AlignmentProvider.Aligner> alignments = ContainerUtil
.map2List(getSpockTable(first), new Function<LeafPsiElement, AlignmentProvider.Aligner>() {
@Override
public AlignmentProvider.Aligner fun(LeafPsiElement leaf) {
return myAlignmentProvider.createAligner(leaf, true, Alignment.Anchor.RIGHT);
}
});
int second = embedded ? 1 : 2;
for (int i = second; i < group.size(); i++) {
List<LeafPsiElement> table = getSpockTable(group.get(i));
for (int j = 0; j < Math.min(table.size(), alignments.size()); j++) {
alignments.get(j).append(table.get(j));
}
}
}
示例15: annotate
import com.intellij.psi.impl.source.tree.LeafPsiElement; //導入依賴的package包/類
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder)
{
PsiElement parent = psiElement.getParent();
IElementType type = psiElement instanceof LeafPsiElement ? psiElement.getNode().getElementType() : null;
// LBRACE || RBRACE
if (parent instanceof PhpDocTagModifier && (type == PhpDocTokenTypes.DOC_LBRACE || type == PhpDocTokenTypes.DOC_RBRACE)) {
annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(ModifierHighlighter.BRACES);
} else if (psiElement instanceof PhpDocTagModifierName) {
annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(ModifierHighlighter.MODIFIER);
} else if (psiElement instanceof PhpDocTagModifierIdentifier || psiElement instanceof PhpDocTagModifierClassType) {
annotationHolder.createInfoAnnotation(psiElement, null).setTextAttributes(ModifierHighlighter.IDENTIFIER);
}
}