List of usage examples for org.eclipse.jdt.core IMethod isLambdaMethod
boolean isLambdaMethod();
From source file:io.sarl.eclipse.util.Jdt2Ecore.java
License:Apache License
/** Analyzing the type hierarchy of the given element, and * extract any type-related information. * * <p>The type finder could be obtained with {@link #toTypeFinder(IJavaProject)}. * * @param typeFinder - the type finder to be used for finding the type definitions. * @param finalOperations - filled with the final operations inherited by the element. * @param overridableOperations - filled with the oervrideable operations inherited by the element. * @param inheritedFields - filled with the fields inherited by the element. * @param operationsToImplement - filled with the abstract operations inherited by the element. * @param superConstructors - filled with the construstors of the super type. * @param superClass - the name of the super class. * @param superInterfaces - the super interfaces. * @return the status of the operation./*w ww . j a va 2s .com*/ * @throws JavaModelException if the Java model is invalid. * @see #toTypeFinder(IJavaProject) */ @SuppressWarnings({ "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:nestedifdepth", "checkstyle:parameternumber" }) public IStatus populateInheritanceContext(TypeFinder typeFinder, Map<ActionPrototype, IMethod> finalOperations, Map<ActionPrototype, IMethod> overridableOperations, Map<String, IField> inheritedFields, Map<ActionPrototype, IMethod> operationsToImplement, Map<ActionParameterTypes, IMethod> superConstructors, String superClass, List<String> superInterfaces) throws JavaModelException { final Set<ActionPrototype> treatedElements = new TreeSet<>(); final SARLEclipsePlugin plugin = SARLEclipsePlugin.getDefault(); final List<IStatus> statuses = new ArrayList<>(); // Get the operations that must be implemented if (operationsToImplement != null) { final SuperTypeIterator typeIterator = new SuperTypeIterator(typeFinder, true, superInterfaces); while (typeIterator.hasNext()) { final IType type = typeIterator.next(); for (final IMethod operation : type.getMethods()) { if (!Flags.isStatic(operation.getFlags()) && !Flags.isFinal(operation.getFlags()) && !operation.isLambdaMethod() && !operation.isConstructor()) { final ActionParameterTypes sig = this.actionPrototypeProvider.createParameterTypes( Flags.isVarargs(operation.getFlags()), getFormalParameterProvider(operation)); final ActionPrototype actionKey = this.actionPrototypeProvider .createActionPrototype(operation.getElementName(), sig); if (treatedElements.add(actionKey)) { if (Flags.isDefaultMethod(operation.getFlags())) { if (!overridableOperations.containsKey(actionKey)) { overridableOperations.put(actionKey, operation); } } else { if (!operationsToImplement.containsKey(actionKey)) { operationsToImplement.put(actionKey, operation); } } } } } } statuses.addAll(typeIterator.getStatuses()); } // Check on the implemented features, inherited from the super type if (isValidSuperType(superClass)) { final SuperTypeIterator typeIterator = new SuperTypeIterator(typeFinder, false, superClass); while (typeIterator.hasNext()) { final IType type = typeIterator.next(); final boolean checkForConstructors = superConstructors != null && type.getFullyQualifiedName().equals(superClass); for (final IMethod operation : type.getMethods()) { if (!Flags.isStatic(operation.getFlags()) && !operation.isLambdaMethod() && isVisible(typeFinder, type, operation)) { if (!operation.isConstructor() && !Utils.isHiddenMember(operation.getElementName())) { final ActionParameterTypes sig = this.actionPrototypeProvider.createParameterTypes( Flags.isVarargs(operation.getFlags()), getFormalParameterProvider(operation)); final ActionPrototype actionKey = this.actionPrototypeProvider .createActionPrototype(operation.getElementName(), sig); if (treatedElements.add(actionKey)) { final int flags = operation.getFlags(); if (Flags.isAbstract(flags) && !Flags.isDefaultMethod(flags)) { if (operationsToImplement != null) { operationsToImplement.put(actionKey, operation); } } else if (Flags.isFinal(flags)) { if (finalOperations != null) { finalOperations.put(actionKey, operation); } if (operationsToImplement != null) { operationsToImplement.remove(actionKey); } } else { if (overridableOperations != null) { overridableOperations.put(actionKey, operation); } if (operationsToImplement != null) { operationsToImplement.remove(actionKey); } } } } else if (checkForConstructors && operation.isConstructor() && superConstructors != null) { final ActionParameterTypes sig = this.actionPrototypeProvider.createParameterTypes( Flags.isVarargs(operation.getFlags()), getFormalParameterProvider(operation)); superConstructors.put(sig, operation); } } } if (inheritedFields != null) { for (final IField field : type.getFields()) { if (!Flags.isStatic(field.getFlags()) && !Utils.isHiddenMember(field.getElementName()) && isVisible(typeFinder, type, field)) { inheritedFields.putIfAbsent(field.getElementName(), field); } } } } statuses.addAll(typeIterator.getStatuses()); } if (statuses.isEmpty()) { return plugin.createOkStatus(); } if (statuses.size() == 1) { return statuses.get(0); } return plugin.createMultiStatus(statuses); }
From source file:io.sarl.eclipse.util.Jdt2Ecore.java
License:Apache License
/** Create the JvmOperation for the given JDT method. * * @param method - the JDT method./* w w w . jav a 2 s . co m*/ * @param context - the context of the constructor. * @return the JvmOperation * @throws JavaModelException if the Java model is invalid. */ public JvmOperation getJvmOperation(IMethod method, XtendTypeDeclaration context) throws JavaModelException { if (!method.isConstructor() && !method.isLambdaMethod() && !method.isMainMethod()) { final JvmType type = this.typeReferences .findDeclaredType(method.getDeclaringType().getFullyQualifiedName(), context); return getJvmOperation(method, type); } return null; }