use of org.eclipse.xtext.xbase.ui.refactoring.NewFeatureNameUtil in project xtext-eclipse by eclipse.
the class NewFeatureNameUtilTest method assertDefaultName.
protected void assertDefaultName(final String modelWithSelectionMarkup, final String expectedName) {
final String cleanedModel = modelWithSelectionMarkup.replaceAll("\\$", "");
final XExpression expression = this.parse(cleanedModel);
final int selectionOffset = modelWithSelectionMarkup.indexOf("$");
int _lastIndexOf = modelWithSelectionMarkup.lastIndexOf("$");
int _minus = (_lastIndexOf - selectionOffset);
final int selectionLength = (_minus - 1);
Resource _eResource = expression.eResource();
TextSelection _textSelection = new TextSelection(selectionOffset, selectionLength);
final XExpression selectedExpression = this.util.findSelectedExpression(((XtextResource) _eResource), _textSelection);
final XExpression successor = this.util.findSuccessorExpressionForVariableDeclaration(selectedExpression);
final NewFeatureNameUtil nameUtil = this.nameUtilProvider.get();
nameUtil.setFeatureScopeContext(successor);
final String defaultName = nameUtil.getDefaultName(selectedExpression);
Assert.assertEquals(expectedName, defaultName);
}
use of org.eclipse.xtext.xbase.ui.refactoring.NewFeatureNameUtil in project xtext-eclipse by eclipse.
the class NewFeatureNameUtilTest method assertInvalidName.
protected void assertInvalidName(final String name, final int severity, final String messageFragment) {
final RefactoringStatus status = new RefactoringStatus();
final NewFeatureNameUtil nameUtil = this.nameUtilProvider.get();
nameUtil.checkNewFeatureName(name, false, status);
Assert.assertEquals(severity, status.getSeverity());
final String message = status.getEntryWithHighestSeverity().getMessage();
Assert.assertTrue(message, message.contains(messageFragment));
}
Aggregations