本文整理汇总了Java中com.intellij.ide.highlighter.JavaFileType.INSTANCE属性的典型用法代码示例。如果您正苦于以下问题:Java JavaFileType.INSTANCE属性的具体用法?Java JavaFileType.INSTANCE怎么用?Java JavaFileType.INSTANCE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.ide.highlighter.JavaFileType
的用法示例。
在下文中一共展示了JavaFileType.INSTANCE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processedFile
private static boolean processedFile(PsiElement element, IconDescriptor iconDescriptor)
{
final PsiFile containingFile = element.getContainingFile();
if(containingFile == null)
{
return false;
}
final FileType fileType = containingFile.getFileType();
if(fileType != JavaFileType.INSTANCE && fileType != JavaClassFileType.INSTANCE)
{
return false;
}
final VirtualFile virtualFile = containingFile.getVirtualFile();
if(virtualFile == null)
{
return false;
}
if(!JavaProjectRootsUtil.isJavaSourceFile(element.getProject(), virtualFile, true))
{
iconDescriptor.setMainIcon(JavaIcons.FileTypes.JavaOutsideSource);
return true;
}
return false;
}
示例2: getInstance
public AbstractFileProvider getInstance(String type) {
if("java".equals(type)) {
return new DefaultProviderImpl(project, outputPath, JavaFileType.INSTANCE);
} else if("sql".equals(type)) {
return new DefaultProviderImpl(project, outputPath, SqlFileType.INSTANCE);
} else if("xml".equals(type)) {
return new DefaultProviderImpl(project, outputPath, XmlFileType.INSTANCE);
} else if("kt".equals(type)) {
return new DefaultProviderImpl(project, outputPath, KotlinFileType.INSTANCE);
} else {
return new DefaultProviderImpl(project, outputPath, MdFileType.INSTANCE);
}
}
示例3: shouldProcessInBatch
@Override
public boolean shouldProcessInBatch(@NotNull PsiFile psiFile) {
final boolean shouldHighlight = shouldHighlightFile(psiFile);
if (shouldHighlight) {
if (psiFile.getFileType() == JavaFileType.INSTANCE) {
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile != null && ProjectRootManager.getInstance(psiFile.getProject()).getFileIndex().isInLibrarySource(virtualFile)) {
return false;
}
}
}
return shouldHighlight;
}
示例4: ExtractMethodDialog
public ExtractMethodDialog(Project project,
PsiClass targetClass, final InputVariables inputVariables, PsiType returnType,
PsiTypeParameterList typeParameterList, PsiType[] exceptions, boolean isStatic, boolean canBeStatic,
final boolean canBeChainedConstructor,
String title,
String helpId,
Nullness nullness,
final PsiElement[] elementsToExtract) {
super(project, true);
myProject = project;
myTargetClass = targetClass;
myReturnType = returnType;
myTypeParameterList = typeParameterList;
myExceptions = exceptions;
myStaticFlag = isStatic;
myCanBeStatic = canBeStatic;
myNullness = nullness;
myElementsToExtract = elementsToExtract;
myVariableData = inputVariables;
myHelpId = helpId;
mySignature = new MethodSignatureComponent("", project, JavaFileType.INSTANCE);
mySignature.setPreferredSize(JBUI.size(500, 100));
mySignature.setMinimumSize(JBUI.size(500, 100));
setTitle(title);
myNameField = new NameSuggestionsField(suggestMethodNames(), myProject);
myMakeStatic = new NonFocusableCheckBox();
myMakeStatic.setText(RefactoringBundle.message("declare.static.checkbox"));
if (canBeChainedConstructor) {
myCbChainedConstructor = new NonFocusableCheckBox(RefactoringBundle.message("extract.chained.constructor.checkbox"));
}
init();
}
示例5: actionPerformed
@Override
public void actionPerformed(ActionEvent e) {
Project project = event.getData(PlatformDataKeys.PROJECT);
Editor editor = event.getData(PlatformDataKeys.EDITOR);
PsiFile currentFile = PsiUtilBase.getPsiFileInEditor(editor, project);
if (JavaFileType.INSTANCE != currentFile.getFileType())
return;
try {
File outputZip = File.createTempFile(project.getName(), ".zip");
VirtualFile file = buildTestProject(project, editor, currentFile);
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(file);
Ziper ziper = new Ziper(outputZip.getAbsolutePath(), project);
//sources folder
buildSources(ziper, module);
//Classpath
buildClasspath(ziper, module);
ProgressManager.getInstance().run(new NoPolTask(project, "NoPol is Fixing", outputZip.getAbsolutePath()));
ziper.close();
this.parent.close(0);
} catch (IOException e1) {
throw new RuntimeException(e1);
}
}
示例6: ExtractMethodDialog
public ExtractMethodDialog(Project project,
PsiClass targetClass, final InputVariables inputVariables, PsiType returnType,
PsiTypeParameterList typeParameterList, PsiType[] exceptions, boolean isStatic, boolean canBeStatic,
final boolean canBeChainedConstructor,
String initialMethodName,
String title,
String helpId,
final PsiElement[] elementsToExtract) {
super(project);
myProject = project;
myTargetClass = targetClass;
myReturnType = returnType;
myTypeParameterList = typeParameterList;
myExceptions = exceptions;
myStaticFlag = isStatic;
myCanBeStatic = canBeStatic;
myElementsToExtract = elementsToExtract;
myVariableData = inputVariables;
myHelpId = helpId;
mySignature = new MethodSignatureComponent("", project, JavaFileType.INSTANCE);
mySignature.setPreferredSize(new Dimension(500, 100));
mySignature.setMinimumSize(new Dimension(500, 100));
setTitle(title);
// Create UI components
myNameField = createNameField(initialMethodName);
int height = myVariableData.getInputVariables().size() + 2;
if (myExceptions.length > 0) {
height += myExceptions.length + 1;
}
myMakeStatic = new NonFocusableCheckBox();
myMakeStatic.setText(RefactoringBundle.message("declare.static.checkbox"));
if (canBeChainedConstructor) {
myCbChainedConstructor = new NonFocusableCheckBox(RefactoringBundle.message("extract.chained.constructor.checkbox"));
}
init();
}
示例7: transform
@NotNull
@Override
@RequiredReadAction
public PsiFile transform(String fileName, @NotNull MsilFile msilFile)
{
DotNetNamedElement[] members = msilFile.getMembers();
StringBuilder builder = new StringBuilder();
for(DotNetNamedElement member : members)
{
JavaClassStubBuilder build = StubBuilder.build((DotNetTypeDeclaration) member);
if(build == null)
{
continue;
}
build.buildToText(builder, null);
builder.append("\n");
}
VirtualFile virtualFile = new MsilFileRepresentationVirtualFile(fileName, JavaFileType.INSTANCE, builder);
SingleRootFileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(msilFile.getProject()), virtualFile, true);
final PsiJavaFileImpl file = new PsiJavaFileImpl(viewProvider);
viewProvider.forceCachedPsi(file);
((PsiManagerEx) PsiManager.getInstance(msilFile.getProject())).getFileManager().setViewProvider(virtualFile, viewProvider);
new WriteCommandAction.Simple<Object>(file.getProject(), file)
{
@Override
protected void run() throws Throwable
{
CodeStyleManager.getInstance(getProject()).reformat(file);
}
}.execute();
return file;
}
示例8: AbstractJavaInplaceIntroducer
public AbstractJavaInplaceIntroducer(final Project project,
Editor editor,
PsiExpression expr,
PsiVariable localVariable,
PsiExpression[] occurrences,
TypeSelectorManagerImpl typeSelectorManager, String title) {
super(project, InjectedLanguageUtil.getTopLevelEditor(editor), expr, localVariable, occurrences, title, JavaFileType.INSTANCE);
myTypeSelectorManager = typeSelectorManager;
}
示例9: isCompilableFile
@Override
public boolean isCompilableFile(VirtualFile file, CompileContext context)
{
if(!myCompilerConfiguration.isAnnotationProcessorsEnabled())
{
return false;
}
return file.getFileType() == JavaFileType.INSTANCE && !isExcludedFromAnnotationProcessing(file, context);
}
示例10: collectReferences
@Nullable
public TreeMap<Integer, PsiReference> collectReferences(PsiFile psiFile, Map<PsiFile, PsiFile> filesMap) {
if (isGenerateHyperlinksToClasses) {
FileType fileType = psiFile.getFileType();
if (JavaFileType.INSTANCE == fileType /*|| StdFileTypes.JSP == fileType*/) {
final TreeMap<Integer, PsiReference> refMap = new TreeMap<Integer, PsiReference>();
findClassReferences(psiFile, refMap, filesMap, psiFile);
return refMap;
}
}
return null;
}
示例11: getInputFilter
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter()
{
return new DefaultFileTypeSpecificInputFilter(JavaFileType.INSTANCE)
{
@Override
public boolean acceptInput(@Nullable Project project, @NotNull VirtualFile file)
{
return JavaStubElementTypes.JAVA_FILE.shouldBuildStubFor(file);
}
};
}
示例12: isJavaSourceFile
public static boolean isJavaSourceFile(@NotNull Project project, @NotNull VirtualFile file, boolean withLibrary)
{
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
if(file.isDirectory())
{
return false;
}
if(file.getFileType() != JavaFileType.INSTANCE && !withLibrary)
{
return false;
}
if(fileTypeManager.isFileIgnored(file))
{
return false;
}
if(!withLibrary)
{
Module module = ModuleUtilCore.findModuleForFile(file, project);
if(module == null)
{
return false;
}
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
if(moduleRootManager.getExtension(JavaModuleExtension.class) == null)
{
return false;
}
}
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
if(isInsideResourceRoot(file, fileIndex))
{
return false;
}
return fileIndex.isInSource(file) || withLibrary && fileIndex.isInLibraryClasses(file);
}
示例13: getAdditionalResolveScope
@Override
public SearchScope getAdditionalResolveScope(@NotNull VirtualFile file, Project project)
{
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(project);
if(index.isInLibraryClasses(file) || index.isInContent(file))
{
return null;
}
FileType fileType = file.getFileType();
if(fileType == JavaFileType.INSTANCE || fileType == JavaClassFileType.INSTANCE)
{
for(PsiElementFinder finder : Extensions.getExtensions(PsiElementFinder.EP_NAME, project))
{
if(finder instanceof NonClasspathClassFinder)
{
final List<VirtualFile> roots = ((NonClasspathClassFinder) finder).getClassRoots();
for(VirtualFile root : roots)
{
if(VfsUtilCore.isAncestor(root, file, true))
{
return NonClasspathDirectoriesScope.compose(roots);
}
}
}
}
}
return null;
}
示例14: createDummyJavaFile
private PsiJavaFile createDummyJavaFile( String type, PsiManager manager, final String text )
{
final FileType fileType = JavaFileType.INSTANCE;
return (PsiJavaFile)PsiFileFactory.getInstance( manager.getProject() ).createFileFromText( type + '.' + JavaFileType.INSTANCE.getDefaultExtension(), fileType, text );
}
示例15: getInputFilter
@NotNull
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new DefaultFileTypeSpecificInputFilter(JavaFileType.INSTANCE);
}