Skip to content

Commit bc98892

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of team/bundles/org.eclipse.team.core
1 parent 1b0231b commit bc98892

File tree

92 files changed

+1026
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1026
-497
lines changed

team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/ProjectSetCapability.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,28 +247,32 @@ protected IProject[] confirmOverwrite(
247247
existingProjects.add(eachProj);
248248
}
249249
}
250-
if (existingProjects.isEmpty())
250+
if (existingProjects.isEmpty()) {
251251
return projects;
252+
}
252253

253254
// Confirm the overwrite
254255

255256
IProject[] confirmed =
256257
context.confirmOverwrite(
257258
existingProjects.toArray(
258259
new IProject[existingProjects.size()]));
259-
if (confirmed == null)
260+
if (confirmed == null) {
260261
return null;
261-
if (existingProjects.size() == confirmed.length)
262+
}
263+
if (existingProjects.size() == confirmed.length) {
262264
return projects;
265+
}
263266

264267
// Return the amended list of projects to be loaded
265268

266269
Collection<IProject> result = new ArrayList<>(projects.length);
267270
result.addAll(Arrays.asList(projects));
268271
result.removeAll(existingProjects);
269272
for (IProject eachProj : confirmed) {
270-
if (existingProjects.contains(eachProj))
273+
if (existingProjects.contains(eachProj)) {
271274
result.add(eachProj);
275+
}
272276
}
273277
return result.toArray(new IProject[result.size()]);
274278
}

team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProvider.java

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,18 @@ public static void map(IProject project, String id) throws TeamException {
131131
mappingLock.acquire();
132132
RepositoryProvider existingProvider = null;
133133

134-
if(project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY) != null)
134+
if(project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY) != null) {
135135
existingProvider = getProvider(project); // get the real one, not the nature one
136+
}
136137

137138
//if we already have a provider, and its the same ID, we're ok
138139
//if the ID's differ, unmap the existing.
139140
if(existingProvider != null) {
140-
if(existingProvider.getID().equals(id))
141+
if(existingProvider.getID().equals(id)) {
141142
return; //nothing to do
142-
else
143+
} else {
143144
unmap(project);
145+
}
144146
}
145147

146148
// Create the provider as a session property before adding the persistent
@@ -196,9 +198,10 @@ public static void map(IProject project, String id) throws TeamException {
196198
private static RepositoryProvider mapNewProvider(final IProject project, final String id) throws TeamException {
197199
final RepositoryProvider provider = newProvider(id); // instantiate via extension point
198200

199-
if(provider == null)
201+
if(provider == null) {
200202
throw new TeamException(
201203
NLS.bind(Messages.RepositoryProvider_couldNotInstantiateProvider, project.getName(), id));
204+
}
202205

203206
// validate that either the provider supports linked resources or the project has no linked resources
204207
if (!provider.canHandleLinkedResourceURI()) {
@@ -207,17 +210,17 @@ private static RepositoryProvider mapNewProvider(final IProject project, final S
207210
if (proxy.isLinked()) {
208211
if (!provider.canHandleLinkedResources() ||
209212
proxy.requestFullPath().segmentCount() > 2 ||
210-
!EFS.SCHEME_FILE.equals(proxy.requestResource().getLocationURI().getScheme()))
213+
!EFS.SCHEME_FILE.equals(proxy.requestResource().getLocationURI().getScheme())) {
211214
throw new TeamException(new Status(IStatus.ERROR, TeamPlugin.ID,
212215
IResourceStatus.LINKING_NOT_ALLOWED,
213216
NLS.bind(Messages.RepositoryProvider_linkedURIsExist, project.getName(), id),
214217
null));
218+
}
215219
}
216220
return true;
217221
}, IResource.NONE);
218222
} catch (CoreException e) {
219-
if (e instanceof TeamException) {
220-
TeamException te = (TeamException) e;
223+
if (e instanceof TeamException te) {
221224
throw te;
222225
}
223226
throw new TeamException(e);
@@ -308,12 +311,16 @@ public static void unmap(IProject project) throws TeamException {
308311
null);
309312
}
310313

311-
if (provider != null) provider.deconfigure();
314+
if (provider != null) {
315+
provider.deconfigure();
316+
}
312317

313318
project.setSessionProperty(TeamPlugin.PROVIDER_PROP_KEY, null);
314319
project.setPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY, null);
315320

