本文整理匯總了Java中com.intellij.lang.Language類的典型用法代碼示例。如果您正苦於以下問題:Java Language類的具體用法?Java Language怎麽用?Java Language使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Language類屬於com.intellij.lang包,在下文中一共展示了Language類的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: createFile
import com.intellij.lang.Language; //導入依賴的package包/類
@Override
protected PsiFile createFile(@NotNull Language lang) {
ParserDefinition parserDefinition = getDefinition(lang);
if (parserDefinition == null) {
return null;
}
if (lang.is(templateDataLanguage)) {
PsiFileImpl file = (PsiFileImpl) parserDefinition.createFile(this);
file.setContentElementType(templateDataLanguageType);
return file;
} else if (lang.isKindOf(baseLanguage)) {
return parserDefinition.createFile(this);
} else {
return null;
}
}
示例3: highlightCurrentColumn
import com.intellij.lang.Language; //導入依賴的package包/類
@Override
@Contract
public void highlightCurrentColumn(@NotNull final Editor editor) {
Validate.notNull(editor);
final Project project = editor.getProject();
if (null == project) {
return;
}
if (project.isDisposed()) {
return;
}
final Language languageInEditor = PsiUtilBase.getLanguageInEditor(editor, project);
if (languageInEditor instanceof ImpexLanguage) {
this.highlightColumnOfValueUnderCaret(editor);
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:22,代碼來源:DefaultImpexColumnHighlighterService.java
示例4: highlightCurrentHeader
import com.intellij.lang.Language; //導入依賴的package包/類
@Override
@Contract(pure = false)
public void highlightCurrentHeader(@NotNull final Editor editor) {
Validate.notNull(editor);
final Project project = editor.getProject();
if (null == project) {
return;
}
if (project.isDisposed()) {
return;
}
final Language languageInEditor = PsiUtilBase.getLanguageInEditor(editor, project);
if (languageInEditor instanceof ImpexLanguage) {
this.highlightHeaderOfValueUnderCaret(editor);
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:22,代碼來源:DefaultImpexHeaderNameHighlighterService.java
示例5: commitModule
import com.intellij.lang.Language; //導入依賴的package包/類
@Nullable
@Override
public Module commitModule(@NotNull Project project, @Nullable ModifiableModuleModel model) {
Module module = super.commitModule(project, model);
if (module == null) {
return null;
}
String languageName = myCourse.getLanguageID();
Language language = Language.findLanguageByID(languageName);
if (language == null) {
return module;
}
EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
if (configurator == null) {
return module;
}
configurator.configureModule(module);
return module;
}
示例6: createModule
import com.intellij.lang.Language; //導入依賴的package包/類
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
Module baseModule = super.createModule(moduleModel);
String languageName = myCourse.getLanguageID();
Language language = Language.findLanguageByID(languageName);
if (language != null) {
EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
if (configurator != null) {
Project project = baseModule.getProject();
myGenerator.setSelectedCourse(myCourse);
myGenerator.generateProject(project, project.getBaseDir());
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
LOG.info("failed to generate course");
return baseModule;
}
configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
}
}
return baseModule;
}
示例7: commitModule
import com.intellij.lang.Language; //導入依賴的package包/類
@Nullable
@Override
public Module commitModule(@NotNull Project project, @Nullable ModifiableModuleModel model) {
Module module = super.commitModule(project, model);
if (module == null) {
return null;
}
String languageName = mySelectedCourse.getLanguageID();
Language language = Language.findLanguageByID(languageName);
if (language == null) {
return module;
}
EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
if (configurator == null) {
return module;
}
configurator.configureModule(module);
return module;
}
示例8: createModule
import com.intellij.lang.Language; //導入依賴的package包/類
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
Module baseModule = super.createModule(moduleModel);
if (mySelectedCourse != null) {
String languageName = mySelectedCourse.getLanguageID();
Language language = Language.findLanguageByID(languageName);
if (language != null) {
EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
if (configurator != null) {
myGenerator.setSelectedCourse(mySelectedCourse);
Project project = baseModule.getProject();
myGenerator.generateProject(project, project.getBaseDir());
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
LOG.info("failed to generate course");
return baseModule;
}
configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
}
}
}
return baseModule;
}
示例9: getTestFiles
import com.intellij.lang.Language; //導入依賴的package包/類
private static List<VirtualFile> getTestFiles(@NotNull Task task, @NotNull Project project) {
final Course course = task.getLesson().getCourse();
final Language language = course.getLanguageById();
final EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
List<VirtualFile> testFiles = new ArrayList<>();
VirtualFile taskDir = task.getTaskDir(project);
if (taskDir == null) {
return testFiles;
}
if (!(task instanceof TaskWithSubtasks)) {
VirtualFile testFile = taskDir.findChild(configurator.getTestFileName());
testFiles.add(testFile);
return testFiles;
}
testFiles.addAll(Arrays.stream(taskDir.getChildren())
.filter(file -> StudyUtils.isTestsFile(project, file.getName()))
.collect(Collectors.toList()));
return testFiles;
}
示例10: createFilesForNewTask
import com.intellij.lang.Language; //導入依賴的package包/類
private static void createFilesForNewTask(@NotNull Project project,
@NotNull Task task,
@NotNull String lessonName,
@NotNull Language language) {
final VirtualFile lessonDir = project.getBaseDir().findChild(lessonName);
if (lessonDir == null) {
return;
}
ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> {
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(lessonDir);
if (directory == null) {
return;
}
EduPluginConfigurator.INSTANCE.forLanguage(language).createTaskContent(project, task, null, directory, task.getLesson().getCourse());
}));
}
示例11: updateProjectFiles
import com.intellij.lang.Language; //導入依賴的package包/類
private static void updateProjectFiles(@NotNull Project project, @NotNull Task task, @NotNull String lessonName, Language language) {
final VirtualFile lessonDir = project.getBaseDir().findChild(lessonName);
if (lessonDir == null) {
return;
}
ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> {
try {
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(lessonDir);
if (directory == null) {
return;
}
removeOldProjectFiles(lessonDir, task.getIndex());
EduPluginConfigurator.INSTANCE.forLanguage(language).createTaskContent(project, task, null, directory, task.getLesson().getCourse());
}
catch (IOException e) {
LOG.warn(e.getMessage());
}
}));
}
示例12: checkCodeTask
import com.intellij.lang.Language; //導入依賴的package包/類
public static StudyCheckResult checkCodeTask(@NotNull Project project, @NotNull Task task, @NotNull StepicUser user) {
int attemptId = -1;
try {
attemptId = getAttemptId(task);
}
catch (IOException e) {
LOG.warn(e.getMessage());
}
if (attemptId != -1) {
Course course = task.getLesson().getCourse();
Language courseLanguage = course.getLanguageById();
final Editor editor = StudyUtils.getSelectedEditor(project);
if (editor != null) {
String commentPrefix = LanguageCommenters.INSTANCE.forLanguage(courseLanguage).getLineCommentPrefix();
final String answer = commentPrefix + PYCHARM_COMMENT + editor.getDocument().getText();
String defaultLanguage = EduPluginConfigurator.INSTANCE.forLanguage(courseLanguage).getStepikDefaultLanguage();
final StepicWrappers.SubmissionToPostWrapper submissionToPost =
new StepicWrappers.SubmissionToPostWrapper(String.valueOf(attemptId), defaultLanguage, answer);
return doAdaptiveCheck(submissionToPost, attemptId, user.getId());
}
}
else {
LOG.warn("Got an incorrect attempt id: " + attemptId);
}
return new StudyCheckResult(StudyStatus.Unchecked, StudyCheckAction.FAILED_CHECK_LAUNCH);
}
示例13: getTestsText
import com.intellij.lang.Language; //導入依賴的package包/類
@NotNull
public String getTestsText(@NotNull final Project project) {
final Course course = getLesson().getCourse();
final Language language = course.getLanguageById();
final EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
final VirtualFile taskDir = getTaskDir(project);
if (taskDir != null) {
final VirtualFile file = taskDir.findChild(configurator.getTestFileName());
if (file == null) return "";
final Document document = FileDocumentManager.getInstance().getDocument(file);
if (document != null) {
return document.getImmutableCharSequence().toString();
}
}
return "";
}
示例14: 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));
}
}
示例15: substituteLanguage
import com.intellij.lang.Language; //導入依賴的package包/類
@Nullable
public static Language substituteLanguage(@NotNull Project project, @NotNull VirtualFile file) {
Language language = null;
if (file != null) {
//logger.debug("*** VFile is " + file);
String newDataType = file.getUserData(WeaveEditor.newFileDataTypeKey);
//logger.debug("*** newDataType is " + newDataType);
if (newDataType != null) {
language = WeaveEditor.getLanguage(newDataType);
//logger.debug("*** Resolved Language is " + language);
}
}
return language;
}