use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class SuspiciousOverloadValidationTest method assertSuspiciousInInnerClass.
protected void assertSuspiciousInInnerClass(final CharSequence contents, final String... messageParts) {
final XtendFile file = this.getParsedXtendFile(contents);
final EList<Resource.Diagnostic> errors = file.eResource().getErrors();
Assert.assertEquals(errors.toString(), 1, errors.size());
Resource.Diagnostic _head = IterableExtensions.<Resource.Diagnostic>head(errors);
final AbstractDiagnostic singleError = ((AbstractDiagnostic) _head);
Assert.assertEquals(singleError.getMessage(), IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, singleError.getCode());
final Function1<String, String> _function = (String it) -> {
return Strings.toUnixLineSeparator(it);
};
final Consumer<String> _function_1 = (String it) -> {
final String message = singleError.getMessage();
boolean _contains = message.contains(it);
boolean _not = (!_contains);
if (_not) {
Assert.assertEquals(it, message);
}
};
ListExtensions.<String, String>map(((List<String>) Conversions.doWrapArray(messageParts)), _function).forEach(_function_1);
final XtendTypeDeclaration firstType = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head_1 = IterableExtensions.<XtendMember>head(firstType.getMembers());
final XtendClass innerType = ((XtendClass) _head_1);
XtendMember _head_2 = IterableExtensions.<XtendMember>head(innerType.getMembers());
final XtendFunction firstMember = ((XtendFunction) _head_2);
XExpression _expression = firstMember.getExpression();
final XBlockExpression block = ((XBlockExpression) _expression);
final Function1<XAbstractFeatureCall, Boolean> _function_2 = (XAbstractFeatureCall it) -> {
return Boolean.valueOf(((!Objects.equal(it.eContainingFeature(), XbasePackage.Literals.XABSTRACT_FEATURE_CALL__IMPLICIT_RECEIVER)) && (it.getFeature() instanceof JvmOperation)));
};
final XAbstractFeatureCall featureCall = IteratorExtensions.<XAbstractFeatureCall>findLast(Iterators.<XAbstractFeatureCall>filter(block.eAllContents(), XAbstractFeatureCall.class), _function_2);
final IFeatureLinkingCandidate linkingCandidate = this._iBatchTypeResolver.resolveTypes(file).getLinkingCandidate(featureCall);
Assert.assertTrue((linkingCandidate instanceof ISuspiciouslyOverloadedCandidate));
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class ValidationBug433213Test method test_03.
@Test
public void test_03() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new Object {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("def m2() {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("new Object {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("def <T> T m3() {}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
final XtendFunction m = ((XtendFunction) _head);
XExpression _expression = m.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
final AnonymousClass anon = ((AnonymousClass) _head_1);
XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
final XtendFunction m2 = ((XtendFunction) _head_2);
XExpression _expression_1 = m2.getExpression();
final XBlockExpression body2 = ((XBlockExpression) _expression_1);
XExpression _head_3 = IterableExtensions.<XExpression>head(body2.getExpressions());
final AnonymousClass anon2 = ((AnonymousClass) _head_3);
XtendMember _head_4 = IterableExtensions.<XtendMember>head(anon2.getMembers());
final XtendFunction m3 = ((XtendFunction) _head_4);
final JvmTypeReference returnType = m3.getReturnType();
final JvmType t = returnType.getType();
Assert.assertNotNull("notNull", t);
Assert.assertFalse("t.eIsProxy", t.eIsProxy());
this.helper.assertNoErrors(file);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class ValidationBug433213Test method test_06.
@Test
public void test_06() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def <K> m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new Object {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("def <V> m2() {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("new java.util.AbstractMap<K, V> {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("def Entry<K, V> m() {}");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("override entrySet() {}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
final XtendFunction m = ((XtendFunction) _head);
XExpression _expression = m.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
final AnonymousClass anon = ((AnonymousClass) _head_1);
XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
final XtendFunction m2 = ((XtendFunction) _head_2);
XExpression _expression_1 = m2.getExpression();
final XBlockExpression body2 = ((XBlockExpression) _expression_1);
XExpression _head_3 = IterableExtensions.<XExpression>head(body2.getExpressions());
final AnonymousClass anon2 = ((AnonymousClass) _head_3);
XtendMember _head_4 = IterableExtensions.<XtendMember>head(anon2.getMembers());
final XtendFunction m3 = ((XtendFunction) _head_4);
final JvmTypeReference returnType = m3.getReturnType();
final JvmType t = returnType.getType();
Assert.assertNotNull("notNull", t);
Assert.assertFalse("t.eIsProxy", t.eIsProxy());
this.helper.assertNoErrors(file);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendRenameStrategy method getPathToRename.
protected IPath getPathToRename(URI elementURI, ResourceSet resourceSet) {
EObject targetObject = resourceSet.getEObject(elementURI, false);
if (targetObject instanceof XtendTypeDeclaration) {
URI resourceURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(targetObject).trimFragment();
if (!resourceURI.isPlatformResource())
throw new RefactoringException("Renamed type does not reside in the workspace");
IPath path = new Path(resourceURI.toPlatformString(true));
if (context instanceof IChangeRedirector.Aware) {
if (((IChangeRedirector.Aware) context).getChangeRedirector().getRedirectedPath(path) != path)
return null;
}
return path;
}
return null;
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendUIValidator method checkFileNamingConventions.
@Check
public void checkFileNamingConventions(XtendFile xtendFile) {
String expectedPackage = getExpectedPackageName(xtendFile);
String declaredPackage = xtendFile.getPackage();
if (expectedPackage != null && !((isEmpty(expectedPackage) && declaredPackage == null) || expectedPackage.equals(declaredPackage))) {
error("The declared package '" + notNull(declaredPackage) + "' does not match the expected package '" + notNull(expectedPackage) + "'", XtendPackage.Literals.XTEND_FILE__PACKAGE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_PACKAGE, expectedPackage);
}
if (xtendFile.getXtendTypes().size() == 1) {
XtendTypeDeclaration xtendType = xtendFile.getXtendTypes().get(0);
String currentFileName = xtendFile.eResource().getURI().trimFileExtension().lastSegment();
String expectedFileName = xtendType.getName();
if (expectedFileName != null && !equal(currentFileName, expectedFileName)) {
addIssue("The type name '" + expectedFileName + "' doesn't match the file name '" + currentFileName + "'", xtendType, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, IssueCodes.WRONG_FILE, expectedFileName);
}
}
}
Aggregations