mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+6
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -22,12 +22,11 @@ import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
|
||||
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
|
||||
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.ui.tree.render.CachedEvaluator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.xdebugger.XExpression;
|
||||
import com.sun.jdi.BooleanValue;
|
||||
import com.sun.jdi.ObjectReference;
|
||||
import com.sun.jdi.Value;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -70,17 +69,11 @@ public class ConditionCheckerImpl implements ConditionChecker {
|
||||
|
||||
@Override
|
||||
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
|
||||
ExpressionEvaluator evaluator;
|
||||
try {
|
||||
evaluator = myEvaluator.getEvaluator();
|
||||
Value result =
|
||||
evaluator.evaluate(new EvaluationContextImpl(suspendContext, suspendContext.getFrameProxy(), myReference));
|
||||
if (result instanceof BooleanValue && ((BooleanValue)result).value()) {
|
||||
myResultReference.set(CheckingResultImpl.SUCCESS);
|
||||
}
|
||||
else {
|
||||
myResultReference.set(CheckingResultImpl.FAIL);
|
||||
}
|
||||
EvaluationContextImpl evaluationContext = new EvaluationContextImpl(suspendContext, suspendContext.getFrameProxy(), myReference);
|
||||
myResultReference.set(DebuggerUtilsEx.evaluateBoolean(myEvaluator.getEvaluator(), evaluationContext)
|
||||
? CheckingResultImpl.SUCCESS
|
||||
: CheckingResultImpl.FAIL);
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
myResultReference.set(CheckingResultImpl.error(e.getMessage()));
|
||||
|
||||
@@ -159,6 +159,7 @@ internal object JavaConverter {
|
||||
is PsiParameterList -> unwrapElements(element.parent)
|
||||
is PsiAnnotationParameterList -> unwrapElements(element.parent)
|
||||
is PsiModifierList -> unwrapElements(element.parent)
|
||||
is PsiExpressionList -> unwrapElements(element.parent)
|
||||
else -> element
|
||||
}
|
||||
|
||||
@@ -228,14 +229,23 @@ internal object JavaConverter {
|
||||
expr<UCallExpression>(build(::JavaConstructorUCallExpression))
|
||||
}
|
||||
is PsiMethodCallExpression -> {
|
||||
if (el.methodExpression.qualifierExpression != null)
|
||||
expr<UQualifiedReferenceExpression> {
|
||||
if (el.methodExpression.qualifierExpression != null) {
|
||||
if (requiredType == null ||
|
||||
requiredType.isAssignableFrom(UQualifiedReferenceExpression::class.java) ||
|
||||
requiredType.isAssignableFrom(UCallExpression::class.java)) {
|
||||
val parent = if (parentCallback == null) null else (parentCallback() ?: return null)
|
||||
JavaUCompositeQualifiedExpression(el, parent).apply {
|
||||
val expr = JavaUCompositeQualifiedExpression(el, parent).apply {
|
||||
receiver = convertOrEmpty(el.methodExpression.qualifierExpression!!, this)
|
||||
selector = JavaUCallExpression(el, this)
|
||||
}
|
||||
if (requiredType?.isAssignableFrom(UCallExpression::class.java) != null)
|
||||
expr.selector
|
||||
else
|
||||
expr
|
||||
}
|
||||
else
|
||||
null
|
||||
}
|
||||
else
|
||||
expr<UCallExpression>(build(::JavaUCallExpression))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
public class Foo {
|
||||
public static String foo = String.format("q");
|
||||
}
|
||||
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package org.jetbrains.uast.test.java
|
||||
|
||||
import org.jetbrains.uast.UFile
|
||||
import org.jetbrains.uast.ULocalVariable
|
||||
import com.intellij.psi.PsiCallExpression
|
||||
import com.intellij.psi.PsiLiteralExpression
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.test.env.findElementByText
|
||||
import org.junit.Test
|
||||
|
||||
@@ -37,4 +40,16 @@ class JavaUastApiTest : AbstractJavaUastTest() {
|
||||
assertEquals(1, file.classes[0].fields.size)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun testCallExpression() {
|
||||
doTest("Simple/CallExpression.java") { name, file ->
|
||||
val index = file.psi.text.indexOf("format")
|
||||
val callExpression = PsiTreeUtil.getParentOfType(file.psi.findElementAt(index), PsiCallExpression::class.java)!!
|
||||
assertNotNull(callExpression.toUElementOfType<UCallExpression>())
|
||||
|
||||
val index2 = file.psi.text.indexOf("q")
|
||||
val literal = PsiTreeUtil.getParentOfType(file.psi.findElementAt(index2), PsiLiteralExpression::class.java)!!
|
||||
UsefulTestCase.assertInstanceOf(literal.toUElement(), ULiteralExpression::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user