本文整理汇总了Java中org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex类的典型用法代码示例。如果您正苦于以下问题:Java JavaFxControllerClassIndex类的具体用法?Java JavaFxControllerClassIndex怎么用?Java JavaFxControllerClassIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaFxControllerClassIndex类属于org.jetbrains.plugins.javaFX包,在下文中一共展示了JavaFxControllerClassIndex类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isImplicitWrite
import org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex; //导入依赖的package包/类
@Override
public boolean isImplicitWrite(PsiElement element) {
if (element instanceof PsiField) {
final String name = ((PsiField)element).getName();
final PsiClass containingClass = ((PsiField)element).getContainingClass();
if (containingClass != null) {
final String qualifiedName = containingClass.getQualifiedName();
if (qualifiedName != null) {
final Project project = element.getProject();
final List<VirtualFile> fxmls = JavaFxControllerClassIndex.findFxmlsWithController(project, qualifiedName);
if (!fxmls.isEmpty()) {
final Collection<String> filePaths = JavaFxIdsIndex.getFilePaths(project, name);
for (VirtualFile fxml : fxmls) {
if (filePaths.contains(fxml.getPath())) return true;
}
}
}
}
}
return false;
}
示例2: collectTargets
import org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex; //导入依赖的package包/类
private static <T> void collectTargets(PsiField field, final ArrayList<T> targets, final Function<PsiElement, T> fun, final boolean stopAtFirst) {
final PsiClass containingClass = field.getContainingClass();
LOG.assertTrue(containingClass != null);
final String qualifiedName = containingClass.getQualifiedName();
LOG.assertTrue(qualifiedName != null);
final List<VirtualFile> fxmls = JavaFxControllerClassIndex.findFxmlsWithController(field.getProject(), qualifiedName);
if (fxmls.isEmpty()) return;
ReferencesSearch.search(field, GlobalSearchScope.filesScope(field.getProject(), fxmls)).forEach(
new Processor<PsiReference>() {
@Override
public boolean process(PsiReference reference) {
final PsiElement referenceElement = reference.getElement();
if (referenceElement == null) return true;
final PsiFile containingFile = referenceElement.getContainingFile();
if (containingFile == null) return true;
if (!JavaFxFileTypeFactory.isFxml(containingFile)) return true;
if (!(referenceElement instanceof XmlAttributeValue)) return true;
final XmlAttributeValue attributeValue = (XmlAttributeValue)referenceElement;
final PsiElement parent = attributeValue.getParent();
if (!(parent instanceof XmlAttribute)) return true;
if (!FxmlConstants.FX_ID.equals(((XmlAttribute)parent).getName())) return true;
targets.add(fun.fun(parent));
return !stopAtFirst;
}
});
}
示例3: getAdditionalUseScope
import org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex; //导入依赖的package包/类
@Nullable
@Override
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
PsiClass containingClass = null;
if (element instanceof PsiField) {
containingClass = ((PsiField)element).getContainingClass();
}
else if (element instanceof PsiParameter) {
final PsiElement declarationScope = ((PsiParameter)element).getDeclarationScope();
if (declarationScope instanceof PsiMethod && PropertyUtil.isSimplePropertySetter((PsiMethod)declarationScope)) {
containingClass = ((PsiMethod)declarationScope).getContainingClass();
}
}
if (containingClass != null) {
if (element instanceof PsiField &&
!((PsiField)element).hasModifierProperty(PsiModifier.PUBLIC) &&
AnnotationUtil.isAnnotated((PsiField)element, JavaFxCommonClassNames.JAVAFX_FXML_ANNOTATION, false) || element instanceof PsiParameter) {
final Project project = element.getProject();
final String qualifiedName = containingClass.getQualifiedName();
if (qualifiedName != null && !JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName).isEmpty()) {
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(project);
return new DelegatingGlobalSearchScope(projectScope){
@Override
public boolean contains(@NotNull VirtualFile file) {
return super.contains(file) && JavaFxFileTypeFactory.isFxml(file);
}
};
}
}
}
return null;
}
示例4: getAdditionalUseScope
import org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex; //导入依赖的package包/类
@Nullable
@Override
public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
PsiClass containingClass = null;
if (element instanceof PsiField) {
containingClass = ((PsiField)element).getContainingClass();
}
else if (element instanceof PsiParameter) {
final PsiElement declarationScope = ((PsiParameter)element).getDeclarationScope();
if (declarationScope instanceof PsiMethod && PropertyUtil.isSimplePropertySetter((PsiMethod)declarationScope)) {
containingClass = ((PsiMethod)declarationScope).getContainingClass();
}
}
if (containingClass != null) {
if (element instanceof PsiField && ((PsiField)element).hasModifierProperty(PsiModifier.PRIVATE) || element instanceof PsiParameter) {
final Project project = element.getProject();
final String qualifiedName = containingClass.getQualifiedName();
if (qualifiedName != null && !JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName).isEmpty()) {
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(project);
return new DelegatingGlobalSearchScope(projectScope){
@Override
public boolean contains(VirtualFile file) {
return super.contains(file) && JavaFxFileTypeFactory.isFxml(file);
}
};
}
}
}
return null;
}
示例5: execute
import org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
final PsiElement elementToSearch = queryParameters.getElementToSearch();
if (elementToSearch instanceof PsiField) {
final PsiField field = (PsiField)elementToSearch;
final PsiClass containingClass = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass>() {
@Override
public PsiClass compute() {
return field.getContainingClass();
}
});
if (containingClass != null) {
final String qualifiedName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return containingClass.getQualifiedName();
}
});
if (qualifiedName != null) {
Project project = PsiUtilCore.getProjectInReadAction(containingClass);
final List<PsiFile> fxmlWithController =
JavaFxControllerClassIndex.findFxmlWithController(project, qualifiedName);
for (final PsiFile file : fxmlWithController) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final String fieldName = field.getName();
final VirtualFile virtualFile = file.getViewProvider().getVirtualFile();
final SearchScope searchScope = queryParameters.getEffectiveSearchScope();
boolean contains = searchScope instanceof LocalSearchScope ? ((LocalSearchScope)searchScope).isInScope(virtualFile) :
((GlobalSearchScope)searchScope).contains(virtualFile);
if (contains) {
file.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlAttributeValue(final XmlAttributeValue value) {
final PsiReference reference = value.getReference();
if (reference != null) {
final PsiElement resolve = reference.resolve();
if (resolve instanceof XmlAttributeValue) {
final PsiElement parent = resolve.getParent();
if (parent instanceof XmlAttribute) {
final XmlAttribute attribute = (XmlAttribute)parent;
if (FxmlConstants.FX_ID.equals(attribute.getName()) && fieldName.equals(attribute.getValue())) {
consumer.process(reference);
}
}
}
}
}
});
}
}
});
}
}
}
}
return true;
}
示例6: execute
import org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
final PsiElement elementToSearch = queryParameters.getElementToSearch();
if (elementToSearch instanceof PsiField) {
final PsiField field = (PsiField)elementToSearch;
final PsiClass containingClass = field.getContainingClass();
if (containingClass != null) {
final String qualifiedName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return containingClass.getQualifiedName();
}
});
if (qualifiedName != null) {
final List<PsiFile> fxmlWithController =
JavaFxControllerClassIndex.findFxmlWithController(containingClass.getProject(), qualifiedName);
final String fieldName = field.getName();
for (PsiFile file : fxmlWithController) {
final VirtualFile virtualFile = file.getViewProvider().getVirtualFile();
final SearchScope searchScope = ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
@Override
public SearchScope compute() {
return queryParameters.getEffectiveSearchScope();
}
});
if (searchScope instanceof LocalSearchScope) {
if (!((LocalSearchScope)searchScope).isInScope(virtualFile)) continue;
} else if (searchScope instanceof GlobalSearchScope) {
if (!((GlobalSearchScope)searchScope).contains(virtualFile)) continue;
}
file.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlAttributeValue(final XmlAttributeValue value) {
Runnable runnable = new Runnable() {
public void run() {
final PsiReference reference = value.getReference();
if (reference != null) {
final PsiElement resolve = reference.resolve();
if (resolve instanceof XmlAttributeValue) {
final PsiElement parent = resolve.getParent();
if (parent instanceof XmlAttribute) {
final XmlAttribute attribute = (XmlAttribute)parent;
if (FxmlConstants.FX_ID.equals(attribute.getName()) && fieldName.equals(attribute.getValue())) {
consumer.process(reference);
}
}
}
}
}
};
ApplicationManager.getApplication().runReadAction(runnable);
}
});
}
}
}
}
return true;
}
示例7: execute
import org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex; //导入依赖的package包/类
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
final PsiElement elementToSearch = queryParameters.getElementToSearch();
if (elementToSearch instanceof PsiField) {
final PsiField field = (PsiField)elementToSearch;
final PsiClass containingClass = field.getContainingClass();
if (containingClass != null) {
final String qualifiedName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return containingClass.getQualifiedName();
}
});
if (qualifiedName != null) {
final List<PsiFile> fxmlWithController =
JavaFxControllerClassIndex.findFxmlWithController(containingClass.getProject(), qualifiedName);
final String fieldName = field.getName();
for (final PsiFile file : fxmlWithController) {
final VirtualFile virtualFile = file.getViewProvider().getVirtualFile();
final SearchScope searchScope = ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
@Override
public SearchScope compute() {
return queryParameters.getEffectiveSearchScope();
}
});
if (searchScope instanceof LocalSearchScope) {
if (!((LocalSearchScope)searchScope).isInScope(virtualFile)) continue;
} else if (searchScope instanceof GlobalSearchScope) {
if (!((GlobalSearchScope)searchScope).contains(virtualFile)) continue;
}
final Runnable runnable = new Runnable() {
public void run() {
file.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlAttributeValue(final XmlAttributeValue value) {
final PsiReference reference = value.getReference();
if (reference != null) {
final PsiElement resolve = reference.resolve();
if (resolve instanceof XmlAttributeValue) {
final PsiElement parent = resolve.getParent();
if (parent instanceof XmlAttribute) {
final XmlAttribute attribute = (XmlAttribute)parent;
if (FxmlConstants.FX_ID.equals(attribute.getName()) && fieldName.equals(attribute.getValue())) {
consumer.process(reference);
}
}
}
}
}
});
}
};
ApplicationManager.getApplication().runReadAction(runnable);
}
}
}
}
return true;
}