本文整理匯總了Java中com.intellij.lang.Language.getAssociatedFileType方法的典型用法代碼示例。如果您正苦於以下問題:Java Language.getAssociatedFileType方法的具體用法?Java Language.getAssociatedFileType怎麽用?Java Language.getAssociatedFileType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.lang.Language
的用法示例。
在下文中一共展示了Language.getAssociatedFileType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: SoyLayeredHighlighter
import com.intellij.lang.Language; //導入方法依賴的package包/類
public SoyLayeredHighlighter(
@Nullable Project project,
@Nullable VirtualFile virtualFile,
@NotNull EditorColorsScheme colors) {
// Creating main highlighter.
super(new SoySyntaxHighlighter(), colors);
// Highlighter for the outer language.
FileType type = null;
if (project == null || virtualFile == null) {
type = StdFileTypes.PLAIN_TEXT;
} else {
Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
if (language != null) type = language.getAssociatedFileType();
if (type == null) type = SoyLanguage.getDefaultTemplateLang();
}
SyntaxHighlighter outerHighlighter =
SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);
registerLayer(OTHER, new LayerDescriptor(outerHighlighter, ""));
}
示例2: getAssociatedFileType
import com.intellij.lang.Language; //導入方法依賴的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;
}
示例3: getAssociatedFileType
import com.intellij.lang.Language; //導入方法依賴的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;
}
示例4: JetLayeredSyntaxHighlighter
import com.intellij.lang.Language; //導入方法依賴的package包/類
public JetLayeredSyntaxHighlighter(Project project, EditorColorsScheme scheme, FileType ptype, VirtualFile virtualFile) {
super(new JetSyntaxHighlighter(), scheme);
// highlighter for outer ide
FileType type = null;
if (project == null || virtualFile == null) {
type = StdFileTypes.PLAIN_TEXT;
} else {
Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
if (language != null) type = language.getAssociatedFileType();
if (type == null) type = JetLanguage.getDefaultTemplateLang();
}
SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);
registerLayer(TEXT, new LayerDescriptor(outerHighlighter, ""));
}
示例5: getFileType
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Nullable
public static FileType getFileType(@Nullable String contentType) {
if (contentType == null) return null;
int end = contentType.indexOf(';');
String mimeType = end == -1 ? contentType : contentType.substring(0, end);
if (mimeType.isEmpty()) {
return null;
}
for (Language language : Language.getRegisteredLanguages()) {
String[] types = language.getMimeTypes();
for (String type : types) {
if (type.equalsIgnoreCase(mimeType)) {
FileType fileType = language.getAssociatedFileType();
if (fileType != null) {
return fileType;
}
}
}
}
return null;
}
示例6: substituteFileType
import com.intellij.lang.Language; //導入方法依賴的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;
}
示例7: updateFileTypeForEditorComponent
import com.intellij.lang.Language; //導入方法依賴的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));
}
}
示例8: createLanguageCellRenderer
import com.intellij.lang.Language; //導入方法依賴的package包/類
private static TableCellRenderer createLanguageCellRenderer() {
return new TableCellRenderer() {
final JLabel myLabel = new JLabel();
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus,
final int row,
final int column) {
final InjInfo injection = (InjInfo)value;
// fix for a marvellous Swing peculiarity: AccessibleJTable likes to pass null here
if (injection == null) return myLabel;
final String languageId = injection.injection.getInjectedLanguageId();
final Language language = InjectedLanguage.findLanguageById(languageId);
final FileType fileType = language == null ? null : language.getAssociatedFileType();
myLabel.setIcon(fileType == null ? null : fileType.getIcon());
myLabel.setText(language == null ? languageId : language.getDisplayName());
setLabelColors(myLabel, table, isSelected, row);
return myLabel;
}
};
}
示例9: nameTaskFileAfterContainingClass
import com.intellij.lang.Language; //導入方法依賴的package包/類
public static void nameTaskFileAfterContainingClass(@NotNull Task task,
@NotNull TaskFile taskFile,
@NotNull Project project) {
Language language = task.getLesson().getCourse().getLanguageById();
if (language.getAssociatedFileType() == null) {
LOG.warn("Cannot rename task file. Unable to find associated file type for language: " + language.getID());
return;
}
task.getTaskFiles().remove(taskFile.name);
taskFile.name = publicClassName(project, taskFile, language.getAssociatedFileType()) + "." + language.getAssociatedFileType().getDefaultExtension();
task.taskFiles.put(taskFile.name, taskFile);
}
示例10: getTaskFileName
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Nullable
private static String getTaskFileName(@NotNull Language language) {
// This is a hacky way to how we should name task file.
// It's assumed that if test's name is capitalized we need to capitalize task file name too.
String testFileName = EduPluginConfigurator.INSTANCE.forLanguage(language).getTestFileName();
boolean capitalize = !testFileName.isEmpty() && Character.isUpperCase(testFileName.charAt(0));
LanguageFileType type = language.getAssociatedFileType();
if (type == null) {
LOG.warn("Failed to create task file name: associated file type for " + language + " is null");
return null;
}
return (capitalize ? StringUtil.capitalize(TASK_NAME) : TASK_NAME) + "." + type.getDefaultExtension();
}
示例11: RythmLayeredSyntaxHighlighter
import com.intellij.lang.Language; //導入方法依賴的package包/類
public RythmLayeredSyntaxHighlighter(Project project, EditorColorsScheme scheme, FileType ptype, VirtualFile virtualFile) {
super(new RythmSyntaxHighlighter(), scheme);
FileType type = null;
//Test for Java implementation
FileType type1 = null;
if (project == null || virtualFile == null) {
type = StdFileTypes.PLAIN_TEXT;
} else {
Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
if (language != null) type = language.getAssociatedFileType();
if (type == null) {
type = RythmLanguage.getDefaultTemplateLang();
//Test for Java implementation
//type1 = RythmLanguage.getLanguage();
}
}
SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);
registerLayer(TEXT, new LayerDescriptor(outerHighlighter, ""));
//Test for Java implementation
/* SyntaxHighlighter middleHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type1, project, virtualFile);
registerLayer(TEXT, new LayerDescriptor(middleHighlighter, ""));
*/
}
示例12: substituteFileType
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Nullable
private static LanguageFileType substituteFileType(Language language, VirtualFile vFile, Project project) {
LanguageFileType fileType = null;
if (vFile != null && project != null) {
Language substLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, vFile, project);
if (substLanguage != language) {
fileType = substLanguage.getAssociatedFileType();
}
}
return fileType;
}
示例13: setLanguage
import com.intellij.lang.Language; //導入方法依賴的package包/類
public void setLanguage(@NotNull Language language) {
myLanguage = language;
FileType type = language.getAssociatedFileType();
if (type == null) {
type = FileTypeRegistry.getInstance().getFileTypeByFileName(getName());
}
setFileType(type);
}
示例14: getErrorsForText
import com.intellij.lang.Language; //導入方法依賴的package包/類
@NotNull
private Collection<PsiErrorElement> getErrorsForText(@NotNull LanguageCodeStyleSettingsProvider provider, @NotNull String sample) {
PsiFile file = provider.createFileFromText(getProject(), sample);
if (file == null) {
Language language = provider.getLanguage();
LanguageFileType type = language.getAssociatedFileType();
if (type == null) return ContainerUtil.newArrayList();
file = myFixture.configureByText(type, sample);
}
return PsiTreeUtil.collectElementsOfType(file, PsiErrorElement.class);
}
示例15: doSetText
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Override
protected void doSetText(XExpression text) {
myExpression = text;
Language language = text.getLanguage();
FileType fileType = language != null ? language.getAssociatedFileType() : getEditorsProvider().getFileType();
myEditorTextField.setNewDocumentAndFileType(fileType, createDocument(text));
}