本文整理汇总了Java中org.jetbrains.plugins.groovy.lang.psi.GroovyFile.isScript方法的典型用法代码示例。如果您正苦于以下问题:Java GroovyFile.isScript方法的具体用法?Java GroovyFile.isScript怎么用?Java GroovyFile.isScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jetbrains.plugins.groovy.lang.psi.GroovyFile
的用法示例。
在下文中一共展示了GroovyFile.isScript方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIcon
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
@Nullable
@Override
public Icon getIcon(@NotNull VirtualFile virtualFile, @Iconable.IconFlags int flags, @Nullable Project project) {
if (project == null || virtualFile.getFileType() != GroovyFileType.GROOVY_FILE_TYPE) return null;
final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
if (!(psiFile instanceof GroovyFile)) return null;
final GroovyFile file = (GroovyFile)psiFile;
final Icon icon;
if (file.isScript()) {
icon = GroovyScriptTypeDetector.getIcon(file);
}
else if (GrFileIndexUtil.isGroovySourceFile(file)) {
final GrTypeDefinition[] typeDefinitions = file.getTypeDefinitions();
icon = typeDefinitions.length > 0
? typeDefinitions[0].getIcon(flags)
: JetgroovyIcons.Groovy.Groovy_16x16;
}
else {
icon = JetgroovyIcons.Groovy.Groovy_outsideSources;
}
return ElementBase.createLayeredIcon(psiFile, icon, ElementBase.transformFlags(psiFile, flags));
}
示例2: getScriptClassesByFQName
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
public List<PsiClass> getScriptClassesByFQName(final String name, final GlobalSearchScope scope, final boolean srcOnly) {
GlobalSearchScope actualScope = srcOnly ? new GrSourceFilterScope(scope) : scope;
final Collection<GroovyFile> files = StubIndex.getElements(GrFullScriptNameIndex.KEY, name.hashCode(), myProject, actualScope,
GroovyFile.class);
if (files.isEmpty()) {
return Collections.emptyList();
}
final ArrayList<PsiClass> result = new ArrayList<PsiClass>();
for (GroovyFile file : files) {
if (file.isScript()) {
final PsiClass scriptClass = file.getScriptClass();
if (scriptClass != null && name.equals(scriptClass.getQualifiedName())) {
result.add(scriptClass);
}
}
}
return result;
}
示例3: appendImplicitlyImportedPackages
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
@Override
public List<String> appendImplicitlyImportedPackages(@NotNull GroovyFile file) {
if (file.isScript() && GroovyScriptUtil.getScriptType(file) instanceof GradleScriptType) {
return Arrays.asList(IMPLICIT_GRADLE_PACKAGES);
}
return Collections.emptyList();
}
示例4: GrFileStub
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
public GrFileStub(GroovyFile file) {
super(file);
myName = StringRef.fromString(file.getViewProvider().getVirtualFile().getNameWithoutExtension());
isScript = file.isScript();
final GrPackageDefinition definition = file.getPackageDefinition();
if (definition != null) {
myAnnotations = GrStubUtils.getAnnotationNames(definition);
} else {
myAnnotations = ArrayUtil.EMPTY_STRING_ARRAY;
}
}
示例5: isRenameFileOnClassRenaming
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
private boolean isRenameFileOnClassRenaming() {
final PsiFile file = getContainingFile();
if (!(file instanceof GroovyFile)) return false;
final GroovyFile groovyFile = (GroovyFile)file;
if (groovyFile.isScript()) return false;
final String name = getName();
final VirtualFile vFile = groovyFile.getVirtualFile();
return vFile != null && name != null && name.equals(vFile.getNameWithoutExtension());
}
示例6: getAntObjects
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; //导入方法依赖的package包/类
private static Map<String, Class> getAntObjects(final GroovyFile groovyFile) {
final Project project = groovyFile.getProject();
final Module module = ModuleUtil.findModuleForPsiElement(groovyFile);
Set<VirtualFile> jars = new HashSet<VirtualFile>();
if (module != null) {
ContainerUtil.addAll(jars, OrderEnumerator.orderEntries(module).getAllLibrariesAndSdkClassesRoots());
}
if (groovyFile.isScript() && GroovyScriptUtil.getScriptType(groovyFile) instanceof GantScriptType) {
jars.addAll(GantScriptType.additionalScopeFiles(groovyFile));
}
final ArrayList<URL> urls = new ArrayList<URL>();
for (VirtualFile jar : jars) {
VirtualFile localFile = PathUtil.getLocalFile(jar);
if (localFile.getFileSystem() instanceof LocalFileSystem) {
urls.add(VfsUtilCore.convertToURL(localFile.getUrl()));
}
}
AntClassLoader loader;
synchronized (ourLock) {
final Map<List<URL>, AntClassLoader> map = CachedValuesManager.getManager(project).getParameterizedCachedValue(project, KEY,
PROVIDER, false, project);
loader = map.get(urls);
if (loader == null) {
map.put(urls, loader = new AntClassLoader(urls));
}
}
return loader.getAntObjects();
}