Cleanup (warnings; minor optimization)

GitOrigin-RevId: 17adfdb304a61f2aca08a906bb3e5775f5156a05
This commit is contained in:
Roman Shevchenko
2019-12-20 14:44:33 +00:00
committed by intellij-monorepo-bot
parent 7b2d0ce401
commit 7a095b84c3
2 changed files with 6 additions and 6 deletions
@@ -46,10 +46,8 @@ class JavadocHtmlLintAnnotator : ExternalAnnotator<JavadocHtmlLintAnnotator.Info
runReadAction { if (isJava8SourceFile(file) && "/**" in file.text) Info(file) else null }
override fun doAnnotate(collectedInfo: Info): Result? {
val text = runReadAction { if (collectedInfo.file.isValid) collectedInfo.file.text else null }
if (text == null) return null
val file = collectedInfo.file.virtualFile!!
val text = runReadAction { if (collectedInfo.file.isValid) collectedInfo.file.text else null } ?: return null
val file = collectedInfo.file.virtualFile ?: return null
val copy = createTempFile(text.toByteArray(file.charset))
try {
@@ -157,7 +155,7 @@ class JavadocHtmlLintAnnotator : ExternalAnnotator<JavadocHtmlLintAnnotator.Info
while (i.hasNext()) {
val line = i.next()
val matcher = lintPattern.matcher(line)
if (matcher.matches() && i.hasNext() && !i.next().isEmpty() && i.hasNext()) {
if (matcher.matches() && i.hasNext() && i.next().isNotEmpty() && i.hasNext()) {
val row = matcher.group(1).toInt() - 1
val col = i.next().indexOf('^')
val error = matcher.group(2) == "error"
@@ -8,13 +8,14 @@ import com.intellij.openapi.projectRoots.impl.JavaSdkImpl
import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import com.intellij.util.lang.JavaVersion
import java.io.File
private val DESCRIPTOR = object : DefaultLightProjectDescriptor() {
override fun getSdk(): Sdk? {
val jreHome = File(System.getProperty("java.home"))
val jdkHome = if (jreHome.name == "jre") jreHome.parentFile else jreHome
return (JavaSdk.getInstance() as JavaSdkImpl).createMockJdk("java version \"1.8.0\"", jdkHome.path, false)
return (JavaSdk.getInstance() as JavaSdkImpl).createMockJdk("java version \"{${JavaVersion.current()}}\"", jdkHome.path, false)
}
}
@@ -25,6 +26,7 @@ class JavadocHtmlLintInspectionTest : LightJavaCodeInsightFixtureTestCase() {
fun testEmptyComment() = doTest("/** */\nclass C { }")
@Suppress("GrazieInspection")
fun testCommonErrors() = doTest("""
package pkg;
/**