本文整理汇总了Java中com.intellij.openapi.fileTypes.LanguageFileType类的典型用法代码示例。如果您正苦于以下问题:Java LanguageFileType类的具体用法?Java LanguageFileType怎么用?Java LanguageFileType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LanguageFileType类属于com.intellij.openapi.fileTypes包,在下文中一共展示了LanguageFileType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromTemplate
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
/**
* @param templateFile Name of the generated file
* @param destinationPath Relative path to the target file system entry
* @param extensionDefinition Extension definition containing all relevant metadata
* @param context Template Context variables
* @param project Project in context
*/
public static PsiElement fromTemplate(@NotNull String templateFile, @NotNull String destinationPath, @NotNull String destinationFileName, @NotNull TYPO3ExtensionDefinition extensionDefinition, @NotNull Map<String, String> context, Project project) {
String template = readTemplateToString(templateFile, context);
VirtualFile targetDirectory = getOrCreateDestinationPath(extensionDefinition.getRootDirectory(), destinationPath);
LanguageFileType fileType = FileTypes.PLAIN_TEXT;
if (templateFile.endsWith(".php")) {
fileType = PhpFileType.INSTANCE;
}
PsiFile fileFromText = PsiFileFactory.getInstance(project).createFileFromText(destinationFileName, fileType, template);
CodeStyleManager.getInstance(project).reformat(fileFromText);
return PsiDirectoryFactory
.getInstance(project)
.createDirectory(targetDirectory)
.add(fileFromText);
}
示例2: publicClassName
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
@NotNull
private static String publicClassName(@NotNull Project project, @NotNull TaskFile taskFile, @NotNull LanguageFileType fileType) {
String fileName = "Main";
PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(taskFile.name, fileType, taskFile.text);
if (file instanceof PsiClassOwner) {
PsiClassOwner fileFromText = (PsiClassOwner) file;
PsiClass[] classes = fileFromText.getClasses();
for (PsiClass aClass : classes) {
boolean isPublic = aClass.hasModifierProperty(PsiModifier.PUBLIC);
if (isPublic && aClass.getName() != null) {
fileName = aClass.getName();
break;
}
}
}
return fileName;
}
示例3: assertIntentionIsAvailable
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
public void assertIntentionIsAvailable(LanguageFileType languageFileType, String configureByText, String intentionText) {
myFixture.configureByText(languageFileType, configureByText);
PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
Set<String> items = new HashSet<>();
for (IntentionAction intentionAction : IntentionManager.getInstance().getIntentionActions()) {
if(!intentionAction.isAvailable(getProject(), getEditor(), psiElement.getContainingFile())) {
continue;
}
String text = intentionAction.getText();
items.add(text);
if(!text.equals(intentionText)) {
continue;
}
return;
}
fail(String.format("Fail intention action '%s' is available in element '%s' with '%s'", intentionText, psiElement.getText(), items));
}
示例4: getAssociatedFileType
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
private static LanguageFileType getAssociatedFileType(VirtualFile file, Project project) {
if (project == null) {
return null;
}
Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);
LanguageFileType associatedFileType = null;
if (language != null) {
associatedFileType = language.getAssociatedFileType();
}
if (language == null || associatedFileType == null) {
associatedFileType = RythmLanguage.getDefaultTemplateLang();
}
return associatedFileType;
}
示例5: getAssociatedFileType
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
private static LanguageFileType getAssociatedFileType(VirtualFile file, Project project) {
if (project == null) {
return null;
}
Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);
LanguageFileType associatedFileType = null;
if (language != null) {
associatedFileType = language.getAssociatedFileType();
}
if (language == null || associatedFileType == null) {
associatedFileType = JetLanguage.getDefaultTemplateLang();
}
return associatedFileType;
}
示例6: JSR45PositionManager
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
public JSR45PositionManager(DebugProcess debugProcess, Scope scope, final String stratumId, final LanguageFileType[] acceptedFileTypes,
final SourcesFinder<Scope> sourcesFinder) {
myDebugProcess = debugProcess;
myScope = scope;
myStratumId = stratumId;
myFileTypes = Collections.unmodifiableSet(new HashSet<LanguageFileType>(Arrays.asList(acceptedFileTypes)));
mySourcesFinder = sourcesFinder;
String generatedClassPattern = getGeneratedClassesPackage();
if(generatedClassPattern.length() == 0) {
generatedClassPattern = getGeneratedClassesNamePattern();
}
else {
generatedClassPattern = generatedClassPattern + "." + getGeneratedClassesNamePattern();
}
GENERATED_CLASS_PATTERN = generatedClassPattern;
myGeneratedClassPatternMatcher = Pattern.compile(generatedClassPattern.replaceAll("\\*", ".*")).matcher("");
}
示例7: acceptInput
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
@Override
public boolean acceptInput(@NotNull final VirtualFile file) {
if (!file.isInLocalFileSystem()) {
return false; // do not index TODOs in library sources
}
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
final Language lang = ((LanguageFileType)fileType).getLanguage();
final ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
final TokenSet commentTokens = parserDef != null ? parserDef.getCommentTokens() : null;
return commentTokens != null;
}
return PlatformIdTableBuilding.isTodoIndexerRegistered(fileType) ||
fileType instanceof CustomSyntaxTableFileType;
}
示例8: createTreeFromText
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
public static PsiElement[] createTreeFromText(String text,
PatternTreeContext context,
FileType fileType,
Language language,
String contextName,
Project project,
boolean physical) throws IncorrectOperationException {
if (language == null && fileType instanceof LanguageFileType) {
language = ((LanguageFileType)fileType).getLanguage();
}
if (language != null) {
StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(language);
if (profile != null) {
return profile.createPatternTree(text, context, fileType, language, contextName, null, project, physical);
}
}
return PsiElement.EMPTY_ARRAY;
}
示例9: canHaveStub
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
@Override
public boolean canHaveStub(VirtualFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
Language l = ((LanguageFileType)fileType).getLanguage();
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition == null) return false;
final IFileElementType elementType = parserDefinition.getFileNodeType();
return elementType instanceof IStubFileElementType && ((IStubFileElementType)elementType).shouldBuildStubFor(file);
}
else if (fileType.isBinary()) {
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
return false;
}
示例10: getCumulativeVersion
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
public static int getCumulativeVersion() {
int version = VERSION;
for (final FileType fileType : FileTypeRegistry.getInstance().getRegisteredFileTypes()) {
if (fileType instanceof LanguageFileType) {
Language l = ((LanguageFileType)fileType).getLanguage();
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition != null) {
final IFileElementType type = parserDefinition.getFileNodeType();
if (type instanceof IStubFileElementType) {
version += ((IStubFileElementType)type).getStubVersion();
}
}
}
BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
if (builder != null) {
version += builder.getStubVersion();
}
}
return version;
}
示例11: calcBaseLanguage
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
private static Language calcBaseLanguage(@NotNull VirtualFile file, @NotNull Project project, @NotNull final FileType fileType) {
if (file instanceof LightVirtualFile) {
final Language language = ((LightVirtualFile)file).getLanguage();
if (language != null) {
return language;
}
}
if (fileType.isBinary()) return Language.ANY;
if (isTooLargeForIntelligence(file)) return PlainTextLanguage.INSTANCE;
if (fileType instanceof LanguageFileType) {
return LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, project);
}
return PlainTextLanguage.INSTANCE;
}
示例12: createFileFromText
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
@Override
@NotNull
public PsiFile createFileFromText(@NotNull String name,
@NotNull FileType fileType,
@NotNull CharSequence text,
long modificationStamp,
final boolean eventSystemEnabled,
boolean markAsCopy) {
final LightVirtualFile virtualFile = new LightVirtualFile(name, fileType, text, modificationStamp);
if(fileType instanceof LanguageFileType){
final Language language =
LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), virtualFile, myManager.getProject());
final PsiFile file = trySetupPsiForFile(virtualFile, language, eventSystemEnabled, markAsCopy);
if (file != null) return file;
}
final SingleRootFileViewProvider singleRootFileViewProvider =
new SingleRootFileViewProvider(myManager, virtualFile, eventSystemEnabled);
final PsiPlainTextFileImpl plainTextFile = new PsiPlainTextFileImpl(singleRootFileViewProvider);
if(markAsCopy) CodeEditUtil.setNodeGenerated(plainTextFile.getNode(), true);
return plainTextFile;
}
示例13: substituteFileType
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
@NotNull
public static FileType substituteFileType(@NotNull VirtualFile file, @NotNull FileType fileType, Project project) {
if (project == null) {
return fileType;
}
if (fileType instanceof LanguageFileType) {
final Language language = ((LanguageFileType)fileType).getLanguage();
final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
LanguageFileType substFileType = substitutedLanguage.getAssociatedFileType();
if (!substitutedLanguage.equals(language) && substFileType != null) {
return new SubstitutedFileType(fileType, substFileType, substitutedLanguage);
}
}
return fileType;
}
示例14: canHaveStub
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
public static boolean canHaveStub(@NotNull VirtualFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof LanguageFileType) {
final Language l = ((LanguageFileType)fileType).getLanguage();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(l);
if (parserDefinition == null) {
return false;
}
final IFileElementType elementType = parserDefinition.getFileNodeType();
if (elementType instanceof IStubFileElementType) {
if (((IStubFileElementType)elementType).shouldBuildStubFor(file)) {
return true;
}
if (IndexingStamp.isFileIndexedStateCurrent(file, INDEX_ID)) {
return true;
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
示例15: updateFileTypeForEditorComponent
import com.intellij.openapi.fileTypes.LanguageFileType; //导入依赖的package包/类
private void updateFileTypeForEditorComponent(@NotNull ComboBox inputComboBox) {
final Component editorComponent = inputComboBox.getEditor().getEditorComponent();
if (editorComponent instanceof EditorTextField) {
boolean isRegexp = myCbRegularExpressions.isSelectedWhenSelectable();
FileType fileType = PlainTextFileType.INSTANCE;
if (isRegexp) {
Language regexpLanguage = Language.findLanguageByID("RegExp");
if (regexpLanguage != null) {
LanguageFileType regexpFileType = regexpLanguage.getAssociatedFileType();
if (regexpFileType != null) {
fileType = regexpFileType;
}
}
}
String fileName = isRegexp ? "a.regexp" : "a.txt";
final PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, ((EditorTextField)editorComponent).getText(), -1, true);
((EditorTextField)editorComponent).setNewDocumentAndFileType(fileType, PsiDocumentManager.getInstance(myProject).getDocument(file));
}
}