use of com.intellij.psi.PsiNameIdentifierOwner in project intellij-community by JetBrains.
the class RenameChangeInfo method perform.
public void perform() {
final PsiNameIdentifierOwner element = getNamedElement();
if (element != null) {
final String name = element.getName();
ApplicationManager.getApplication().runWriteAction(() -> {
element.setName(myOldName);
});
new RenameProcessor(element.getProject(), element, name, false, false).run();
}
}
use of com.intellij.psi.PsiNameIdentifierOwner in project intellij-community by JetBrains.
the class NamedElementDuplicateHandler method findNameIdentifier.
@Nullable
private static PsiElement findNameIdentifier(Editor editor, PsiFile file, TextRange toDuplicate) {
int nonWs = CharArrayUtil.shiftForward(editor.getDocument().getCharsSequence(), toDuplicate.getStartOffset(), "\n\t ");
PsiElement psi = file.findElementAt(nonWs);
PsiElement named = null;
while (psi != null) {
TextRange range = psi.getTextRange();
if (range == null || psi instanceof PsiFile || !toDuplicate.contains(psi.getTextRange())) {
break;
}
if (psi instanceof PsiNameIdentifierOwner) {
named = ((PsiNameIdentifierOwner) psi).getNameIdentifier();
}
psi = psi.getParent();
}
return named;
}
use of com.intellij.psi.PsiNameIdentifierOwner in project intellij-community by JetBrains.
the class ChangeSignatureAction method findTargetMember.
@Nullable
private static PsiElement findTargetMember(@Nullable PsiElement element) {
if (element == null)
return null;
final ChangeSignatureHandler fileHandler = getChangeSignatureHandler(element.getLanguage());
if (fileHandler != null) {
final PsiElement targetMember = fileHandler.findTargetMember(element);
if (targetMember != null)
return targetMember;
}
PsiReference reference = element.getReference();
if (reference == null && element instanceof PsiNameIdentifierOwner) {
return element;
}
if (reference != null) {
return reference.resolve();
}
return null;
}
use of com.intellij.psi.PsiNameIdentifierOwner in project intellij-community by JetBrains.
the class RelatedItemLineMarkerProvider method collectNavigationMarkers.
public void collectNavigationMarkers(List<PsiElement> elements, Collection<? super RelatedItemLineMarkerInfo> result, boolean forNavigation) {
//noinspection ForLoopReplaceableByForEach
for (int i = 0, size = elements.size(); i < size; i++) {
PsiElement element = elements.get(i);
collectNavigationMarkers(element, result);
if (forNavigation && element instanceof PsiNameIdentifierOwner) {
PsiElement nameIdentifier = ((PsiNameIdentifierOwner) element).getNameIdentifier();
if (nameIdentifier != null && !elements.contains(nameIdentifier)) {
collectNavigationMarkers(nameIdentifier, result);
}
}
}
}
use of com.intellij.psi.PsiNameIdentifierOwner in project intellij-community by JetBrains.
the class UnfocusedNameIdentifier method shouldFocusLookup.
@NotNull
@Override
public ThreeState shouldFocusLookup(@NotNull CompletionParameters parameters) {
final PsiElement position = parameters.getPosition();
final PsiElement parent = position.getParent();
if (parent instanceof PsiNameIdentifierOwner) {
final PsiElement nameIdentifier = ((PsiNameIdentifierOwner) parent).getNameIdentifier();
if (nameIdentifier == position) {
return ThreeState.NO;
}
if (nameIdentifier != null && position.getTextRange().equals(nameIdentifier.getTextRange())) {
//sometimes name identifiers are non-physical (e.g. Groovy)
return ThreeState.NO;
}
}
return ThreeState.UNSURE;
}
Aggregations