mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
method refs: turn highlighting on; check valid context
This commit is contained in:
@@ -339,6 +339,9 @@ public class HighlightUtil {
|
||||
if (operandType == null) return null;
|
||||
if (operandType instanceof PsiLambdaExpressionType) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, "Lambda expression is not expected here");
|
||||
}
|
||||
if (operandType instanceof PsiMethodReferenceType) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, expression, "Method reference expression is not expected here");
|
||||
}
|
||||
if (TypeConversionUtil.isPrimitiveAndNotNull(operandType)
|
||||
|| TypeConversionUtil.isPrimitiveAndNotNull(checkType)
|
||||
@@ -2633,11 +2636,7 @@ public class HighlightUtil {
|
||||
|
||||
@Nullable
|
||||
public static HighlightInfo checkMethodReferencesFeature(final PsiMethodReferenceExpression expression) {
|
||||
final HighlightInfo info = checkFeature(expression, Feature.METHOD_REFERENCES);
|
||||
if (info != null) return info;
|
||||
// todo[r.sh] stub; remove after implementing support in TypeConversionUtil
|
||||
final String message = "Method references type check is not yet implemented";
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.WEAK_WARNING, expression, message);
|
||||
return checkFeature(expression, Feature.METHOD_REFERENCES);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ class C {
|
||||
void use(Simplest s) { }
|
||||
|
||||
void test() {
|
||||
Simplest simplest = <weak_warning descr="Method references type check is not yet implemented">this::simplest</weak_warning>;
|
||||
use(<weak_warning descr="Method references type check is not yet implemented">this::simplest</weak_warning>);
|
||||
Simplest simplest = this::simplest;
|
||||
use(this::simplest);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class Test {
|
||||
{
|
||||
if (<error descr="Method reference expression is not expected here">Test::length instanceof String</error>) {
|
||||
}
|
||||
bar(Test::length);
|
||||
}
|
||||
|
||||
public static Integer length(String s) {
|
||||
return s.length();
|
||||
}
|
||||
|
||||
public static void bar(Bar bar) {}
|
||||
|
||||
interface Bar {
|
||||
Integer _(String s);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/methodRef";
|
||||
|
||||
public void testValidContext() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user