316-
if (provider != null) provider.deconfigured();
321+
if (provider != null) {
322+
provider.deconfigured();
323+
}
317324

318325
//removing the nature would've caused project description delta, so trigger one
319326
project.touch(null);
@@ -440,8 +447,9 @@ public IFileModificationValidator getFileModificationValidator() {
440447
*/
441448
public FileModificationValidator getFileModificationValidator2() {
442449
final IFileModificationValidator fileModificationValidator = getFileModificationValidator();
443-
if (fileModificationValidator == null)
450+
if (fileModificationValidator == null) {
444451
return null;
452+
}
445453
return new FileModificationValidator() {
446454
@Override
447455
public IStatus validateSave(IFile file) {
@@ -452,10 +460,11 @@ public IStatus validateEdit(IFile[] files,
452460
FileModificationValidationContext context) {
453461
// Extract the shell from the context in order to invoke the old API
454462
Object shell;
455-
if (context == null)
463+
if (context == null) {
456464
shell = null;
457-
else
465+
} else {
458466
shell = context.getShell();
467+
}
459468
return fileModificationValidator.validateEdit(files, shell);
460469
}
461470
};
@@ -538,18 +547,21 @@ final public static RepositoryProvider getProvider(IProject project) {
538547
//-----------------------------
539548
//First, look for the session property
540549
RepositoryProvider provider = lookupProviderProp(project);
541-
if(provider != null)
550+
if(provider != null) {
542551
return provider;
552+
}
543553
// Do a quick check to see it the project is known to be unshared.
544554
// This is done to avoid accessing the persistent property store
545-
if (isMarkedAsUnshared(project))
555+
if (isMarkedAsUnshared(project)) {
546556
return null;
557+
}
547558

548559
// -----------------------------
549560
//Next, check if it has the ID as a persistent property, if yes then instantiate provider
550561
String id = project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY);
551-
if(id != null)
562+
if(id != null) {
552563
return mapExistingProvider(project, id);
564+
}
553565

554566
//Couldn't find using new method, fall back to lookup using natures for backwards compatibility
555567
//-----------------------------
@@ -613,8 +625,9 @@ final public static RepositoryProvider getProvider(IProject project, String id)
613625
}
614626
// Do a quick check to see it the project is known to be unshared.
615627
// This is done to avoid accessing the persistent property store
616-
if (isMarkedAsUnshared(project))
628+
if (isMarkedAsUnshared(project)) {
617629
return null;
630+
}
618631

619632
// There isn't one so check the persistent property
620633
String existingID = project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY);
@@ -635,8 +648,9 @@ final public static RepositoryProvider getProvider(IProject project, String id)
635648
// if the nature id given is not in the team set then return
636649
// null.
637650
IProjectNatureDescriptor desc = ResourcesPlugin.getWorkspace().getNatureDescriptor(id);
638-
if(desc == null) //for backwards compatibility, may not have any nature by that ID
651+
if(desc == null) { //for backwards compatibility, may not have any nature by that ID
639652
return null;
653+
}
640654

641655
String[] setIds = desc.getNatureSetIds();
642656
for (String setId : setIds) {
@@ -671,16 +685,22 @@ final public static RepositoryProvider getProvider(IProject project, String id)
671685
* @since 2.1
672686
*/
673687
public static boolean isShared(IProject project) {
674-
if (!project.isAccessible()) return false;
688+
if (!project.isAccessible()) {
689+
return false;
690+
}
675691
try {
676-
if (lookupProviderProp(project) != null) return true;
692+
if (lookupProviderProp(project) != null) {
693+
return true;
694+
}
677695
// Do a quick check to see it the project is known to be unshared.
678696
// This is done to avoid accessing the persistent property store
679-
if (isMarkedAsUnshared(project))
697+
if (isMarkedAsUnshared(project)) {
680698
return false;
699+
}
681700
boolean shared = project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY) != null;
682-
if (!shared)
701+
if (!shared) {
683702
markAsUnshared(project);
703+
}
684704
return shared;
685705
} catch (CoreException e) {
686706
TeamPlugin.log(e);
@@ -907,8 +927,9 @@ public IResourceRuleFactory getRuleFactory() {
907927
*/
908928
public final Subscriber getSubscriber() {
909929
RepositoryProviderType type = RepositoryProviderType.getProviderType(getID());
910-
if (type != null)
930+
if (type != null) {
911931
return type.getSubscriber();
932+
}
912933
return null;
913934
}
914935
}

team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/RepositoryProviderType.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ public RepositoryProviderType() {
8787
public static RepositoryProviderType getProviderType(String id) {
8888
RepositoryProviderType type = allProviderTypes.get(id);
8989

90-
if(type != null)
90+
if(type != null) {
9191
return type;
92+
}
9293

9394
//If there isn't one in the table, we'll try to create one from the extension point
9495
//Its possible that newProviderType() will return null, but in that case it will have also logged the error so just return the result
@@ -107,8 +108,9 @@ public static RepositoryProviderType getProviderType(String id) {
107108
*/
108109
public static RepositoryProviderType getTypeForScheme(String scheme) {
109110
for (RepositoryProviderType type : allProviderTypes.values()) {
110-
if (type.getFileSystemScheme() != null && type.getFileSystemScheme().equals(scheme))
111+
if (type.getFileSystemScheme() != null && type.getFileSystemScheme().equals(scheme)) {
111112
return type;
113+
}
112114
}
113115
return findProviderForScheme(scheme);
114116
}

team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/Team.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ public static int getType(IStorage storage) {
138138
* @return whether the file should be ignored
139139
*/
140140
public static boolean isIgnoredHint(IResource resource) {
141-
if (resource.isDerived()) return true;
141+
if (resource.isDerived()) {
142+
return true;
143+
}
142144
return matchesEnabledIgnore(resource);
143145
}
144146

@@ -150,7 +152,9 @@ public static boolean isIgnoredHint(IResource resource) {
150152
*/
151153
@Deprecated
152154
public static boolean isIgnoredHint(IFile file) {
153-
if (file.isDerived()) return true;
155+
if (file.isDerived()) {
156+
return true;
157+
}
154158
return matchesEnabledIgnore(file);
155159
}
156160

@@ -400,22 +404,29 @@ private static String collectContributingExtentionsToDisplay(
400404
* Reads global ignore preferences and populates globalIgnore
401405
*/
402406
private static void readIgnoreState() throws TeamException {
403-
if (readBackwardCompatibleIgnoreState()) return;
407+
if (readBackwardCompatibleIgnoreState()) {
408+
return;
409+
}
404410
Preferences pref = TeamPlugin.getPlugin().getPluginPreferences();
405-
if (!pref.contains(PREF_TEAM_IGNORES)) return;
411+
if (!pref.contains(PREF_TEAM_IGNORES)) {
412+
return;
413+
}
406414
pref.addPropertyChangeListener(event -> {
407415
// when a property is changed, invalidate our cache so that
408416
// properties will be recalculated.
409-
if(event.getProperty().equals(PREF_TEAM_IGNORES))
417+
if(event.getProperty().equals(PREF_TEAM_IGNORES)) {
410418
globalIgnore = null;
419+
}
411420
});
412421
String prefIgnores = pref.getString(PREF_TEAM_IGNORES);
413422
StringTokenizer tok = new StringTokenizer(prefIgnores, PREF_TEAM_SEPARATOR);
414423
String pattern, enabled;
415424
try {
416425
while (true) {
417426
pattern = tok.nextToken();
418-
if (pattern.length()==0) return;
427+
if (pattern.length()==0) {
428+
return;
429+
}
419430
enabled = tok.nextToken();
420431
globalIgnore.put(pattern, Boolean.valueOf(enabled));
421432
}
@@ -431,7 +442,9 @@ private static boolean readBackwardCompatibleIgnoreState() throws TeamException
431442
String GLOBALIGNORE_FILE = ".globalIgnores"; //$NON-NLS-1$
432443
IPath pluginStateLocation = TeamPlugin.getPlugin().getStateLocation().append(GLOBALIGNORE_FILE);
433444
File f = pluginStateLocation.toFile();
434-
if (!f.exists()) return false;
445+
if (!f.exists()) {
446+
return false;
447+
}
435448
try {
436449
try (DataInputStream dis = new DataInputStream(new FileInputStream(f))) {
437450
int ignoreCount = 0;

team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/Diff.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ public int hashCode() {
8989

9090
@Override
9191
public boolean equals(Object obj) {
92-
if (obj == this)
92+
if (obj == this) {
9393
return true;
94-
if (obj instanceof Diff) {
95-
Diff other = (Diff) obj;
94+
}
95+
if (obj instanceof Diff other) {
9696
return other.getPath().equals(getPath()) && getStatus() == other.getStatus();
9797
}
9898
return false;

team/bundles/org.eclipse.team.core/src/org/eclipse/team/core/diff/provider/DiffTree.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ public void removeDiffChangeListener(IDiffChangeListener listener) {
9090
public void accept(IPath path, IDiffVisitor visitor, int depth) {
9191
IDiff delta = getDiff(path);
9292
if (delta == null || visitor.visit(delta)) {
93-
if (depth == IResource.DEPTH_ZERO)
93+
if (depth == IResource.DEPTH_ZERO) {
9494
return;
95+
}
9596
IPath[] children = getChildren(path);
9697
for (IPath child : children) {
9798
accept(child, visitor, depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : IResource.DEPTH_INFINITE);
@@ -241,7 +242,9 @@ private void fireChanges(final IProgressMonitor monitor) {
241242
final Map<Integer, Set<IPath>> propertyChanges = this.propertyChanges;
242243
this.propertyChanges = new HashMap<>();
243244

244-
if(event.isEmpty() && ! event.isReset() && propertyChanges.isEmpty()) return;
245+
if(event.isEmpty() && ! event.isReset() && propertyChanges.isEmpty()) {
246+
return;
247+
}
245248
Object[] listeners = this.listeners.getListeners();
246249
for (Object l : listeners) {
247250
final IDiffChangeListener listener = (IDiffChangeListener) l;
@@ -254,8 +257,9 @@ public void handleException(Throwable exception) {
254257
public void run() throws Exception {
255258
try {
256259
lockedForModification = true;
257-
if (!event.isEmpty() || event.isReset())
260+
if (!event.isEmpty() || event.isReset()) {
258261
listener.diffsChanged(event, Policy.subMonitorFor(monitor, 100));
262+
}
259263
for (Integer key : propertyChanges.keySet()) {
260264
Set<IPath> paths = propertyChanges.get(key);
261265
listener.propertyChanged(DiffTree.this, key.intValue(), paths.toArray(new IPath[paths
@@ -294,8 +298,7 @@ private void internalAdd(IDiff delta) {
294298
statistics.add(delta);
295299
}
296300
boolean isConflict = false;
297-
if (delta instanceof IThreeWayDiff) {
298-
IThreeWayDiff twd = (IThreeWayDiff) delta;
301+
if (delta instanceof IThreeWayDiff twd) {
299302
isConflict = twd.getDirection() == IThreeWayDiff.CONFLICTING;
300303
}
301304
setPropertyToRoot(delta, P_HAS_DESCENDANT_CONFLICTS, isConflict);
@@ -342,8 +345,9 @@ public IDiff[] getDiffs() {
342345

343346
@Override
344347
public long countFor(int state, int mask) {
345-
if (state == 0)
348+
if (state == 0) {
346349
return size();
350+
}
347351
return statistics.countFor(state, mask);
348352
}
349353

@@ -414,8 +418,9 @@ public boolean hasMatchingDiffs(IPath path, final FastDiffFilter filter) {
414418
return false;
415419
}, IResource.DEPTH_INFINITE);
416420
} catch (RuntimeException e) {
417-
if (e == found)
421+
if (e == found) {
418422
return true;
423+
}
419424
throw e;
420425
}
421426
return false;

0 commit comments

Comments
 (0)