mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java: helper method for Kotlin
This commit is contained in:
@@ -66,30 +66,39 @@ public class ClsParameterImpl extends ClsRepositoryPsiElement<PsiParameterStub>
|
||||
String name = myName;
|
||||
|
||||
if (name == null) {
|
||||
if (DumbService.getInstance(getProject()).isDumb()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ClsMethodImpl method = (ClsMethodImpl)getDeclarationScope();
|
||||
PsiMethod sourceMethod = method.getSourceMirrorMethod();
|
||||
if (sourceMethod != null) {
|
||||
assert sourceMethod != method : method;
|
||||
name = sourceMethod.getParameterList().getParameters()[getIndex()].getName();
|
||||
PsiParameterStubImpl parameterStub = (PsiParameterStubImpl)getStub();
|
||||
if (!parameterStub.isAutoGeneratedName()) {
|
||||
name = parameterStub.getName();
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
PsiParameterStubImpl parameterStub = (PsiParameterStubImpl)getStub();
|
||||
name = !parameterStub.isAutoGeneratedName() ? parameterStub.getName() : getMirrorName();
|
||||
if (DumbService.getInstance(getProject()).isDumb()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ClsMethodImpl method = (ClsMethodImpl)getDeclarationScope();
|
||||
PsiMethod sourceMethod = method.getSourceMirrorMethod();
|
||||
if (sourceMethod != null) {
|
||||
assert sourceMethod != method : method;
|
||||
name = sourceMethod.getParameterList().getParameters()[getIndex()].getName();
|
||||
}
|
||||
else {
|
||||
name = getMirrorName();
|
||||
}
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
myName = name;
|
||||
}
|
||||
myName = name;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isAutoGeneratedName() {
|
||||
return ((PsiParameterStubImpl)getStub()).isAutoGeneratedName() &&
|
||||
!DumbService.getInstance(getProject()).isDumb() &&
|
||||
((ClsMethodImpl)getDeclarationScope()).getSourceMirrorMethod() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NotNull String name) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.psi.impl.compiled.ClsParameterImpl;
|
||||
import com.intellij.psi.impl.java.stubs.PsiMethodStub;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -504,6 +505,8 @@ public class ClsRepositoryUseTest extends PsiTestCase {
|
||||
assertNotNull(parameters[0].getModifierList());
|
||||
assertNotNull(parameters[1].getModifierList());
|
||||
|
||||
assertTrue(((ClsParameterImpl)parameters[0]).isAutoGeneratedName());
|
||||
assertTrue(((ClsParameterImpl)parameters[1]).isAutoGeneratedName());
|
||||
assertEquals("ints", parameters[0].getName());
|
||||
assertEquals("o", parameters[1].getName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user