本文整理汇总了Java中org.netbeans.api.java.source.ElementHandle.resolve方法的典型用法代码示例。如果您正苦于以下问题:Java ElementHandle.resolve方法的具体用法?Java ElementHandle.resolve怎么用?Java ElementHandle.resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.java.source.ElementHandle
的用法示例。
在下文中一共展示了ElementHandle.resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveHandles
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
/**
*/
private <T extends Element> List<T> resolveHandles(
CompilationInfo compInfo,
List<ElementHandle<T>> handles) {
if (handles == null) {
return null;
}
if (handles.isEmpty()) {
return Collections.<T>emptyList();
}
List<T> elements = new ArrayList<T>(handles.size());
for (ElementHandle<T> handle : handles) {
T element = handle.resolve(compInfo);
if (element != null) {
elements.add(element);
} else {
ErrorManager.getDefault().log(
ErrorManager.WARNING,
"TestNG: Could not resolve element handle " //NOI18N
+ handle.getBinaryName());
}
}
return elements;
}
示例2: fillSubTypes
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private List<DeclaredType> fillSubTypes(CompilationController cc, DeclaredType dType) {
List<DeclaredType> subtypes = new ArrayList<>();
//Set<? extends SearchScopeType> scope = Collections.singleton(new ClassSearchScopeType(prefix));
Types types = cc.getTypes();
if (prefix != null && prefix.length() > 2 && lastPrefixDot < 0) {
//Trees trees = cc.getTrees();
ClassIndex.NameKind kind = ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX;
for (ElementHandle<TypeElement> handle : cpi.getClassIndex().getDeclaredTypes(prefix, kind, EnumSet.allOf(ClassIndex.SearchScope.class))) {
TypeElement te = handle.resolve(cc);
if (te != null && /*trees.isAccessible(scope, te) &&*/ types.isSubtype(types.getDeclaredType(te), dType)) {
subtypes.add(types.getDeclaredType(te));
}
}
} else {
HashSet<TypeElement> elems = new HashSet<>();
LinkedList<DeclaredType> bases = new LinkedList<>();
bases.add(dType);
ClassIndex index = cpi.getClassIndex();
while (!bases.isEmpty()) {
DeclaredType head = bases.remove();
TypeElement elem = (TypeElement) head.asElement();
if (!elems.add(elem)) {
continue;
}
if (accept(elem)) {
subtypes.add(head);
}
//List<? extends TypeMirror> tas = head.getTypeArguments();
//boolean isRaw = !tas.iterator().hasNext();
for (ElementHandle<TypeElement> eh : index.getElements(ElementHandle.create(elem), EnumSet.of(ClassIndex.SearchKind.IMPLEMENTORS), EnumSet.allOf(ClassIndex.SearchScope.class))) {
TypeElement e = eh.resolve(cc);
if (e != null) {
DeclaredType dt = types.getDeclaredType(e);
bases.add(dt);
}
}
}
}
return subtypes;
}
示例3: resolveHandles
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
/**
*/
private <T extends Element> List<T> resolveHandles(
CompilationInfo compInfo,
List<ElementHandle<T>> handles) {
if (handles == null) {
return null;
}
if (handles.isEmpty()) {
return Collections.<T>emptyList();
}
List<T> elements = new ArrayList<T>(handles.size());
for (ElementHandle<T> handle : handles) {
T element = handle.resolve(compInfo);
if (element != null) {
elements.add(element);
} else {
ErrorManager.getDefault().log(
ErrorManager.WARNING,
"JUnit: Could not resolve element handle " //NOI18N
+ handle.getBinaryName());
}
}
return elements;
}
示例4: isMatch
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private boolean isMatch(Element element, Element elementToFind) {
if(element == null) {
return false;
}
if(allMethods == null || element.getKind() != ElementKind.METHOD) {
return element.equals(elementToFind);
} else {
for (ElementHandle<ExecutableElement> mh: allMethods) {
ExecutableElement baseMethod = mh.resolve(workingCopy);
if (baseMethod==null) {
Logger.getLogger("org.netbeans.modules.refactoring.java").log(Level.INFO, "DeleteTransformer cannot resolve {0}", mh);
continue;
}
if (baseMethod.equals(element) || workingCopy.getElements().overrides((ExecutableElement)element, baseMethod, workingCopy.getElementUtilities().enclosingTypeElement(baseMethod))) {
return true;
}
}
}
return false;
}
示例5: run
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
@Override
public void run(CompilationController javac) throws Exception {
for (ElementHandle<ExecutableElement> method : allMethods) {
ExecutableElement el = method.resolve(javac);
Collection<ExecutableElement> overriddenMethods = JavaRefactoringUtils.getOverriddenMethods(el, javac);
for (ExecutableElement overriddenMethod : overriddenMethods) {
ElementHandle<ExecutableElement> handle = ElementHandle.create(overriddenMethod);
if(!allMethods.contains(handle)) {
TypeElement type1 = javac.getElementUtilities().enclosingTypeElement(el);
TypeElement type2 = javac.getElementUtilities().enclosingTypeElement(overriddenMethod);
Problem prob = new Problem(false, NbBundle.getMessage(OverriddenAbsMethodFinder.class, "WRN_Implements", overriddenMethod.getSimpleName(), type1.getQualifiedName(), type2.getQualifiedName()));
problem = JavaPluginUtils.chainProblems(problem, prob);
}
}
}
}
示例6: visitSource
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
@Override
public void visitSource(FxModel source) {
String controller = source.getController();
if (controller != null) {
ElementHandle<TypeElement> cTypeH = source.getControllerType();
if (cTypeH != null) {
controllerElement = cTypeH.resolve(env.getCompilationInfo());
}
}
TypeElement el = env.getCompilationInfo().getElements().getTypeElement(FX_EVENT_TYPE);
if (el == null) {
return;
}
eventType = el.asType();
super.visitSource(source);
}
示例7: createItem
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private CompletionItem createItem(ElementHandle<TypeElement> handle, int priority) {
TypeElement el = handle.resolve(ctx.getCompilationInfo());
if (el == null) {
// element does not exist etc
return null;
}
if (el.getKind() != ElementKind.CLASS && el.getKind() != ElementKind.ENUM) {
// do not honour interfaces
return null;
}
if (!el.getModifiers().contains(Modifier.PUBLIC)) {
return null;
}
CompletionItem item = null;
Collection<? extends ClassItemFactory> converters = MimeLookup.getLookup(JavaFXEditorUtils.FXML_MIME_TYPE).lookupAll(ClassItemFactory.class);
for (ClassItemFactory converter : converters) {
item = converter.convert(el, ctx, priority);
if (item != null) {
break;
}
}
return item;
}
示例8: ReferenceTransformer
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
public ReferenceTransformer(WorkingCopy info, ElementKind kind,
MemberSearchResult result, String name, Element target) {
this.kind = kind;
this.name = name;
this.copy = info;
this.target = target;
if (result != null) {
ElementHandle<? extends Element> s = result.getShadowed();
if (s == null) {
s = result.getOverriden();
}
if (s != null) {
this.shadowed = s.resolve(info);
}
s = result.getShadowedGate();
if (s != null) {
this.shadowedGate = result.getShadowedGate().resolve(info);
}
}
}
示例9: typesAdded
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
void typesAdded(Iterable<? extends ElementHandle<TypeElement>> typeHandles) {
// XXX assert not in AMH java context
LOGGER.log(Level.FINE, "typesAdded: called with {0}", typeHandles); // NOI18N
if (!initialized) {
LOGGER.log(Level.FINE, "typesAdded: not initialized, firing change event"); // NOI18N
fireChange();
return;
}
for (ElementHandle<TypeElement> typeHandle : typeHandles) {
TypeElement type = typeHandle.resolve(helper.getCompilationController());
if (type == null) {
LOGGER.log(Level.WARNING, "typesAdded: type {0} has dissapeared", typeHandle); // NOI18N
continue;
}
List<T> newObjects = provider.createObjects(type);
LOGGER.log(Level.FINE, "typesAdded: new objects {0}", newObjects); // NOI18N
if (objectList.put(typeHandle, newObjects)) {
fireChange();
}
}
}
示例10: getMethodsFromHandles
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
public static Collection<ExecutableElement> getMethodsFromHandles(CompilationInfo ci, Collection<ElementHandle<ExecutableElement>> methodHandles) {
List<ExecutableElement> methods = new ArrayList<ExecutableElement>(methodHandles.size());
for(ElementHandle<ExecutableElement> handle : methodHandles) {
ExecutableElement ee = handle.resolve(ci);
if(ee != null) {
methods.add(ee);
}
}
return methods;
}
示例11: getOldSimpleName
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private String getOldSimpleName(Element p) {
if (p!=null) {
return p.getSimpleName().toString();
}
for (ElementHandle<ExecutableElement> mh : allMethods) {
ExecutableElement baseMethod = mh.resolve(workingCopy);
if (baseMethod == null) {
continue;
}
return baseMethod.getSimpleName().toString();
}
return null;
}
示例12: isMethodMatch
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private boolean isMethodMatch(Element method) {
if (method.getKind() == ElementKind.METHOD && allMethods !=null) {
for (ElementHandle<ExecutableElement> mh: allMethods) {
ExecutableElement baseMethod = mh.resolve(workingCopy);
if (baseMethod==null) {
Logger.getLogger("org.netbeans.modules.refactoring.java").info("RenameTransformer cannot resolve " + mh);
continue;
}
if (baseMethod.equals(method) || workingCopy.getElements().overrides((ExecutableElement)method, baseMethod, workingCopy.getElementUtilities().enclosingTypeElement(baseMethod))) {
return true;
}
}
}
return false;
}
示例13: run
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
/**
* Go through all classes in the set and check which ones are acceptable to be filtered out.
* In this case, we require classes to be
* <ul>
* <li>nonabstract</li>
* <li>public</li>
* </ul>
* @param cc
* @throws Exception
*/
@Override
public void run(CompilationController cc) throws Exception {
String annotationFQN = PrimitiveInfo.class.getCanonicalName();
TypeMirror annotationType = getTypeMirror4Class(cc, annotationFQN);
if (annotationType == null) {
throw new ClassNotFoundException("Unable to find class " + annotationFQN);
}
result = new HashSet<PrimitiveData>();
for (ElementHandle<TypeElement> element : set) {
TypeElement type = element.resolve(cc);
if (!isAbstract(type) && isPublic(type)) {
String classFQN = element.getQualifiedName();
// Go through annotation of class if exists and fill the data
AnnotationMirror annotation = findAnnotationMirror(type, annotationType);
if (annotation != null) {
result.add(getInfo(classFQN, annotation));
} else {
result.add(new PrimitiveData(classFQN, null, null, new String[0]));
}
}
}
}
示例14: loadFromAllTypes
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private Set<ElementHandle<TypeElement>> loadFromAllTypes() {
ClasspathInfo info = ctx.getClasspathInfo();
Set<ElementHandle<TypeElement>> els =
new HashSet<ElementHandle<TypeElement>>(
info.getClassIndex().getDeclaredTypes(namePrefix, ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX,
EnumSet.of(ClassIndex.SearchScope.DEPENDENCIES, ClassIndex.SearchScope.SOURCE)
));
TypeMirror pt = getPropertyType();
if (pt == null) {
return els;
}
for (Iterator<ElementHandle<TypeElement>> it = els.iterator(); it.hasNext(); ) {
ElementHandle<TypeElement> teh = it.next();
String qn = teh.getQualifiedName();
int lastDot = qn.lastIndexOf('.');
String sn = lastDot == -1 ? qn : qn.substring(lastDot + 1);
if (!acceptsQName(qn, sn)) {
continue;
}
TypeElement t = teh.resolve(ctx.getCompilationInfo());
if (t == null ||
!acceptsType(t)) {
it.remove();
}
}
return els;
}
示例15: getInstanceType
import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private TypeElement getInstanceType(FxInstance decl) {
ElementHandle<TypeElement> compType = decl.getJavaType();
if (compType == null) {
return null;
}
TypeElement tel = compType.resolve(wcopy);
return tel;
}