Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reformat with AlignSingleLineCaseStatements(true)

  • Loading branch information...
commit 6fc91f2fa7de0284878b9bd5e8cda24b72aee6b5 1 parent 0c60045
@mdr authored
View
2  README.rst
@@ -218,7 +218,7 @@ Is reformatted as::
alignSingleLineCaseStatements.maxArrowIndent
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Default: ``25``
+Default: ``40``
When using alignSingleLineCaseStatements == true, this is a limit on
the number of spaces that can be inserted before an arrow to align it
View
2  docs/source/README.rst
@@ -218,7 +218,7 @@ Is reformatted as::
alignSingleLineCaseStatements.maxArrowIndent
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Default: ``25``
+Default: ``40``
When using alignSingleLineCaseStatements == true, this is a limit on
the number of spaces that can be inserted before an arrow to align it
View
4 gui/src/main/scala/scalariform/gui/ParseTreeModel.scala
@@ -41,7 +41,7 @@ class ParseTreeModel(rootAstNode: AstNode) extends TreeModel {
val fields = astNode.getFields
lazy val children = fields flatMap {
case (_, None) | (_, Nil) None
- case (fieldName, value) Some(makeTreeNode(value.asInstanceOf[AnyRef], fieldName))
+ case (fieldName, value) Some(makeTreeNode(value.asInstanceOf[AnyRef], fieldName))
}
override def toString = {
val typeName = astNode.getClass.getSimpleName
@@ -64,7 +64,7 @@ class ParseTreeModel(rootAstNode: AstNode) extends TreeModel {
case class EitherNode(name: String, either: Either[_ <: AnyRef, _ <: AnyRef]) extends TreeNode(name) {
lazy val children = either match {
- case Left(obj) List(makeTreeNode(obj))
+ case Left(obj) List(makeTreeNode(obj))
case Right(obj) List(makeTreeNode(obj))
}
View
2  project/build/Project.scala
@@ -5,7 +5,7 @@ class Project(info: ProjectInfo) extends ParentProject(info) {
trait FormatterOptions /* extends ScalariformPlugin */ {
- /* override */ def scalariformOptions = Seq(VerboseScalariform, RewriteArrowSymbols(true), AlignParameters(true))
+ /* override */ def scalariformOptions = Seq(VerboseScalariform, RewriteArrowSymbols(true), AlignParameters(true), AlignSingleLineCaseStatements(true))
}
View
6 scalariform/src/main/scala/scalariform/commandline/Main.scala
@@ -152,9 +152,9 @@ object Main {
for (file files) {
val formatResult = checkSource(Source.fromFile(file, encoding))
val resultString = formatResult match {
- case FormattedCorrectly "OK"
+ case FormattedCorrectly "OK"
case NotFormattedCorrectly "FAILED"
- case DidNotParse "ERROR"
+ case DidNotParse "ERROR"
}
val padding = " " * (6 - resultString.length)
log("[" + resultString + "]" + padding + " " + file)
@@ -231,7 +231,7 @@ object Main {
for {
key sortedPreferences
preference = AllPreferences.preferencesByKey(key)
- IntegerPreference(min, max) <- Some(preference.preferenceType)
+ IntegerPreference(min, max) Some(preference.preferenceType)
} {
val optionText = " -" + key + "=[" + min + "-" + max + "]"
val filler = " " * (descriptionColumn - optionText.length)
View
64 scalariform/src/main/scala/scalariform/formatter/ExprFormatter.scala
@@ -43,7 +43,7 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
if (formattingPreferences(CompactStringConcatenation)) {
val infixPlus = element match {
case InfixExprElement(Token(PLUS, _, _, _)) true
- case _ false
+ case _ false
}
val stringConcatenation = (previousElement, nextElementOption) match {
case (GeneralTokens(tokens), _) if tokens.last.tokenType == STRING_LITERAL true
@@ -95,26 +95,26 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
}
private def format(exprElement: ExprElement)(implicit formatterState: FormatterState): FormatResult = exprElement match {
- case ifExpr: IfExpr format(ifExpr)
- case whileExpr: WhileExpr format(whileExpr)
- case doExpr: DoExpr format(doExpr)
- case blockExpr: BlockExpr format(blockExpr, indent = true)
- case forExpr: ForExpr format(forExpr)
- case tryExpr: TryExpr format(tryExpr)
- case template: Template format(template)
- case statSeq: StatSeq format(statSeq) // TODO: revisit
- case argumentExprs: ArgumentExprs format(argumentExprs)
+ case ifExpr: IfExpr format(ifExpr)
+ case whileExpr: WhileExpr format(whileExpr)
+ case doExpr: DoExpr format(doExpr)
+ case blockExpr: BlockExpr format(blockExpr, indent = true)
+ case forExpr: ForExpr format(forExpr)
+ case tryExpr: TryExpr format(tryExpr)
+ case template: Template format(template)
+ case statSeq: StatSeq format(statSeq) // TODO: revisit
+ case argumentExprs: ArgumentExprs format(argumentExprs)
case anonymousFunction: AnonymousFunction format(anonymousFunction)
- case GeneralTokens(_) NoFormatResult
- case PrefixExprElement(_) NoFormatResult
- case InfixExprElement(_) NoFormatResult
- case PostfixExprElement(_) NoFormatResult
- case annotation: Annotation format(annotation)
- case typeExprElement: TypeExprElement format(typeExprElement.contents)
- case expr: Expr format(expr.contents)
- case xmlExpr: XmlExpr format(xmlExpr)
- case parenExpr: ParenExpr format(parenExpr)
- case _ NoFormatResult
+ case GeneralTokens(_) NoFormatResult
+ case PrefixExprElement(_) NoFormatResult
+ case InfixExprElement(_) NoFormatResult
+ case PostfixExprElement(_) NoFormatResult
+ case annotation: Annotation format(annotation)
+ case typeExprElement: TypeExprElement format(typeExprElement.contents)
+ case expr: Expr format(expr.contents)
+ case xmlExpr: XmlExpr format(xmlExpr)
+ case parenExpr: ParenExpr format(parenExpr)
+ case _ NoFormatResult
}
def format(anonymousFunction: AnonymousFunction)(implicit formatterState: FormatterState): FormatResult = { // <-- Also formatted specially in BlockExpr
@@ -132,7 +132,7 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
}
def format(argumentExprs: ArgumentExprs)(implicit formatterState: FormatterState): FormatResult = argumentExprs match {
- case BlockArgumentExprs(contents) format(contents)
+ case BlockArgumentExprs(contents) format(contents)
case ParenArgumentExprs(lparen, contents, rparen) format(GeneralTokens(List(lparen)) :: contents)
}
@@ -337,9 +337,9 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
private def format(enumerator: Enumerator)(implicit formatterState: FormatterState): FormatResult = {
enumerator match {
- case expr@Expr(_) format(expr)
+ case expr@Expr(_) format(expr)
case generator@Generator(_, _, _, _, _) format(generator)
- case guard@Guard(_, _) format(guard: Guard)
+ case guard@Guard(_, _) format(guard: Guard)
}
}
@@ -520,11 +520,11 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
private def format(stat: Stat)(implicit formatterState: FormatterState): FormatResult =
stat match {
- case expr: Expr format(expr)
+ case expr: Expr format(expr)
case fullDefOrDcl: FullDefOrDcl format(fullDefOrDcl)
- case import_ : ImportClause format(import_)
+ case import_ : ImportClause format(import_)
case packageBlock: PackageBlock format(packageBlock)
- case _ NoFormatResult // TODO
+ case _ NoFormatResult // TODO
}
def format(packageBlock: PackageBlock)(implicit formatterState: FormatterState): FormatResult = {
@@ -559,7 +559,7 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
formatResult = formatResult.before(annotation.firstToken, preAnnotationFormattingInstruction)
if (nextOption.isEmpty) {
val firstPostAnnotationToken = modifiers match {
- case Nil defOrDcl.firstToken
+ case Nil defOrDcl.firstToken
case (modifier :: rest) modifier.firstToken
}
formatResult = formatResult.before(firstPostAnnotationToken, preAnnotationFormattingInstruction)
@@ -570,11 +570,11 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
}
private def format(defOrDcl: DefOrDcl)(implicit formatterState: FormatterState): FormatResult = defOrDcl match {
- case patDefOrDcl: PatDefOrDcl format(patDefOrDcl)
+ case patDefOrDcl: PatDefOrDcl format(patDefOrDcl)
case typeDefOrDcl: TypeDefOrDcl format(typeDefOrDcl)
- case funDefOrDcl: FunDefOrDcl format(funDefOrDcl)
- case tmplDef: TmplDef format(tmplDef)
- case _ NoFormatResult // TODO
+ case funDefOrDcl: FunDefOrDcl format(funDefOrDcl)
+ case tmplDef: TmplDef format(tmplDef)
+ case _ NoFormatResult // TODO
}
private def format(patDefOrDcl: PatDefOrDcl)(implicit formatterState: FormatterState): FormatResult = {
@@ -699,7 +699,7 @@ trait ExprFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
}
private def format(importExpr: ImportExpr)(implicit formatterState: FormatterState): FormatResult = importExpr match {
- case expr@Expr(_) format(expr)
+ case expr@Expr(_) format(expr)
case blockImportExpr@BlockImportExpr(_, _) format(blockImportExpr)
}
View
16 scalariform/src/main/scala/scalariform/formatter/ScalaFormatter.scala
@@ -116,7 +116,7 @@ abstract class ScalaFormatter extends HasFormattingPreferences with TypeFormatte
for ((previousOption, line) Utils.pairWithPrevious(lines)) {
line match {
case StarLine(fromStar) sb.append(newlineSequence).indent(indentLevel).append(" ").append(fromStar)
- case _ sb.append(line)
+ case _ sb.append(line)
}
}
sb.toString
@@ -194,7 +194,7 @@ abstract class ScalaFormatter extends HasFormattingPreferences with TypeFormatte
val newlineCount = token.getText.count(_ == '\n')
val newlinesToWrite = previousOpt match {
case Some(SingleLineComment(_)) math.min(1, newlineCount)
- case _ math.min(2, newlineCount)
+ case _ math.min(2, newlineCount)
}
for (i 1 to newlinesToWrite)
builder.newline()
@@ -250,9 +250,9 @@ abstract class ScalaFormatter extends HasFormattingPreferences with TypeFormatte
def write(token: Token, replacementOption: Option[String] = None): Option[TextEdit] = {
val rewriteArrows = formattingPreferences(RewriteArrowSymbols)
val actualReplacementOption = replacementOption orElse (condOpt(token.getType) {
- case ARROW if rewriteArrows ""
+ case ARROW if rewriteArrows ""
case LARROW if rewriteArrows ""
- case EOF ""
+ case EOF ""
})
builder.append(actualReplacementOption getOrElse token.getText)
actualReplacementOption map { replaceEdit(token, _) }
@@ -368,14 +368,14 @@ abstract class ScalaFormatter extends HasFormattingPreferences with TypeFormatte
return CompactEnsuringGap
type1 match {
case ARROW if type2 != RPAREN return CompactEnsuringGap // TODO: Redundant? no test fails.
- case COMMA return CompactEnsuringGap
- case _
+ case COMMA return CompactEnsuringGap
+ case _
}
type2 match {
- case IF if type1 != LPAREN return CompactEnsuringGap
+ case IF if type1 != LPAREN return CompactEnsuringGap
case ARROW if type1 != LPAREN return CompactEnsuringGap
case AT if IDS contains type2 return CompactEnsuringGap
- case _
+ case _
}
Compact
}
View
12 scalariform/src/main/scala/scalariform/formatter/TypeFormatter.scala
@@ -39,13 +39,13 @@ trait TypeFormatter { self: HasFormattingPreferences with AnnotationFormatter wi
private def format(typeElement: TypeElement)(implicit formatterState: FormatterState): FormatResult = {
typeElement match {
- case type_ @Type(_) format(type_)
- case refinement@Refinement(_, _, _) format(refinement)
+ case type_ @Type(_) format(type_)
+ case refinement@Refinement(_, _, _) format(refinement)
case annotation@Annotation(_, _, _, _) format(annotation)
- case TypeParamClause(contents) format(contents)
- case VarianceTypeElement(id) NoFormatResult
- case VarargsTypeElement(star) NoFormatResult
- case _ NoFormatResult
+ case TypeParamClause(contents) format(contents)
+ case VarianceTypeElement(id) NoFormatResult
+ case VarargsTypeElement(star) NoFormatResult
+ case _ NoFormatResult
}
}
View
4 scalariform/src/main/scala/scalariform/formatter/XmlFormatter.scala
@@ -21,10 +21,10 @@ trait XmlFormatter { self: HasFormattingPreferences with ExprFormatter with Scal
def format(xmlContent: XmlContents)(implicit formatterState: FormatterState): FormatResult = {
xmlContent match {
- case expr@Expr(_) format(expr)
+ case expr@Expr(_) format(expr)
case xmlNonEmpty@XmlNonEmptyElement(_, _, _) format(xmlNonEmpty)
case xmlEmpty@XmlEmptyElement(_, _, _, _, _) format(xmlEmpty)
- case _ NoFormatResult // TODO
+ case _ NoFormatResult // TODO
}
}
View
4 scalariform/src/main/scala/scalariform/formatter/preferences/PreferenceDescriptor.scala
@@ -11,9 +11,9 @@ sealed trait PreferenceType[T] {
case object BooleanPreference extends PreferenceType[Boolean] {
def parseValue(s: String) =
s.toLowerCase match {
- case "true" Right(true)
+ case "true" Right(true)
case "false" Right(false)
- case _ Left("Could not parse as boolean value: " + s)
+ case _ Left("Could not parse as boolean value: " + s)
}
}
View
2  scalariform/src/main/scala/scalariform/lexer/Lexer.scala
@@ -62,7 +62,7 @@ abstract class Lexer(reader: UnicodeEscapeReader) extends TokenTests {
val virtualChar = chQueue.dequeue()
tokenTextBuffer.append(virtualChar)
val delta = unicodeEscapesQueue.dequeue() match {
- case None 1
+ case None 1
case Some(s) s.length
}
actualTokenTextLength += delta
View
2  scalariform/src/main/scala/scalariform/lexer/NewlineInferencer.scala
@@ -102,7 +102,7 @@ class NewlineInferencer(private val delegate: Iterator[(HiddenTokens, Token)]) {
private def followingTokenIsClassOrObject: Boolean =
buffer.headOption match {
- case None false
+ case None false
case Some((_, followingToken)) followingToken.getType == CLASS || followingToken.getType == OBJECT
}
View
8 scalariform/src/main/scala/scalariform/lexer/ScalaOnlyLexer.scala
@@ -60,7 +60,7 @@ trait ScalaOnlyLexer extends Lexer {
(ch(1): @switch) match {
case '/' getSingleLineComment()
case '*' getMultilineComment()
- case _ nextChar(); getOperatorRest()
+ case _ nextChar(); getOperatorRest()
}
case '0'
if (ch(1) == 'x' || ch(1) == 'X')
@@ -242,7 +242,7 @@ trait ScalaOnlyLexer extends Lexer {
case '/'
(ch(1): @switch) match {
case '/' | '*' finishNamed()
- case _ nextChar(); getOperatorRest()
+ case _ nextChar(); getOperatorRest()
}
case _
if (isSpecial(ch)) { nextChar(); getOperatorRest() } else finishNamed()
@@ -367,11 +367,11 @@ trait ScalaOnlyLexer extends Lexer {
def restOfUncertainToken() = {
def isEfd = ch match {
case 'e' | 'E' | 'f' | 'F' | 'd' | 'D' true
- case _ false
+ case _ false
}
def isL = ch match {
case 'l' | 'L' true
- case _ false
+ case _ false
}
if (isEfd)
View
2  scalariform/src/main/scala/scalariform/lexer/WhitespaceAndCommentsGrouper.scala
@@ -30,7 +30,7 @@ class WhitespaceAndCommentsGrouper(private val delegate: ScalaLexer) extends Ite
private def isHiddenToken(token: Token) = token.getType match {
case WS | LINE_COMMENT | MULTILINE_COMMENT true
- case _ false
+ case _ false
}
private def makeHiddenToken(token: Token) = token.getType match {
View
2  scalariform/src/main/scala/scalariform/parser/AstNodes.scala
@@ -26,7 +26,7 @@ trait AstNode extends CaseClassReflector {
protected implicit def pairToFlattenable[T1 <% Flattenable, T2 <% Flattenable](pair: (T1, T2)): Flattenable = new Flattenable { val tokens = pair._1.tokens ::: pair._2.tokens }
protected implicit def eitherToFlattenable[T1 <% Flattenable, T2 <% Flattenable](either: T1 Either T2): Flattenable = new Flattenable {
val tokens = either match {
- case Left(f) f.tokens
+ case Left(f) f.tokens
case Right(f) f.tokens
}
}
View
62 scalariform/src/main/scala/scalariform/parser/ScalaParser.scala
@@ -74,17 +74,17 @@ class ScalaParser(tokens: Array[Token]) {
private def isDclIntro: Boolean = currentTokenType match {
case VAL | VAR | DEF | TYPE true
- case _ false
+ case _ false
}
private def isNumericLit: Boolean = currentTokenType match {
case INTEGER_LITERAL | FLOATING_POINT_LITERAL true
- case _ false
+ case _ false
}
private def isUnaryOp: Boolean = currentTokenType match {
case MINUS | PLUS | TILDE | EXCLAMATION true
- case _ false
+ case _ false
}
private def isIdent: Boolean = isIdent(currentTokenType)
@@ -108,8 +108,8 @@ class ScalaParser(tokens: Array[Token]) {
private def isTypeIntroToken(tokenType: TokenType): Boolean = tokenType match {
case THIS | SUPER | USCORE | LPAREN | AT true
- case _ if isIdent(tokenType) true
- case _ false
+ case _ if isIdent(tokenType) true
+ case _ false
}
private def isTypeIntro: Boolean = isTypeIntroToken(currentTokenType)
@@ -570,7 +570,7 @@ class ScalaParser(tokens: Array[Token]) {
exprElementFlatten2(AnonymousFunction(intermediateResult, arrowToken, List(postArrow)))
}
anonFuncOpt match {
- case None intermediateResult
+ case None intermediateResult
case Some(stuff) stuff
} // erk, why can't I use getOrElse here!?
} else
@@ -1189,11 +1189,11 @@ class ScalaParser(tokens: Array[Token]) {
private def defOrDcl(): DefOrDcl = {
currentTokenType match {
- case VAL patDefOrDcl()
- case VAR patDefOrDcl()
- case DEF funDefOrDcl()
+ case VAL patDefOrDcl()
+ case VAR patDefOrDcl()
+ case DEF funDefOrDcl()
case TYPE typeDefOrDcl()
- case _ tmplDef()
+ case _ tmplDef()
}
}
@@ -1325,12 +1325,12 @@ class ScalaParser(tokens: Array[Token]) {
private def tmplDef(): TmplDef = {
currentTokenType match {
- case TRAIT classDef()
- case CLASS classDef()
- case CASE if lookahead(1) == CLASS classDef()
- case OBJECT objectDef()
+ case TRAIT classDef()
+ case CLASS classDef()
+ case CASE if lookahead(1) == CLASS classDef()
+ case OBJECT objectDef()
case CASE if lookahead(1) == OBJECT objectDef()
- case _ throw new ScalaParserException("expected start of definition, but was " + currentTokenType)
+ case _ throw new ScalaParserException("expected start of definition, but was " + currentTokenType)
}
}
@@ -1735,14 +1735,14 @@ class ScalaParser(tokens: Array[Token]) {
val contents = ListBuffer[XmlContents]()
while (!XML_END_OPEN) {
val content = currentTokenType match {
- case XML_START_OPEN xmlElement(isPattern)
- case XML_PCDATA XmlPCDATA(nextToken())
- case XML_COMMENT XmlComment(nextToken())
- case XML_CDATA XmlCDATA(nextToken())
- case XML_UNPARSED XmlUnparsed(nextToken())
+ case XML_START_OPEN xmlElement(isPattern)
+ case XML_PCDATA XmlPCDATA(nextToken())
+ case XML_COMMENT XmlComment(nextToken())
+ case XML_CDATA XmlCDATA(nextToken())
+ case XML_UNPARSED XmlUnparsed(nextToken())
case XML_PROCESSING_INSTRUCTION XmlProcessingInstruction(nextToken())
- case LBRACE xmlEmbeddedScala(isPattern)
- case _ throw new ScalaParserException("Unexpected token in XML: " + currentToken)
+ case LBRACE xmlEmbeddedScala(isPattern)
+ case _ throw new ScalaParserException("Unexpected token in XML: " + currentToken)
}
contents += content
}
@@ -1757,13 +1757,13 @@ class ScalaParser(tokens: Array[Token]) {
private def xml(isPattern: Boolean): XmlExpr = {
def xmlContent(): XmlContents =
currentTokenType match {
- case XML_START_OPEN xmlElement(isPattern)
- case XML_PCDATA XmlPCDATA(nextToken())
- case XML_COMMENT XmlComment(nextToken())
- case XML_CDATA XmlCDATA(nextToken())
- case XML_UNPARSED XmlUnparsed(nextToken())
+ case XML_START_OPEN xmlElement(isPattern)
+ case XML_PCDATA XmlPCDATA(nextToken())
+ case XML_COMMENT XmlComment(nextToken())
+ case XML_CDATA XmlCDATA(nextToken())
+ case XML_UNPARSED XmlUnparsed(nextToken())
case XML_PROCESSING_INSTRUCTION XmlProcessingInstruction(nextToken())
- case _ throw new ScalaParserException("Expected XML: " + currentToken)
+ case _ throw new ScalaParserException("Expected XML: " + currentToken)
}
val first = xmlContent()
val otherContents = ListBuffer[XmlContents]()
@@ -1877,7 +1877,7 @@ object ScalaParser {
def groupGeneralTokens(xs: List[ExprElement]): List[ExprElement] = {
val eq = (x: ExprElement, y: ExprElement) (x, y) match {
case (GeneralTokens(_), GeneralTokens(_)) true
- case _ false
+ case _ false
}
val groups = groupBy(eq, xs)
groups map { group
@@ -1904,7 +1904,7 @@ object ScalaParser {
implicit def tripleToExprFlattenable[A <% ExprElementFlattenable, B <% ExprElementFlattenable, C <% ExprElementFlattenable](triple: (A, B, C)): ExprElementFlattenable =
ExprElements(triple._1.elements ::: triple._2.elements ::: triple._3.elements)
implicit def eitherToExprFlattenable[A <% ExprElementFlattenable, B <% ExprElementFlattenable](either: Either[A, B]): ExprElementFlattenable = ExprElements(either match {
- case Left(x) x.elements
+ case Left(x) x.elements
case Right(x) x.elements
})
implicit def optionToExprFlattenable[T <% ExprElementFlattenable](option: Option[T]): ExprElementFlattenable = option.toList
@@ -1923,7 +1923,7 @@ object ScalaParser {
implicit def listOfTokenToTypeFlattenable(tokens: List[Token]): TypeElementFlattenable = GeneralTokens(tokens)
implicit def typeElementToTypeFlattenable(typeElement: TypeElement): TypeElementFlattenable = TypeElements(List(typeElement))
implicit def eitherToTypeFlattenable[A <% TypeElementFlattenable, B <% TypeElementFlattenable](either: Either[A, B]): TypeElementFlattenable = TypeElements(either match {
- case Left(x) x.elements
+ case Left(x) x.elements
case Right(x) x.elements
})
implicit def pairToTypeFlattenable[A <% TypeElementFlattenable, B <% TypeElementFlattenable](pair: (A, B)): TypeElementFlattenable =
Please sign in to comment.
Something went wrong with that request. Please try again.