Skip to content

Commit 16abbbf

Browse files
authored
Merge pull request #2146 from apache/master
Sync master to release 12.0 beta 5
2 parents 6a0e13f + ac4e72f commit 16abbbf

30 files changed

Lines changed: 791 additions & 93 deletions

File tree

enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/ClasspathUtil.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import java.io.IOException;
2525
import java.net.URL;
2626
import java.util.ArrayList;
27+
import java.util.Arrays;
2728
import java.util.Collection;
29+
import java.util.Comparator;
2830
import java.util.Enumeration;
2931
import java.util.LinkedHashMap;
3032
import java.util.List;
@@ -292,18 +294,33 @@ public static File[] getJ2eePlatformClasspathEntries(@NullAllowed Project projec
292294
J2eePlatform j2eePlatformLocal = j2eePlatform != null ? j2eePlatform : Deployment.getDefault().getJ2eePlatform(j2eeModuleProvider.getServerInstanceID());
293295
if (j2eePlatformLocal != null) {
294296
try {
295-
return j2eePlatformLocal.getClasspathEntries(j2eeModuleProvider.getConfigSupport().getLibraries());
297+
File[] files = j2eePlatformLocal.getClasspathEntries(j2eeModuleProvider.getConfigSupport().getLibraries());
298+
sortClassPathEntries(files);
299+
return files;
296300
} catch (ConfigurationException ex) {
297301
LOGGER.log(Level.FINE, null, ex);
298-
return j2eePlatformLocal.getClasspathEntries();
302+
File[] files = j2eePlatformLocal.getClasspathEntries();
303+
sortClassPathEntries(files);
304+
return files;
299305
}
300306
}
301307
}
302308
}
303309
if (j2eePlatform != null) {
304-
return j2eePlatform.getClasspathEntries();
310+
File[] files = j2eePlatform.getClasspathEntries();
311+
sortClassPathEntries(files);
312+
return files;
305313
}
306314
return new File[]{};
307315
}
316+
317+
private static void sortClassPathEntries(File[] files) {
318+
Arrays.sort(files, new Comparator < File > () {
319+
@Override
320+
public int compare(File f1, File f2) {
321+
return f1.getAbsolutePath().compareTo(f2.getAbsolutePath());
322+
}
323+
});
324+
}
308325

309326
}

