1 19 20 package org.netbeans.api.java.source.gen; 21 22 import com.sun.source.tree.Tree; 23 import java.util.Collections ; 24 import java.util.HashMap ; 25 import java.util.Map ; 26 import org.netbeans.api.java.lexer.JavaTokenId; 27 import org.netbeans.api.lexer.TokenHierarchy; 28 import org.netbeans.api.lexer.TokenSequence; 29 import org.netbeans.api.lexer.TokenUtilities; 30 31 36 public class TreeChecker { 37 38 39 private TreeChecker() { 40 } 41 42 static boolean compareTrees(Tree firstTree, Tree secondTree) { 43 return true; 44 } 45 46 static Map <Object , CharSequence []> compareTokens(TokenHierarchy hierarchy0, TokenHierarchy hierarchy1) { 47 Map result = new HashMap <Integer , String []>(); 48 TokenSequence ts0 = hierarchy0.tokenSequence(JavaTokenId.language()); 49 TokenSequence ts1 = hierarchy1.tokenSequence(JavaTokenId.language()); 50 while (ts0.moveNext()) { 51 if (ts1.moveNext()) { 52 if (!TokenUtilities.equals(ts0.token().text(), ts1.token().text())) { 53 result.put(ts0.token().id(), new CharSequence [] { ts0.token().text(), ts1.token().text() }); 54 } 55 } 56 } 57 if (result.size() > 0) { 58 return result; 59 } else { 60 return Collections.EMPTY_MAP; 61 } 62 } 63 } 64 | Popular Tags |