Skip to content

Commit ccf00e8

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of ua/org.eclipse.help
1 parent 22084fa commit ccf00e8

19 files changed

+113
-85
lines changed

ua/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,33 @@ public static TocManager getTocManager() {
8383
* Used to obtain Context Manager returns an instance of ContextManager
8484
*/
8585
public static ContextManager getContextManager() {
86-
if (getDefault().contextManager == null)
86+
if (getDefault().contextManager == null) {
8787
getDefault().contextManager = new ContextManager();
88+
}
8889
return getDefault().contextManager;
8990
}
9091

9192
/**
9293
* Used to obtain the ContentExtensionManager
9394
*/
9495
public static ContentExtensionManager getContentExtensionManager() {
95-
if (getDefault().contentExtensionManager == null)
96+
if (getDefault().contentExtensionManager == null) {
9697
getDefault().contentExtensionManager = new ContentExtensionManager();
98+
}
9799
return getDefault().contentExtensionManager;
98100
}
99101

100102
public static IndexManager getIndexManager() {
101-
if (getDefault().indexManager == null)
103+
if (getDefault().indexManager == null) {
102104
getDefault().indexManager = new IndexManager();
105+
}
103106
return getDefault().indexManager;
104107
}
105108

106109
public static CriteriaManager getCriteriaManager() {
107-
if (getDefault().criteriaManager == null)
110+
if (getDefault().criteriaManager == null) {
108111
getDefault().criteriaManager = new CriteriaManager();
112+
}
109113
return getDefault().criteriaManager;
110114
}
111115

ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,13 @@ private Map<String, Context> loadContextsFromInputStream(ContextFile descriptor,
234234
IUAElement[] children = root.getChildren();
235235
Map<String, Context> contexts = new HashMap<>();
236236
for (int i=0;i<children.length;++i) {
237-
if (children[i] instanceof Context) {
238-
Context context = (Context)children[i];
237+
if (children[i] instanceof Context context) {
239238
String id = context.getId();
240239
if (id != null) {
241240
Object existingContext = contexts.get(id);
242-
if (existingContext==null)
241+
if (existingContext==null) {
243242
contexts.put(id, context);
244-
else
243+
} else
245244
{
246245
((Context)existingContext).mergeContext(context);
247246

@@ -290,8 +289,7 @@ private Map<String, String[]> getRequiredAttributes() {
290289
private class NormalizeHandler extends ProcessorHandler {
291290
@Override
292291
public short handle(UAElement element, String id) {
293-
if (element instanceof Context) {
294-
Context context = (Context)element;
292+
if (element instanceof Context context) {
295293
IUAElement[] children = context.getChildren();
296294
if (children.length > 0 && Context.ELEMENT_DESCRIPTION.equals(((UAElement)children[0]).getElementName())) {
297295
StringBuilder buf = new StringBuilder();
@@ -321,8 +319,7 @@ else if (node.getNodeType() == Node.ELEMENT_NODE) {
321319
description.appendChild(document.createTextNode(buf.toString()));
322320
}
323321
}
324-
else if (element instanceof Topic) {
325-
Topic topic = (Topic)element;
322+
else if (element instanceof Topic topic) {
326323
String href = topic.getHref();
327324
if (href != null) {
328325
int index = id.indexOf('/', 1);

ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ public class ContextManager {
4545

4646
public ContextManager()
4747
{
48-
if (HelpPlugin.DEBUG_CONTEXT)
48+
if (HelpPlugin.DEBUG_CONTEXT) {
4949
checkContextProviders();
50+
}
5051
}
5152

5253
/*
@@ -88,8 +89,9 @@ public IContext getContext(String contextId, String locale) {
8889

8990
String id = contextId;
9091
ArrayList<String> potentialMatches = new ArrayList<>();
91-
if ((index = contextId.lastIndexOf('.'))>-1)
92+
if ((index = contextId.lastIndexOf('.'))>-1) {
9293
id = contextId.substring(index+1);
94+
}
9395

9496
String warning = "Registered Context Provider IDs:\n"; //$NON-NLS-1$
9597
Iterator<String> iter = contextIDsByPluginId.keySet().iterator();
@@ -109,8 +111,9 @@ public IContext getContext(String contextId, String locale) {
109111
warning+="--------------------------------"; //$NON-NLS-1$
110112
System.out.println(warning);
111113

112-
if (!potentialMatches.isEmpty())
114+
if (!potentialMatches.isEmpty()) {
113115
System.out.println("The ID searched is "+contextId+". Did you mean to call setHelp with:\n"+potentialMatches); //$NON-NLS-1$ //$NON-NLS-2$
116+
}
114117
}
115118

116119
return null;

ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ public String getPluginId() {
4444
}
4545

4646
public InputStream getInputStream() throws IOException {
47-
if (pluginId != null)
47+
if (pluginId != null) {
4848
return ResourceLocator.openFromPlugin(pluginId, file, locale);
49-
else
49+
} else {
5050
return new FileInputStream(file);
51+
}
5152
}
5253
}

ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFileProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ public ICriteriaDefinitionContribution[] getCriteriaDefinitionContributions(Stri
5757

5858
// Use the contained exception.
5959
Exception x = spe;
60-
if (spe.getException() != null)
60+
if (spe.getException() != null) {
6161
x = spe.getException();
62+
}
6263
ILog.of(getClass()).error(buffer.toString(), x);
6364

6465
}

ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ public void addCriteriaValues(ICriteria[] criteria, String locale){
8181
List<String> criterionValues = criterion.getCriterionValues();
8282

8383
Set<String> existedValues = criteriaInLocale.get(criterionName);
84-
if (null == existedValues)
84+
if (null == existedValues) {
8585
existedValues = new HashSet<>();
86+
}
8687
existedValues.addAll(criterionValues);
8788
criteriaInLocale.put(criterionName, existedValues);
8889
}

ua/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public IIndexEntry[] getEntries() {
5050
* @return the entry with matching keyword or null
5151
*/
5252
public IndexEntry getSeeTarget(IndexSee see) {
53-
if (children == null) getChildren();
53+
if (children == null) {
54+
getChildren();
55+
}
5456
String keyword = see.getKeyword();
5557
for (Iterator<UAElement> iter = children.iterator(); iter.hasNext();) {
5658
UAElement next = iter.next();

ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ boolean isValidSeeReference(IndexSee see) {
211211
private static class NormalizeHandler extends ProcessorHandler {
212212
@Override
213213
public short handle(UAElement element, String id) {
214-
if (element instanceof Topic) {
215-
Topic topic = (Topic)element;
214+
if (element instanceof Topic topic) {
216215
String href = topic.getHref();
217216
if (href != null) {
218217
int index = id.indexOf('/', 1);
@@ -295,8 +294,7 @@ else if (Character.isLetter(c)) {
295294
* used for sorting.
296295
*/
297296
private String getLabel(IUAElement element) {
298-
if (element instanceof Topic) {
299-
Topic topic = (Topic)element;
297+
if (element instanceof Topic topic) {
300298
if (topic.getLabel() == null) {
301299
ITopic topic2 = HelpPlugin.getTocManager().getTopic(topic.getHref(), locale);
302300
if (topic2 != null) {

ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ public String getPluginId() {
4545
}
4646

4747
public InputStream getInputStream() throws IOException {
48-
if (pluginId != null)
48+
if (pluginId != null) {
4949
return ResourceLocator.openFromPlugin(pluginId, file, locale);
50-
else
50+
} else {
5151
return new FileInputStream(file);
52+
}
5253
}
5354
}

ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ public IIndexContribution[] getIndexContributions(String locale) {
5757

5858
// Use the contained exception.
5959
Exception x = spe;
60-
if (spe.getException() != null)
60+
if (spe.getException() != null) {
6161
x = spe.getException();
62+
}
6263
ILog.of(getClass()).error(buffer.toString(), x);
6364

6465
}

0 commit comments

Comments
 (0)