From 9c94ace79f0166277c359d12cf906f3f7351de66 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 29 Oct 2014 13:48:42 +0400 Subject: [PATCH] IDEA-131761 Quick documentation incorrectly renders value of byte[] constant --- .../javadoc/JavaDocInfoGenerator.java | 2 +- .../methodExpressionWithLiteral.html | 1 + .../methodExpressionWithLiteral.java | 3 +++ .../javadoc/JavaDocInfoGeneratorTest.java | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/javadocIG/methodExpressionWithLiteral.html create mode 100644 java/java-tests/testData/codeInsight/javadocIG/methodExpressionWithLiteral.java diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java index c0742de3c7f6..975af4a8dd67 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java @@ -2053,7 +2053,7 @@ public class JavaDocInfoGenerator { @Override public void visitMethodCallExpression(PsiMethodCallExpression expression) { - myBuffer.append(expression.getMethodExpression().getText()).append("("); + myBuffer.append(StringUtil.escapeXml(expression.getMethodExpression().getText())).append("("); expression.getArgumentList().accept(this); myBuffer.append(")"); } diff --git a/java/java-tests/testData/codeInsight/javadocIG/methodExpressionWithLiteral.html b/java/java-tests/testData/codeInsight/javadocIG/methodExpressionWithLiteral.html new file mode 100644 index 000000000000..5d73a26bc75f --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/methodExpressionWithLiteral.html @@ -0,0 +1 @@ + A
public byte[] bytes = "&".getBytes()
\ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/javadocIG/methodExpressionWithLiteral.java b/java/java-tests/testData/codeInsight/javadocIG/methodExpressionWithLiteral.java new file mode 100644 index 000000000000..3d13bcd7296a --- /dev/null +++ b/java/java-tests/testData/codeInsight/javadocIG/methodExpressionWithLiteral.java @@ -0,0 +1,3 @@ +class A { + public byte[] bytes = "&".getBytes(); +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java index 871c758d08fd..bda17baaa0ce 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.codeInsight.javadoc; import com.intellij.JavaTestUtil; @@ -72,6 +87,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase { doTestField(); } + public void testMethodExpressionWithLiteral() throws Exception { + doTestField(); + } + public void testInitializerWithReference() throws Exception { doTestField(); }