本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFile.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.isValid方法的具体用法?Java VirtualFile.isValid怎么用?Java VirtualFile.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VirtualFile
的用法示例。
在下文中一共展示了VirtualFile.isValid方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDictionaryFileFromInclude
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
private static XmlFile getDictionaryFileFromInclude(@NotNull Project project, IncludedXmlTag xmlIncludeTag) {
XmlFile xmlFile = null;
XmlElement origXmlElement = xmlIncludeTag.getOriginal();
PsiFile origPsiFile = origXmlElement != null ? origXmlElement.getContainingFile() : null;
if (origPsiFile instanceof XmlFile) {
xmlFile = (XmlFile) origPsiFile;
AppleScriptSystemDictionaryRegistryService dictionaryService = ServiceManager.getService(AppleScriptSystemDictionaryRegistryService
.class);
VirtualFile vFile = origPsiFile.getVirtualFile();
DictionaryInfo dInfo = dictionaryService.getDictionaryInfoByApplicationPath(vFile.getPath());
if (dInfo != null) {
File ioFile = dInfo.getDictionaryFile();
if (ioFile.exists()) {
vFile = LocalFileSystem.getInstance().findFileByIoFile(ioFile);
if (vFile == null || !vFile.isValid()) return null;
PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
xmlFile = (XmlFile) psiFile;
}
}
}
return xmlFile;
}
示例2: createDictionaryFromInfo
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
private ApplicationDictionary createDictionaryFromInfo(final @NotNull DictionaryInfo dInfo) {
if (!dInfo.isInitialized()) {
//dictionary terms must be ridden from the dictionary file before creating a PSI for it
LOG.error("Attempt to create dictionary for not initialized Dictionary Info for application" + dInfo.getApplicationName());
return null;
}
String applicationName = dInfo.getApplicationName();
VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(dInfo.getDictionaryFile());
if (vFile != null && vFile.isValid()) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
XmlFile xmlFile = (XmlFile) psiFile;
if (xmlFile != null) {
ApplicationDictionary dictionary = new ApplicationDictionaryImpl(project, xmlFile, applicationName, dInfo.getApplicationFile());
dictionaryMap.put(applicationName, dictionary);
return dictionary;
}
}
LOG.warn("Failed to create dictionary from info for application: " + applicationName + ". Reason: file is null");
return null;
}
示例3: processIncludes
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private static void processIncludes(@NotNull ApplicationDictionary parsedDictionary, @Nullable XmlTag[] includes) {
if (includes == null) return;
for (XmlTag include : includes) {
String hrefIncl = include.getAttributeValue("href");
if (!StringUtil.isEmpty(hrefIncl)) {
hrefIncl = hrefIncl.replace("file://localhost", "");
File includedFile = new File(hrefIncl);
// ((IncludedXmlTag) suiteTag).getOriginal().getContainingFile();
//as there is assertion error (java.lang.AssertionError: File accessed outside allowed roots),
// we are trying to find if the dictionary file for this included dictionary was already generated
AppleScriptSystemDictionaryRegistryService dictionarySystemRegistry = ServiceManager
.getService(AppleScriptSystemDictionaryRegistryService.class);
VirtualFile vFile;
File ioFile = null;
DictionaryInfo dInfo = dictionarySystemRegistry.getDictionaryInfoByApplicationPath(includedFile.getPath());
if (dInfo != null) {
ioFile = dInfo.getDictionaryFile();
} else if (includedFile.isFile()) {
String fName = includedFile.getName();
int index = fName.lastIndexOf('.');
fName = index < 0 ? fName : fName.substring(0, index);
ioFile = dictionarySystemRegistry.getDictionaryFile(fName);
}
if (ioFile == null || !ioFile.exists()) ioFile = includedFile;
if (ioFile.exists()) {
vFile = LocalFileSystem.getInstance().findFileByIoFile(ioFile);
if (vFile == null || !vFile.isValid()) continue;
PsiFile psiFile = PsiManager.getInstance(parsedDictionary.getProject()).findFile(vFile);
XmlFile xmlFile = (XmlFile) psiFile;
if (xmlFile != null) {
parsedDictionary.processInclude(xmlFile);
}
}
}
}
}
示例4: extractVirtualFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private VirtualFile extractVirtualFile() {
for (SeedStackSimpleNode each : getSelectedNodes(SeedStackSimpleNode.class)) {
VirtualFile file = each.getVirtualFile();
if (file != null && file.isValid()) return file;
}
return null;
}
示例5: extractVirtualFiles
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private Object extractVirtualFiles() {
final List<VirtualFile> files = new ArrayList<>();
for (SeedStackSimpleNode each : getSelectedNodes(SeedStackSimpleNode.class)) {
VirtualFile file = each.getVirtualFile();
if (file != null && file.isValid()) files.add(file);
}
return files.isEmpty() ? null : VfsUtil.toVirtualFileArray(files);
}
示例6: createNavigatableForFile
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
public static Navigatable createNavigatableForFile(final Project project, final VirtualFile file) {
if (file != null && file.isValid()) {
final PsiFile result = PsiManager.getInstance(project).findFile(file);
return result == null ? null : new NavigatableAdapter() {
public void navigate(boolean requestFocus) {
navigate(project, file, 0, requestFocus);
}
};
} else {
return null;
}
}
示例7: isInterfaceMadeStructuralByExtension
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private boolean isInterfaceMadeStructuralByExtension( PsiClass psiInterface, ManModule module )
{
final String fqn = psiInterface.getQualifiedName();
ManModule manModule = ManProject.getModule( module.getIjModule() );
for( ITypeManifold sp : manModule.getTypeManifolds() )
{
if( sp.getProducerKind() == Supplemental )
{
if( sp.isType( fqn ) )
{
List<IFile> files = sp.findFilesForType( fqn );
for( IFile file : files )
{
VirtualFile vExtensionClassFile = ((IjFile)file).getVirtualFile();
if( !vExtensionClassFile.isValid() )
{
continue;
}
PsiJavaFile psiExtClassJavaFile =
(PsiJavaFile)PsiManager.getInstance( module.getIjModule().getProject() ).findFile( vExtensionClassFile );
PsiClass[] classes = psiExtClassJavaFile.getClasses();
if( classes.length > 0 )
{
PsiClass psiExtClass = classes[0];
if( psiExtClass.getModifierList().findAnnotation( Structural.class.getName() ) != null )
{
return true;
}
}
}
}
}
}
return false;
}
示例8: markTemporaryWritable
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
/**
* Requests to temporary ignore the read-only status provided by this provider.
* Does nothing if read-only status is for some other reason
*/
public void markTemporaryWritable(@NotNull VirtualFile vFile) {
if (vFile.isValid() && !isPotentiallyWritable(vFile)) {
vFile.putUserData(KEY_TEMPORARY_WRITABLE, true);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:10,代码来源:HybrisWritingAccessProvider.java
示例9: unmarkTemporaryWritable
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
/**
* Clears any possible flag marked by {@link #markTemporaryWritable(VirtualFile)} call
*/
public static void unmarkTemporaryWritable(@NotNull VirtualFile vFile) {
if (vFile.isValid()) {
vFile.putUserData(KEY_TEMPORARY_WRITABLE, null);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:9,代码来源:HybrisWritingAccessProvider.java
示例10: addMethods
import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private void addMethods( String fqn, PsiClass psiClass, List<PsiElement> augFeatures, Module start, Module module )
{
ManModule manModule = ManProject.getModule( module );
for( ITypeManifold sp : manModule.getTypeManifolds() )
{
if( sp.getProducerKind() == Supplemental )
{
if( sp.isType( fqn ) )
{
List<IFile> files = sp.findFilesForType( fqn );
for( IFile file : files )
{
VirtualFile vFile = ((IjFile)file).getVirtualFile();
if( !vFile.isValid() )
{
continue;
}
PsiFile psiFile = PsiManager.getInstance( module.getProject() ).findFile( vFile );
PsiJavaFile psiJavaFile = (PsiJavaFile)psiFile;
PsiClass[] classes = psiJavaFile.getClasses();
if( classes.length > 0 )
{
SrcClass srcExtClass = new StubBuilder().make( classes[0].getQualifiedName(), manModule );
SrcClass scratchClass = new SrcClass( psiClass.getQualifiedName(), psiClass.isInterface() ? SrcClass.Kind.Interface : SrcClass.Kind.Class );
for( PsiTypeParameter tv : psiClass.getTypeParameters() )
{
scratchClass.addTypeVar( new SrcType( StubBuilder.makeTypeVar( tv ) ) );
}
for( AbstractSrcMethod m : srcExtClass.getMethods() )
{
SrcMethod srcMethod = addExtensionMethod( scratchClass, m, psiClass );
if( srcMethod != null )
{
PsiMethod extMethod = makePsiMethod( srcMethod, psiClass );
if( extMethod != null )
{
PsiMethod plantedMethod = plantMethodInPsiClass( extMethod, psiClass, classes[0] );
augFeatures.add( plantedMethod );
}
}
}
}
}
}
}
}
for( Dependency d : manModule.getDependencies() )
{
if( module == start || d.isExported() )
{
addMethods( fqn, psiClass, augFeatures, start, ((ManModule)d.getModule()).getIjModule() );
}
}
}