From 8bc85d6a837e05e101a0237df85c73ff653eb08d Mon Sep 17 00:00:00 2001 From: godenji Date: Mon, 10 Jul 2017 13:13:26 -0400 Subject: [PATCH] fix 2.12 deprecation warnings; remove deprecated 0.1.5 descriptors --- .../commandline/ScalaFileWalker.scala | 4 ++-- .../scalariform/formatter/ExprFormatter.scala | 2 +- .../formatter/TemplateFormatter.scala | 4 ++-- .../preferences/PreferenceDescriptor.scala | 18 ++---------------- .../PreferencesImporterExporter.scala | 4 ++-- .../scalariform/lexer/ScalaOnlyLexer.scala | 4 ++-- 6 files changed, 11 insertions(+), 25 deletions(-) diff --git a/cli/src/main/scala/scalariform/commandline/ScalaFileWalker.scala b/cli/src/main/scala/scalariform/commandline/ScalaFileWalker.scala index 102fa56b..0b00446b 100644 --- a/cli/src/main/scala/scalariform/commandline/ScalaFileWalker.scala +++ b/cli/src/main/scala/scalariform/commandline/ScalaFileWalker.scala @@ -2,7 +2,7 @@ package scalariform.commandline import java.io.File import java.util.{ ArrayList, Collection } -import scala.collection.JavaConversions._ +import scala.collection.JavaConverters._ import org.apache.commons.io._ import org.apache.commons.io.filefilter._ @@ -14,7 +14,7 @@ object ScalaFileWalker extends DirectoryWalker(TrueFileFilter.INSTANCE, FileFilt def findScalaFiles(path: File): List[File] = { val results = new ArrayList[File] walk(path, results) - results.toList + results.asScala.toList } override protected def handleFile(file: File, depth: Int, results: Collection[_]) { diff --git a/scalariform/src/main/scala/scalariform/formatter/ExprFormatter.scala b/scalariform/src/main/scala/scalariform/formatter/ExprFormatter.scala index ccd27fd2..e25a0832 100755 --- a/scalariform/src/main/scala/scalariform/formatter/ExprFormatter.scala +++ b/scalariform/src/main/scala/scalariform/formatter/ExprFormatter.scala @@ -110,7 +110,7 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi for ((previousElementOption, element, nextElementOption) ← Utils.withPreviousAndNext(exprElements)) { previousElementOption match { case Some(previousElement) ⇒ - val instructionOption = condOpt(previousElement, element) { + val instructionOption = condOpt((previousElement, element)) { case (PrefixExprElement(_), _) ⇒ if (Chars.isOperatorPart(element.firstToken.text(0))) CompactEnsuringGap else Compact case (Argument(_), _) ⇒ Compact case (_, _: ArgumentExprs) if formattingPreferences(PreserveSpaceBeforeArguments) ⇒ CompactPreservingGap // TODO: Probably not needed now with CallExpr diff --git a/scalariform/src/main/scala/scalariform/formatter/TemplateFormatter.scala b/scalariform/src/main/scala/scalariform/formatter/TemplateFormatter.scala index 5cd3360b..20f352c9 100644 --- a/scalariform/src/main/scala/scalariform/formatter/TemplateFormatter.scala +++ b/scalariform/src/main/scala/scalariform/formatter/TemplateFormatter.scala @@ -30,7 +30,7 @@ trait TemplateFormatter { self: HasFormattingPreferences with AnnotationFormatte } { if (annotations.size > 0) formatResult = formatResult.formatNewlineOrOrdinary(firstToken, CompactEnsuringGap) - val doubleIndentParams = (formattingPreferences(DoubleIndentClassDeclaration) && + val doubleIndentParams = (formattingPreferences(DoubleIndentConstructorArguments) && !templateInheritanceSectionOpt.exists { section ⇒ containsNewline(section) || hiddenPredecessors(section.firstToken).containsNewline } && @@ -39,7 +39,7 @@ trait TemplateFormatter { self: HasFormattingPreferences with AnnotationFormatte } for (TemplateInheritanceSection(extendsOrSubtype, earlyDefsOpt, templateParentsOpt) ← templateInheritanceSectionOpt) { val doubleIndentTemplateInheritance = !formattingPreferences(DoubleIndentConstructorArguments) && - formattingPreferences(DoubleIndentClassDeclaration) && + formattingPreferences(DoubleIndentConstructorArguments) && (templateBodyOption.exists(containsNewline(_)) || paramClausesOpt.exists(containsNewline(_))) val inheritanceIndent = if (doubleIndentTemplateInheritance) 2 else 1 var currentFormatterState = formatterState diff --git a/scalariform/src/main/scala/scalariform/formatter/preferences/PreferenceDescriptor.scala b/scalariform/src/main/scala/scalariform/formatter/preferences/PreferenceDescriptor.scala index b03beaba..79411542 100755 --- a/scalariform/src/main/scala/scalariform/formatter/preferences/PreferenceDescriptor.scala +++ b/scalariform/src/main/scala/scalariform/formatter/preferences/PreferenceDescriptor.scala @@ -92,8 +92,8 @@ object AllPreferences { val preferences: List[PreferenceDescriptor[_]] = List( RewriteArrowSymbols, IndentSpaces, SpaceBeforeColon, SpaceBeforeContextColon, CompactStringConcatenation, PreserveSpaceBeforeArguments, AlignParameters, FirstParameterOnNewline, AlignArguments, FirstArgumentOnNewline, - DoubleIndentClassDeclaration, FormatXml, IndentPackageBlocks, AlignSingleLineCaseStatements, - AlignSingleLineCaseStatements.MaxArrowIndent, IndentLocalDefs, PreserveDanglingCloseParenthesis, DanglingCloseParenthesis, + DoubleIndentConstructorArguments, FormatXml, IndentPackageBlocks, AlignSingleLineCaseStatements, + AlignSingleLineCaseStatements.MaxArrowIndent, IndentLocalDefs, DanglingCloseParenthesis, SpaceInsideParentheses, SpaceInsideBrackets, SpacesWithinPatternBinders, MultilineScaladocCommentsStartOnFirstLine, IndentWithTabs, CompactControlReadability, PlaceScaladocAsterisksBeneathSecondAsterisk, DoubleIndentMethodDeclaration, SpacesAroundMultiImports, NewlineAtEndOfFile @@ -166,13 +166,6 @@ case object FirstArgumentOnNewline extends IntentPreferenceDescriptor { val defaultValue = Force } -@deprecated("This has been dropped in favor of DoubleIndentConstructorArguments.", since = "0.1.5") -case object DoubleIndentClassDeclaration extends BooleanPreferenceDescriptor { - val key = "doubleIndentClassDeclaration" - val description = "Double indent either a class's parameters or its inheritance list" - val defaultValue = false -} - case object DoubleIndentConstructorArguments extends BooleanPreferenceDescriptor { val key = "doubleIndentConstructorArguments" val description = "Class (and trait / object) declarations will be formatted as recommended by the Scala Style Guide" @@ -217,13 +210,6 @@ case object IndentLocalDefs extends BooleanPreferenceDescriptor { val defaultValue = false } -@deprecated("This has been dropped in favor of DanglingCloseParenthesis.", since = "0.1.5") -case object PreserveDanglingCloseParenthesis extends BooleanPreferenceDescriptor { - val key = "preserveDanglingCloseParenthesis" - val description = "Allow a newline before a ')' in an argument expression" - val defaultValue = false -} - case object DanglingCloseParenthesis extends IntentPreferenceDescriptor { val key = "danglingCloseParenthesis" val description = "Put a newline before a ')' in an argument expression" diff --git a/scalariform/src/main/scala/scalariform/formatter/preferences/PreferencesImporterExporter.scala b/scalariform/src/main/scala/scalariform/formatter/preferences/PreferencesImporterExporter.scala index a1827f16..3c036cd0 100644 --- a/scalariform/src/main/scala/scalariform/formatter/preferences/PreferencesImporterExporter.scala +++ b/scalariform/src/main/scala/scalariform/formatter/preferences/PreferencesImporterExporter.scala @@ -1,7 +1,7 @@ package scalariform.formatter.preferences import java.util.Properties -import scala.collection.JavaConversions._ +import scala.collection.JavaConverters._ import scalariform.utils.Utils._ import java.io.IOException @@ -22,7 +22,7 @@ object PreferencesImporterExporter { } for { - key @ (dummy: String) ← properties.propertyNames + key @ (dummy: String) ← properties.propertyNames.asScala descriptor ← AllPreferences.preferencesByKey.get(key) valueString = properties.getProperty(key) } setPreference(descriptor, valueString) diff --git a/scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala b/scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala index 129f3d82..0c3bd36d 100644 --- a/scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala +++ b/scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala @@ -78,9 +78,9 @@ private[lexer] trait ScalaOnlyLexer { self: ScalaLexer ⇒ case '\'' ⇒ nextChar() if (isIdentifierStart(ch)) - charLitOr(getIdentRest) + charLitOr(() => getIdentRest) else if (isOperatorPart(ch) && (ch != '\\')) - charLitOr(getOperatorRest) + charLitOr(() => getOperatorRest) else { getLitChar() if (ch == '\'' || forgiveErrors) {