Rename method

This commit is contained in:
Natalia.Ukhorskaya
2013-03-18 14:41:30 +04:00
parent abed8b59cb
commit 31d3d2bb3a
6 changed files with 12 additions and 14 deletions
@@ -157,9 +157,7 @@ public class JetAddImportAction implements QuestionAction {
public void run() {
PsiFile file = element.getContainingFile();
if (!(file instanceof JetFile)) return;
ImportInsertHelper.addImportDirective(selectedImport,
(JetFile) file
);
ImportInsertHelper.addImportDirectiveIfNeeded(selectedImport, (JetFile) file);
}
});
}
@@ -71,7 +71,7 @@ public class ReferenceToClassesShortening {
compactReferenceToClass(userType, targetClass);
}
else if (classifier == null) {
ImportInsertHelper.addImportDirective(DescriptorUtils.getFQName(targetTopLevelClass).toSafe(), file);
ImportInsertHelper.addImportDirectiveIfNeeded(DescriptorUtils.getFQName(targetTopLevelClass).toSafe(), file);
compactReferenceToClass(userType, targetClass);
}
else {
@@ -61,7 +61,7 @@ public class JetClassInsertHandler implements InsertHandler<LookupElement> {
ImportInsertHelper.addImportDirectiveOrChangeToFqName(fqn, jetFile, context.getStartOffset(), targetElement);
}
else if (KotlinFrameworkDetector.isJsKotlinModule(jetFile)) {
ImportInsertHelper.addImportDirective(fqn, jetFile);
ImportInsertHelper.addImportDirectiveIfNeeded(fqn, jetFile);
}
}
}
@@ -198,7 +198,7 @@ public class JetFunctionInsertHandler implements InsertHandler<LookupElement> {
@Override
public void run() {
FqName fqn = DescriptorUtils.getFQName(functionDescriptor).toSafe();
ImportInsertHelper.addImportDirective(fqn, file);
ImportInsertHelper.addImportDirectiveIfNeeded(fqn, file);
}
});
}
@@ -62,7 +62,7 @@ public class ImportInsertHelper {
return;
}
for (ClassDescriptor clazz : TypeUtils.getAllClassDescriptors(type)) {
addImportDirective(DescriptorUtils.getFQName(getTopLevelClass(clazz)).toSafe(), file);
addImportDirectiveIfNeeded(DescriptorUtils.getFQName(getTopLevelClass(clazz)).toSafe(), file);
}
}
@@ -72,8 +72,8 @@ public class ImportInsertHelper {
* @param importFqn full name of the import
* @param file File where directive should be added.
*/
public static void addImportDirective(@NotNull FqName importFqn, @NotNull JetFile file) {
addImportDirective(new ImportPath(importFqn, false), file);
public static void addImportDirectiveIfNeeded(@NotNull FqName importFqn, @NotNull JetFile file) {
addImportDirectiveIfNeeded(new ImportPath(importFqn, false), file);
}
public static void addImportDirectiveOrChangeToFqName(@NotNull FqName importFqn, @NotNull JetFile file, int refOffset, @NotNull PsiElement targetElement) {
@@ -108,10 +108,10 @@ public class ImportInsertHelper {
return;
}
}
addImportDirective(new ImportPath(importFqn, false), file);
addImportDirectiveIfNeeded(new ImportPath(importFqn, false), file);
}
public static void addImportDirective(@NotNull ImportPath importPath, @NotNull JetFile file) {
public static void addImportDirectiveIfNeeded(@NotNull ImportPath importPath, @NotNull JetFile file) {
if (!doNeedImport(importPath, file)) {
return;
}
@@ -46,7 +46,7 @@ public class ImportClassHelperTest extends LightDaemonAnalyzerTestCase {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ImportInsertHelper.addImportDirective(new FqName("java.util.ArrayList"), (JetFile) getFile());
ImportInsertHelper.addImportDirectiveIfNeeded(new FqName("java.util.ArrayList"), (JetFile) getFile());
}
});
@@ -58,7 +58,7 @@ public class ImportClassHelperTest extends LightDaemonAnalyzerTestCase {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ImportInsertHelper.addImportDirective(new FqName("java.util.ArrayList"), (JetFile) getFile());
ImportInsertHelper.addImportDirectiveIfNeeded(new FqName("java.util.ArrayList"), (JetFile) getFile());
}
});
@@ -70,7 +70,7 @@ public class ImportClassHelperTest extends LightDaemonAnalyzerTestCase {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ImportInsertHelper.addImportDirective(new FqName(importString), (JetFile) getFile());
ImportInsertHelper.addImportDirectiveIfNeeded(new FqName(importString), (JetFile) getFile());
}
});
checkResultByFile(getTestName(false) + ".kt.after");