在Android Studio中连接字符串时遇到了一个问题。似乎最大长度为120个字符,但仅限于连接时。
如果我有这个例子:
private static final String HOW_LONG_CAN_A_STRING_BE =
"123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "";
String test = HOW_LONG_CAN_A_STRING_BE;
当我将鼠标悬停在字符串HOW_LONG_CAN_A_STRING_BE上时,它会解析连接的字符串。
但是,如果我在此示例中添加更多字符:
private static final String HOW_LONG_CAN_A_STRING_BE =
"123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "123456789A"
+ "1";
String test = HOW_LONG_CAN_A_STRING_BE;
当我将鼠标悬停在HOW_LONG_CAN_A_STRING_BE上时会导致错误显示在Android Studio的事件日志中,其中包含以下详细信息:
"123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A12345 ...
": Incorrect expression ""123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A12345 ...
"".
com.intellij.util.IncorrectOperationException: Incorrect expression ""123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A123456789A12345 ...
"".
at com.intellij.psi.impl.PsiJavaParserFacadeImpl.createExpressionFromText(PsiJavaParserFacadeImpl.java:325)
at com.intellij.psi.impl.PsiElementFactoryImpl.createExpressionFromText(PsiElementFactoryImpl.java:667)
at com.intellij.codeInsight.javadoc.JavaDocInfoGenerator.calcInitializerExpression(JavaDocInfoGenerator.java:613)
at com.intellij.codeInsight.javadoc.JavaDocInfoGenerator.appendInitializer(JavaDocInfoGenerator.java:661)
at com.intellij.codeInsight.javadoc.JavaDocInfoGenerator.generateFieldJavaDoc(JavaDocInfoGenerator.java:459)
at com.intellij.codeInsight.javadoc.JavaDocInfoGenerator.generateDocInfoCore(JavaDocInfoGenerator.java:231)
at com.intellij.codeInsight.javadoc.JavaDocInfoGenerator.generateDocInfo(JavaDocInfoGenerator.java:255)
at com.intellij.lang.java.JavaDocumentationProvider.generateExternalJavadoc(JavaDocumentationProvider.java:512)
at com.intellij.lang.java.JavaDocumentationProvider.generateDoc(JavaDocumentationProvider.java:500)
at com.intellij.lang.documentation.CompositeDocumentationProvider.generateDoc(CompositeDocumentationProvider.java:138)
at com.intellij.codeInsight.documentation.DocumentationManager$9$4.compute(DocumentationManager.java:665)
at com.intellij.codeInsight.documentation.DocumentationManager$9$4.compute(DocumentationManager.java:660)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.intellij.codeInsight.documentation.DocumentationManager$9.getDocumentation(DocumentationManager.java:659)
at com.intellij.codeInsight.documentation.DocumentationManager$10.run(DocumentationManager.java:763)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:298)
at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:295)
at com.intellij.util.concurrency.QueueProcessor$2$1.run(QueueProcessor.java:110)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:107)
at com.intellij.util.concurrency.QueueProcessor$2.consume(QueueProcessor.java:104)
at com.intellij.util.concurrency.QueueProcessor$3$1.run(QueueProcessor.java:215)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.concurrency.QueueProcessor$3.run(QueueProcessor.java:212)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:419)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:149)
这是一个问题,因为我正在尝试创建一个数据库,并且保存数据库create语句的String大于120个字符。有没有人之前遇到过这个问题,如果是这样的话,如何解决这个问题而不必让我的列名不可读?
以下是失败的create语句:
CREATE TABLE reminder( id INTEGER PRIMARY KEY, createdAt TEXT, startDate TEXT, endDate TEXT, reminder_time INTEGER, repeats INTEGER, deferTime INTEGER, alarmOn INTEGER, reminderOn INTEGER, description TEXT )
答案 0 :(得分:0)
我在Artjom B发表评论后跟进,发现它并没有影响数据库的创建。
我最近更新到Android Studio版本0.61,问题似乎不再存在。