Code cleanup: removed redundant semicolons

This commit is contained in:
Valentin Kipyatkov
2016-04-26 23:30:42 +03:00
parent e1d8c72aa7
commit b551886889
141 changed files with 2520 additions and 239 deletions
@@ -38,7 +38,7 @@ class KotlinSpacingBuilder(val codeStyleSettings: CodeStyleSettings, val spacing
inner class BasicSpacingBuilder() : SpacingBuilder(codeStyleSettings, KotlinLanguage.INSTANCE), Builder {
override fun getSpacing(parent: ASTBlock, left: ASTBlock, right: ASTBlock): Spacing? {
return super<SpacingBuilder>.getSpacing(parent, left, right)
return super.getSpacing(parent, left, right)
}
}
@@ -50,7 +50,7 @@ class KDocMissingDocumentationInspection(): AbstractKotlinInspection() {
if (element is KtNamedDeclaration) {
val nameIdentifier = element.nameIdentifier
val descriptor = element.resolveToDescriptor() as? MemberDescriptor;
val descriptor = element.resolveToDescriptor() as? MemberDescriptor
if (nameIdentifier != null && descriptor?.visibility == Visibilities.PUBLIC) {
val hasDocumentation = element.docComment != null ||
(descriptor as? CallableMemberDescriptor)?.overriddenDescriptors
@@ -100,7 +100,7 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere
override fun handleElementRename(newElementName: String?): PsiElement {
if (!canRename()) throw IncorrectOperationException()
if (newElementName == null) return expression;
if (newElementName == null) return expression
// Do not rename if the reference corresponds to synthesized component function
val expressionText = expression.text
@@ -83,7 +83,7 @@ class IllegalIdentifierInspection : AbstractKotlinInspection() {
val editor = editorManager.getSelectedEditor(file.virtualFile) ?: return
val dataContext = DataManager.getInstance().getDataContext(editor.component)
val renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(dataContext)
renameHandler?.invoke(project, arrayOf(element), dataContext);
renameHandler?.invoke(project, arrayOf(element), dataContext)
}
}
}
@@ -52,7 +52,7 @@ abstract class DeclarationLookupObjectImpl(
(psiElement as? PsiClass)?.qualifiedName?.let { FqName(it) }
}
override fun toString() = super<DeclarationLookupObject>.toString() + " " + (descriptor ?: psiElement)
override fun toString() = super.toString() + " " + (descriptor ?: psiElement)
override fun hashCode(): Int {
return if (descriptor != null) descriptor.original.hashCode() else psiElement!!.hashCode()
@@ -115,7 +115,7 @@ abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtureTestCa
if (lookup.currentItem != item) { // do not touch selection if not changed - important for char filter tests
lookup.currentItem = item
}
lookup.focusDegree = LookupImpl.FocusDegree.FOCUSED;
lookup.focusDegree = LookupImpl.FocusDegree.FOCUSED
if (LookupEvent.isSpecialCompletionChar(completionChar)) {
(object : WriteCommandAction.Simple<Any>(project) {
override fun run(result: Result<Any>) {
@@ -28,7 +28,7 @@ class ExtraSteppingFilter : com.intellij.debugger.engine.ExtraSteppingFilter {
override fun isApplicable(context: SuspendContext?): Boolean {
if (context == null) {
return false;
return false
}
val debugProcess = context.debugProcess ?: return false
@@ -43,7 +43,7 @@ class ExtraSteppingFilter : com.intellij.debugger.engine.ExtraSteppingFilter {
private fun shouldFilter(positionManager: KotlinPositionManager, location: Location): Boolean {
val defaultStrata = location.declaringType()?.defaultStratum()
if ("Kotlin" != defaultStrata) {
return false;
return false
}
val sourcePosition =
@@ -68,7 +68,7 @@ class ExtraSteppingFilter : com.intellij.debugger.engine.ExtraSteppingFilter {
}
}
return false;
return false
}
override fun getStepRequestDepth(context: SuspendContext?): Int {
@@ -90,7 +90,7 @@ class KotlinReferenceData(
public override fun clone(): KotlinReferenceData {
try {
return super<Cloneable>.clone() as KotlinReferenceData
return super.clone() as KotlinReferenceData
}
catch (e: CloneNotSupportedException) {
throw RuntimeException()
@@ -171,7 +171,7 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
if (start == null || end == null) return null
val literalsOrFunctions = getLambdasAtLineIfAny(file, lineNumber)
if (literalsOrFunctions.isEmpty()) return null;
if (literalsOrFunctions.isEmpty()) return null
val elementAt = file.findElementAt(start) ?: return null
val typeMapper = KotlinDebuggerCaches.getOrCreateTypeMapper(elementAt)
@@ -161,10 +161,10 @@ class KotlinFieldBreakpointType : JavaBreakpointType<KotlinPropertyBreakpointPro
override fun getDisplayText(breakpoint: XLineBreakpoint<KotlinPropertyBreakpointProperties>): String? {
val kotlinBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint) as? BreakpointWithHighlighter
if (kotlinBreakpoint != null) {
return kotlinBreakpoint.description;
return kotlinBreakpoint.description
}
else {
return super.getDisplayText(breakpoint);
return super.getDisplayText(breakpoint)
}
}
@@ -67,8 +67,8 @@ class KotlinEnterHandler: EnterHandlerDelegateAdapter() {
if (elementAt is PsiWhiteSpace && ("\n" in elementAt.getText()!!)) return EnterHandlerDelegate.Result.Continue
// Indent for LBRACE can be removed after fixing IDEA-124917
val elementBefore = CodeInsightUtils.getElementAtOffsetIgnoreWhitespaceAfter(file, caretOffset);
val elementAfter = CodeInsightUtils.getElementAtOffsetIgnoreWhitespaceBefore(file, caretOffset);
val elementBefore = CodeInsightUtils.getElementAtOffsetIgnoreWhitespaceAfter(file, caretOffset)
val elementAfter = CodeInsightUtils.getElementAtOffsetIgnoreWhitespaceBefore(file, caretOffset)
val isAfterLBraceOrArrow = elementBefore != null && elementBefore.node!!.elementType in FORCE_INDENT_IN_LAMBDA_AFTER
val isBeforeRBrace = elementAfter == null || elementAfter.node!!.elementType == KtTokens.RBRACE
@@ -81,7 +81,7 @@ class KotlinEnterHandler: EnterHandlerDelegateAdapter() {
CodeStyleManager.getInstance(file.getProject())!!.adjustLineIndent(file, editor.caretModel.offset)
}
catch (e: IncorrectOperationException) {
LOG.error(e);
LOG.error(e)
}
return EnterHandlerDelegate.Result.DefaultForceIndent
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.psi.KtNamedFunction
class KotlinFunctionParametersFixer : SmartEnterProcessorWithFixers.Fixer<KotlinSmartEnterHandler>() {
override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, psiElement: PsiElement) {
if (psiElement !is KtNamedFunction) return;
if (psiElement !is KtNamedFunction) return
val parameterList = psiElement.valueParameterList
if (parameterList == null) {
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset
class KotlinPropertySetterParametersFixer : SmartEnterProcessorWithFixers.Fixer<KotlinSmartEnterHandler>() {
override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, psiElement: PsiElement) {
if (psiElement !is KtPropertyAccessor) return;
if (psiElement !is KtPropertyAccessor) return
if (!psiElement.isSetter) return
@@ -154,7 +154,7 @@ class KotlinExceptionFilter(private val searchScope: GlobalSearchScope) : Filter
}
private fun readDebugInfo(bytes: ByteArray): SmapData? {
val cr = ClassReader(bytes);
val cr = ClassReader(bytes)
var debugInfo: String? = null
cr.accept(object : ClassVisitor(InlineCodegenUtil.API) {
override fun visitSource(source: String?, debug: String?) {
@@ -178,7 +178,7 @@ class ConflictingExtensionPropertyInspection : AbstractKotlinInspection(), Clean
}
private class DeleteRedundantExtensionAction(property: KtProperty) : KotlinQuickFixAction<KtProperty>(property) {
private val LOG = Logger.getInstance(DeleteRedundantExtensionAction::class.java);
private val LOG = Logger.getInstance(DeleteRedundantExtensionAction::class.java)
override fun getFamilyName() = "Delete redundant extension property"
override fun getText() = familyName
@@ -58,13 +58,13 @@ class ConvertPropertyToFunctionIntention : SelfTargetingIntention<KtProperty>(Kt
private val newName: String = JvmAbi.getterName(callableDescriptor.name.asString())
private fun convertProperty(originalProperty: KtProperty, psiFactory: KtPsiFactory) {
val property = originalProperty.copy() as KtProperty;
val getter = property.getter;
val property = originalProperty.copy() as KtProperty
val getter = property.getter
val sampleFunction = psiFactory.createFunction("fun foo() {\n\n}");
val sampleFunction = psiFactory.createFunction("fun foo() {\n\n}")
property.valOrVarKeyword.replace(sampleFunction.funKeyword!!);
property.addAfter(psiFactory.createParameterList("()"), property.nameIdentifier);
property.valOrVarKeyword.replace(sampleFunction.funKeyword!!)
property.addAfter(psiFactory.createParameterList("()"), property.nameIdentifier)
if (property.initializer == null) {
if (getter != null) {
val dropGetterTo = (getter.equalsToken ?: getter.bodyExpression)
@@ -73,11 +73,11 @@ class DoubleBangToIfThenIntention : SelfTargetingRangeIntention<KtPostfixExpress
val exceptionLookupExpression = ChooseStringExpression(listOf(nullPtrExceptionText, kotlinNullPtrExceptionText))
val project = element.project
val builder = TemplateBuilderImpl(thrownExpression)
builder.replaceElement(thrownExpression, exceptionLookupExpression);
builder.replaceElement(thrownExpression, exceptionLookupExpression)
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.document);
editor.caretModel.moveToOffset(thrownExpression.node!!.startOffset);
PsiDocumentManager.getInstance(project).commitAllDocuments()
PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.document)
editor.caretModel.moveToOffset(thrownExpression.node!!.startOffset)
TemplateManager.getInstance(project).startTemplate(editor, builder.buildInlineTemplate(), object: TemplateEditingAdapter() {
override fun templateFinished(template: Template?, brokenOff: Boolean) {
@@ -68,7 +68,7 @@ object KDocRenderer {
to.append(", ")
}
}
to.append("</DD></DL></DD>");
to.append("</DD></DL></DD>")
}
private fun renderTagList(tags: List<KDocTag>, title: String, to: StringBuilder) {
@@ -33,7 +33,7 @@ class RenameUnderscoreFix(declaration: KtDeclaration) : KotlinQuickFixAction<KtD
if (editor == null) return
val dataContext = DataManager.getInstance().getDataContext(editor.component)
val renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(dataContext)
renameHandler?.invoke(project, arrayOf(element), dataContext);
renameHandler?.invoke(project, arrayOf(element), dataContext)
}
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean {
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.utils.singletonOrEmptyList
import java.util.*
abstract class WholeProjectModalAction<TData : Any>(val title: String) : IntentionAction {
private val LOG = Logger.getInstance(WholeProjectModalAction::class.java);
private val LOG = Logger.getInstance(WholeProjectModalAction::class.java)
override final fun startInWriteAction() = false
@@ -87,7 +87,7 @@ class TypeCandidate(val theType: KotlinType, scope: HierarchicalScope? = null) {
private set
fun render(typeParameterNameMap: Map<TypeParameterDescriptor, String>, fakeFunction: FunctionDescriptor?) {
renderedType = theType.renderShort(typeParameterNameMap);
renderedType = theType.renderShort(typeParameterNameMap)
renderedTypeParameters = typeParameters.map {
RenderedTypeParameter(it, it.containingDeclaration == fakeFunction, typeParameterNameMap[it]!!)
}
@@ -97,10 +97,10 @@ class TypeCandidate(val theType: KotlinType, scope: HierarchicalScope? = null) {
val typeParametersInType = theType.getTypeParameters()
if (scope == null) {
typeParameters = typeParametersInType.toTypedArray()
renderedType = theType.renderShort(Collections.emptyMap());
renderedType = theType.renderShort(Collections.emptyMap())
}
else {
typeParameters = getTypeParameterNamesNotInScope(typeParametersInType, scope).toTypedArray();
typeParameters = getTypeParameterNamesNotInScope(typeParametersInType, scope).toTypedArray()
}
}
@@ -874,7 +874,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
}
modifierList.setModifierProperty(PsiModifier.STATIC, needStatic)
JavaCodeStyleManager.getInstance(project).shortenClassReferences(newJavaMember);
JavaCodeStyleManager.getInstance(project).shortenClassReferences(newJavaMember)
val descriptor = OpenFileDescriptor(project, targetClass.containingFile.virtualFile)
val targetEditor = FileEditorManager.getInstance(project).openTextEditor(descriptor, true)!!
@@ -47,7 +47,7 @@ class DeprecatedSymbolUsageInWholeProjectFix(
private val text: String
) : DeprecatedSymbolUsageFixBase(element, replaceWith) {
private val LOG = Logger.getInstance(DeprecatedSymbolUsageInWholeProjectFix::class.java);
private val LOG = Logger.getInstance(DeprecatedSymbolUsageInWholeProjectFix::class.java)
override fun getFamilyName() = "Replace deprecated symbol usage in whole project"
@@ -144,7 +144,7 @@ open class KotlinChangeInfo(
}
fun removeParameter(index: Int) {
val parameterInfo = newParameters.removeAt(index);
val parameterInfo = newParameters.removeAt(index)
if (parameterInfo == receiverParameterInfo) {
receiverParameterInfo = null
}
@@ -160,7 +160,7 @@ class KotlinChangeSignatureData(
}
override fun canChangeVisibility(): Boolean {
if (DescriptorUtils.isLocal(baseDescriptor)) return false;
if (DescriptorUtils.isLocal(baseDescriptor)) return false
val parent = baseDescriptor.containingDeclaration
return !(baseDescriptor is AnonymousFunctionDescriptor || parent is ClassDescriptor && parent.kind == ClassKind.INTERFACE)
}
@@ -385,7 +385,7 @@ class KotlinChangeSignatureDialog(
methodName,
myDefaultValueContext,
false)
changeInfo.primaryPropagationTargets = myMethodsToPropagateParameters ?: emptyList();
changeInfo.primaryPropagationTargets = myMethodsToPropagateParameters ?: emptyList()
return KotlinChangeSignatureProcessor(myProject, changeInfo, commandName ?: title)
}
@@ -266,7 +266,7 @@ private fun makeCall(
anchor.nextSibling?.let { from ->
val to = rangeToReplace.endElement
if (to != anchor) {
anchorParent.deleteChildRange(from, to);
anchorParent.deleteChildRange(from, to)
}
}
@@ -165,7 +165,7 @@ fun IntroduceParameterDescriptor.performRefactoring() {
override fun performSilently(affectedFunctions: Collection<PsiElement>): Boolean = true
}
val project = callable.project;
val project = callable.project
val changeSignature = { runChangeSignature(project, callableDescriptor, config, callable, INTRODUCE_PARAMETER) }
changeSignature.runRefactoringWithPostprocessing(project, "refactoring.changeSignature") {
try {
@@ -254,7 +254,7 @@ fun <T, E: PsiElement> getPsiElementPopup(
}
addListener(object: JBPopupAdapter() {
override fun onClosed(event: LightweightWindowEvent?) {
highlighter?.dropHighlight();
highlighter?.dropHighlight()
}
})
@@ -61,7 +61,7 @@ class KotlinMemberSelectionTable(
}
override fun setVisibilityIcon(memberInfo: KotlinMemberInfo, icon: RowIcon) {
icon.setIcon(KotlinIconProvider.getVisibilityIcon(memberInfo.member.modifierList), 1);
icon.setIcon(KotlinIconProvider.getVisibilityIcon(memberInfo.member.modifierList), 1)
}
override fun getOverrideIcon(memberInfo: KotlinMemberInfo): Icon? {
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.refactoring.move.changePackage;
package org.jetbrains.kotlin.idea.refactoring.move.changePackage
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.codeInsight.template.*
@@ -95,7 +95,7 @@ sealed class MoveDeclarationsDelegate {
) {
val usageIterator = usages.iterator()
while (usageIterator.hasNext()) {
val usage = usageIterator.next();
val usage = usageIterator.next()
val element = usage.element ?: continue
val isConflict = when (usage) {
@@ -39,7 +39,7 @@ class RenameDynamicMemberHandler: VariableInplaceRenameHandler() {
}
override fun invoke(project: Project, editor: Editor, file: PsiFile, dataContext: DataContext?) {
CodeInsightUtils.showErrorHint(project, editor, "Rename is not applicable to dynamically invoked members", "Rename", null);
CodeInsightUtils.showErrorHint(project, editor, "Rename is not applicable to dynamically invoked members", "Rename", null)
}
override fun invoke(project: Project, elements: Array<out PsiElement>, dataContext: DataContext?) {
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.refactoring.rename;
package org.jetbrains.kotlin.idea.refactoring.rename
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
@@ -42,13 +42,13 @@ class RenameOnSecondaryConstructorHandler : RenameHandler {
file, editor.caretModel.offset, KtSecondaryConstructor::class.java, false,
KtBlockExpression::class.java, KtValueArgumentList::class.java, KtParameterList::class.java
)
return element != null;
return element != null
}
override fun isRenaming(dataContext: DataContext?): Boolean = isAvailableOnDataContext(dataContext)
override fun invoke(project: Project, editor: Editor, file: PsiFile, dataContext: DataContext?) {
CodeInsightUtils.showErrorHint(project, editor, "Rename is not applicable to secondary constructors", "Rename", null);
CodeInsightUtils.showErrorHint(project, editor, "Rename is not applicable to secondary constructors", "Rename", null)
}
override fun invoke(project: Project, elements: Array<out PsiElement>, dataContext: DataContext?) {
@@ -262,7 +262,7 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
val virtualFile = file.virtualFile
val runnable = {
var offset = -1;
var offset = -1
while (true) {
val fileText = document.text
offset = fileText.indexOf("point!", offset + 1)
@@ -217,7 +217,7 @@ abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() {
Printer(config).printTree(tree)
for (extra in getExtraVars()) {
watchesView.addWatchExpression(XExpressionImpl.fromText(extra.text), -1, false);
watchesView.addWatchExpression(XExpressionImpl.fromText(extra.text), -1, false)
}
Printer(config).printTree(watchesView.tree)
}
@@ -56,5 +56,5 @@ abstract class AbstractSelectExpressionForDebuggerTest : LightCodeInsightFixture
override fun getProjectDescriptor() = KotlinLightProjectDescriptor.INSTANCE
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/debugger/selectExpression";
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/debugger/selectExpression"
}
@@ -33,7 +33,7 @@ class QuickDocNavigationTest() : LightPlatformCodeInsightFixtureTestCase() {
myFixture.configureByFile(getTestName(true) + ".kt")
val source = myFixture.elementAtCaret.getParentOfType<KtFunction>(false)
val target = KotlinQuickDocumentationProvider().getDocumentationElementForLink(
myFixture.psiManager, "C", source);
myFixture.psiManager, "C", source)
Assert.assertTrue(target is KtClass)
Assert.assertEquals("C", (target as KtClass).name)
}
@@ -26,7 +26,7 @@ import kotlin.test.assertEquals
abstract class AbstractHighlightExitPointsTest : LightCodeInsightFixtureTestCase() {
fun doTest(testDataPath: String) {
myFixture.configureByFile(testDataPath)
HighlightUsagesHandler.invoke(myFixture.project, myFixture.editor, myFixture.file);
HighlightUsagesHandler.invoke(myFixture.project, myFixture.editor, myFixture.file)
val text = myFixture.file.text
val expectedToBeHighlighted = InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "//HIGHLIGHTED:")
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.quickfix;
package org.jetbrains.kotlin.idea.quickfix
import com.intellij.testFramework.TestDataPath
import org.jetbrains.kotlin.idea.quickfix.replaceWith.DeprecatedSymbolUsageFix
@@ -33,31 +33,31 @@ class KotlinNamesValidatorTest : LightCodeInsightFixtureTestCase() {
}
fun testKeywords() {
Assert.assertTrue(isKeyword("val"));
Assert.assertTrue(isKeyword("class"));
Assert.assertTrue(isKeyword("fun"));
Assert.assertTrue(isKeyword("val"))
Assert.assertTrue(isKeyword("class"))
Assert.assertTrue(isKeyword("fun"))
Assert.assertFalse(isKeyword("constructor"));
Assert.assertFalse(isKeyword("123"));
Assert.assertFalse(isKeyword("a.c"));
Assert.assertFalse(isKeyword("-"));
Assert.assertFalse(isKeyword("constructor"))
Assert.assertFalse(isKeyword("123"))
Assert.assertFalse(isKeyword("a.c"))
Assert.assertFalse(isKeyword("-"))
}
fun testIdentifiers() {
Assert.assertTrue(isIdentifier("abc"));
Assert.assertTrue(isIdentifier("q_q"));
Assert.assertTrue(isIdentifier("constructor"));
Assert.assertTrue(isIdentifier("`val`"));
Assert.assertTrue(isIdentifier("abc"))
Assert.assertTrue(isIdentifier("q_q"))
Assert.assertTrue(isIdentifier("constructor"))
Assert.assertTrue(isIdentifier("`val`"))
Assert.assertFalse(isIdentifier("val"));
Assert.assertFalse(isIdentifier("class"));
Assert.assertFalse(isIdentifier("fun"));
Assert.assertFalse(isIdentifier("val"))
Assert.assertFalse(isIdentifier("class"))
Assert.assertFalse(isIdentifier("fun"))
Assert.assertFalse(isIdentifier("123"));
Assert.assertFalse(isIdentifier("a.c"));
Assert.assertFalse(isIdentifier("-"));
Assert.assertFalse(isIdentifier("``"));
Assert.assertFalse(isIdentifier(""));
Assert.assertFalse(isIdentifier(" '"));
Assert.assertFalse(isIdentifier("123"))
Assert.assertFalse(isIdentifier("a.c"))
Assert.assertFalse(isIdentifier("-"))
Assert.assertFalse(isIdentifier("``"))
Assert.assertFalse(isIdentifier(""))
Assert.assertFalse(isIdentifier(" '"))
}
}
@@ -42,8 +42,8 @@ class StringInjectionHostTest : KotlinTestWithEnvironment() {
}
fun testUnclosedSimpleLiteral() {
assertFalse(stringExpression("\"").isValidHost);
assertFalse(stringExpression("\"a").isValidHost);
assertFalse(stringExpression("\"").isValidHost)
assertFalse(stringExpression("\"a").isValidHost)
}
fun testEscapeSequences() {