本文整理汇总了Java中com.intellij.psi.xml.XmlFile.getProject方法的典型用法代码示例。如果您正苦于以下问题:Java XmlFile.getProject方法的具体用法?Java XmlFile.getProject怎么用?Java XmlFile.getProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.xml.XmlFile
的用法示例。
在下文中一共展示了XmlFile.getProject方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDomFileEditor
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static DomFileEditor createDomFileEditor(final String name,
@Nullable final Icon icon,
final DomElement element,
final Factory<? extends CommittablePanel> committablePanel) {
final XmlFile file = DomUtil.getFile(element);
final Factory<BasicDomElementComponent> factory = new Factory<BasicDomElementComponent>() {
@Override
public BasicDomElementComponent create() {
CaptionComponent captionComponent = new CaptionComponent(name, icon);
captionComponent.initErrorPanel(element);
BasicDomElementComponent component = createComponentWithCaption(committablePanel.create(), captionComponent, element);
Disposer.register(component, captionComponent);
return component;
}
};
return new DomFileEditor<BasicDomElementComponent>(file.getProject(), file.getVirtualFile(), name, factory) {
@Override
public JComponent getPreferredFocusedComponent() {
return null;
}
};
}
示例2: doCreateAndNavigate
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
PsiElement[] doCreateAndNavigate(String newName, PsiDirectory directory, String rootTagName, boolean chooseTagName, boolean navigate)
throws Exception {
final XmlFile file = AndroidResourceUtil
.createFileResource(newName, directory, rootTagName, myResourceType.getName(), myValuesResourceFile);
if (navigate) {
doNavigate(file);
}
if (chooseTagName) {
XmlDocument document = file.getDocument();
if (document != null) {
XmlTag rootTag = document.getRootTag();
if (rootTag != null) {
final Project project = file.getProject();
final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor != null) {
CaretModel caretModel = editor.getCaretModel();
caretModel.moveToOffset(rootTag.getTextOffset() + 1);
XmlTagInplaceRenamer.rename(editor, rootTag);
}
}
}
}
return new PsiElement[]{file};
}
示例3: processForwardDependencies
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static boolean processForwardDependencies(XmlFile file, final PsiElementProcessor<XmlFile> processor) {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return processor.execute(file);
}
final Project project = file.getProject();
final VirtualFile[] files = FileIncludeManager.getManager(project).getIncludedFiles(virtualFile, true);
return processRelatedFiles(file, files, processor);
}
示例4: processBackwardDependencies
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static boolean processBackwardDependencies(@NotNull XmlFile file, PsiElementProcessor<XmlFile> processor) {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return processor.execute(file);
}
final Project project = file.getProject();
final VirtualFile[] files = FileIncludeManager.getManager(project).getIncludingFiles(virtualFile, true);
return processRelatedFiles(file, files, processor);
}
示例5: AntHectorConfigurable
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public AntHectorConfigurable(XmlFile file) {
myFile = file;
myProject = file.getProject();
final VirtualFile selfVFile = myFile.getVirtualFile();
myLocalPath = PathUtil.getLocalPath(selfVFile);
myFileFilter = GlobalSearchScope.projectScope(myProject);
}
示例6: AntBuildFileImpl
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public AntBuildFileImpl(final XmlFile antFile, final AntConfigurationBase configuration) {
myVFile = antFile.getOriginalFile().getVirtualFile();
myProject = antFile.getProject();
myAntConfiguration = configuration;
myWorkspaceOptions = new ExternalizablePropertyContainer();
myWorkspaceOptions.registerProperty(RUN_IN_BACKGROUND);
myWorkspaceOptions.registerProperty(CLOSE_ON_NO_ERRORS);
myWorkspaceOptions.registerProperty(TREE_VIEW);
myWorkspaceOptions.registerProperty(VERBOSE);
myWorkspaceOptions.registerProperty(TARGET_FILTERS, "filter", NewInstanceFactory.fromClass(TargetFilter.class));
myWorkspaceOptions.rememberKey(RUN_WITH_ANT);
myProjectOptions = new ExternalizablePropertyContainer();
myProjectOptions.registerProperty(MAX_HEAP_SIZE);
myProjectOptions.registerProperty(MAX_STACK_SIZE);
myProjectOptions.registerProperty(CUSTOM_JDK_NAME);
myProjectOptions.registerProperty(ANT_COMMAND_LINE_PARAMETERS);
myProjectOptions.registerProperty(ANT_PROPERTIES, "property", NewInstanceFactory.fromClass(BuildFileProperty.class));
myProjectOptions.registerProperty(ADDITIONAL_CLASSPATH, "entry", SinglePathEntry.EXTERNALIZER);
myProjectOptions.registerProperty(ANT_REFERENCE, AntReference.EXTERNALIZER);
myAllOptions = new CompositePropertyContainer(new AbstractProperty.AbstractPropertyContainer[]{myWorkspaceOptions, myProjectOptions,
GlobalAntConfiguration.getInstance().getProperties(getProject())});
myClassloaderHolder = new AntBuildFileClassLoaderHolder(myAllOptions);
}
示例7: processForwardDependencies
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static boolean processForwardDependencies(@NotNull XmlFile file, Processor<XmlFile> processor) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return true;
}
final Project project = file.getProject();
final VirtualFile[] files = FileIncludeManager.getManager(project).getIncludedFiles(virtualFile, true);
return _process(files, project, processor);
}
示例8: processBackwardDependencies
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public static boolean processBackwardDependencies(@NotNull XmlFile file, Processor<XmlFile> processor) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return true;
}
final Project project = file.getProject();
final VirtualFile[] files = FileIncludeManager.getManager(project).getIncludingFiles(virtualFile, true);
return _process(files, project, processor);
}
示例9: DomElementsTrafficLightRenderer
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
public DomElementsTrafficLightRenderer(@NotNull XmlFile xmlFile) {
super(xmlFile.getProject(),
PsiDocumentManager.getInstance(xmlFile.getProject()).getDocument(xmlFile), xmlFile);
}
示例10: execute
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
@Override
public boolean execute(@NotNull final PsiElement queryParameters, @NotNull final Processor<PsiElement> consumer) {
if (queryParameters instanceof XmlTagImpl) {
final XmlTagImpl xml = (XmlTagImpl) queryParameters;
if (isTypeElement(xml)) {
final Collection<SchemaTypeInfo> infos = ApplicationManager.getApplication().runReadAction(new Computable<Collection<SchemaTypeInfo>>() {
@Override
public Collection<SchemaTypeInfo> compute() {
return gatherInheritors(xml);
}
});
if (infos != null && ! infos.isEmpty()) {
final XmlFile file = XmlUtil.getContainingFile(xml);
final Project project = file.getProject();
final Module module = ModuleUtilCore.findModuleForPsiElement(queryParameters);
//if (module == null) return false;
final VirtualFile vf = file.getVirtualFile();
String thisNs = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return XmlNamespaceIndex.getNamespace(vf, project, file);
}
});
thisNs = thisNs == null ? getDefaultNs(file) : thisNs;
// so thisNs can be null
if (thisNs == null) return false;
final ArrayList<SchemaTypeInfo> infosLst = new ArrayList<SchemaTypeInfo>(infos);
Collections.sort(infosLst);
final Map<String, Set<XmlFile>> nsMap = new HashMap<String, Set<XmlFile>>();
for (final SchemaTypeInfo info : infosLst) {
Set<XmlFile> targetFiles = nsMap.get(info.getNamespaceUri());
if (targetFiles == null) {
targetFiles = new HashSet<XmlFile>();
if (Comparing.equal(info.getNamespaceUri(), thisNs)) {
targetFiles.add(file);
}
final Collection<XmlFile> files = ApplicationManager.getApplication().runReadAction(new Computable<Collection<XmlFile>>() {
@Override
public Collection<XmlFile> compute() {
return XmlUtil.findNSFilesByURI(info.getNamespaceUri(), project, module);
}
});
if (files != null) {
targetFiles.addAll(files);
}
nsMap.put(info.getNamespaceUri(), targetFiles);
}
if (! targetFiles.isEmpty()) {
for (final XmlFile targetFile : targetFiles) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
final String prefixByURI = XmlUtil.findNamespacePrefixByURI(targetFile, info.getNamespaceUri());
if (prefixByURI == null) return;
final PsiElementProcessor processor = new PsiElementProcessor() {
@Override
public boolean execute(@NotNull PsiElement element) {
if (element instanceof XmlTagImpl) {
if (isCertainTypeElement((XmlTagImpl)element, info.getTagName(), prefixByURI) ||
isElementWithEmbeddedType((XmlTagImpl)element, info.getTagName(), prefixByURI)) {
consumer.process(element);
return false;
}
}
return true;
}
};
XmlUtil.processXmlElements(targetFile, processor, true);
}
});
}
}
}
}
}
}
return true;
}
示例11: gatherInheritors
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
private Collection<SchemaTypeInfo> gatherInheritors(XmlTagImpl xml) {
XmlAttribute name = getNameAttr(xml);
if (name == null || StringUtil.isEmptyOrSpaces(name.getValue())) return null;
String localName = name.getValue();
final boolean hasPrefix = localName.contains(":");
localName = hasPrefix ? localName.substring(localName.indexOf(':') + 1) : localName;
final String nsPrefix = hasPrefix ? name.getValue().substring(0, name.getValue().indexOf(':')) : null;
final XmlFile file = XmlUtil.getContainingFile(xml);
if (file == null) return null;
final Project project = file.getProject();
if (project == null) return null;
final Set<SchemaTypeInfo> result = new HashSet<SchemaTypeInfo>();
final ArrayDeque<SchemaTypeInfo> queue = new ArrayDeque<SchemaTypeInfo>();
String nsUri;
if (! hasPrefix) {
nsUri = getDefaultNs(file);
} else {
nsUri = XmlUtil.findNamespaceByPrefix(nsPrefix, file.getRootTag());
}
if (nsUri == null) return null;
queue.add(new SchemaTypeInfo(localName, true, nsUri));
final PairConvertor<String,String,List<Set<SchemaTypeInfo>>> worker =
SchemaTypeInheritanceIndex.getWorker(project, file.getContainingFile().getVirtualFile());
while (! queue.isEmpty()) {
final SchemaTypeInfo info = queue.removeFirst();
final List<Set<SchemaTypeInfo>> childrenOfType = worker.convert(info.getNamespaceUri(), info.getTagName());
for (Set<SchemaTypeInfo> infos : childrenOfType) {
for (SchemaTypeInfo typeInfo : infos) {
if (typeInfo.isIsTypeName()) {
queue.add(typeInfo);
}
result.add(typeInfo);
}
}
}
return result;
}
示例12: getMenuIdNames
import com.intellij.psi.xml.XmlFile; //导入方法依赖的package包/类
@Override
public List<String> getMenuIdNames() {
if (myMenus != null) {
return myMenus;
}
boolean token = RenderSecurityManager.enterSafeRegion(myCredential);
try {
final XmlFile xmlFile = myRenderTask.getPsiFile();
String commaSeparatedMenus = xmlFile == null ? null : AndroidPsiUtils.getRootTagAttributeSafely(xmlFile, ATTR_MENU, TOOLS_URI);
if (commaSeparatedMenus != null) {
myMenus = new ArrayList<String>();
Iterables.addAll(myMenus, Splitter.on(',').trimResults().omitEmptyStrings().split(commaSeparatedMenus));
} else {
final String fqn = xmlFile == null ? null : AndroidPsiUtils.getDeclaredContextFqcn(myRenderTask.getModule(), xmlFile);
if (fqn != null) {
final Project project = xmlFile.getProject();
DumbService.getInstance(project).smartInvokeLater(new Runnable() {
@Override
public void run() {
// Glance at the onCreateOptionsMenu of the associated context and use any menus found there.
// This is just a simple textual search; we need to replace this with a proper model lookup.
PsiClass clz = JavaPsiFacade.getInstance(project).findClass(fqn, GlobalSearchScope.allScope(project));
if (clz != null) {
for (PsiMethod method : clz.findMethodsByName(ON_CREATE_OPTIONS_MENU, true)) {
if (method instanceof PsiCompiledElement) {
continue;
}
// TODO: This should instead try to use the GotoRelated implementation's notion
// of associated activities; see what is done in
// AndroidMissingOnClickHandlerInspection. However, the AndroidGotoRelatedProvider
// will first need to properly handle menus.
String matchText = method.getText();
Matcher matcher = MENU_FIELD_PATTERN.matcher(matchText);
Set<String> menus = Sets.newTreeSet();
int index = 0;
while (true) {
if (matcher.find(index)) {
menus.add(matcher.group(1));
index = matcher.end();
} else {
break;
}
}
if (!menus.isEmpty()) {
myMenus = new ArrayList<String>(menus);
}
}
}
}
});
}
}
if (myMenus == null) {
myMenus = Collections.emptyList();
}
} finally {
RenderSecurityManager.exitSafeRegion(token);
}
return myMenus;
}