Skip to content

Commit

Permalink
Improved type completion.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylussaud committed Feb 23, 2024
1 parent b711a15 commit 6322c35
Show file tree
Hide file tree
Showing 20 changed files with 539 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,18 @@ private void classifierTypeRuleContextError(Object offendingSymbol, String msg,
setPositions(errorExpression, (Token)offendingSymbol, (Token)offendingSymbol);
} else {
errorRule = QueryParser.RULE_classifierTypeRule;
final ErrorEClassifierTypeLiteral errorEClassifierTypeLiteral;
if (ctx.getChildCount() > 0) {
errorEClassifierTypeLiteral = builder.errorEClassifierTypeLiteral(false, ctx.getChild(0)
.getText());
final Error error;
if (ctx.getParent() instanceof ClassifierSetTypeContext) {
if (ctx.getChildCount() > 0) {
error = builder.errorEClassifierTypeLiteral(false, ctx.getChild(0).getText());
} else {
error = builder.errorEClassifierTypeLiteral(false, null);
}
} else {
errorEClassifierTypeLiteral = builder.errorEClassifierTypeLiteral(false, null);
error = builder.errorTypeLiteral();
}
setPositions(errorEClassifierTypeLiteral, ctx.start, (Token)offendingSymbol);
pushError(errorEClassifierTypeLiteral, "missing classifier literal");
setPositions(error, ctx.start, (Token)offendingSymbol);
pushError(error, "missing classifier literal");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@ public List<ICompletionProposal> getExpressionTextPrefixes() {
result.add(new TextCompletionProposal("false", 0));
result.add(new TextCompletionProposal("null", 0));
result.add(new TextCompletionProposal("{}", 1));
result.add(new TextCompletionProposal(AstSerializer.STRING_TYPE, 0));
result.add(new TextCompletionProposal(AstSerializer.INTEGER_TYPE, 0));
result.add(new TextCompletionProposal(AstSerializer.REAL_TYPE, 0));
result.add(new TextCompletionProposal(AstSerializer.BOOLEAN_TYPE, 0));
result.add(new TextCompletionProposal("Sequence{}", 1));
result.add(new TextCompletionProposal("OrderedSet{}", 1));
result.add(new TextCompletionProposal(AstBuilderListener.LET_OPERATOR + SPACE, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

public class CompletionTest {

private static final int TOTAL_NUMBER_OF_PROPOSAL = 131;
private static final int TOTAL_NUMBER_OF_PROPOSAL = 135;

QueryCompletionEngine engine;

Expand Down Expand Up @@ -331,9 +331,9 @@ public void errorTypeLiteralTwoSegmentsTest() {
public void selfSelectTest() {
final ICompletionResult completionResult = engine.getCompletion("self->select(", 13, variableTypes);

assertCompletion(completionResult, 132, "", "", 13, 0, "myEClass | ");
assertCompletion(completionResult, 136, "", "", 13, 0, "myEClass | ");
final ICompletionProposal proposal = completionResult.getProposals(new BasicFilter(completionResult))
.get(131);
.get(135);
assertEquals(true, proposal instanceof VariableDeclarationCompletionProposal);
assertEquals("myEClass | ".length(), proposal.getCursorOffset());
}
Expand Down Expand Up @@ -454,7 +454,7 @@ public void testConditionalIfCompletionFromNothing() {
public void testConditionalIfCompletion() {
final ICompletionResult completionResult = engine.getCompletion("i", 1, variableTypes);

assertCompletion(completionResult, 2, "i", "", 0, 1, "if ", "anydsl::Kind::Inflorescence");
assertCompletion(completionResult, 3, "i", "", 0, 1, "Integer", "if ", "anydsl::Kind::Inflorescence");
}

@Test
Expand Down Expand Up @@ -650,7 +650,7 @@ public void test477213VariableDeclarationCollectCompletion_Classifier() {

final ICompletionResult completionResult = engine.getCompletion("self->collect()", 14, types);

assertCompletion(completionResult, 131, "", "", 14, 0, "myEObject | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 14, 0, "myEObject | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -665,7 +665,7 @@ public void test477213VariableDeclarationCollectCompletion_Class() {

final ICompletionResult completionResult = engine.getCompletion("self->collect()", 14, types);

assertCompletion(completionResult, 131, "", "", 14, 0, "myEObject | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 14, 0, "myEObject | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -680,7 +680,7 @@ public void test477213VariableDeclarationCollectCompletion_Nothing() {

final ICompletionResult completionResult = engine.getCompletion("self->collect()", 14, types);

assertCompletion(completionResult, 131, "", "", 14, 0, "myNothing | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 14, 0, "myNothing | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -695,7 +695,7 @@ public void test477213VariableDeclarationCollectCompletion_SequenceOfNothing() {

final ICompletionResult completionResult = engine.getCompletion("self->collect()", 14, types);

assertCompletion(completionResult, 131, "", "", 14, 0, "myNothing | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 14, 0, "myNothing | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -710,7 +710,7 @@ public void test477213VariableDeclarationSelectCompletion_Classifier() {

final ICompletionResult completionResult = engine.getCompletion("self->select(", 13, types);

assertCompletion(completionResult, 131, "", "", 13, 0, "myEObject | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 13, 0, "myEObject | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -725,7 +725,7 @@ public void test477213VariableDeclarationSelectCompletion_Class() {

final ICompletionResult completionResult = engine.getCompletion("self->select(", 13, types);

assertCompletion(completionResult, 131, "", "", 13, 0, "myEObject | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 13, 0, "myEObject | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -740,7 +740,7 @@ public void test477213VariableDeclarationSelectCompletion_Nothing() {

final ICompletionResult completionResult = engine.getCompletion("self->select(", 13, types);

assertCompletion(completionResult, 131, "", "", 13, 0, "myNothing | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 13, 0, "myNothing | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -755,7 +755,7 @@ public void test477213VariableDeclarationSelectCompletion_SequenceOfNothing() {

final ICompletionResult completionResult = engine.getCompletion("self->select(", 13, types);

assertCompletion(completionResult, 131, "", "", 13, 0, "myNothing | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 13, 0, "myNothing | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -770,7 +770,7 @@ public void test477213VariableDeclarationRejectCompletion_Classifier() {

final ICompletionResult completionResult = engine.getCompletion("self->reject(", 13, types);

assertCompletion(completionResult, 131, "", "", 13, 0, "myEObject | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 13, 0, "myEObject | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -785,7 +785,7 @@ public void test477213VariableDeclarationRejectCompletion_Class() {

final ICompletionResult completionResult = engine.getCompletion("self->reject(", 13, types);

assertCompletion(completionResult, 131, "", "", 13, 0, "myEObject | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 13, 0, "myEObject | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -800,7 +800,7 @@ public void test477213VariableDeclarationRejectCompletion_Nothing() {

final ICompletionResult completionResult = engine.getCompletion("self->reject(", 13, types);

assertCompletion(completionResult, 131, "", "", 13, 0, "myNothing | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 13, 0, "myNothing | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand All @@ -815,7 +815,7 @@ public void test477213VariableDeclarationRejectCompletion_SequenceOfNothing() {

final ICompletionResult completionResult = engine.getCompletion("self->reject(", 13, types);

assertCompletion(completionResult, 131, "", "", 13, 0, "myNothing | ");
assertCompletion(completionResult, TOTAL_NUMBER_OF_PROPOSAL, "", "", 13, 0, "myNothing | ");
assertNoEOperationCompletionProposal(completionResult);
assertNoFeatureCompletionProposal(completionResult);
assertNoServiceCompletionProposal(completionResult);
Expand Down Expand Up @@ -895,7 +895,7 @@ public void testOrderedSetMinus() {

final ICompletionResult completionResult = engine.getCompletion("OrderedSet{}-", 13, types);

assertCompletion(completionResult, 129, "", "", 13, 0, "OrderedSet{}", "ecore::EPackage");
assertCompletion(completionResult, 133, "", "", 13, 0, "OrderedSet{}", "ecore::EPackage");
assertNoEOperationCompletionProposal(completionResult);
assertNoVariableCompletionProposal(completionResult);
assertNoVariableDeclarationCompletionProposal(completionResult);
Expand Down Expand Up @@ -1104,7 +1104,7 @@ public void inLetVariableInSecondBinding() {
}
}
assertFalse(variableAFound);
assertCompletion(completionResult, 130, "", "", 18, 0, "self");
assertCompletion(completionResult, 134, "", "", 18, 0, "self");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,24 @@ http://www.eclipse.org/acceleo/4.0#//Expression
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Boolean
* Description:
Boolean
* Text:
Boolean
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Integer
* Description:
Integer
* Text:
Integer
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
OrderedSet{}
* Description:
Expand All @@ -511,6 +529,15 @@ OrderedSet{}
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Real
* Description:
Real
* Text:
Real
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Sequence{}
* Description:
Expand All @@ -520,6 +547,15 @@ Sequence{}
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
String
* Description:
String
* Text:
String
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
false
* Description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,24 @@ http://www.eclipse.org/acceleo/4.0#//Expression
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Boolean
* Description:
Boolean
* Text:
Boolean
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Integer
* Description:
Integer
* Text:
Integer
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
OrderedSet{}
* Description:
Expand All @@ -511,6 +529,15 @@ OrderedSet{}
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Real
* Description:
Real
* Text:
Real
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Sequence{}
* Description:
Expand All @@ -520,6 +547,15 @@ Sequence{}
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
String
* Description:
String
* Text:
String
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
false
* Description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,24 @@ http://www.eclipse.org/acceleo/4.0#//Expression
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Boolean
* Description:
Boolean
* Text:
Boolean
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Integer
* Description:
Integer
* Text:
Integer
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
OrderedSet{}
* Description:
Expand All @@ -529,6 +547,15 @@ OrderedSet{}
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Real
* Description:
Real
* Text:
Real
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
Sequence{}
* Description:
Expand All @@ -538,6 +565,15 @@ Sequence{}
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
String
* Description:
String
* Text:
String
* Type (optional):
http://www.eclipse.org/acceleo/4.0#//Expression

* Label:
false
* Description:
Expand Down
Loading

0 comments on commit 6322c35

Please sign in to comment.