Skip to content

Commit 6551632

Browse files
eclipse-platform-botHeikoKlare
authored andcommitted
Perform clean code of ua/org.eclipse.ua.tests
1 parent 6d87f26 commit 6551632

File tree

11 files changed

+51
-43
lines changed

11 files changed

+51
-43
lines changed

ua/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/util/CheatSheetModelSerializer.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,19 @@ public static String serialize(AbstractSubItem subItem, String indent) {
147147
buf.append(indent + "<nullSubItem/>\n");
148148
}
149149
else {
150-
if (subItem instanceof ConditionalSubItem) {
151-
ConditionalSubItem c = (ConditionalSubItem)subItem;
150+
if (subItem instanceof ConditionalSubItem c) {
152151
buf.append(indent + "<conditionalSubItem\n");
153152
buf.append(indent + " condition=\"" + c.getCondition() + "\">\n");
154153
buf.append(serialize(c.getSubItems(), indent + " "));
155154
buf.append(indent + "</conditionalSubItem>\n");
156155
}
157-
else if (subItem instanceof RepeatedSubItem) {
158-
RepeatedSubItem r = (RepeatedSubItem)subItem;
156+
else if (subItem instanceof RepeatedSubItem r) {
159157
buf.append(indent + "<repeatedSubItem\n");
160158
buf.append(indent + " values=\"" + r.getValues() + "\">\n");
161159
buf.append(serialize(r.getSubItems(), indent + " "));
162160
buf.append(indent + "</repeatedSubItem>\n");
163161
}
164-
else if (subItem instanceof SubItem) {
165-
SubItem s = (SubItem)subItem;
162+
else if (subItem instanceof SubItem s) {
166163
buf.append(indent + "<subItem\n");
167164
buf.append(indent + " label=\"" + s.getLabel() + "\"\n");
168165
buf.append(indent + " when=\"" + s.getWhen() + "\"\n");

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/other/ResourceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ private void checkFields(Class<?> messages) throws IllegalAccessException {
5353
int modifiers = field.getModifiers();
5454
if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers)) {
5555
Object value = field.get(null);
56-
if (value instanceof String) {
57-
String stringValue = (String)value;
56+
if (value instanceof String stringValue) {
5857
if (stringValue.startsWith("NLS missing message")) {
5958
fail("Missing resource for " + field.getName());
6059
}

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/IndexServletTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ private Element[] findEntryInAllContributions(Node parent, String keyword) {
125125
List<Node> results = new ArrayList<>();
126126
for (int i = 0; i < contributions.getLength(); i++) {
127127
Node next = contributions.item(i);
128-
if (next instanceof Element) {
129-
Element nextElement = (Element)next;
128+
if (next instanceof Element nextElement) {
130129
if ("indexContribution".equals(nextElement.getTagName())) {
131130
findEntryInIndexContribution(nextElement, keyword, results);
132131
}
@@ -140,8 +139,7 @@ private void findEntryInIndexContribution(Element parent, String keyword,
140139
NodeList indexes = parent.getChildNodes();
141140
for (int i = 0; i < indexes.getLength(); i++) {
142141
Node next = indexes.item(i);
143-
if (next instanceof Element) {
144-
Element nextElement = (Element) next;
142+
if (next instanceof Element nextElement) {
145143
if ("index".equals(nextElement.getTagName())) {
146144
findMatchingChildEntry(nextElement, keyword, results);
147145
}
@@ -154,8 +152,7 @@ private void findMatchingChildEntry(Element parent, String keyword,
154152
NodeList topLevelEntries = parent.getChildNodes();
155153
for (int i = 0; i < topLevelEntries.getLength(); i++) {
156154
Node next = topLevelEntries.item(i);
157-
if (next instanceof Element) {
158-
Element nextElement = (Element) next;
155+
if (next instanceof Element nextElement) {
159156
if ("entry".equals(nextElement.getTagName())
160157
&& keyword.equals(nextElement
161158
.getAttribute("keyword"))) {

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocManagerTest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ public void testLocalProviderPriority() throws Exception {
7373
HelpPlugin.getTocManager().clearCache();
7474
AbstractTocProvider [] tocProviders = HelpPlugin.getTocManager().getTocProviders();
7575
for (AbstractTocProvider tocProvider : tocProviders) {
76-
if(tocProvider instanceof TocFileProvider)
76+
if(tocProvider instanceof TocFileProvider) {
7777
localPriority = tocProvider.getPriority();
78+
}
7879

79-
if(tocProvider instanceof RemoteTocProvider)
80+
if(tocProvider instanceof RemoteTocProvider) {
8081
remotePriority = tocProvider.getPriority();
82+
}
8183
}
8284

8385
assertTrue(localPriority<remotePriority);
@@ -93,11 +95,13 @@ public void testRemoteProviderPriority() throws Exception {
9395

9496
AbstractTocProvider [] tocProviders = HelpPlugin.getTocManager().getTocProviders();
9597
for (AbstractTocProvider tocProvider : tocProviders) {
96-
if(tocProvider instanceof TocFileProvider)
98+
if(tocProvider instanceof TocFileProvider) {
9799
localPriority = tocProvider.getPriority();
100+
}
98101

99-
if(tocProvider instanceof RemoteTocProvider)
102+
if(tocProvider instanceof RemoteTocProvider) {
100103
remotePriority = tocProvider.getPriority();
104+
}
101105
}
102106

103107
assertTrue(remotePriority<localPriority);
@@ -108,10 +112,11 @@ public static boolean hasDuplicateContributions(TocContribution[] tocContributio
108112
HashSet<String> contributionsFound = new HashSet<>();
109113

110114
for (TocContribution tocContribution : tocContributions) {
111-
if(contributionsFound.contains(tocContribution.getId()))
115+
if(contributionsFound.contains(tocContribution.getId())) {
112116
return true;
113-
else
117+
} else {
114118
contributionsFound.add(tocContribution.getId());
119+
}
115120
}
116121

117122
return false;

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/remote/TocServletTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ private Element[] findChildren(Node parent, String childKind, String attributeNa
110110
List<Node> results = new ArrayList<>();
111111
for (int i = 0; i < contributions.getLength(); i++) {
112112
Node next = contributions.item(i);
113-
if (next instanceof Element) {
114-
Element nextElement = (Element)next;
113+
if (next instanceof Element nextElement) {
115114
if ( childKind.equals(nextElement.getTagName()) && attributeValue.equals(nextElement.getAttribute(attributeName))) {
116115

117116
results.add(next);

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/search/WrappedSearchProcessor.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,40 @@ private static boolean isNotSearchProcessorTest(String query) {
3232

3333
@Override
3434
public SearchProcessorInfo preSearch(String query) {
35-
if (isNotSearchProcessorTest(query))
35+
if (isNotSearchProcessorTest(query)) {
3636
return null;
37+
}
3738
synchronized (WrappedSearchProcessor.class) {
38-
if (isNotSearchProcessorTest(query))
39+
if (isNotSearchProcessorTest(query)) {
3940
return null;
41+
}
4042
return wrapped.preSearch(query);
4143
}
4244
}
4345

4446
@Override
4547
public ISearchResult[] postSearch(String query, ISearchResult[] results) {
46-
if (wrapped == null)
48+
if (wrapped == null) {
4749
return null;
50+
}
4851
synchronized (WrappedSearchProcessor.class) {
49-
if (wrapped == null)
52+
if (wrapped == null) {
5053
return null;
54+
}
5155
return wrapped.postSearch(query, results);
5256
}
5357
}
5458

5559
@Override
5660
public ISearchResult[] postSearch(String query, String originalQuery, ISearchResult[] results, String locale,
5761
IHelpResource[] scopes) {
58-
if (isNotSearchProcessorTest(originalQuery))
62+
if (isNotSearchProcessorTest(originalQuery)) {
5963
return null;
64+
}
6065
synchronized (WrappedSearchProcessor.class) {
61-
if (isNotSearchProcessorTest(originalQuery))
66+
if (isNotSearchProcessorTest(originalQuery)) {
6267
return null;
68+
}
6369
return wrapped.postSearch(query, originalQuery, results, locale, scopes);
6470
}
6571
}

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/ExtensionServiceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ private Element[] findChildren(Node parent, String childKind,
127127
List<Node> results = new ArrayList<>();
128128
for (int i = 0; i < contributions.getLength(); i++) {
129129
Node next = contributions.item(i);
130-
if (next instanceof Element) {
131-
Element nextElement = (Element)next;
130+
if (next instanceof Element nextElement) {
132131
if ( childKind.equals(nextElement.getTagName()) && attributeValue.equals(nextElement.getAttribute(attributeName))) {
133132

134133
results.add(next);

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/SchemaValidator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ public static String testXMLSchema(String uri, String schemaFile) {
3131
try {
3232
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); //$NON-NLS-1$
3333
Schema schema = null;
34-
if (schemaFile.startsWith("http") || schemaFile.startsWith("ftp"))
34+
if (schemaFile.startsWith("http") || schemaFile.startsWith("ftp")) {
3535
schema = factory.newSchema(new URL(schemaFile));
36-
else
36+
} else {
3737
schema = factory.newSchema(new File(schemaFile));
38+
}
3839

3940
Validator validator = schema.newValidator();
4041
Source source = new StreamSource(uri);

ua/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/service/TocFragmentServiceTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ private Element[] findChildren(Node parent, String childKind,
154154
List<Node> results = new ArrayList<>();
155155
for (int i = 0; i < nodes.getLength(); i++) {
156156
Node next = nodes.item(i);
157-
if (next instanceof Element) {
158-
Element nextElement = (Element)next;
157+
if (next instanceof Element nextElement) {
159158
if ( childKind.equals(nextElement.getTagName())
160159
&& attributeValue.equals(nextElement.getAttribute(attributeName))) {
161160

@@ -175,8 +174,7 @@ private Element[] findHref(Node parent, String childKind,
175174
List<Node> results = new ArrayList<>();
176175
for (int i = 0; i < nodes.getLength(); i++) {
177176
Node next = nodes.item(i);
178-
if (next instanceof Element) {
179-
Element nextElement = (Element)next;
177+
if (next instanceof Element nextElement) {
180178
if ( childKind.equals(nextElement.getTagName()) ) {
181179
String href = nextElement.getAttribute("href");
182180
if (href != null) {

ua/org.eclipse.ua.tests/intro/org/eclipse/ua/tests/intro/anchors/ExtensionReorderingTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ protected IConfigurationElement[] getConfigurationsFromAttribute(
162162
String currentAttributeValue = configElement
163163
.getAttribute(attributeName);
164164
if (currentAttributeValue != null
165-
&& currentAttributeValue.equals(attributeValue))
165+
&& currentAttributeValue.equals(attributeValue)) {
166166
elements.add(configElement);
167+
}
167168
}
168169

169170
// now return array.

0 commit comments

Comments
 (0)