mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1984,7 +1984,7 @@ externalizable.without.public.no.arg.constructor.problem.descriptor=Externalizab
|
||||
make.constructor.public=Make constructor 'public'
|
||||
string.concatenation.missing.whitespace.display.name=String literal concatenation missing whitespace
|
||||
string.concatenation.missing.whitespace.problem.descriptor=String literal concatenation missing whitespace #loc
|
||||
string.concatenation.missing.whitespace.option=Ignore when one or both sides are not string literals
|
||||
string.concatenation.missing.whitespace.option=Ignore when one or both sides are not literals
|
||||
negated.equality.expression.display.name=Negated equality expression
|
||||
negated.equality.expression.problem.descriptor=Negating ''{0}'' #loc
|
||||
negated.equality.expression.quickfix=Remove negation
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -83,38 +83,31 @@ public class StringConcatenationMissingWhitespaceInspection extends BaseInspecti
|
||||
}
|
||||
|
||||
private boolean isMissingWhitespace(PsiExpression lhs, PsiExpression rhs) {
|
||||
final boolean lhsIsString = ExpressionUtils.hasStringType(lhs);
|
||||
final PsiLiteralExpression lhsLiteral = ExpressionUtils.getLiteral(lhs);
|
||||
final PsiLiteralExpression rhsLiteral = ExpressionUtils.getLiteral(rhs);
|
||||
if (lhsLiteral != null && lhsIsString) {
|
||||
final String value = (String)lhsLiteral.getValue();
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
final int length = value.length();
|
||||
final String lhsLiteral = ExpressionUtils.getLiteralString(lhs);
|
||||
if (lhsLiteral != null) {
|
||||
final int length = lhsLiteral.length();
|
||||
if (length == 0) {
|
||||
return false;
|
||||
}
|
||||
final char c = value.charAt(length - 1);
|
||||
final char c = lhsLiteral.charAt(length - 1);
|
||||
if (Character.isWhitespace(c) || !Character.isLetterOrDigit(c)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (ignoreNonStringLiterals || rhsLiteral == null || lhsIsString) {
|
||||
else if (ignoreNonStringLiterals) {
|
||||
return false;
|
||||
}
|
||||
final boolean rhsIsString = ExpressionUtils.hasStringType(rhs);
|
||||
if (rhsLiteral != null && rhsIsString) {
|
||||
final String value = (String)rhsLiteral.getValue();
|
||||
if ((value == null) || value.isEmpty()) {
|
||||
final String rhsLiteral = ExpressionUtils.getLiteralString(rhs);
|
||||
if (rhsLiteral != null) {
|
||||
if (rhsLiteral.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final char c = value.charAt(0);
|
||||
final char c = rhsLiteral.charAt(0);
|
||||
if (Character.isWhitespace(c) || !Character.isLetterOrDigit(c)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (ignoreNonStringLiterals || rhsIsString) {
|
||||
else if (ignoreNonStringLiterals) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2012 Bas Leijdekkers
|
||||
* Copyright 2005-2013 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -154,6 +154,19 @@ public class ExpressionUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getLiteralString(@Nullable PsiExpression expression) {
|
||||
final PsiLiteralExpression literal = getLiteral(expression);
|
||||
if (literal == null) {
|
||||
return null;
|
||||
}
|
||||
final Object value = literal.getValue();
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiLiteralExpression getLiteral(@Nullable PsiExpression expression) {
|
||||
expression = ParenthesesUtils.stripParentheses(expression);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports string concatenations where the left literal does not
|
||||
end with whitespace and the right literal does not start with whitespace. For example:
|
||||
Reports string concatenations where the left-hand side does not
|
||||
end with whitespace or a symbol and the right-hand side does not start with whitespace or a symbol. For example:
|
||||
<pre><code>
|
||||
String sql = "SELECT column" +
|
||||
"FROM table";
|
||||
</code></pre>
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the checkbox below to have this inspection only report when both the left and right side of the concatenation are string literals.
|
||||
Use the checkbox below to have this inspection only report when both the left and right side of the concatenation are literals.
|
||||
<p>
|
||||
<small>New in 12, Powered by InspectionGadgets</small>
|
||||
</body>
|
||||
|
||||
@@ -8,5 +8,6 @@ class Concatenations {
|
||||
System.out.println("no:" + i);
|
||||
System.out.println("i" + i);
|
||||
System.out.println("i" + ((String)"j"));
|
||||
System.out.println('{' + "a" + '\'');
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 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.
|
||||
@@ -13,8 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.actions.generate;
|
||||
package org.jetbrains.plugins.groovy.lang.actions.generate
|
||||
|
||||
import com.intellij.codeInsight.generation.*
|
||||
import com.intellij.openapi.application.Result
|
||||
import com.intellij.openapi.application.RunResult
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
@@ -28,7 +29,6 @@ import org.jetbrains.annotations.Nullable
|
||||
import org.jetbrains.plugins.groovy.actions.generate.accessors.GroovyGenerateGetterSetterAction
|
||||
import org.jetbrains.plugins.groovy.actions.generate.constructors.GroovyGenerateConstructorHandler
|
||||
import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
import com.intellij.codeInsight.generation.*
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -203,7 +203,8 @@ class Test {
|
||||
@Nullable
|
||||
def foo
|
||||
|
||||
@Nullable getFoo() {
|
||||
@Nullable
|
||||
getFoo() {
|
||||
return foo
|
||||
}
|
||||
}'''
|
||||
|
||||
Reference in New Issue
Block a user