ergonomics/ide.ergonomics/src/org/netbeans/modules/ide/ergonomics/fod/ConfigurationPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void setInfo(FeatureInfo info, String displayName, Collection<UpdateEleme
117117

118118
if (extraModule.isRequiredFor(jdk)) {
119119
jCheckBox.setSelected(true);
120-
jCheckBox.setEnabled(false);
120+
// jCheckBox.setEnabled(false);
121121
extrasFilter.add(extraModule);
122122
}
123123
jCheckBox.addActionListener(e -> {

ergonomics/ide.ergonomics/src/org/netbeans/modules/ide/ergonomics/fod/FindComponentModules.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public Map<FeatureInfo.ExtraModuleInfo, FeatureInfo> getExtrasToDownload() {
299299
private void registerExtraDownloadable(FeatureInfo fi, FeatureInfo.ExtraModuleInfo fmi) {
300300
boolean required = false;
301301
if (fmi.isRequiredFor(jdk)) {
302-
required = true;
302+
// required = true;
303303
}
304304
if (fi.getExtraModulesRequiredText() != null && fi.getExtraModulesRecommendedText() == null) {
305305
required = true;

ergonomics/ide.ergonomics/src/org/netbeans/modules/ide/ergonomics/fod/FoDUpdateUnitProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Map<String, UpdateItem> getUpdateItems () throws IOException {
103103
boolean required = false;
104104

105105
if (mi.isRequiredFor(jdk)) {
106-
required = true;
106+
// required = true;
107107
}
108108
if (fi.getExtraModulesRequiredText() != null && fi.getExtraModulesRecommendedText() == null) {
109109
required = true;

ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldViewFactory.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -260,24 +260,25 @@ public void finishCreation() {
260260

261261
@Override
262262
public void foldHierarchyChanged(FoldHierarchyEvent evt) {
263-
if (!collapsedFoldEncountered) {
264-
// Check if any collapsed fold was added or a collapsed/expanded state changed
265-
for (int i = evt.getAddedFoldCount() - 1; i >= 0; i--) {
266-
if (evt.getAddedFold(i).isCollapsed()) {
267-
collapsedFoldEncountered = true;
268-
break;
269-
}
263+
boolean collapsedAdded = false;
264+
boolean changedToCollapsed = false;
265+
// Check if any collapsed fold was added or a collapsed/expanded state changed
266+
for (int i = evt.getAddedFoldCount() - 1; i >= 0; i--) {
267+
if (evt.getAddedFold(i).isCollapsed()) {
268+
collapsedAdded = true;
269+
break;
270270
}
271-
if (!collapsedFoldEncountered) {
272-
for (int i = evt.getFoldStateChangeCount() - 1; i >= 0; i--) {
273-
FoldStateChange foldStateChange = evt.getFoldStateChange(i);
274-
if (foldStateChange.isCollapsedChanged() && foldStateChange.getFold().isCollapsed()) {
275-
collapsedFoldEncountered = true;
276-
break;
277-
}
271+
}
272+
if (!collapsedAdded) {
273+
for (int i = evt.getFoldStateChangeCount() - 1; i >= 0; i--) {
274+
FoldStateChange foldStateChange = evt.getFoldStateChange(i);
275+
if (foldStateChange.isCollapsedChanged() && foldStateChange.getFold().isCollapsed()) {
276+
changedToCollapsed = true;
277+
break;
278278
}
279279
}
280280
}
281+
collapsedFoldEncountered |= collapsedAdded || changedToCollapsed;
281282
JTextComponent comp = textComponent();
282283
if (collapsedFoldEncountered && comp != null) {
283284
// [TODO] there could be more detailed inspection done among folds
@@ -289,7 +290,11 @@ public void foldHierarchyChanged(FoldHierarchyEvent evt) {
289290
ViewUtils.log(CHANGE_LOG, "CHANGE in FoldViewFactory: <" + // NOI18N
290291
startOffset + "," + endOffset + ">\n"); // NOI18N
291292
}
292-
comp.putClientProperty("editorcaret.updateRetainsVisibleOnce", Boolean.TRUE);
293+
if (collapsedAdded) {
294+
// this hint covers a specific case when a fold is created as *initially* collapsed
295+
// to maintain caret position on screen, if the caret was visible.
296+
comp.putClientProperty("editorcaret.updateRetainsVisibleOnce", Boolean.TRUE);
297+
}
293298
fireEvent(EditorViewFactoryChange.createList(startOffset, endOffset,
294299
EditorViewFactoryChange.Type.PARAGRAPH_CHANGE));
295300
}

ide/editor.lib2/src/org/netbeans/api/editor/caret/EditorCaret.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,9 @@ private void update(boolean calledFromPaint) {
19991999
if (cbounds != null) {
20002000
// save relative position of the main caret
20012001
maybeSaveCaretOffset(cbounds);
2002+
if (log) {
2003+
LOG.fine("EditorCaret.update: forced:true, savedBounds=" + cbounds + ", relativeOffset=" + lastCaretVisualOffset + "\n"); // NOI18N
2004+
}
20022005
}
20032006
}
20042007
if (!calledFromPaint && !c.isValid() /* && maintainVisible == null */) {
@@ -2025,6 +2028,11 @@ private void update(boolean calledFromPaint) {
20252028
scroll = scrollToLastCaret;
20262029
scrollToLastCaret = false;
20272030
}
2031+
if (lastCaretVisualOffset == -1) {
2032+
// wasn't able to save the visual offset, the caret was already off screen. Do not scroll just because of fold updates.
2033+
forceUpdate = false;
2034+
c.putClientProperty("editorcaret.updateRetainsVisibleOnce", null); // NOI18N
2035+
}
20282036
if (scroll || forceUpdate) {
20292037
Rectangle caretBounds;
20302038
Rectangle oldCaretBounds;
@@ -2035,6 +2043,10 @@ private void update(boolean calledFromPaint) {
20352043
caretBounds = lastCaretItem.getCaretBounds();
20362044
oldCaretBounds = caretBounds;
20372045
}
2046+
if (log) {
2047+
LOG.fine("EditorCaret.update: caretBounds=" + caretBounds + "\n"); // NOI18N
2048+
LOG.fine("EditorCaret.update: oldCaretBounds=" + oldCaretBounds + "\n"); // NOI18N
2049+
}
20382050
if (caretBounds != null) {
20392051
Rectangle scrollBounds = new Rectangle(caretBounds); // Must possibly be cloned upon change
20402052
if (viewport != null && isWrapping()) {

ide/libs.git/src/org/netbeans/libs/git/jgit/commands/IgnoreUnignoreCommand.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ protected final void save (File gitIgnore, List<IgnoreRule> ignoreRules) throws
137137
for (ListIterator<IgnoreRule> it = ignoreRules.listIterator(); it.hasNext(); ) {
138138
String s = it.next().getPattern(false);
139139
bw.write(s, 0, s.length());
140-
if (it.hasNext()) {
141-
bw.newLine();
142-
}
140+
bw.newLine();
143141
}
144142
} finally {
145143
if (bw != null) {

ide/libs.git/test/unit/src/org/netbeans/libs/git/jgit/AbstractGitTestCase.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,15 @@ protected Repository getRepositoryForWC(File wc) throws IOException {
9898
}
9999

100100
protected void write(File file, String str) throws IOException {
101-
FileWriter w = null;
102-
try {
103-
w = new FileWriter(file);
101+
try (FileWriter w = new FileWriter(file)) {
104102
w.write(str);
105103
w.flush();
106-
} finally {
107-
if (w != null) {
108-
w.close();
109-
}
110104
}
111105
}
112106

113107
protected String read(File file) throws IOException {
114108
StringBuilder sb = new StringBuilder();
115-
BufferedReader r = null;
116-
try {
117-
r = new BufferedReader(new FileReader(file));
109+
try (BufferedReader r = new BufferedReader(new FileReader(file))) {
118110
String s = r.readLine();
119111
if (s != null) {
120112
while( true ) {
@@ -124,14 +116,22 @@ protected String read(File file) throws IOException {
124116
sb.append('\n');
125117
}
126118
}
127-
} finally {
128-
if (r != null) {
129-
r.close();
130-
}
131119
}
132120
return sb.toString();
133121
}
134122

123+
protected boolean containsCRorLF(File file) throws IOException {
124+
try (BufferedReader r = new BufferedReader(new FileReader(file))) {
125+
int i;
126+
while ((i = r.read()) > -1) {
127+
if (i == '\n' || i == '\r') {
128+
return true;
129+
}
130+
}
131+
}
132+
return false;
133+
}
134+
135135
protected static void assertStatus (Map<File, GitStatus> statuses, File workDir, File file, boolean tracked, Status headVsIndex, Status indexVsWorking, Status headVsWorking, boolean conflict) {
136136
GitStatus status = statuses.get(file);
137137
assertNotNull(file.getAbsolutePath() + " not in " + statuses.keySet(), status);

ide/libs.git/test/unit/src/org/netbeans/libs/git/jgit/commands/IgnoreTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,4 +589,13 @@ public void test242551_DoubleStarPattern () throws Exception {
589589
statuses = client.getStatus(new File[0], NULL_PROGRESS_MONITOR);
590590
assertEquals(Status.STATUS_IGNORED, statuses.get(f).getStatusIndexWC());
591591
}
592+
593+
public void testGitIgnoreEndsWithNewLine () throws Exception {
594+
File f = new File(workDir, "file");
595+
f.createNewFile();
596+
File gitIgnore = new File(workDir, Constants.DOT_GIT_IGNORE);
597+
File[] ignores = getClient(workDir).ignore(new File[] { f }, NULL_PROGRESS_MONITOR);
598+
assertTrue(gitIgnore.exists());
599+
assertTrue("The .gitignore file should ends with an empty new line.",containsCRorLF(gitIgnore));
600+
}
592601
}

ide/o.eclipse.jgit/external/binaries-list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
75C27F087134757A8AC335E637C117D68D41C773 org.eclipse.jgit:org.eclipse.jgit:5.5.0.201909110433-r
17+
E0BA7A468E8C62DA8521CA3A06A061D4DDE95223 org.eclipse.jgit:org.eclipse.jgit:5.5.1.201910021850-r

0 commit comments

Comments
 (0)