Skip to content

Commit 0c9cefe

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.search.core
1 parent 4e8711a commit 0c9cefe

File tree

6 files changed

+40
-27
lines changed

6 files changed

+40
-27
lines changed

bundles/org.eclipse.search.core/search/org/eclipse/search/internal/core/SearchCorePlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public DirtyFileProvider getDirtyFileDiscovery() {
7878

7979
/**
8080
* Log status to platform log
81-
*
81+
*
8282
* @param status
8383
* the status to log
8484
*/

bundles/org.eclipse.search.core/search/org/eclipse/search/internal/core/text/DirtyFileProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public interface DirtyFileProvider {
2323
/**
2424
* Discover a list of dirty IFile resources and the current content of those
2525
* resources in the dirty editor
26-
*
26+
*
2727
* @return A map of dirty resources to contents
2828
*/
2929
Map<IFile, IDocument> dirtyFiles();

bundles/org.eclipse.search.core/search/org/eclipse/search/internal/core/text/FileCharSequenceProvider.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ private FileCharSequence getCharSequence(IFile file) throws CoreException, IOExc
5959
}
6060

6161
public void releaseCharSequence(CharSequence seq) throws IOException {
62-
if (seq instanceof FileCharSequence) {
63-
FileCharSequence curr= (FileCharSequence) seq;
62+
if (seq instanceof FileCharSequence curr) {
6463
try {
6564
curr.close();
6665
} finally {
@@ -307,12 +306,13 @@ private InputStream getInputStream(String charset) throws CoreException, IOExcep
307306
}
308307
ok= true;
309308
} finally {
310-
if (!ok && contents != null)
309+
if (!ok && contents != null) {
311310
try {
312311
contents.close();
313312
} catch (IOException ex) {
314313
// ignore
315314
}
315+
}
316316
}
317317
return contents;
318318
}
@@ -515,8 +515,9 @@ private static boolean startsWith(byte[] a, byte[] start) {
515515
return false;
516516
}
517517
for (int i = 0; i < start.length; i++) {
518-
if (a[i] != start[i])
518+
if (a[i] != start[i]) {
519519
return false;
520+
}
520521
}
521522
return true;
522523
}

bundles/org.eclipse.search.core/search/org/eclipse/search/internal/core/text/FileNamePatternSearchScope.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static FileNamePatternSearchScope newSearchScope(String description, IRes
5050
private final Set<String> fFileNamePatterns;
5151
private Matcher fFileNameMatcher;
5252

53-
private boolean fVisitDerived;
53+
private final boolean fVisitDerived;
5454

5555
private FileNamePatternSearchScope(String description, IResource[] resources, boolean visitDerived) {
5656
Assert.isNotNull(description);

bundles/org.eclipse.search.core/search/org/eclipse/search/internal/core/text/PatternConstructor.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static Pattern createPattern(String pattern, boolean isRegex, boolean isS
6363
if (isWholeWord && len > 0 && isWordChar(pattern.charAt(len - 1))) {
6464
buffer.append("\\b"); //$NON-NLS-1$
6565
}
66-
pattern= buffer.toString();
66+
pattern= buffer.toString();
6767
}
6868

6969
int regexOptions= Pattern.MULTILINE;
@@ -92,34 +92,39 @@ private static String substituteLinebreak(String findString) throws PatternSynta
9292
switch (ch) {
9393
case '[':
9494
buf.append(ch);
95-
if (! inQuote)
95+
if (! inQuote) {
9696
inCharGroup++;
97+
}
9798
break;
9899

99100
case ']':
100101
buf.append(ch);
101-
if (! inQuote)
102+
if (! inQuote) {
102103
inCharGroup--;
104+
}
103105
break;
104106

105107
case '{':
106108
buf.append(ch);
107-
if (! inQuote && inCharGroup == 0)
109+
if (! inQuote && inCharGroup == 0) {
108110
inBraces++;
111+
}
109112
break;
110113

111114
case '}':
112115
buf.append(ch);
113-
if (! inQuote && inCharGroup == 0)
116+
if (! inQuote && inCharGroup == 0) {
114117
inBraces--;
118+
}
115119
break;
116120

117121
case '\\':
118122
if (i + 1 < length) {
119123
char ch1= findString.charAt(i + 1);
120124
if (inQuote) {
121-
if (ch1 == 'E')
125+
if (ch1 == 'E') {
122126
inQuote= false;
127+
}
123128
buf.append(ch).append(ch1);
124129
i++;
125130

@@ -427,8 +432,9 @@ private int interpretReplaceEscape(final char ch, int i, StringBuilder buf, Stri
427432
int parsedInt;
428433
try {
429434
parsedInt= Integer.parseInt(replaceText.substring(i + 1, i + 3), 16);
430-
if (parsedInt < 0)
435+
if (parsedInt < 0) {
431436
throw new NumberFormatException();
437+
}
432438
} catch (NumberFormatException e) {
433439
String msg= SearchCoreMessages.PatternConstructor_error_hex_escape_sequence;
434440
throw new PatternSyntaxException(msg, replaceText, i);
@@ -446,8 +452,9 @@ private int interpretReplaceEscape(final char ch, int i, StringBuilder buf, Stri
446452
int parsedInt;
447453
try {
448454
parsedInt= Integer.parseInt(replaceText.substring(i + 1, i + 5), 16);
449-
if (parsedInt < 0)
455+
if (parsedInt < 0) {
450456
throw new NumberFormatException();
457+
}
451458
} catch (NumberFormatException e) {
452459
String msg= SearchCoreMessages.PatternConstructor_error_unicode_escape_sequence;
453460
throw new PatternSyntaxException(msg, replaceText, i);
@@ -461,14 +468,15 @@ private int interpretReplaceEscape(final char ch, int i, StringBuilder buf, Stri
461468
break;
462469

463470
case 'C':
464-
if(foundText.toUpperCase().equals(foundText)) // is whole match upper-case?
471+
if(foundText.toUpperCase().equals(foundText)) { // is whole match upper-case?
465472
fRetainCaseMode= RC_UPPER;
466-
else if (foundText.toLowerCase().equals(foundText)) // is whole match lower-case?
473+
} else if (foundText.toLowerCase().equals(foundText)) { // is whole match lower-case?
467474
fRetainCaseMode= RC_LOWER;
468-
else if(Character.isUpperCase(foundText.charAt(0))) // is first character upper-case?
475+
} else if(Character.isUpperCase(foundText.charAt(0))) { // is first character upper-case?
469476
fRetainCaseMode= RC_FIRSTUPPER;
470-
else
477+
} else {
471478
fRetainCaseMode= RC_MIXED;
479+
}
472480
break;
473481

474482
default:
@@ -488,15 +496,16 @@ else if(Character.isUpperCase(foundText.charAt(0))) // is first character upper-
488496
* @since 3.4
489497
*/
490498
private void interpretRetainCase(StringBuilder buf, char ch) {
491-
if (fRetainCaseMode == RC_UPPER)
499+
if (fRetainCaseMode == RC_UPPER) {
492500
buf.append(String.valueOf(ch).toUpperCase());
493-
else if (fRetainCaseMode == RC_LOWER)
501+
} else if (fRetainCaseMode == RC_LOWER) {
494502
buf.append(String.valueOf(ch).toLowerCase());
495-
else if (fRetainCaseMode == RC_FIRSTUPPER) {
503+
} else if (fRetainCaseMode == RC_FIRSTUPPER) {
496504
buf.append(String.valueOf(ch).toUpperCase());
497505
fRetainCaseMode= RC_MIXED;
498-
} else
506+
} else {
499507
buf.append(ch);
508+
}
500509
}
501510

502511
}

bundles/org.eclipse.search.core/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ protected IStatus run(IProgressMonitor inner) {
171171
while (((sameFiles = fileBatches.poll()) != null) && !fFatalError && !fProgressMonitor.isCanceled()) {
172172
IStatus status = processFile(sameFiles, subMonitor.split(1));
173173
// Only accumulate interesting status
174-
if (!status.isOK())
174+
if (!status.isOK()) {
175175
multiStatus.add(status);
176176
// Group cancellation is propagated to this job's monitor.
177177
// Stop processing and return the status for the completed jobs.
178+
}
178179
}
179180
fileCharSequenceProvider= null;
180181
synchronized (fLock) {
@@ -299,7 +300,7 @@ public Map<IFile, IDocument> getDocumentsInEditors() {
299300
private volatile boolean fFatalError; // If true, terminates the search.
300301

301302
private volatile boolean fIsLightweightAutoRefresh;
302-
private DirtyFileProvider fDirtyDiscovery;
303+
private final DirtyFileProvider fDirtyDiscovery;
303304

304305
public TextSearchVisitor(TextSearchRequestor collector, Pattern searchPattern, DirtyFileProvider dirtyDiscovery) {
305306
fCollector= collector;
@@ -429,8 +430,9 @@ public IStatus search(IFile[] files, IProgressMonitor monitor) {
429430
private Map<IFile, IDocument> findDirtyFiles() {
430431
if (fDirtyDiscovery != null) {
431432
Map<IFile, IDocument> ret = fDirtyDiscovery.dirtyFiles();
432-
if (ret != null)
433+
if (ret != null) {
433434
return ret;
435+
}
434436
}
435437
return Collections.emptyMap();
436438
}
@@ -476,8 +478,9 @@ private boolean hasBinaryContent(CharSequence seq) {
476478
} catch (IndexOutOfBoundsException e) {
477479
// ignored
478480
} catch (FileCharSequenceException ex) {
479-
if (ex.getCause() instanceof CharConversionException)
481+
if (ex.getCause() instanceof CharConversionException) {
480482
return true;
483+
}
481484
throw ex;
482485
}
483486
return false;

0 commit comments

Comments
 (0)