|
33 | 33 | import org.eclipse.jdt.core.dom.JavacBindingResolver.BindingKeyException; |
34 | 34 | import org.eclipse.jdt.core.dom.LambdaExpression; |
35 | 35 | import org.eclipse.jdt.core.dom.MethodDeclaration; |
36 | | -import org.eclipse.jdt.core.dom.Modifier; |
37 | 36 | import org.eclipse.jdt.core.dom.SingleVariableDeclaration; |
38 | 37 | import org.eclipse.jdt.core.dom.VariableDeclaration; |
39 | 38 | import org.eclipse.jdt.core.dom.VariableDeclarationExpression; |
|
48 | 47 | import org.eclipse.jdt.internal.core.ResolvedBinaryField; |
49 | 48 | import org.eclipse.jdt.internal.core.ResolvedSourceField; |
50 | 49 | import org.eclipse.jdt.internal.core.SourceField; |
51 | | -import org.eclipse.jdt.internal.core.util.Util; |
52 | 50 |
|
53 | 51 | import com.sun.tools.javac.code.Flags; |
54 | 52 | import com.sun.tools.javac.code.Kinds; |
@@ -165,13 +163,13 @@ private IJavaElement computeJavaElement() { |
165 | 163 | } else { |
166 | 164 | ASTNode node = this.resolver.findNode(this.variableSymbol); |
167 | 165 | if (node instanceof VariableDeclarationFragment fragment) { |
168 | | - return toLocalVariable(fragment, (JavaElement) method); |
| 166 | + return DOMToModelPopulator.toLocalVariable(fragment, (JavaElement) method); |
169 | 167 | } else if (node instanceof SingleVariableDeclaration variableDecl) { |
170 | 168 | return DOMToModelPopulator.toLocalVariable(variableDecl, (JavaElement) method); |
171 | 169 | } else if (node instanceof VariableDeclarationStatement statement && statement.fragments().size() == 1) { |
172 | | - return toLocalVariable((VariableDeclarationFragment)statement.fragments().get(0), (JavaElement)method); |
| 170 | + return DOMToModelPopulator.toLocalVariable((VariableDeclarationFragment)statement.fragments().get(0), (JavaElement)method); |
173 | 171 | } else if (node instanceof VariableDeclarationExpression expression && expression.fragments().size() == 1) { |
174 | | - return toLocalVariable((VariableDeclarationFragment)expression.fragments().get(0), (JavaElement)method); |
| 172 | + return DOMToModelPopulator.toLocalVariable((VariableDeclarationFragment)expression.fragments().get(0), (JavaElement)method); |
175 | 173 | } |
176 | 174 | } |
177 | 175 | } |
@@ -387,53 +385,6 @@ public boolean isEffectivelyFinal() { |
387 | 385 | return (this.variableSymbol.flags() & Flags.EFFECTIVELY_FINAL) != 0; |
388 | 386 | } |
389 | 387 |
|
390 | | - private static LocalVariable toLocalVariable(VariableDeclarationFragment fragment, JavaElement parent) { |
391 | | - if (fragment.getParent() instanceof VariableDeclarationStatement variableDeclaration) { |
392 | | - return new LocalVariable(parent, |
393 | | - fragment.getName().getIdentifier(), |
394 | | - variableDeclaration.getStartPosition(), |
395 | | - variableDeclaration.getStartPosition() + variableDeclaration.getLength() - 1, |
396 | | - fragment.getName().getStartPosition(), |
397 | | - fragment.getName().getStartPosition() + fragment.getName().getLength() - 1, |
398 | | - Util.getSignature(variableDeclaration.getType()), |
399 | | - null, // I don't think we need this, also it's the ECJ's annotation node |
400 | | - toModelFlags(variableDeclaration.getModifiers(), false), |
401 | | - false); |
402 | | - } else if (fragment.getParent() instanceof VariableDeclarationExpression variableDeclaration) { |
403 | | - return new LocalVariable(parent, |
404 | | - fragment.getName().getIdentifier(), |
405 | | - variableDeclaration.getStartPosition(), |
406 | | - variableDeclaration.getStartPosition() + variableDeclaration.getLength() - 1, |
407 | | - fragment.getName().getStartPosition(), |
408 | | - fragment.getName().getStartPosition() + fragment.getName().getLength() - 1, |
409 | | - Util.getSignature(variableDeclaration.getType()), |
410 | | - null, // I don't think we need this, also it's the ECJ's annotation node |
411 | | - toModelFlags(variableDeclaration.getModifiers(), false), |
412 | | - false); |
413 | | - } |
414 | | - return null; |
415 | | - } |
416 | | - |
417 | | - private static int toModelFlags(int domModifiers, boolean isDeprecated) { |
418 | | - int res = 0; |
419 | | - if (Modifier.isAbstract(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccAbstract; |
420 | | - if (Modifier.isDefault(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccDefaultMethod; |
421 | | - if (Modifier.isFinal(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccFinal; |
422 | | - if (Modifier.isNative(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccNative; |
423 | | - if (Modifier.isNonSealed(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccNonSealed; |
424 | | - if (Modifier.isPrivate(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccPrivate; |
425 | | - if (Modifier.isProtected(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccProtected; |
426 | | - if (Modifier.isPublic(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccPublic; |
427 | | - if (Modifier.isSealed(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccSealed; |
428 | | - if (Modifier.isStatic(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccStatic; |
429 | | - if (Modifier.isStrictfp(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccStrictfp; |
430 | | - if (Modifier.isSynchronized(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccSynchronized; |
431 | | - if (Modifier.isTransient(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccTransient; |
432 | | - if (Modifier.isVolatile(domModifiers)) res |= org.eclipse.jdt.core.Flags.AccVolatile; |
433 | | - if (isDeprecated) res |= org.eclipse.jdt.core.Flags.AccDeprecated; |
434 | | - return res; |
435 | | - } |
436 | | - |
437 | 388 | @Override |
438 | 389 | public String toString() { |
439 | 390 | return getType().getQualifiedName() + " " + getName(); |
|
0 commit comments