Skip to content

Commit

Permalink
[DOM to Model] fix exception and varargs translation
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Feb 13, 2024
1 parent ff9884e commit 4235dcf
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import java.util.stream.Stream;

import org.eclipse.core.runtime.ILog;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.AbstractTagElement;
Expand Down Expand Up @@ -406,10 +408,15 @@ public boolean visit(MethodDeclaration method) {
if (this.infos.peek() instanceof SourceTypeElementInfo parentInfo) {
parentInfo.addCategories(newElement, getCategories(method));
}
if (method.getAST().apiLevel() >= AST.JLS8) {

Check warning on line 411 in org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler and API Tools

Deprecation

NORMAL: The field AST.JLS8 is deprecated
info.setExceptionTypeNames(((List<Type>)method.thrownExceptionTypes()).stream().map(Type::toString).map(String::toCharArray).toArray(char[][]::new));
}
info.setSourceRangeStart(method.getStartPosition());
info.setSourceRangeEnd(method.getStartPosition() + method.getLength() - 1);
boolean isDeprecated = isNodeDeprecated(method);
info.setFlags(method.getModifiers() | (isDeprecated ? ClassFileConstants.AccDeprecated : 0));
info.setFlags(method.getModifiers()
| (isDeprecated ? ClassFileConstants.AccDeprecated : 0)
| (((List<SingleVariableDeclaration>)method.parameters()).stream().anyMatch(decl -> decl.isVarargs()) ? Flags.AccVarargs : 0));
info.setNameSourceStart(method.getName().getStartPosition());
info.setNameSourceEnd(method.getName().getStartPosition() + method.getName().getLength() - 1);
this.infos.push(info);
Expand Down

0 comments on commit 4235dcf

Please sign in to comment.