Skip to content

Commit

Permalink
fix 2.12 deprecation warnings; remove deprecated 0.1.5 descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
godenji committed Jul 10, 2017
1 parent d516a85 commit 8bc85d6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 25 deletions.
Expand Up @@ -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._
Expand All @@ -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[_]) {
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
} &&
Expand All @@ -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
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
@@ -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

Expand All @@ -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)
Expand Down
Expand Up @@ -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) {
Expand Down

0 comments on commit 8bc85d6

Please sign in to comment.