나는 수신 기능을 가지고 MethodDeclaration
:MethodDeclaration 클래스에서 반복자 유형을 반환하는 방법은 무엇입니까?
public boolean visit(MethodDeclaration node){ }
나는 나무 (node
부터 시작)을 반복해야하는, 그래서 선언 for 루프에서
Iterator<MethodDeclaration> itr;
및처럼 사용 이 :
for(Iterator<MethodDeclaration> itr = node; itr.hasNext();)
그래서 내 기능은 지금까지 다음과 같은 :
public boolean visit(MethodDeclaration node)
{
if (node != null)
{
for (Iterator<MethodDeclaration> itr = node; itr.hasNext();)
{
....
}
}
}
itr
선언문과 itr.hasNext()
이 작동합니다 (eclipse에서 식별합니다). 그러나 라인 Iterator<MethodDeclaration> itr = node;
은 그렇지 않습니다. 분명히 iterator
형식을 반환하는 node
의 일부 메서드를 활성화해야합니다. 그러나 나는 아무것도 찾을 수 없었다.
어떻게해야합니까?
감사
'MethodDeclaration'은'Iterator'를 구현합니까? 그렇지 않으면 반복자를 사용할 수 없습니다. while 루프를 사용하여 노드를 반복해야 할 수도 있습니다. –
무엇을 반복하려고합니까? –