use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.
the class IdeStubIndexService method indexObject.
@Override
public void indexObject(KotlinObjectStub stub, IndexSink sink) {
String name = stub.getName();
if (name != null) {
sink.occurrence(KotlinClassShortNameIndex.getInstance().getKey(), name);
}
FqName fqName = stub.getFqName();
if (fqName != null) {
sink.occurrence(KotlinFullClassNameIndex.getInstance().getKey(), fqName.asString());
if (stub.isTopLevel()) {
sink.occurrence(KotlinTopLevelClassByPackageIndex.getInstance().getKey(), fqName.parent().asString());
}
}
indexSuperNames(stub, sink);
}
use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.
the class IdeStubIndexService method indexProperty.
@Override
public void indexProperty(KotlinPropertyStub stub, IndexSink sink) {
String name = stub.getName();
if (name != null) {
sink.occurrence(KotlinPropertyShortNameIndex.getInstance().getKey(), name);
if (TypeIndexUtilKt.isProbablyNothing(stub.getPsi().getTypeReference())) {
sink.occurrence(KotlinProbablyNothingPropertyShortNameIndex.getInstance().getKey(), name);
}
}
if (stub.isTopLevel()) {
FqName fqName = stub.getFqName();
// can have special fq name in case of syntactically incorrect property with no name
if (fqName != null) {
sink.occurrence(KotlinTopLevelPropertyFqnNameIndex.getInstance().getKey(), fqName.asString());
sink.occurrence(KotlinTopLevelPropertyByPackageIndex.getInstance().getKey(), fqName.parent().asString());
IndexUtilsKt.indexTopLevelExtension(stub, sink);
}
}
}
use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.
the class IdeStubIndexService method indexTypeAlias.
@Override
public void indexTypeAlias(KotlinTypeAliasStub stub, IndexSink sink) {
String name = stub.getName();
if (name != null) {
sink.occurrence(KotlinTypeAliasShortNameIndex.getInstance().getKey(), name);
}
IndexUtilsKt.indexTypeAliasExpansion(stub, sink);
if (stub.isTopLevel()) {
FqName fqName = stub.getFqName();
if (fqName != null) {
sink.occurrence(KotlinTopLevelTypeAliasFqNameIndex.getInstance().getKey(), fqName.asString());
sink.occurrence(KotlinTopLevelTypeAliasByPackageIndex.getInstance().getKey(), fqName.parent().asString());
}
}
}
use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.
the class MoveKotlinNestedClassesToUpperLevelDialog method init.
@Override
protected void init() {
classNameField.setText(innerClass.getName());
classNameField.selectAll();
if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) {
passOuterClassCheckBox.setSelected(true);
passOuterClassCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
parameterField.setEnabled(passOuterClassCheckBox.isSelected());
}
});
} else {
passOuterClassCheckBox.setSelected(false);
passOuterClassCheckBox.setEnabled(false);
parameterField.setEnabled(false);
}
if (passOuterClassCheckBox.isEnabled()) {
boolean thisNeeded = isThisNeeded();
passOuterClassCheckBox.setSelected(thisNeeded);
parameterField.setEnabled(thisNeeded);
}
passOuterClassCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean selected = passOuterClassCheckBox.isSelected();
parameterField.getComponent().setEnabled(selected);
}
});
if (!(targetContainer instanceof PsiDirectory)) {
packageNameField.setVisible(false);
packageNameLabel.setVisible(false);
}
if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) {
KtClassBody innerClassBody = innerClass.getBody();
Function1<String, Boolean> validator = innerClassBody != null ? new NewDeclarationNameValidator(innerClassBody, (PsiElement) null, NewDeclarationNameValidator.Target.VARIABLES, Collections.<KtDeclaration>emptyList()) : new CollectingNameValidator();
List<String> suggestions = KotlinNameSuggester.INSTANCE.suggestNamesByType(getOuterInstanceType(), validator, "outer");
parameterField.setSuggestions(ArrayUtil.toStringArray(suggestions));
} else {
parameterField.getComponent().setEnabled(false);
}
FqName packageFqName = getTargetPackageFqName();
if (packageFqName != null) {
packageNameField.prependItem(packageFqName.asString());
}
KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance();
searchForTextOccurrencesCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT);
searchInCommentsCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS);
super.init();
}
use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.
the class AbstractScriptCodegenTest method doTest.
@Override
protected void doTest(@NotNull String filename) {
loadFileByFullPath(filename);
try {
//noinspection ConstantConditions
FqName fqName = myFiles.getPsiFile().getScript().getFqName();
Class<?> scriptClass = generateClass(fqName.asString());
Constructor constructor = getTheOnlyConstructor(scriptClass);
Object scriptInstance = constructor.newInstance(myFiles.getScriptParameterValues().toArray());
assertFalse("expecting at least one expectation", myFiles.getExpectedValues().isEmpty());
for (Pair<String, String> nameValue : myFiles.getExpectedValues()) {
String fieldName = nameValue.first;
String expectedValue = nameValue.second;
if (expectedValue.equals("<nofield>")) {
try {
scriptClass.getDeclaredField(fieldName);
fail("must have no field " + fieldName);
} catch (NoSuchFieldException e) {
continue;
}
}
Field field = scriptClass.getDeclaredField(fieldName);
field.setAccessible(true);
Object result = field.get(scriptInstance);
String resultString = result != null ? result.toString() : "null";
assertEquals("comparing field " + fieldName, expectedValue, resultString);
}
} catch (Throwable e) {
System.out.println(generateToText());
throw ExceptionUtilsKt.rethrow(e);
}
}
Aggregations