From 43b03c6cdcaa89255304c475e3de826ec47cfc62 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 12 May 2016 18:33:16 +0200 Subject: [PATCH] [tests] minor optimization --- .../intellij/testFramework/LexerTestCase.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/LexerTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LexerTestCase.java index 599d31ed09e1..2ab56cd8e1b9 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LexerTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LexerTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ import java.io.IOException; * @author peter */ public abstract class LexerTestCase extends UsefulTestCase { - protected void doTest(@NonNls String text) { doTest(text, null); } @@ -97,19 +96,13 @@ public abstract class LexerTestCase extends UsefulTestCase { public static String printTokens(CharSequence text, int start, Lexer lexer) { lexer.start(text, start, text.length()); - String result = ""; - while (true) { - IElementType tokenType = lexer.getTokenType(); - if (tokenType == null) { - break; - } - String tokenText = getTokenText(lexer); - String tokenTypeName = tokenType.toString(); - String line = tokenTypeName + " ('" + tokenText + "')\n"; - result += line; + StringBuilder result = new StringBuilder(); + IElementType tokenType; + while ((tokenType = lexer.getTokenType()) != null) { + result.append(tokenType).append(" ('").append(getTokenText(lexer)).append("')\n"); lexer.advance(); } - return result; + return result.toString(); } protected void doFileTest(@NonNls String fileExt) { @@ -143,4 +136,4 @@ public abstract class LexerTestCase extends UsefulTestCase { protected abstract Lexer createLexer(); protected abstract String getDirPath(); -} +} \ No newline at end of file