Unverified Commit 8feac4cb authored by Geertjan Wielenga's avatar Geertjan Wielenga Committed by GitHub
Browse files

Merge pull request #2925 from apache/delivery

Sync delivery to release for 12.4 rc2
parents b8c421ef 4cf84542
......@@ -77,7 +77,7 @@ public final class CPPLiteActionsProvider extends ActionsProviderSupport {
public void doAction (Object action) {
LOGGER.log(Level.FINE, "CPPLiteDebugger.doAction({0}), is kill = {1}", new Object[]{action, action == ActionsManager.ACTION_KILL});
if (action == ActionsManager.ACTION_KILL) {
debugger.finish();
debugger.finish(true);
} else
if (action == ActionsManager.ACTION_CONTINUE) {
debugger.resume();
......
......@@ -118,6 +118,8 @@ public final class CPPLiteDebugger {
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
// Debug I/O has finished.
finish(false);
}).start();
proxy.waitStarted();
......@@ -356,14 +358,16 @@ public final class CPPLiteDebugger {
proxy.send(new Command("-exec-continue --all"));
}
void finish () {
void finish (boolean sendExit) {
LOGGER.fine("CPPLiteDebugger.finish()");
if (finished) {
LOGGER.fine("finish(): already finished.");
return ;
}
breakpointsHandler.dispose();
proxy.send(new Command("-gdb-exit"));
if (sendExit) {
proxy.send(new Command("-gdb-exit"));
}
Utils.unmarkCurrent ();
engineProvider.getDestructor().killEngine();
finished = true;
......@@ -405,7 +409,7 @@ public final class CPPLiteDebugger {
} catch (InterruptedException ex) {
return null;
}
return versionRecord.results().toString();
return versionRecord.command().getConsoleStream();
}
ContextProvider getContextProvider() {
......@@ -423,6 +427,7 @@ public final class CPPLiteDebugger {
private final CountDownLatch runningLatch = new CountDownLatch(1);
private final CountDownLatch runningCommandLatch = new CountDownLatch(0);
private final Semaphore runningCommandSemaphore = new Semaphore(1);
private final Object sendLock = new Object();
LiteMIProxy(MICommandInjector injector, String prompt, String encoding) {
super(injector, prompt, encoding);
......@@ -460,7 +465,7 @@ public final class CPPLiteDebugger {
switch (reason) {
case "exited-normally":
if ('*' == record.type()) {
finish();
finish(false);
} else {
threadsCollector.remove(threadId);
}
......@@ -551,7 +556,9 @@ public final class CPPLiteDebugger {
Exceptions.printStackTrace(ex);
}
LOGGER.log(Level.FINE, "MIProxy.send({0})", cmd);
super.send(cmd);
synchronized (sendLock) {
super.send(cmd);
}
}
}
......@@ -564,7 +571,9 @@ public final class CPPLiteDebugger {
Exceptions.printStackTrace(ex);
}
LOGGER.log(Level.FINE, "MIProxy.send({0})", cmd);
super.send(cmd);
synchronized (sendLock) {
super.send(cmd);
}
}
@Override
......
......@@ -21,6 +21,7 @@ package org.netbeans.modules.cpplite.debugger.ni;
import java.io.File;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Semaphore;
import java.util.function.Consumer;
import org.netbeans.api.debugger.Breakpoint;
......@@ -91,37 +92,47 @@ public class NIDebuggerProviderImpl implements NIDebuggerProvider {
.controllable(true);
}
CompletableFuture<Void> completed = new CompletableFuture<>();
Semaphore started = new Semaphore(0);
ExecutionService.newService(() -> {
LifecycleManager.getDefault().saveAll();
Pair<DebuggerEngine, Process> engineProcess = CPPLiteDebugger.startDebugging(
new CPPLiteDebuggerConfig(command, workingDirectory, miDebugger),
frameDisplayer,
variablesDisplayer);
DebuggerEngine engine = engineProcess.first();
CPPLiteDebugger debugger = engine.lookupFirst(null, CPPLiteDebugger.class);
this.debugger = debugger;
if (startedEngine != null) {
startedEngine.accept(engine);
}
debugger.addStateListener(new CPPLiteDebugger.StateListener() {
@Override
public void currentThread(CPPThread thread) {}
Pair<DebuggerEngine, Process> engineProcess;
CPPLiteDebugger debugger;
try {
LifecycleManager.getDefault().saveAll();
engineProcess = CPPLiteDebugger.startDebugging(
new CPPLiteDebuggerConfig(command, workingDirectory, miDebugger),
frameDisplayer,
variablesDisplayer);
DebuggerEngine engine = engineProcess.first();
debugger = engine.lookupFirst(null, CPPLiteDebugger.class);
this.debugger = debugger;
if (startedEngine != null) {
startedEngine.accept(engine);
}
debugger.addStateListener(new CPPLiteDebugger.StateListener() {
@Override
public void currentThread(CPPThread thread) {}
@Override
public void currentFrame(CPPFrame frame) {}
@Override
public void currentFrame(CPPFrame frame) {}
@Override
public void suspended(boolean suspended) {}
@Override
public void suspended(boolean suspended) {}
@Override
public void finished() {
breakpointsHandler.dispose();
completed.complete(null);
}
});
@Override
public void finished() {
breakpointsHandler.dispose();
completed.complete(null);
}
});
} finally {
started.release();
}
debugger.execRun();
return engineProcess.second();
}, executionDescriptor, displayName).run();
// Wait for the debugger to actually start up.
// This is necessary to be able to safely call other methods on the NIDebuggerProvider.
started.acquireUninterruptibly();
return completed;
}
......
......@@ -244,15 +244,20 @@ public final class GradleModuleFileCache21 {
}
public static String[] gavSplit(String gav) {
int firstColon = gav.indexOf(':');
int lastColon = gav.lastIndexOf(':');
if (firstColon == -1 || firstColon == lastColon) {
// the general GAV format is - <group>:<artifact>:<version/snapshot>[:<classifier>][@extension]
int firstColon = gav.indexOf(':'); // NOI18N
int versionColon = gav.indexOf(':', firstColon + 1); // NOI18N
int versionEnd = gav.indexOf(':', versionColon + 1); // NO18N
int end = versionEnd == -1 ? gav.length() : versionEnd;
if (firstColon == -1 || firstColon == versionColon) {
throw new IllegalArgumentException("Invalid GAV format: " + gav); //NOI18N
}
return new String[] {
return new String[]{
gav.substring(0, firstColon),
gav.substring(firstColon + 1, lastColon),
gav.substring(lastColon + 1)
gav.substring(firstColon + 1, versionColon),
gav.substring(versionColon + 1, end)
};
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.netbeans.modules.gradle;
import org.netbeans.junit.NbTestCase;
/**
*
* @author sdedic
*/
public class GradleModuleFileCache21Test extends NbTestCase {
public GradleModuleFileCache21Test(String name) {
super(name);
}
/**
* Checks GAV split with regular fixed versions.
*/
public void testGavSplitFixedVersion() throws Exception {
String[] parts = GradleModuleFileCache21.gavSplit("io.micronaut:micronaut-core:2.3.4"); // NOI18N
assertEquals(parts[0], "io.micronaut"); // NOI18N
assertEquals(parts[1], "micronaut-core"); // NOI18N
assertEquals(parts[2], "2.3.4"); // NOI18N
}
/**
* Checks GAV split with -SNAPSHOT and a maven-like timestamp/sequence as the
* snapshot unique id.
*/
public void testGavSplitFixedSnapshotWithMavenTimestamp() throws Exception {
String[] parts = GradleModuleFileCache21.gavSplit("io.micronaut:micronaut-core:2.3.4-SNAPSHOT:20210302.164619-21"); // NOI18N
assertEquals(parts[0], "io.micronaut"); // NOI18N
assertEquals(parts[1], "micronaut-core"); // NOI18N
assertEquals(parts[2], "2.3.4-SNAPSHOT"); // NOI18N
}
public void testGavSplitFixedSnapshotWithoutUnqiueId() throws Exception {
String[] parts = GradleModuleFileCache21.gavSplit("io.micronaut:micronaut-core:2.3.4-SNAPSHOT"); // NOI18N
assertEquals(parts[0], "io.micronaut"); // NOI18N
assertEquals(parts[1], "micronaut-core"); // NOI18N
assertEquals(parts[2], "2.3.4-SNAPSHOT"); // NOI18N
}
}
......@@ -17,4 +17,6 @@
9B6A3169E240EE48800EA215DDF033EBFB221097 com.vladsch.flexmark:flexmark:0.50.36
4C77069222E80816F73B6277F09F742382E14E30 com.vladsch.flexmark:flexmark-html2md-converter:0.50.36
FF0452A9FF56D164C9FA1B880562ED1FC8F93F57 com.vladsch.flexmark:flexmark-util:0.50.36
983105CC5A42FF82979C742FB6BE525AB1FED8E9 com.vladsch.flexmark:flexmark-ext-emoji:0.50.36
A01A46E369E0C4A271A519481C422206D54A60D1 com.vladsch.flexmark:flexmark-formatter:0.50.36
36DA09A8F68484523FA2AAA100399D612B247D67 org.jsoup:jsoup:1.11.3
......@@ -3,7 +3,7 @@ Version: 0.50.36
License: BSD-flexmark
Description: FlexMark library
Origin: https://github.com/vsch/flexmark-java
Files: flexmark-0.50.36.jar flexmark-html2md-converter-0.50.36.jar flexmark-util-0.50.36.jar
Files: flexmark-0.50.36.jar flexmark-ext-emoji-0.50.36.jar flexmark-formatter-0.50.36.jar flexmark-html2md-converter-0.50.36.jar flexmark-util-0.50.36.jar
Copyright (c) 2015-2016, Atlassian Pty Ltd
All rights reserved.
......
......@@ -20,4 +20,6 @@ javac.compilerargs=-Xlint -Xlint:-serial
release.external/flexmark-0.50.36.jar=modules/ext/flexmark-0.50.36.jar
release.external/flexmark-html2md-converter-0.50.36.jar=modules/ext/flexmark-html2md-converter-0.50.36.jar
release.external/flexmark-util-0.50.36.jar=modules/ext/flexmark-util-0.50.36.jar
release.external/flexmark-ext-emoji-0.50.36.jar=modules/ext/flexmark-ext-emoji-0.50.36.jar
release.external/flexmark-formatter-0.50.36.jar=modules/ext/flexmark-formatter-0.50.36.jar
release.external/jsoup-1.11.3.jar=modules/ext/jsoup-1.11.3.jar
......@@ -41,6 +41,14 @@
<runtime-relative-path>ext/flexmark-util-0.50.36.jar</runtime-relative-path>
<binary-origin>external/flexmark-util-0.50.36.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/flexmark-formatter-0.50.36.jar</runtime-relative-path>
<binary-origin>external/flexmark-formatter-0.50.36.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/flexmark-ext-emoji-0.50.36.jar</runtime-relative-path>
<binary-origin>external/flexmark-ext-emoji-0.50.36.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/flexmark-0.50.36.jar</runtime-relative-path>
<binary-origin>external/flexmark-0.50.36.jar</binary-origin>
......
......@@ -366,7 +366,7 @@ public class LSPBindings {
project2MimeType2Server.values()
.stream()
.flatMap(n -> n.values().stream())
.map(description -> description.bindings.get())
.map(description -> description.bindings != null ? description.bindings.get() : null)
.filter(binding -> binding != null)
.forEach(allBindings::add);
workspace2Extension2Server.values()
......
......@@ -551,8 +551,8 @@ public class SimpleTargetChooserPanelGUI extends javax.swing.JPanel implements A
public @Override Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value instanceof SourceGroup) {
SourceGroup group = (SourceGroup)value;
String projectDisplayName = ProjectUtils.getInformation( project ).getDisplayName();
String groupDisplayName = group.getDisplayName();
String projectDisplayName = project != null ? ProjectUtils.getInformation( project ).getDisplayName() : groupDisplayName;
if ( projectDisplayName.equals( groupDisplayName ) ) {
setText( groupDisplayName );
}
......
......@@ -71,6 +71,8 @@ import org.netbeans.modules.debugger.jpda.expr.JDIVariable;
import org.netbeans.modules.debugger.jpda.jdi.ClassTypeWrapper;
import org.netbeans.modules.debugger.jpda.jdi.IllegalThreadStateExceptionWrapper;
import org.netbeans.modules.debugger.jpda.jdi.InternalExceptionWrapper;
import org.netbeans.modules.debugger.jpda.jdi.LocatableWrapper;
import org.netbeans.modules.debugger.jpda.jdi.LocationWrapper;
import org.netbeans.modules.debugger.jpda.jdi.ObjectCollectedExceptionWrapper;
import org.netbeans.modules.debugger.jpda.jdi.ThreadReferenceWrapper;
import org.netbeans.modules.debugger.jpda.jdi.VMDisconnectedExceptionWrapper;
......@@ -273,17 +275,16 @@ public class TruffleAccess implements JPDABreakpointListener {
Method suspendHereMethod = ClassTypeWrapper.concreteMethodByName(debugAccessorClass, METHOD_SUSPEND_HERE, METHOD_SUSPEND_HERE_SGN);
JPDADebuggerImpl debugger = threadImpl.getDebugger();
Value haltInfo;
Lock writeLock = threadImpl.accessLock.writeLock();
threadImpl.notifyMethodInvoking();
Runnable cleanup = null;
try {
writeLock.lock();
cleanup = skipSuspendedEventClearLeakingReferences(debugger, thread);
haltInfo = ClassTypeWrapper.invokeMethod(debugAccessorClass, tr, suspendHereMethod, Collections.emptyList(), ObjectReference.INVOKE_SINGLE_THREADED);
} finally {
try {
cleanup.run();
} finally {
writeLock.unlock();
threadImpl.notifyMethodInvokeDone();
}
}
if (haltInfo instanceof ObjectReference) {
......@@ -297,23 +298,28 @@ public class TruffleAccess implements JPDABreakpointListener {
return null;
}
private static final String CLEAR_REFERENCES_CLASS = "com.oracle.truffle.api.debug.SuspendedEvent";
private static final String CLEAR_REFERENCES_METHOD = "clearLeakingReferences";
private static Runnable skipSuspendedEventClearLeakingReferences(JPDADebugger debugger, JPDAThread thread) {
ThreadReference tr = ((JPDAThreadImpl) thread).getThreadReference();
MethodBreakpoint clearLeakingReferencesBreakpoint = MethodBreakpoint.create("com.oracle.truffle.api.debug.SuspendedEvent", "clearLeakingReferences");
MethodBreakpoint clearLeakingReferencesBreakpoint = MethodBreakpoint.create(CLEAR_REFERENCES_CLASS, CLEAR_REFERENCES_METHOD);
clearLeakingReferencesBreakpoint.setBreakpointType(MethodBreakpoint.TYPE_METHOD_ENTRY);
clearLeakingReferencesBreakpoint.setThreadFilters(debugger, new JPDAThread[] { thread });
clearLeakingReferencesBreakpoint.setHidden(true);
Function<EventSet, Boolean> breakpointEventInterceptor = eventSet -> {
ThreadReference etr = null;
try {
ThreadReference etr = null;
Method method = null;
for (Event e: eventSet) {
if (e instanceof ClassPrepareEvent) {
etr = ClassPrepareEventWrapper.thread((ClassPrepareEvent) e);
} else if (e instanceof LocatableEvent) {
etr = LocatableEventWrapper.thread((LocatableEvent) e);
method = LocationWrapper.method(LocatableWrapper.location((LocatableEvent) e));
}
}
if (tr.equals(etr)) {
if (tr.equals(etr) && method != null && CLEAR_REFERENCES_METHOD.equals(method.name()) && CLEAR_REFERENCES_CLASS.equals(method.declaringType().name())) {
boolean resume = true;
for (Event e: eventSet) {
EventRequest r = EventWrapper.request(e);
......
......@@ -19,6 +19,7 @@
package org.netbeans.modules.debugger.jpda.truffle.source;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
......@@ -48,12 +49,20 @@ final class SourceFilesCache {
}
public URL getSourceFile(String name, long hash, URI uri, String content) throws IOException {
String path = Long.toHexString(hash) + '/' + name;
String justName = name;
int i = justName.lastIndexOf(File.separatorChar);
if (i >= 0) {
justName = justName.substring(i + 1);
if (justName.isEmpty()) {
justName = name.replace(File.separatorChar, '_');
}
}
String path = Long.toHexString(hash) + '/' + justName;
FileObject fo = fs.findResource(path);
if (fo == null) {
fo = fs.createFile(path, content);
if (fo == null) {
throw new IllegalArgumentException("Not able to create file with name '"+name+"'. Path = "+path);
throw new IllegalArgumentException("Not able to create file with name '"+justName+"'. Path = "+path);
}
fo.setAttribute(Source.ATTR_URI, uri);
}
......
......@@ -134,11 +134,13 @@ public class GradleJavaTokenProvider implements ReplaceTokenProvider {
GradleJavaSourceSet sourceSet = gjp.containingSourceSet(f);
if (sourceSet != null) {
String relPath = sourceSet.relativePath(f);
ret = (relPath.lastIndexOf('.') > 0 ?
relPath.substring(0, relPath.lastIndexOf('.')) :
relPath).replace('/', '.');
if (fo.isFolder()) {
ret = ret + '*';
if (relPath != null) {
ret = (relPath.lastIndexOf('.') > 0 ?
relPath.substring(0, relPath.lastIndexOf('.')) :
relPath).replace('/', '.');
if (fo.isFolder()) {
ret = ret + '*';
}
}
}
}
......
......@@ -113,15 +113,17 @@ public class FileBuiltQueryImpl extends ProjectOpenedHook implements FileBuiltQu
GradleJavaSourceSet sourceSet = gjp.containingSourceSet(f);
if (sourceSet != null) {
String relFile = sourceSet.relativePath(f);
String relClass = relFile.substring(0, relFile.lastIndexOf('.')) + ".class"; //NOI18N
String moduleRoot = null;
File moduleInfo = sourceSet.findResource("module-info.java", false, JAVA); //NOI18N
if (moduleInfo != null && sourceSet.getCompilerArgs(JAVA).contains("--module-source-path")) {
moduleRoot = SourceUtils.parseModuleName(FileUtil.toFileObject(moduleInfo));
if (relFile != null) {
String relClass = relFile.substring(0, relFile.lastIndexOf('.')) + ".class"; //NOI18N
String moduleRoot = null;
File moduleInfo = sourceSet.findResource("module-info.java", false, JAVA); //NOI18N
if (moduleInfo != null && sourceSet.getCompilerArgs(JAVA).contains("--module-source-path")) {
moduleRoot = SourceUtils.parseModuleName(FileUtil.toFileObject(moduleInfo));
}
try {
ret = new StatusImpl(file, sourceSet.getOutputClassDirs(), relClass, moduleRoot);
} catch (DataObjectNotFoundException ex) {}
}
try {
ret = new StatusImpl(file, sourceSet.getOutputClassDirs(), relClass, moduleRoot);
} catch (DataObjectNotFoundException ex) {}
}
}
......
......@@ -126,6 +126,7 @@ public final class JavaCompletionTask<T> extends BaseTask {
public static enum Options {
ALL_COMPLETION,
COMBINED_COMPLETION,
SKIP_ACCESSIBILITY_CHECK
}
......@@ -743,16 +744,15 @@ public final class JavaCompletionTask<T> extends BaseTask {
if (last != null && last.token().id() == JavaTokenId.IMPORT && Utilities.startsWith(STATIC_KEYWORD, prefix)) {
addKeyword(env, STATIC_KEYWORD, SPACE, false);
}
addPackages(env, null, false);
}
if (options.contains(Options.ALL_COMPLETION)) {
EnumSet<ElementKind> classKinds = EnumSet.of(CLASS, INTERFACE, ENUM, ANNOTATION_TYPE);
if (isRecordSupported(env)) {
classKinds.add(TreeShims.getRecordKind());
if (options.contains(Options.ALL_COMPLETION) || options.contains(Options.COMBINED_COMPLETION)) {
EnumSet<ElementKind> classKinds = EnumSet.of(CLASS, INTERFACE, ENUM, ANNOTATION_TYPE);
if (isRecordSupported(env)) {
classKinds.add(TreeShims.getRecordKind());
}
addTypes(env, classKinds, null);
} else {
addPackages(env, null, false);
}
addTypes(env, classKinds, null);
} else {
hasAdditionalClasses = true;
}
}
......@@ -4122,7 +4122,7 @@ public final class JavaCompletionTask<T> extends BaseTask {
}
private void addTypes(Env env, EnumSet<ElementKind> kinds, DeclaredType baseType) throws IOException {
if (options.contains(Options.ALL_COMPLETION)) {
if (options.contains(Options.ALL_COMPLETION) || options.contains(Options.COMBINED_COMPLETION)) {
if (baseType == null) {
addAllTypes(env, kinds);
} else {
......
......@@ -3146,9 +3146,6 @@ public abstract class JavaCompletionItem implements CompletionItem {
private AttributeValueItem(CompilationInfo info, String value, String documentation, TypeElement element, int substitutionOffset, ReferencesCount referencesCount, WhiteListQuery.WhiteList whiteList) {
super(substitutionOffset, element != null ? ElementHandle.create(element) : null, whiteList);
if (value.charAt(0) == '\"' && value.charAt(value.length() - 1) != '\"') { //NOI18N
value = value + '\"'; //NOI18N
}
this.value = value;
this.documentation = documentation;
if (element != null) {
......@@ -3233,7 +3230,7 @@ public abstract class JavaCompletionItem implements CompletionItem {
} else {
StringBuilder sb = new StringBuilder();
sb.append(ATTRIBUTE_VALUE_COLOR);
sb.append(value);
sb.append(escape(getLastLine()));
sb.append(COLOR_END);
leftText = sb.toString();
}
......@@ -3265,6 +3262,12 @@ public abstract class JavaCompletionItem implements CompletionItem {
return super.substituteText(c, offset, length, sb, toAdd);
}
private String getLastLine() {
String[] lines = value.split("\n");
String last = lines.length > 0 ? lines[lines.length - 1] : value;
return last.trim();
}
@Override
public String toString() {
return value;
......@@ -4428,7 +4431,7 @@ public abstract class JavaCompletionItem implements CompletionItem {
private static String escape(String s) {
if (s != null) {
try {
return XMLUtil.toAttributeValue(s);
return XMLUtil.toElementContent(s);
} catch (Exception ex) {}
}
return s;
......
......@@ -160,6 +160,10 @@ public class ElementDescription {
}
}
public ClasspathInfo getOriginalCPInfo() {
return originalCPInfo;
}
public ElementHandle<Element> getHandle() {
return handle;
}
......