Skip to content

Commit e44c41f

Browse files
committed
refactor: rename contentTester ist editorTest
1 parent e92996d commit e44c41f

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

org.eclipse.cdt.lsp/schema/serverProvider.exsd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<complexType>
2222
<sequence>
2323
<element ref="server"/>
24-
<element ref="contentTester" minOccurs="0" maxOccurs="1"/>
24+
<element ref="editorTest" minOccurs="0" maxOccurs="1"/>
2525
</sequence>
2626
<attribute name="point" type="string" use="required">
2727
<annotation>
@@ -68,10 +68,10 @@
6868
</complexType>
6969
</element>
7070

71-
<element name="contentTester">
71+
<element name="editorTest">
7272
<annotation>
7373
<documentation>
74-
Test if the content should be opened by the C/C++ LSP based editor
74+
Test whether the editor input should be opened by the C/C++ LSP based editor
7575
</documentation>
7676
</annotation>
7777
<complexType>

org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/CLanguageServerRegistry.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class CLanguageServerRegistry {
3131
private static final String EXTENSION_ID = LspPlugin.PLUGIN_ID + ".serverProvider"; //$NON-NLS-1$
3232
private static final String SERVER_ELEMENT = "server"; //$NON-NLS-1$
33-
private static final String ELEMENT_CONTENT_TESTER = "contentTester"; //$NON-NLS-1$
33+
private static final String ELEMENT_EDITOR_TEST = "editorTest"; //$NON-NLS-1$
3434
private static final String CLASS = "class"; //$NON-NLS-1$
3535
private static final String ENABLED_WHEN_ATTRIBUTE = "enabledWhen"; //$NON-NLS-1$
3636
private final IExtensionPoint cExtensionPoint;
@@ -40,7 +40,7 @@ public CLanguageServerRegistry() {
4040
}
4141

4242
public ICEditorTest createCEditorTest() throws InvalidRegistryObjectException {
43-
ICEditorTest propertyTester = (ICEditorTest) getInstanceFromExtension(ELEMENT_CONTENT_TESTER,ICEditorTest.class);
43+
ICEditorTest propertyTester = (ICEditorTest) getInstanceFromExtension(ELEMENT_EDITOR_TEST, ICEditorTest.class);
4444
if (propertyTester == null) {
4545
LspPlugin.logWarning("No C/C++ editor input tester defined");
4646
return new DefaultCEditorTest();
@@ -55,10 +55,10 @@ public ICLanguageServerCommandProvider createCLanguageServerCommandProvider() {
5555
if (provider == null) {
5656
LspPlugin.logWarning("No C/C++ language server defined");
5757
}
58-
58+
5959
return provider;
6060
}
61-
61+
6262
public EnableExpression getEnablementExpression() {
6363
EnableExpression enableExpression = null;
6464
for (IConfigurationElement configurationElement : cExtensionPoint.getConfigurationElements()) {
@@ -70,7 +70,8 @@ public EnableExpression getEnablementExpression() {
7070
IConfigurationElement[] enabledWhenChildren = enabledWhen.getChildren();
7171
if (enabledWhenChildren.length == 1) {
7272
try {
73-
enableExpression = new EnableExpression(this::getEvaluationContext, ExpressionConverter.getDefault().perform(enabledWhenChildren[0]));
73+
enableExpression = new EnableExpression(this::getEvaluationContext,
74+
ExpressionConverter.getDefault().perform(enabledWhenChildren[0]));
7475
} catch (CoreException e) {
7576
LspPlugin.logWarning(e.getMessage(), e);
7677
}
@@ -81,7 +82,7 @@ public EnableExpression getEnablementExpression() {
8182
}
8283
return enableExpression;
8384
}
84-
85+
8586
private IEvaluationContext getEvaluationContext() {
8687
return Optional.ofNullable(PlatformUI.getWorkbench().getService(IHandlerService.class)).map(IHandlerService::getCurrentState).orElse(null);
8788
}

org.eclipse.cdt.lsp/src/org/eclipse/cdt/lsp/server/EnableExpression.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
* available under the terms of the Eclipse Public License 2.0
55
* which is available at https://www.eclipse.org/legal/epl-2.0/
66
* SPDX-License-Identifier: EPL-2.0
7-
*
87
* Contributors:
9-
*
108
* Gesa Hentschke (Bachmann electronic GmbH) - initial implementation
119
*******************************************************************************/
1210

@@ -22,16 +20,16 @@
2220
import org.eclipse.core.runtime.CoreException;
2321

2422
public final class EnableExpression {
25-
private final Expression expression;
26-
private final Supplier<IEvaluationContext> parent;
23+
private final Expression cExpression;
24+
private final Supplier<IEvaluationContext> cParent;
2725

2826
public EnableExpression(Supplier<IEvaluationContext> parent, Expression expression) {
29-
this.expression = expression;
30-
this.parent = parent;
27+
this.cExpression = expression;
28+
this.cParent = parent;
3129
}
3230

3331
/**
34-
* Evaluates enable expression with the given context. The context defualtVariable can be set by the input document.
32+
* Evaluates enable expression with the given context and document.
3533
*
3634
* @return true if expression evaluates to true, false otherwise
3735
*/
@@ -40,9 +38,9 @@ public boolean evaluate(Object document) {
4038
if (document == null) {
4139
document = new Object();
4240
}
43-
final var context = new EvaluationContext(parent.get(), document);
41+
final var context = new EvaluationContext(cParent.get(), document);
4442
context.setAllowPluginActivation(true);
45-
return expression.evaluate(context).equals(EvaluationResult.TRUE);
43+
return cExpression.evaluate(context).equals(EvaluationResult.TRUE);
4644
} catch (CoreException e) {
4745
LspPlugin.logError("Error occured during evaluation of enablement expression", e); //$NON-NLS-1$
4846
}

0 commit comments

Comments
 (0)