本文整理汇总了Java中com.intellij.lang.LanguageParserDefinitions类的典型用法代码示例。如果您正苦于以下问题:Java LanguageParserDefinitions类的具体用法?Java LanguageParserDefinitions怎么用?Java LanguageParserDefinitions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LanguageParserDefinitions类属于com.intellij.lang包,在下文中一共展示了LanguageParserDefinitions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: acceptInput
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TodoIndex.java
示例2: canHaveStub
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CoreStubTreeLoader.java
示例3: getCumulativeVersion
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CumulativeStubVersion.java
示例4: isComment
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
private boolean isComment(int offset) {
final HighlighterIterator it = myEditor.getHighlighter().createIterator(offset);
IElementType tokenType = it.getTokenType();
Language language = tokenType.getLanguage();
TokenSet comments = myComments.get(language);
if (comments == null) {
ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
if (definition != null) {
comments = definition.getCommentTokens();
}
if (comments == null) {
return false;
}
else {
myComments.put(language, comments);
}
}
return comments.contains(tokenType);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:IndentsPass.java
示例5: canHaveStub
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:StubUpdatingIndex.java
示例6: startInjecting
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
@Override
@NotNull
public MultiHostRegistrar startInjecting(@NotNull Language language) {
escapers = new SmartList<LiteralTextEscaper<? extends PsiLanguageInjectionHost>>();
shreds = new SmartList<PsiLanguageInjectionHost.Shred>();
outChars = new StringBuilder();
if (!cleared) {
clear();
throw new IllegalStateException("Seems you haven't called doneInjecting()");
}
if (LanguageParserDefinitions.INSTANCE.forLanguage(language) == null) {
ReferenceInjector injector = ReferenceInjector.findById(language.getID());
if (injector == null) {
throw new UnsupportedOperationException("Cannot inject language '" + language + "' since its getParserDefinition() returns null");
}
myLanguage = null;
myReferenceInjector = injector;
}
myLanguage = language;
return this;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MultiHostRegistrarImpl.java
示例7: processStringLiteralsContainingIdentifier
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
private static boolean processStringLiteralsContainingIdentifier(@NotNull String identifier, @NotNull SearchScope searchScope, PsiSearchHelper helper, final Processor<PsiElement> processor) {
TextOccurenceProcessor occurenceProcessor = new TextOccurenceProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, int offsetInElement) {
final ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(element.getLanguage());
final ASTNode node = element.getNode();
if (definition != null && node != null && definition.getStringLiteralElements().contains(node.getElementType())) {
return processor.process(element);
}
return true;
}
};
return helper.processElementsWithWord(occurenceProcessor,
searchScope,
identifier,
UsageSearchContext.IN_STRINGS,
true);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TextOccurrencesUtil.java
示例8: registerProblemStart
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
private static void registerProblemStart(@NotNull final AnnotationHolder holder,
@NotNull final XmlTag tag,
@NotNull final XmlToken start,
@NotNull final XmlToken end) {
PsiElement context = tag.getContainingFile().getContext();
if (context != null) {
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage());
if (parserDefinition != null) {
ASTNode contextNode = context.getNode();
if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) {
// TODO: we should check for concatenations here
return;
}
}
}
final String tagName = tag.getName();
final String endTokenText = end.getText();
final RenameTagBeginOrEndIntentionAction renameEndAction = new RenameTagBeginOrEndIntentionAction(tagName, endTokenText, false);
final RenameTagBeginOrEndIntentionAction renameStartAction = new RenameTagBeginOrEndIntentionAction(endTokenText, tagName, true);
final Annotation annotation = holder.createErrorAnnotation(start, XmlErrorMessages.message("tag.has.wrong.closing.tag.name"));
annotation.registerFix(renameEndAction);
annotation.registerFix(renameStartAction);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlWrongClosingTagNameInspection.java
示例9: registerProblemEnd
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
private static void registerProblemEnd(@NotNull final AnnotationHolder holder,
@NotNull final XmlTag tag,
@NotNull final XmlToken end) {
PsiElement context = tag.getContainingFile().getContext();
if (context != null) {
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(context.getLanguage());
if (parserDefinition != null) {
ASTNode contextNode = context.getNode();
if (contextNode != null && contextNode.getChildren(parserDefinition.getStringLiteralElements()) != null) {
// TODO: we should check for concatenations here
return;
}
}
}
final String tagName = tag.getName();
final String endTokenText = end.getText();
final RenameTagBeginOrEndIntentionAction renameEndAction = new RenameTagBeginOrEndIntentionAction(tagName, endTokenText, false);
final RenameTagBeginOrEndIntentionAction renameStartAction = new RenameTagBeginOrEndIntentionAction(endTokenText, tagName, true);
final Annotation annotation = holder.createErrorAnnotation(end, XmlErrorMessages.message("wrong.closing.tag.name"));
annotation.registerFix(new RemoveExtraClosingTagIntentionAction());
annotation.registerFix(renameEndAction);
annotation.registerFix(renameStartAction);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlWrongClosingTagNameInspection.java
示例10: DtdParsing
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
public DtdParsing(CharSequence chars,
final IElementType type,
final XmlEntityDecl.EntityContextType contextType,
PsiFile contextFile
) {
this(
type,
contextType,
PsiBuilderFactory.getInstance().createBuilder(
LanguageParserDefinitions.INSTANCE.forLanguage(DTDLanguage.INSTANCE),
new DtdLexer(false) {
final int myInitialState = getLexerInitialState(type, contextType);
@Override
public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
super.start(buffer, startOffset, endOffset, myInitialState);
}
}, chars
)
);
if (contextFile != null) myBuilder.putUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY, contextFile);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:DtdParsing.java
示例11: isInsideStringLiteral
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
private static boolean isInsideStringLiteral(final Editor editor, final PsiFile file) {
int offset = editor.getCaretModel().getOffset();
PsiElement element = file.findElementAt(offset);
if (element == null) return false;
final ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(element.getLanguage());
if (definition != null) {
final TokenSet stringLiteralElements = definition.getStringLiteralElements();
final ASTNode node = element.getNode();
if (node == null) return false;
final IElementType elementType = node.getElementType();
if (stringLiteralElements.contains(elementType)) {
return true;
}
PsiElement parent = element.getParent();
if (parent != null) {
ASTNode parentNode = parent.getNode();
if (parentNode != null && stringLiteralElements.contains(parentNode.getElementType())) {
return true;
}
}
}
return false;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:TypedHandler.java
示例12: canHaveStub
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的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;
}
final ID indexId = IndexInfrastructure.getStubId(INDEX_ID, file.getFileType());
if (IndexingStamp.isFileIndexed(file, indexId, IndexInfrastructure.getIndexCreationStamp(indexId))) {
return true;
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
return builder != null && builder.acceptsFile(file);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:StubUpdatingIndex.java
示例13: computeVersionMap
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
private static Map<FileType, Integer> computeVersionMap() {
Map<FileType, Integer> map = new HashMap<FileType, Integer>();
for (final FileType fileType : FileTypeManager.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) {
map.put(fileType, ((IStubFileElementType)type).getStubVersion());
}
}
}
final BinaryFileStubBuilder builder = BinaryFileStubBuilders.INSTANCE.forFileType(fileType);
if (builder != null) {
map.put(fileType, builder.getStubVersion());
}
}
return map;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:StubUpdatingIndex.java
示例14: acceptInput
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
@Override
public boolean acceptInput(final VirtualFile file) {
if (!(file.getFileSystem() instanceof LocalFileSystem)) {
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;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:TodoIndex.java
示例15: startInjecting
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
@Override
@NotNull
public MultiHostRegistrar startInjecting(@NotNull Language language) {
escapers = new SmartList<LiteralTextEscaper<? extends PsiLanguageInjectionHost>>();
shreds = new SmartList<PsiLanguageInjectionHost.Shred>();
outChars = new StringBuilder();
if (!cleared) {
clear();
throw new IllegalStateException("Seems you haven't called doneInjecting()");
}
if (LanguageParserDefinitions.INSTANCE.forLanguage(language) == null) {
throw new UnsupportedOperationException("Cannot inject language '" + language + "' since its getParserDefinition() returns null");
}
myLanguage = language;
return this;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:MultiHostRegistrarImpl.java
示例16: processStringLiteralsContainingIdentifier
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
private static boolean processStringLiteralsContainingIdentifier(@NotNull String identifier, @NotNull SearchScope searchScope, PsiSearchHelper helper, final Processor<PsiElement> processor) {
TextOccurenceProcessor occurenceProcessor = new TextOccurenceProcessor() {
@Override
public boolean execute(PsiElement element, int offsetInElement) {
final ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(element.getLanguage());
final ASTNode node = element.getNode();
if (definition != null && node != null && definition.getStringLiteralElements().contains(node.getElementType())) {
return processor.process(element);
}
return true;
}
};
return helper.processElementsWithWord(occurenceProcessor,
searchScope,
identifier,
UsageSearchContext.IN_STRINGS,
true);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:TextOccurrencesUtil.java
示例17: DtdParsing
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
public DtdParsing(CharSequence chars,
final IElementType type,
final XmlEntityDecl.EntityContextType contextType,
PsiFile contextFile
) {
this(
type,
contextType,
PsiBuilderFactory.getInstance().createBuilder(
LanguageParserDefinitions.INSTANCE.forLanguage(DTDLanguage.INSTANCE),
new DtdLexer(false) {
final int myInitialState = getLexerInitialState(type, contextType);
@Override
public void start(CharSequence buffer, int startOffset, int endOffset, int initialState) {
super.start(buffer, startOffset, endOffset, myInitialState);
}
}, chars
)
);
if (contextFile != null) myBuilder.putUserDataUnprotected(FileContextUtil.CONTAINING_FILE_KEY, contextFile);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:DtdParsing.java
示例18: IgnoreFile
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
/** Builds a new instance of {@link IgnoreFile}. */
public IgnoreFile(@NotNull FileViewProvider viewProvider, @NotNull IgnoreFileType fileType) {
super(viewProvider);
this.fileType = fileType;
this.language = findLanguage(fileType.getLanguage(), viewProvider);
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(this.language);
if (parserDefinition == null) {
throw new RuntimeException(
"PsiFileBase: language.getParserDefinition() returned null for: " + this.language
);
}
this.parserDefinition = parserDefinition;
final IFileElementType nodeType = parserDefinition.getFileNodeType();
init(nodeType, nodeType);
}
开发者ID:hsz,项目名称:idea-gitignore,代码行数:19,代码来源:IgnoreFile.java
示例19: createFile
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
@Override
protected PsiFile createFile(@NotNull Language lang) {
ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
if (parserDefinition == null) {
return null;
}
Language templateDataLanguage = getTemplateDataLanguage(myManager, myFile);
if (lang == templateDataLanguage) {
PsiFileImpl file = (PsiFileImpl) parserDefinition.createFile(this);
file.setContentElementType(new TemplateDataElementType("Dot_TEMPLATE_DATA", templateDataLanguage, DotTokenTypes.CONTENT, DotTokenTypes.OUTER_ELEMENT_TYPE));
return file;
} else if (lang == DotLanguage.INSTANCE) {
return parserDefinition.createFile(this);
} else {
return null;
}
}
开发者ID:webschik,项目名称:idea-doT,代码行数:19,代码来源:DotFileViewProvider.java
示例20: createFile
import com.intellij.lang.LanguageParserDefinitions; //导入依赖的package包/类
@Nullable
@Override
protected PsiFile createFile(@NotNull final Language lang)
{
if(lang == getBaseLanguage())
{
return LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this);
}
if(lang == JavaLanguage.INSTANCE)
{
return new JspJavaFileImpl(this);
}
if(lang == getTemplateDataLanguage())
{
PsiFileImpl file = (PsiFileImpl) LanguageParserDefinitions.INSTANCE.forLanguage(lang).createFile(this);
file.setContentElementType(JspTemplateTokens.HTML_TEMPLATE_DATA);
return file;
}
return null;
}
开发者ID:consulo,项目名称:consulo-javaee,代码行数:23,代码来源:JspFileViewProviderImpl.java
注:本文中的com.intellij.lang.LanguageParserDefinitions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论