Skip to content

Commit

Permalink
Eclipse 4.16 (M3) JDT Patch for Groovy-Eclipse: JDT commit 8767458
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed May 22, 2020
1 parent c99d20b commit fba9d61
Show file tree
Hide file tree
Showing 114 changed files with 12,238 additions and 10,687 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</license>

<requires>
<import feature="org.eclipse.jdt" version="3.18.400.v20200501-0520" patch="true"/>
<import feature="org.eclipse.jdt" version="3.18.400.v20200521-1000" patch="true"/>
</requires>

<plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
package org.eclipse.jdt.core.tests.builder;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
Expand Down Expand Up @@ -168,21 +166,21 @@ private void checkOpenDescriptors(IFile file) throws Exception {

private static List<String> getOpenDescriptors() throws Exception {
int pid = getPid();
if (pid > 0) {
// -F n : to print only name column (note: all lines start with "n")
// -a : to "and" all following options
// -b :to avoid blocking calls
// -p <pid>: to select process with opened files
List<String> lines = readLsofLines("lsof -F n -a -p " + pid + " / -b ", true);
return lines;
}
return Collections.emptyList();
assertTrue("JVM PID must be > 0 : " + pid, pid > 0);
// -F n : to print only name column (note: all lines start with "n")
// -a : to "and" all following options
// -b :to avoid blocking calls
// -p <pid>: to select process with opened files
List<String> lines = readLsofLines("lsof -F n -a -p " + pid + " / -b ", true);
return lines;
}

private static int getPid() throws Exception {
try (BufferedReader rdr = new BufferedReader(new FileReader("/proc/self/stat"));) {
return Integer.parseInt(new StringTokenizer(rdr.readLine()).nextToken());
}
String jvmName = ManagementFactory.getRuntimeMXBean().getName();
int indexOfAt = jvmName.indexOf('@');
String pidSubstring = jvmName.substring(0, indexOfAt);
int pid = Integer.valueOf(pidSubstring);
return pid;
}

private static List<String> readLsofLines(String cmd, boolean skipFirst) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import junit.framework.Test;

import java.util.Map;

import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.builder.ReferenceCollection;
Expand All @@ -35,8 +37,8 @@ public static Test suite() {
public void testIncludes() {
try {
State state = (State) JavaModelManager.getJavaModelManager().getLastBuiltState(null, null);
SimpleLookupTable references = state.getReferences();
ReferenceCollection r = (ReferenceCollection) references.valueTable[0];
Map<String, ReferenceCollection> references = state.getReferences();
ReferenceCollection r = references.values().iterator().next();
char[][][] qualifiedNames = null;
char[][] simpleNames = null;
char[][] rootNames = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo;
import org.eclipse.jdt.internal.core.builder.JavaBuilder;
Expand Down Expand Up @@ -98,20 +99,17 @@ private void writeReadAndCompareReferences(IPath projectPath)
JavaBuilder.writeState(savedState, new DataOutputStream(outputStream));
byte[] bytes = outputStream.toByteArray();
State readState = JavaBuilder.readState(project, new DataInputStream(new ByteArrayInputStream(bytes)));
SimpleLookupTable readReferences = readState.getReferences();
Map<String, ReferenceCollection> readReferences = readState.getReferences();
assertEqualLookupTables(savedState.getReferences(), readReferences);
}

private void assertEqualLookupTables(SimpleLookupTable expectation, SimpleLookupTable actual) {
assertEquals(expectation.elementSize, actual.elementSize);
Object[] expectedKeys = expectation.keyTable;
for(int i = 0; i < expectedKeys.length; i++) {
Object key = expectedKeys[i];
if (key != null) {
ReferenceCollection actualReferenceCollection = (ReferenceCollection) actual.get(key);
ReferenceCollection expectedReferenceCollection = (ReferenceCollection) expectation.valueTable[i];
assertEqualReferenceCollections(expectedReferenceCollection, actualReferenceCollection);
}
private void assertEqualLookupTables(Map<String, ReferenceCollection> expectation, Map<String, ReferenceCollection> actual) {
assertEquals(expectation.size(), actual.size());
Set<String> expectedKeys = expectation.keySet();
for (String key : expectedKeys) {
ReferenceCollection actualReferenceCollection = actual.get(key);
ReferenceCollection expectedReferenceCollection = expectation.get(key);
assertEqualReferenceCollections(expectedReferenceCollection, actualReferenceCollection);
}
}

Expand Down
Loading

0 comments on commit fba9d61

Please sign in to comment.