use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class ChangeConverter method _handleReplacements.
protected void _handleReplacements(final IEmfResourceChange change) {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final Procedure0 _function = () -> {
try {
final IFile file = this.resourceUriConverter.toFile(change.getResource().getURI());
boolean _canWrite = this.canWrite(file);
boolean _not = (!_canWrite);
if (_not) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Affected file \'");
IPath _fullPath = file.getFullPath();
_builder.append(_fullPath);
_builder.append("\' is read-only");
this.issues.add(RefactoringIssueAcceptor.Severity.ERROR, _builder.toString());
}
this.checkDerived(file);
change.getResource().save(outputStream, null);
final byte[] newContent = outputStream.toByteArray();
String _lastSegment = change.getOldURI().lastSegment();
final ReplaceFileContentChange ltkChange = new ReplaceFileContentChange(_lastSegment, file, newContent);
this.addChange(ltkChange);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
TryWithResource.tryWith(outputStream, _function);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class StatusWidget method addStatus.
public Procedure0 addStatus(final int severity, final String text) {
Procedure0 _xifexpression = null;
boolean _isEmpty = this.link.getText().trim().isEmpty();
if (_isEmpty) {
final Procedure0 _function = () -> {
};
final Procedure0 _function_1 = () -> {
};
_xifexpression = this.setStatus(severity, text, _function, _function_1);
} else {
String _text = this.link.getText();
String _plus = (_text + "\n");
String _plus_1 = (_plus + text);
this.link.setText(_plus_1);
final Matcher matcher = Pattern.compile("<a>(.*)</a>").matcher(text.trim());
this.link.setToolTipText(matcher.replaceAll("$1"));
if ((severity > this.severity)) {
this.severity = severity;
this.setVisible((severity != IMessageProvider.NONE));
this.imageLabel.setImage(this.imageFor(severity));
}
}
return _xifexpression;
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testRenameMethod.
@Test
public void testRenameMethod() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
int idx = document.get().lastIndexOf("method(");
assertNull("event is null before the document was modified", event);
try {
document.replace(idx + "method".length(), 0, "2");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 3, event.getDeltas().size());
Collection<String> allNames = getNames(event.getDeltas());
assertOriginalValues(allNames);
assertEquals("" + allNames, 3, allNames.size());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testCloseEditor.
@Test
public void testCloseEditor() throws InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
((ITextEditor) editor).close(false);
}
}, false);
assertNull(event);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testAddMethod.
@Test
public void testAddMethod() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
String lookup = "abstract boolean method();";
int idx = document.get().lastIndexOf(lookup);
assertNull("event is null before the document was modified", event);
try {
document.replace(idx + lookup.length(), 0, "abstract int foobar();");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 3, event.getDeltas().size());
Collection<String> allNames = getNames(event.getDeltas());
assertOriginalValues(allNames);
assertEquals("" + allNames, 3, allNames.size());
}
Aggregations