本文整理汇总了Java中consulo.lang.LanguageVersion类的典型用法代码示例。如果您正苦于以下问题:Java LanguageVersion类的具体用法?Java LanguageVersion怎么用?Java LanguageVersion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LanguageVersion类属于consulo.lang包,在下文中一共展示了LanguageVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@NotNull
@Override
public ASTNode parse(@NotNull IElementType root, @NotNull PsiBuilder b, @NotNull LanguageVersion languageVersion)
{
ShaderLabParserBuilder builder = new ShaderLabParserBuilder(b);
PsiBuilder.Marker mark = builder.mark();
if(!ShaderLabRoles.Shader.tryParse(builder))
{
builder.error("Shader expected");
}
while(!builder.eof())
{
doneError(builder, "Unexpected token");
}
mark.done(root);
return builder.getTreeBuilt();
}
示例2: getLanguageVersion
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public LanguageVersion getLanguageVersion(@NotNull Language language, @Nullable PsiElement element)
{
if(element == null)
{
return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
}
Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement(element);
if(moduleForPsiElement == null)
{
return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
}
CSharpSimpleModuleExtension extension = ModuleUtilCore.getExtension(moduleForPsiElement, CSharpSimpleModuleExtension.class);
if(extension == null)
{
return CSharpLanguageVersionHelper.getInstance().getHighestVersion();
}
return CSharpLanguageVersionHelper.getInstance().getWrapper(extension.getLanguageVersion());
}
示例3: createElementType
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@NotNull
private static IElementType createElementType(String id, BiConsumer<PsiBuilder, LanguageVersion> consumer)
{
return new IFileElementType(id, CSharpLanguage.INSTANCE)
{
@Override
protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi)
{
final Project project = psi.getProject();
final Language languageForParser = getLanguageForParser(psi);
final LanguageVersion tempLanguageVersion = chameleon.getUserData(LanguageVersion.KEY);
final LanguageVersion languageVersion = tempLanguageVersion == null ? psi.getLanguageVersion() : tempLanguageVersion;
final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, languageForParser, languageVersion, chameleon.getChars());
consumer.accept(builder, languageVersion);
while(!builder.eof())
{
builder.advanceLexer();
}
return builder.getTreeBuilt();
}
};
}
示例4: resolveLanguageVersion
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@NotNull
@Override
public LanguageVersion resolveLanguageVersion(@NotNull FileType fileType)
{
String name = getName();
try
{
Method declaredMethod = getClass().getDeclaredMethod(name);
SetLanguageVersion annotation = declaredMethod.getAnnotation(SetLanguageVersion.class);
if(annotation != null)
{
return CSharpLanguageVersionHelper.getInstance().getWrapper(annotation.version());
}
else
{
throw new IllegalArgumentException("Missed @SetLanguageVersion");
}
}
catch(NoSuchMethodException e)
{
throw new Error(e);
}
}
示例5: updateVersionsCombo
import consulo.lang.LanguageVersion; //导入依赖的package包/类
private void updateVersionsCombo(@Nullable final String lastUsed) {
final Object source = getSource();
List<LanguageVersion> items = new ArrayList<LanguageVersion>();
if (source instanceof LanguageFileType) {
final Language baseLang = ((LanguageFileType)source).getLanguage();
LanguageVersion[] versions = baseLang.getVersions();
Collections.addAll(items, versions);
}
myDialectComboBox.setModel(new CollectionComboBoxModel(items));
final int size = items.size();
final boolean visible = size > 1;
myDialectLabel.setVisible(visible);
myDialectComboBox.setVisible(visible);
if (visible && (myCurrentFile != null || lastUsed != null)) {
String currentLaversion = myCurrentFile != null ? myCurrentFile.getLanguageVersion().getName() : lastUsed;
for (int i = 0; i < size; ++i) {
if (currentLaversion.equals(items.get(i).getName())) {
myDialectComboBox.setSelectedIndex(i);
return;
}
}
myDialectComboBox.setSelectedIndex(size > 0 ? 0 : -1);
}
}
示例6: parse
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@NotNull
@Override
public ASTNode parse(IElementType root, PsiBuilder builder, LanguageVersion languageVersion) {
//builder.setDebugMode(true);
PsiBuilder.Marker rootMarker = builder.mark();
// Parser should accept empty string
if (!builder.eof()) {
parseQuery(builder);
while (!builder.eof()) {
builder.error("Illegal query part");
builder.advanceLexer();
}
}
rootMarker.done(root);
return builder.getTreeBuilt();
}
示例7: getLanguageVersion
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@NotNull
@RequiredReadAction
@Override
public LanguageVersion getLanguageVersion(@NotNull Language language, @Nullable Project project, @Nullable VirtualFile virtualFile)
{
if(project == null || virtualFile == null)
{
return StandardJavaScriptVersions.getInstance().getDefaultVersion();
}
FileType fileType = virtualFile.getFileType();
if(fileType instanceof JavaScriptFileTypeWithVersion)
{
return ((JavaScriptFileTypeWithVersion) fileType).getLanguageVersion(project, virtualFile);
}
return StandardJavaScriptVersions.getInstance().getDefaultVersion();
}
示例8: isCommentToken
import consulo.lang.LanguageVersion; //导入依赖的package包/类
public static boolean isCommentToken(@Nonnull IElementType tokenType, @Nonnull LanguageVersion languageVersion) {
final Language language = tokenType.getLanguage();
if(language != languageVersion.getLanguage()) {
return false;
}
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
if (parserDefinition != null) {
final TokenSet commentTokens = parserDefinition.getCommentTokens(languageVersion);
if (commentTokens.contains(tokenType)) {
return true;
}
}
return false;
}
示例9: getValidLanguageVersions
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@NotNull
public List<JavaScriptLanguageVersion> getValidLanguageVersions()
{
List<JavaScriptLanguageVersion> list = new ArrayList<>();
LanguageVersion[] versions = JavaScriptLanguage.INSTANCE.getVersions();
for(LanguageVersion version : versions)
{
if(version instanceof StandardJavaScriptVersions.Marker)
{
list.add((BaseJavaScriptLanguageVersion) version);
}
}
ContainerUtil.sort(list, (o1, o2) -> ((Marker) o1).getWeight() - ((Marker) o2).getWeight());
return list;
}
示例10: getLanguageVersion
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@NotNull
@Override
public LanguageVersion getLanguageVersion(@Nullable Project project, @Nullable VirtualFile virtualFile)
{
if(virtualFile == null || project == null)
{
return StandardJavaScriptVersions.getInstance().getDefaultVersion();
}
Module moduleForFile = ModuleUtilCore.findModuleForFile(virtualFile, project);
if(moduleForFile == null)
{
return StandardJavaScriptVersions.getInstance().getDefaultVersion();
}
JavaScriptModuleExtension<?> extension = ModuleUtilCore.getExtension(moduleForFile, JavaScriptModuleExtension.class);
if(extension != null)
{
return extension.getLanguageVersion();
}
return StandardJavaScriptVersions.getInstance().getDefaultVersion();
}
示例11: getCurrentStylesheetElementType
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@Nullable
protected IElementType getCurrentStylesheetElementType()
{
LanguageVersion languageVersion = getStyleLanguageVersion();
if(languageVersion != null)
{
for(EmbeddedTokenTypesProvider provider : EmbeddedTokenTypesProvider.EXTENSION_POINT_NAME.getExtensions())
{
if(provider.isMyVersion(languageVersion))
{
return provider.getElementType();
}
}
}
return null;
}
示例12: createElementFromText
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@Nullable
public PsiElement createElementFromText(@Nullable final String text,
@Nonnull final Language language,
@Nonnull final LanguageVersion languageVersion,
@Nonnull final IElementType type,
@Nullable final PsiElement context) {
if (text == null) return null;
final DummyHolder result = DummyHolderFactory.createHolder(myManager, language, context);
final FileElement holder = result.getTreeElement();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
if (parserDefinition == null) {
throw new AssertionError("No parser definition for " + language);
}
final Project project = myManager.getProject();
final Lexer lexer = parserDefinition.createLexer(languageVersion);
final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, holder, lexer, language, languageVersion, text);
final ASTNode node = parserDefinition.createParser(languageVersion).parse(type, builder, languageVersion);
holder.rawAddChildren((TreeElement)node);
markGenerated(result);
return node.getPsi();
}
示例13: createFileFromText
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@Nullable
@Override
public PsiFile createFileFromText(@Nonnull String name,
@Nonnull LanguageVersion languageVersion,
@Nonnull CharSequence text,
boolean physical,
boolean markAsCopy,
boolean noSizeLimit,
@Nullable VirtualFile original) {
LightVirtualFile virtualFile = new LightVirtualFile(name, languageVersion.getLanguage(), text);
if (original != null) virtualFile.setOriginalFile(original);
virtualFile.putUserData(LanguageVersion.KEY, languageVersion);
if (noSizeLimit) {
SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile);
}
return trySetupPsiForFile(virtualFile, languageVersion.getLanguage(), languageVersion, physical, markAsCopy);
}
示例14: NodeJSModuleExtensionPanel
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@RequiredDispatchThread
public NodeJSModuleExtensionPanel(final NodeJSMutableModuleExtension extension, Runnable runnable)
{
super(new VerticalFlowLayout(true, false));
add(ModuleExtensionSdkBoxBuilder.createAndDefine(extension, runnable).build());
List<JavaScriptLanguageVersion> validLanguageVersions = StandardJavaScriptVersions.getInstance().getValidLanguageVersions();
ComboBox languageVersionComboBox = new ComboBox(new CollectionComboBoxModel(validLanguageVersions, extension.getLanguageVersion()));
languageVersionComboBox.addItemListener(new ItemListener()
{
@Override
public void itemStateChanged(ItemEvent e)
{
if(e.getStateChange() == ItemEvent.SELECTED)
{
//noinspection unchecked
extension.setLanguageVersion((LanguageVersion) e.getItem());
}
}
});
languageVersionComboBox.setRenderer(new ColoredListCellRenderer<BaseJavaScriptLanguageVersion>()
{
@Override
protected void customizeCellRenderer(JList list, BaseJavaScriptLanguageVersion value, int index, boolean selected, boolean hasFocus)
{
append(value.getPresentableName());
}
});
add(LabeledComponent.create(languageVersionComboBox, "Language Version"));
}
示例15: parse
import consulo.lang.LanguageVersion; //导入依赖的package包/类
@NotNull
@Override
public ASTNode parse(@NotNull IElementType elementType, @NotNull PsiBuilder builder, @NotNull LanguageVersion languageVersion)
{
PsiBuilder.Marker mark = builder.mark();
while(!builder.eof())
{
PreprocessorParsing.parse(builder);
}
mark.done(elementType);
return builder.getTreeBuilt();
}