當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiFile.putUserData方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiFile.putUserData方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiFile.putUserData方法的具體用法?Java PsiFile.putUserData怎麽用?Java PsiFile.putUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiFile的用法示例。


在下文中一共展示了PsiFile.putUserData方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getViewVariables

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@NotNull
public static ArrayList<String> getViewVariables(PsiFile psiFile) {
    ArrayList<String> result = null;

    Long viewModified = psiFile.getUserData(VIEW_FILE_MODIFIED);
    if (viewModified != null && psiFile.getModificationStamp() == viewModified) {
        result = psiFile.getUserData(VIEW_VARIABLES);
    }

    if (result == null) {
        if (psiFile instanceof PhpFile) {
            result = getPhpViewVariables(psiFile);
        }

        if (result == null) {
            result = new ArrayList<>();
        }

        psiFile.putUserData(VIEW_VARIABLES, result);
        psiFile.putUserData(VIEW_FILE_MODIFIED, psiFile.getModificationStamp());
    }

    return new ArrayList<>(result);
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:25,代碼來源:ViewsUtil.java

示例2: findDirectory

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
private static PsiDirectory findDirectory(PsiElement element) {
    final PhpClass phpClass = PsiTreeUtil.getParentOfType(element, PhpClass.class);
    final PsiFile file = element.getContainingFile();
    if (phpClass != null) {
        return findClassDirectory(phpClass, file);
    }

    PsiDirectory context = file.getOriginalFile().getContainingDirectory();
    if (context != null) {
        PsiDirectory root = context.getParentDirectory();
        while (root != null && !root.getName().equals("views")) {
            root = root.getParentDirectory();
        }

        file.putUserData(VIEWS_CONTEXT_DIRECTORY, context);
        file.putUserData(VIEWS_DIRECTORY, root);
        file.putUserData(VIEWS_DIRECTORY_MODIFIED, file.getModificationStamp());

        return root;
    }

    return null;
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:25,代碼來源:ViewsUtil.java

示例3: getTypeSystemMeta

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Override
public synchronized TSMetaModel getTypeSystemMeta(@Nullable final PsiFile contextFile) {
    if (contextFile == null || !TSMetaModelBuilder.isTsFile(contextFile)) {
        return myCachedValue.getValue();
    }
    final TSMetaModelImpl externalModel = doGetExternalModel(contextFile);
    final Project project = contextFile.getProject();
    CachedValue<TSMetaModelImpl> fileModelCache = contextFile.getUserData(FILE_MODEL_CACHE_KEY);

    if (fileModelCache == null) {
        fileModelCache = CachedValuesManager.getManager(project).createCachedValue(
            () -> ApplicationManager.getApplication().runReadAction(
                (Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {

                    final TSMetaModelBuilder builder = new TSMetaModelBuilder(project);
                    final TSMetaModelImpl modelForFile = builder.buildModelForFile(contextFile);
                    return CachedValueProvider.Result.create(modelForFile, contextFile);

                }), false);
        contextFile.putUserData(FILE_MODEL_CACHE_KEY, fileModelCache);
    }
    final TSMetaModelImpl fileModel = fileModelCache.getValue();
    return new TSMetaModelImpl(Arrays.asList(externalModel, fileModel));
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:25,代碼來源:TSMetaModelAccessImpl.java

示例4: doGetExternalModel

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@NotNull
private TSMetaModelImpl doGetExternalModel(final @NotNull PsiFile contextFile) {
    final PsiFile originalFile = contextFile.getOriginalFile();
    final VirtualFile vFile = originalFile.getVirtualFile();
    final Project project = originalFile.getProject();
    CachedValue<TSMetaModelImpl> externalModelCache = originalFile.getUserData(EXTERNAL_MODEL_CACHE_KEY);

    if (externalModelCache == null) {

        externalModelCache = CachedValuesManager.getManager(project).createCachedValue(
            () -> ApplicationManager.getApplication().runReadAction(
                (Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {

                    final List<VirtualFile> excludes = vFile == null
                        ? Collections.emptyList()
                        : Collections.singletonList(vFile);

                    final TSMetaModelBuilder builder = new TSMetaModelBuilder(project, excludes);
                    final TSMetaModelImpl model = builder.buildModel();
                    return CachedValueProvider.Result.create(model, builder.getFiles());

                }), false);
        originalFile.putUserData(EXTERNAL_MODEL_CACHE_KEY, externalModelCache);
    }
    return externalModelCache.getValue();
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:27,代碼來源:TSMetaModelAccessImpl.java

示例5: initialize

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
public void initialize( PsiClass delegate, List<IFile> files, String fqn, DiagnosticCollector issues )
{
  _ifiles = files;
  _fqn = fqn;
  _issues = issues;
  PsiManager manager = PsiManagerImpl.getInstance( delegate.getProject() );
  _files = new ArrayList<>( _ifiles.size() );
  for( IFile ifile : _ifiles )
  {
    VirtualFile vfile = ((IjFile)ifile).getVirtualFile();
    if( vfile != null )
    {
      PsiFile file = manager.findFile( vfile );
      _files.add( file );

      Module module = ModuleUtilCore.findModuleForFile( vfile, delegate.getProject() );
      if( module != null )
      {
        file.putUserData( ModuleUtil.KEY_MODULE, module );
      }
    }
  }
  delegate.getContainingFile().putUserData( KEY_MANIFOLD_PSI_CLASS, this );
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:25,代碼來源:ManifoldPsiClass.java

示例6: findClassDirectory

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
private static PsiDirectory findClassDirectory(PhpClass phpClass, PsiFile file) {
    if (phpClass != null) {
        Method getViewPath = phpClass.findMethodByName("getViewPath");
        PhpClass ownClass = phpClass.getSuperClass();
        PsiDirectory directory = file.getOriginalFile().getContainingDirectory();
        if (directory != null) {
            while (ownClass != null) {
                if (getViewPath != null) {
                    getViewPath = ownClass.findMethodByName("getViewPath");
                }
                switch (ownClass.getFQN()) {
                    case "\\yii\\base\\Controller":
                        directory = directory.getParentDirectory();
                        if (directory == null) {
                            return null;
                        }
                        if (getViewPath != null && Objects.equals(getViewPath.getContainingClass(), ownClass)) {
                            directory = directory.findSubdirectory("views");
                        }

                        if (directory != null) {
                            file.putUserData(VIEWS_DIRECTORY_MODIFIED, file.getModificationStamp());
                            file.putUserData(VIEWS_DIRECTORY, directory);

                            String controllerId = phpClass.getName();
                            controllerId = controllerId.substring(0, controllerId.length() - 10);
                            controllerId = new SplitWordsMacro.LowercaseAndDash().convertString(controllerId);

                            PsiDirectory context = directory.findSubdirectory(controllerId);
                            if (context != null) {
                                file.putUserData(VIEWS_CONTEXT_DIRECTORY, context);
                            }
                        }

                        return directory;
                    case "\\yii\\base\\Widget":
                        directory = directory.findSubdirectory("views");
                        if (directory != null) {
                            file.putUserData(VIEWS_DIRECTORY_MODIFIED, file.getModificationStamp());
                            file.putUserData(VIEWS_DIRECTORY, directory);
                            file.putUserData(VIEWS_CONTEXT_DIRECTORY, directory);
                        }

                        return directory;
                }
                ownClass = ownClass.getSuperClass();
            }
        }
    }

    return null;
}
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:54,代碼來源:ViewsUtil.java

示例7: testFrom

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
public void testFrom() {
    final PsiFile           sampleFile = getResourceFile("utils/DummyFile.php");
    final Key<List<String>> sampleKey  = new Key("SampleKey");

    final Object instanceOriginal    = UserDataHolderUtil.from(sampleFile, sampleKey, Object::new);
    final Object instanceShoudBeSame = UserDataHolderUtil.from(sampleFile, sampleKey, Object::new);

    Assert.assertSame(instanceShoudBeSame, instanceOriginal);

    sampleFile.putUserData(sampleKey, null);

    final Object instanceShoudBeAnotherInstance = UserDataHolderUtil.from(sampleFile, sampleKey, Object::new);

    Assert.assertNotSame(instanceShoudBeAnotherInstance, instanceOriginal);
}
 
開發者ID:rentalhost,項目名稱:laravel-insight,代碼行數:16,代碼來源:UserDataHolderUtilTest.java


注:本文中的com.intellij.psi.PsiFile.putUserData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。