Commit ddf59fe1 authored by Roman Shevchenko's avatar Roman Shevchenko
Browse files

Merge remote-tracking branch 'origin/master'

parents c4111f32 357c5ccd
Showing with 189 additions and 148 deletions
+189 -148
<component name="libraryTable">
<library name="Gradle">
<CLASSES>
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-tooling-api-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-core-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-messaging-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-model-core-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-model-groovy-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-wrapper-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-base-services-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-base-services-groovy-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-process-services-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-native-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-resources-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-cli-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-logging-3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-tooling-api-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-core-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-messaging-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-model-core-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-model-groovy-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-wrapper-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-base-services-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-base-services-groovy-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-process-services-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-resources-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-cli-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-logging-3.3.jar!/" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-version-info-3.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/tooling-api/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/core/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/model-core/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/model-groovy/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/messaging/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/wrapper/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/base-services/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/base-services-groovy/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/process-services/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/native/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/resources/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/cli/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.1-src.zip!/gradle-3.1/subprojects/logging/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/tooling-api/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/core/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/model-core/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/model-groovy/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/messaging/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/wrapper/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/base-services/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/base-services-groovy/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/process-services/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/resources/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/cli/src/main/java" />
<root url="jar://$PROJECT_DIR$/plugins/gradle/lib/gradle-3.3-src.zip!/gradle-3.3/subprojects/logging/src/main/java" />
</SOURCES>
</library>
</component>
\ No newline at end of file
/*
* 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.
......@@ -27,7 +27,7 @@ import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_105_CompilerAndPlugin_NoTests"
String kotlinBuildConfigurationOnPublicTeamCity = "Kotlin_110_CompilerAndPlugin_NoTests"
target('default': 'Ensures that build/kotlinc directory contains JARs from Kotlin plugin compatible with current IDEA sources. These JARs are used by build scripts.') {
def communityHome = guessHome(this)
......@@ -321,6 +321,6 @@ class TeamCityBuildLocator {
String getDownloadUrl(String buildNumber) {
String encodedBuildNumber = URLEncoder.encode(buildNumber, "UTF-8")
return "$host/guestAuth/repository/download/$buildTypeId/$encodedBuildNumber/kotlin-plugin-1.0.5-release-IJ2016.3-3.zip"
return "$host/guestAuth/repository/download/$buildTypeId/$encodedBuildNumber/kotlin-plugin-$encodedBuildNumber-IJ2017.1-1.zip"
}
}
......@@ -89,6 +89,7 @@ final class ImageEditorUI extends JPanel implements DataProvider, CopyProvider,
private final JLabel infoLabel;
private final PropertyChangeListener optionsChangeListener = new OptionsChangeListener();
private final JScrollPane myScrollPane;
ImageEditorUI(@Nullable ImageEditor editor) {
this.editor = editor;
......@@ -130,12 +131,12 @@ final class ImageEditorUI extends JPanel implements DataProvider, CopyProvider,
view.addMouseListener(new EditorMouseAdapter());
view.addMouseListener(new FocusRequester());
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(view);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
myScrollPane = ScrollPaneFactory.createScrollPane(view);
myScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
myScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
// Zoom by wheel listener
scrollPane.addMouseWheelListener(wheelAdapter);
myScrollPane.addMouseWheelListener(wheelAdapter);
// Construct UI
setLayout(new BorderLayout());
......@@ -164,7 +165,7 @@ final class ImageEditorUI extends JPanel implements DataProvider, CopyProvider,
errorPanel.add(errorLabel, BorderLayout.CENTER);
contentPanel = new JPanel(new CardLayout());
contentPanel.add(scrollPane, IMAGE_PANEL);
contentPanel.add(myScrollPane, IMAGE_PANEL);
contentPanel.add(errorPanel, ERROR_PANEL);
JPanel topPanel = new JPanel(new BorderLayout());
......@@ -331,12 +332,29 @@ final class ImageEditorUI extends JPanel implements DataProvider, CopyProvider,
ZoomOptions zoomOptions = editorOptions.getZoomOptions();
if (zoomOptions.isWheelZooming() && e.isControlDown()) {
int rotation = e.getWheelRotation();
double oldZoomFactor = zoomModel.getZoomFactor();
Point oldPosition = myScrollPane.getViewport().getViewPosition();
if (rotation < 0) {
zoomModel.zoomOut();
}
else if (rotation > 0) {
zoomModel.zoomIn();
}
// reset view, otherwise view size is not obtained correctly sometimes
Component view = myScrollPane.getViewport().getView();
myScrollPane.setViewport(null);
myScrollPane.setViewportView(view);
if (oldZoomFactor > 0 && rotation != 0) {
Point mousePoint = e.getPoint();
double zoomChange = zoomModel.getZoomFactor() / oldZoomFactor;
Point newPosition = new Point((int)Math.max(0, (oldPosition.getX() + mousePoint.getX()) * zoomChange - mousePoint.getX()),
(int)Math.max(0, (oldPosition.getY() + mousePoint.getY()) * zoomChange - mousePoint.getY()));
myScrollPane.getViewport().setViewPosition(newPosition);
}
e.consume();
}
}
......
......@@ -29,7 +29,7 @@ import java.beans.PropertyChangeSupport;
* @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
*/
final class ZoomOptionsImpl implements ZoomOptions, JDOMExternalizable {
private boolean wheelZooming;
private boolean wheelZooming = true;
private boolean smartZooming = true;
private int prefferedWidth = DEFAULT_PREFFERED_SIZE.width;
private int prefferedHeight = DEFAULT_PREFFERED_SIZE.height;
......
......@@ -207,7 +207,9 @@ public class ThreadDumpAction extends AnAction implements AnAction.TransparentUp
for (String waiting : waitingMap.keySet()) {
final ThreadState waitingThread = nameToThreadMap.get(waiting);
final ThreadState awaitedThread = nameToThreadMap.get(waitingMap.get(waiting));
awaitedThread.addWaitingThread(waitingThread);
if (waitingThread != null && awaitedThread != null) { //zombie
awaitedThread.addWaitingThread(waitingThread);
}
}
// detect simple deadlocks
......
/*
* 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.
......@@ -100,7 +100,11 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR
@Override
public SourcePosition getSourcePosition(final Location location) {
if (location == null) return null;
SourcePosition res = mySourcePositionCache.get(location);
SourcePosition res = null;
try {
res = mySourcePositionCache.get(location);
} catch (IllegalArgumentException ignored) { // Invalid method id
}
if (checkCacheEntry(res, location)) return res;
return DebuggerUtilsImpl.runInReadActionWithWriteActionPriorityWithRetries(
......@@ -111,7 +115,7 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR
}, null, null, false));
}
private static boolean checkCacheEntry(SourcePosition position, Location location) {
private static boolean checkCacheEntry(@Nullable SourcePosition position, @NotNull Location location) {
if (position == null) return false;
PsiFile psiFile = position.getFile();
if (!psiFile.isValid()) return false;
......
......@@ -1415,7 +1415,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
@Override
public void stop(boolean forceTerminate) {
stopConnecting(); // does this first place in case debugger manager hanged accepting debugger connection (forever)
getManagerThread().terminateAndInvoke(createStopCommand(forceTerminate), DebuggerManagerThreadImpl.COMMAND_TIMEOUT);
getManagerThread().terminateAndInvoke(createStopCommand(forceTerminate), ApplicationManager.getApplication().isUnitTestMode() ? 0 : DebuggerManagerThreadImpl.COMMAND_TIMEOUT);
}
@NotNull
......
......@@ -112,7 +112,7 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
invoke(command);
if (currentCommand != null) {
final ScheduledFuture<?> future = AppExecutorUtil.getAppScheduledExecutorService().schedule(
AppExecutorUtil.getAppScheduledExecutorService().schedule(
() -> {
if (currentCommand == myEvents.getCurrentEvent()) {
// if current command is still in progress, cancel it
......@@ -132,17 +132,6 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
}
}
}, terminateTimeoutMillis, TimeUnit.MILLISECONDS);
// register on project instead of this because it would cause significant delays on each session termination otherwise
Disposer.register(myProject, () -> {
if (!future.cancel(true)) {
WorkerThreadRequest request = getCurrentThreadRequest();
if (request != null) {
request.requestStop();
}
}
// else scheduled future was de-scheduled successfully before starting
});
}
}
......
......@@ -82,7 +82,7 @@ public class LambdaAsyncMethodFilter extends BasicStepMethodFilter {
return false;
}
if (!DebuggerUtilsEx.isLambdaName(event.location().method().name())) {
if (!DebuggerUtilsEx.isLambda(event.location().method())) {
return false;
}
......
......@@ -80,7 +80,7 @@ public class LambdaMethodFilter implements BreakpointStepMethodFilter {
public boolean locationMatches(DebugProcessImpl process, Location location) throws EvaluateException {
final VirtualMachineProxyImpl vm = process.getVirtualMachineProxy();
final Method method = location.method();
return DebuggerUtilsEx.isLambdaName(method.name()) && (!vm.canGetSyntheticAttribute() || method.isSynthetic());
return DebuggerUtilsEx.isLambda(method) && (!vm.canGetSyntheticAttribute() || method.isSynthetic());
}
@Nullable
......
......@@ -162,14 +162,12 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
sourcePosition = calcLineMappedSourcePosition(psiFile, lineNumber);
}
final Method method = location.method();
final Method method = DebuggerUtilsEx.getMethod(location);
if (sourcePosition == null && (psiFile instanceof PsiCompiledElement || lineNumber < 0)) {
String methodSignature = method.signature();
String methodName = method.name();
if (methodSignature != null && methodName != null) {
if (method != null && method.name() != null && method.signature() != null) {
PsiClass psiClass = findPsiClassByName(qName, null);
PsiMethod compiledMethod = findMethod(psiClass != null ? psiClass : psiFile, qName, methodName, methodSignature);
PsiMethod compiledMethod = findMethod(psiClass != null ? psiClass : psiFile, qName, method.name(), method.signature());
if (compiledMethod != null) {
sourcePosition = SourcePosition.createFromElement(compiledMethod);
if (lineNumber >= 0) {
......@@ -187,11 +185,11 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
}
int lambdaOrdinal = -1;
if (DebuggerUtilsEx.isLambdaName(method.name())) {
if (DebuggerUtilsEx.isLambda(method)) {
Set<Method> lambdas =
ContainerUtil.map2SetNotNull(locationsOfLine(location.declaringType(), sourcePosition), location1 -> {
Method method1 = location1.method();
if (DebuggerUtilsEx.isLambdaName(method1.name())) {
if (DebuggerUtilsEx.isLambda(method1)) {
return method1;
}
return null;
......@@ -551,71 +549,67 @@ public class PositionManagerImpl implements PositionManager, MultiRequestPositio
ApplicationManager.getApplication().assertReadAccessAllowed();
final VirtualMachineProxyImpl vmProxy = myDebugProcess.getVirtualMachineProxy();
if (fromClass.isPrepared()) {
try {
if (currentDepth < requiredDepth) {
final List<ReferenceType> nestedTypes = vmProxy.nestedTypes(fromClass);
for (ReferenceType nested : nestedTypes) {
final ReferenceType found = findNested(nested, currentDepth + 1, classToFind, requiredDepth, position);
if (found != null) {
return found;
}
if (currentDepth < requiredDepth) {
final List<ReferenceType> nestedTypes = vmProxy.nestedTypes(fromClass);
for (ReferenceType nested : nestedTypes) {
final ReferenceType found = findNested(nested, currentDepth + 1, classToFind, requiredDepth, position);
if (found != null) {
return found;
}
return null;
}
return null;
}
int rangeBegin = Integer.MAX_VALUE;
int rangeEnd = Integer.MIN_VALUE;
for (Location location : fromClass.allLineLocations()) {
final int lnumber = location.lineNumber();
if (lnumber <= 1) {
// should be a native method, skipping
// sometimes compiler generates location where line number is exactly 1 (e.g. GWT)
// such locations are hardly correspond to real lines in code, so skipping them too
continue;
}
final Method method = location.method();
if (method == null || DebuggerUtils.isSynthetic(method) || method.isBridge()) {
// do not take into account synthetic stuff
continue;
}
int locationLine = lnumber - 1;
PsiFile psiFile = position.getFile().getOriginalFile();
if (psiFile instanceof PsiCompiledFile) {
locationLine = DebuggerUtilsEx.bytecodeToSourceLine(psiFile, locationLine);
if (locationLine < 0) continue;
}
rangeBegin = Math.min(rangeBegin, locationLine);
rangeEnd = Math.max(rangeEnd, locationLine);
int rangeBegin = Integer.MAX_VALUE;
int rangeEnd = Integer.MIN_VALUE;
for (Location location : DebuggerUtilsEx.allLineLocations(fromClass)) {
final int lnumber = DebuggerUtilsEx.getLineNumber(location, false);
if (lnumber <= 1) {
// should be a native method, skipping
// sometimes compiler generates location where line number is exactly 1 (e.g. GWT)
// such locations are hardly correspond to real lines in code, so skipping them too
continue;
}
final Method method = DebuggerUtilsEx.getMethod(location);
if (method == null || DebuggerUtils.isSynthetic(method) || method.isBridge()) {
// do not take into account synthetic stuff
continue;
}
int locationLine = lnumber - 1;
PsiFile psiFile = position.getFile().getOriginalFile();
if (psiFile instanceof PsiCompiledFile) {
locationLine = DebuggerUtilsEx.bytecodeToSourceLine(psiFile, locationLine);
if (locationLine < 0) continue;
}
rangeBegin = Math.min(rangeBegin, locationLine);
rangeEnd = Math.max(rangeEnd, locationLine);
}
final int positionLine = position.getLine();
if (positionLine >= rangeBegin && positionLine <= rangeEnd) {
// Now we use the last line to find the class, previously it was:
// choose the second line to make sure that only this class' code exists on the line chosen
// Otherwise the line (depending on the offset in it) can contain code that belongs to different classes
// and JVMNameUtil.getClassAt(candidatePosition) will return the wrong class.
// Example of such line:
// list.add(new Runnable(){......
// First offsets belong to parent class, and offsets inside te substring "new Runnable(){" belong to anonymous runnable.
if (!classToFind.isValid()) {
return null;
}
Set<PsiClass> lineClasses = getLineClasses(position.getFile(), rangeEnd);
if (lineClasses.size() > 1) {
// if there's more than one class on the line - try to match by name
for (PsiClass aClass : lineClasses) {
if (classToFind.equals(aClass)) {
return fromClass;
}
final int positionLine = position.getLine();
if (positionLine >= rangeBegin && positionLine <= rangeEnd) {
// Now we use the last line to find the class, previously it was:
// choose the second line to make sure that only this class' code exists on the line chosen
// Otherwise the line (depending on the offset in it) can contain code that belongs to different classes
// and JVMNameUtil.getClassAt(candidatePosition) will return the wrong class.
// Example of such line:
// list.add(new Runnable(){......
// First offsets belong to parent class, and offsets inside te substring "new Runnable(){" belong to anonymous runnable.
if (!classToFind.isValid()) {
return null;
}
Set<PsiClass> lineClasses = getLineClasses(position.getFile(), rangeEnd);
if (lineClasses.size() > 1) {
// if there's more than one class on the line - try to match by name
for (PsiClass aClass : lineClasses) {
if (classToFind.equals(aClass)) {
return fromClass;
}
}
else if (!lineClasses.isEmpty()){
return classToFind.equals(lineClasses.iterator().next())? fromClass : null;
}
return null;
}
}
catch (AbsentInformationException ignored) {
else if (!lineClasses.isEmpty()){
return classToFind.equals(lineClasses.iterator().next())? fromClass : null;
}
return null;
}
}
return null;
......
......@@ -600,15 +600,36 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
}
}
@NotNull
public static List<Location> allLineLocations(ReferenceType cls) {
try {
return cls.allLineLocations();
}
catch (AbsentInformationException | ObjectCollectedException ignored) {
return Collections.emptyList();
}
}
public static int getLineNumber(Location location, boolean zeroBased) {
try {
return location.lineNumber() - (zeroBased ? 1 : 0);
}
catch (InternalError e) {
catch (InternalError | IllegalArgumentException e) {
return -1;
}
}
@Nullable
public static Method getMethod(Location location) {
try {
return location.method();
}
catch (IllegalArgumentException e) { // Invalid method id
LOG.info(e);
}
return null;
}
public static Value createValue(VirtualMachineProxyImpl vm, String expectedType, double value) {
if (PsiType.DOUBLE.getPresentableText().equals(expectedType)) {
return vm.mirrorOf(value);
......@@ -817,6 +838,10 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
return !StringUtil.isEmpty(name) && name.startsWith("lambda$");
}
public static boolean isLambda(@Nullable Method method) {
return method != null && isLambdaName(method.name());
}
public static final Comparator<Method> LAMBDA_ORDINAL_COMPARATOR = Comparator.comparingInt(m -> getLambdaOrdinal(m.name()));
public static int getLambdaOrdinal(@NotNull String name) {
......
......@@ -94,14 +94,15 @@ public class SourceCodeChecker {
}
private static ThreeState check(Location location, SourcePosition position, Project project) {
Method method = location.method();
Method method = DebuggerUtilsEx.getMethod(location);
// for now skip constructors, bridges, lambdas etc.
if (method.isConstructor() ||
if (method == null ||
method.isConstructor() ||
method.isSynthetic() ||
method.isBridge() ||
method.isStaticInitializer() ||
(method.declaringType() instanceof ClassType && ((ClassType)method.declaringType()).isEnum()) ||
DebuggerUtilsEx.isLambdaName(method.name())) {
DebuggerUtilsEx.isLambda(method)) {
return ThreeState.UNSURE;
}
List<Location> locations = DebuggerUtilsEx.allLineLocations(method);
......
/*
* 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.
......@@ -24,6 +24,7 @@ import com.intellij.debugger.engine.DebuggerManagerThreadImpl;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
import com.intellij.debugger.engine.jdi.StackFrameProxy;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ThreeState;
import com.sun.jdi.*;
......@@ -66,7 +67,8 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
InvalidStackFrameException error = null;
for (int attempt = 0; attempt < 2; attempt++) {
try {
boolean isObsolete = (getVirtualMachine().canRedefineClasses() && location().method().isObsolete());
Method method = DebuggerUtilsEx.getMethod(location());
boolean isObsolete = (getVirtualMachine().canRedefineClasses() && (method == null || method.isObsolete()));
myIsObsolete = ThreeState.fromBoolean(isObsolete);
return isObsolete;
}
......@@ -243,7 +245,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
@NotNull
public List<LocalVariableProxyImpl> visibleVariables() throws EvaluateException {
DebuggerManagerThreadImpl.assertIsManagerThread();
InvalidStackFrameException error = null;
RuntimeException error = null;
for (int attempt = 0; attempt < 2; attempt++) {
try {
final List<LocalVariable> list = getStackFrame().visibleVariables();
......@@ -254,7 +256,7 @@ public class StackFrameProxyImpl extends JdiProxy implements StackFrameProxy {
}
return locals;
}
catch (InvalidStackFrameException e) {
catch (InvalidStackFrameException | IllegalArgumentException e) {
error = e;
clearCaches();
}
......
......@@ -312,8 +312,10 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
catch (IllegalThreadStateException e) {
// must be zombie thread
LOG.info(e);
return false;
} catch (ObjectCollectedException ignored) {
}
return false;
}
public boolean isAtBreakpoint() {
......@@ -321,6 +323,7 @@ public final class ThreadReferenceProxyImpl extends ObjectReferenceProxyImpl imp
return getThreadReference().isAtBreakpoint();
} catch (InternalException e) {
LOG.info(e);
} catch (ObjectCollectedException ignored) {
}
return false;
}
......
/*
* 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.
......@@ -19,6 +19,7 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContext;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.impl.DebuggerUtilsEx;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.ui.impl.nodes.NodeComparator;
import com.intellij.debugger.ui.tree.DebuggerTreeNode;
......@@ -111,7 +112,10 @@ public class NodeManagerImpl extends NodeDescriptorFactoryImpl implements NodeMa
}
try {
final Location location = frame.location();
final Method method = location.method();
final Method method = DebuggerUtilsEx.getMethod(location);
if (method == null) {
return null;
}
final ReferenceType referenceType = location.declaringType();
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
......
......@@ -70,7 +70,7 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
}
LOG.info(e);
}
myMethodOccurrence = tracker.getMethodOccurrence(myUiIndex, getMethod(myLocation));
myMethodOccurrence = tracker.getMethodOccurrence(myUiIndex, DebuggerUtilsEx.getMethod(myLocation));
myIsSynthetic = DebuggerUtils.isSynthetic(myMethodOccurrence.getMethod());
mySourcePosition = ContextUtil.getSourcePosition(this);
PsiFile psiFile = mySourcePosition != null ? mySourcePosition.getFile() : null;
......@@ -85,17 +85,6 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
}
}
@Nullable
private static Method getMethod(Location location) {
try {
return location.method();
}
catch (IllegalArgumentException e) { // Invalid method id
LOG.info(e);
}
return null;
}
public int getUiIndex() {
return myUiIndex;
}
......@@ -165,7 +154,7 @@ public class StackFrameDescriptorImpl extends NodeDescriptorImpl implements Stac
if (settings.SHOW_LINE_NUMBER) {
String lineNumber;
try {
lineNumber = Integer.toString(myLocation.lineNumber());
lineNumber = Integer.toString(DebuggerUtilsEx.getLineNumber(myLocation, false));
}
catch (InternalError e) {
lineNumber = e.toString();
......
......@@ -31,6 +31,7 @@ import com.intellij.execution.util.ProgramParametersUtil;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.options.SettingsEditorGroup;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.ex.JavaSdkUtil;
......@@ -266,8 +267,10 @@ public class ApplicationConfiguration extends ModuleBasedConfiguration<JavaRunCo
final JavaRunConfigurationModule module = myConfiguration.getConfigurationModule();
final String jreHome = myConfiguration.ALTERNATIVE_JRE_PATH_ENABLED ? myConfiguration.ALTERNATIVE_JRE_PATH : null;
if (module.getModule() != null) {
final int classPathType = JavaParametersUtil.getClasspathType(module, myConfiguration.MAIN_CLASS_NAME, false);
JavaParametersUtil.configureModule(module, params, classPathType, jreHome);
DumbService.getInstance(module.getProject()).runWithAlternativeResolveEnabled(() -> {
int classPathType = JavaParametersUtil.getClasspathType(module, myConfiguration.MAIN_CLASS_NAME, false);
JavaParametersUtil.configureModule(module, params, classPathType, jreHome);
});
}
else {
JavaParametersUtil.configureProject(module.getProject(), params, JavaParameters.JDK_AND_CLASSES_AND_TESTS, jreHome);
......
......@@ -44,6 +44,7 @@ public class JUnitUtil {
@NonNls private static final String TEST_INTERFACE = "junit.framework.Test";
@NonNls private static final String TESTSUITE_CLASS = "junit.framework.TestSuite";
@NonNls public static final String TEST_ANNOTATION = "org.junit.Test";
@NonNls public static final String TEST5_PACKAGE_FQN = "org.junit.jupiter.api";
@NonNls public static final String TEST5_ANNOTATION = "org.junit.jupiter.api.Test";
@NonNls public static final String CUSTOM_TESTABLE_ANNOTATION = "org.junit.platform.commons.annotation.Testable";
@NonNls public static final String TEST5_FACTORY_ANNOTATION = "org.junit.jupiter.api.TestFactory";
......@@ -251,7 +252,8 @@ public class JUnitUtil {
}
public static boolean isJUnit5(GlobalSearchScope scope, Project project) {
return JavaPsiFacade.getInstance(project).findClass(TEST5_ANNOTATION, scope) != null;
PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(TEST5_PACKAGE_FQN);
return aPackage != null && aPackage.getDirectories(scope).length > 0;
}
public static boolean isTestAnnotated(final PsiMethod method) {
......@@ -285,6 +287,14 @@ public class JUnitUtil {
return getTestCaseClass(scope.getLibrariesScope(), scope.getProject());
}
public static void checkTestCase(SourceScope scope, Project project) throws NoJUnitException {
if (scope == null) throw new NoJUnitException();
PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage("junit.framework");
if (aPackage == null || aPackage.getDirectories(scope.getLibrariesScope()).length == 0) {
throw new NoJUnitException();
}
}
private static PsiClass getTestCaseClass(final GlobalSearchScope scope, final Project project) throws NoJUnitException {
PsiClass testCaseClass = getTestCaseClassOrNull(scope, project);
if (testCaseClass == null) throw new NoJUnitException(scope.getDisplayName());
......
......@@ -15,11 +15,9 @@
*/
package com.intellij.execution.testDiscovery;
import com.intellij.execution.JavaTestConfigurationBase;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Ref;
......@@ -227,7 +225,7 @@ public class TestDiscoveryIndex implements ProjectComponent {
if (holder == null) {
synchronized (myLock) {
holder = myHolder;
if (holder == null && myBasePath != null) holder = myHolder = new TestInfoHolder(myBasePath, myReadOnly, myLock);
if (holder == null && myBasePath != null) myHolder = holder = new TestInfoHolder(myBasePath, myReadOnly, myLock);
}
}
return holder;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment