use of com.intellij.psi.impl.source.tree.LeafPsiElement in project intellij-community by JetBrains.
the class GrVariableBaseImpl method delete.
@Override
public void delete() throws IncorrectOperationException {
PsiElement parent = getParent();
PsiElement prev = PsiUtil.getPrevNonSpace(this);
PsiElement next = PsiUtil.getNextNonSpace(this);
ASTNode parentNode = parent.getNode();
assert parentNode != null;
super.delete();
if (prev != null && prev.getNode() != null && prev.getNode().getElementType() == GroovyTokenTypes.mCOMMA) {
prev.delete();
} else if (next instanceof LeafPsiElement && next.getNode() != null && next.getNode().getElementType() == GroovyTokenTypes.mCOMMA) {
next.delete();
}
if (parent instanceof GrVariableDeclaration && ((GrVariableDeclaration) parent).getVariables().length == 0) {
parent.delete();
}
}
use of com.intellij.psi.impl.source.tree.LeafPsiElement in project intellij-community by JetBrains.
the class GrArgumentLabelImpl method getReferenceFromNamedArgumentProviders.
@Nullable
private PsiPolyVariantReference getReferenceFromNamedArgumentProviders() {
PsiElement namedArgument = getParent();
if (!(namedArgument instanceof GrNamedArgument))
return null;
PsiElement nameElement = getNameElement();
if (!(nameElement instanceof LeafPsiElement))
return null;
IElementType elementType = ((LeafPsiElement) nameElement).getElementType();
if (elementType != GroovyTokenTypes.mIDENT && !CommonClassNames.JAVA_LANG_STRING.equals(TypesUtil.getBoxedTypeName(elementType))) {
return null;
}
GrCall call = PsiUtil.getCallByNamedParameter((GrNamedArgument) namedArgument);
if (call == null)
return NamedArgumentUtilKt.getReferenceFromDescriptor(this);
String labelName = getName();
Map<String, NamedArgumentDescriptor> providers = GroovyNamedArgumentProvider.getNamedArgumentsFromAllProviders(call, labelName, false);
if (providers != null) {
NamedArgumentDescriptor descr = providers.get(labelName);
if (descr != null) {
PsiPolyVariantReference res = descr.createReference(this);
if (res != null) {
return res;
}
}
}
return null;
}
use of com.intellij.psi.impl.source.tree.LeafPsiElement in project intellij-plugins by JetBrains.
the class GherkinStepParameterImpl method setName.
@Override
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
final LeafPsiElement content = PsiTreeUtil.getChildOfType(this, LeafPsiElement.class);
PsiElement[] elements = GherkinElementFactory.getTopLevelElements(getProject(), name);
getNode().replaceChild(content, elements[0].getNode());
return this;
}
use of com.intellij.psi.impl.source.tree.LeafPsiElement in project intellij-plugins by JetBrains.
the class AngularJavaScriptCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
if (AngularJSCompletionContributor.getElementLanguage(parameters).isKindOf(JavascriptLanguage.INSTANCE)) {
PsiElement originalPosition = parameters.getOriginalPosition();
if (originalPosition == null)
return;
final Project project = originalPosition.getProject();
if (AngularJSReferencesContributor.UI_VIEW_PATTERN.accepts(originalPosition)) {
final FileBasedIndex instance = FileBasedIndex.getInstance();
final Collection<String> keys = instance.getAllKeys(AngularUiRouterViewsIndex.UI_ROUTER_VIEWS_CACHE_INDEX, project);
addCompletionVariants(result, keys, " (angular-ui-router ui-view)");
} else {
originalPosition = originalPosition instanceof LeafPsiElement && ((LeafPsiElement) originalPosition).getElementType() == JSTokenTypes.STRING_LITERAL ? originalPosition.getParent() : originalPosition;
if (AngularJSReferencesContributor.MODULE_PATTERN.accepts(originalPosition) || AngularJSReferencesContributor.MODULE_DEPENDENCY_PATTERN.accepts(originalPosition)) {
final Collection<String> keys = AngularIndexUtil.getAllKeys(AngularModuleIndex.KEY, project);
addCompletionVariants(result, keys, " (AngularJS module)");
}
}
}
}
use of com.intellij.psi.impl.source.tree.LeafPsiElement in project intellij-plugins by JetBrains.
the class JstdTestFileStructureBuilder method addPrototypeTest.
private static void addPrototypeTest(@NotNull JstdTestCaseStructure testCaseStructure, @Nullable JSExpression rightAssignmentOperand, @NotNull JSDefinitionExpression wholeLeftDefExpr) {
JSReferenceExpression wholeLeftRefExpr = ObjectUtils.tryCast(wholeLeftDefExpr.getExpression(), JSReferenceExpression.class);
LeafPsiElement testMethodLeafPsiElement = null;
if (wholeLeftRefExpr != null) {
testMethodLeafPsiElement = ObjectUtils.tryCast(wholeLeftRefExpr.getReferenceNameElement(), LeafPsiElement.class);
}
if (testMethodLeafPsiElement != null && testMethodLeafPsiElement.getElementType() == JSTokenTypes.IDENTIFIER) {
JSFunctionExpression jsFunctionExpression = JsPsiUtils.extractFunctionExpression(rightAssignmentOperand);
JstdTestStructure jstdTestStructure = JstdTestStructure.newPrototypeBasedTestStructure(wholeLeftDefExpr, testMethodLeafPsiElement, jsFunctionExpression);
if (jstdTestStructure != null) {
testCaseStructure.addTestStructure(jstdTestStructure);
}
}
}
Aggregations