本文整理匯總了Java中com.intellij.lang.Language.isKindOf方法的典型用法代碼示例。如果您正苦於以下問題:Java Language.isKindOf方法的具體用法?Java Language.isKindOf怎麽用?Java Language.isKindOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.lang.Language
的用法示例。
在下文中一共展示了Language.isKindOf方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
}
示例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(getTemplateDataLanguage())) {
PsiFileImpl file = (PsiFileImpl) parserDefinition.createFile(this);
file.setContentElementType(getTemplateDataElementType(getBaseLanguage()));
return file;
} else if (lang.isKindOf(getBaseLanguage())) {
return parserDefinition.createFile(this);
} else {
return null;
}
}
示例3: match
import com.intellij.lang.Language; //導入方法依賴的package包/類
void match(PsiElement element, final Language language) {
final MatchingStrategy strategy = matchContext.getPattern().getStrategy();
final Language elementLanguage = element.getLanguage();
if (strategy.continueMatching(element) && elementLanguage.isKindOf(language)) {
visitor.matchContext(new ArrayBackedNodeIterator(new PsiElement[] {element}));
return;
}
for(PsiElement el=element.getFirstChild();el!=null;el=el.getNextSibling()) {
match(el, language);
}
if (element instanceof PsiLanguageInjectionHost) {
InjectedLanguageUtil.enumerate(element, new PsiLanguageInjectionHost.InjectedPsiVisitor() {
@Override
public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
match(injectedPsi, language);
}
});
}
}
示例4: isValidName
import com.intellij.lang.Language; //導入方法依賴的package包/類
public static boolean isValidName(final Project project, final PsiElement psiElement, final String newName) {
if (newName == null || newName.length() == 0) {
return false;
}
final Condition<String> inputValidator = RenameInputValidatorRegistry.getInputValidator(psiElement);
if (inputValidator != null) {
return inputValidator.value(newName);
}
if (psiElement instanceof PsiFile || psiElement instanceof PsiDirectory) {
return newName.indexOf('\\') < 0 && newName.indexOf('/') < 0;
}
if (psiElement instanceof PomTargetPsiElement) {
return !StringUtil.isEmptyOrSpaces(newName);
}
final PsiFile file = psiElement.getContainingFile();
final Language elementLanguage = psiElement.getLanguage();
final Language fileLanguage = file == null ? null : file.getLanguage();
Language language = fileLanguage == null ? elementLanguage : fileLanguage.isKindOf(elementLanguage) ? fileLanguage : elementLanguage;
return LanguageNamesValidation.INSTANCE.forLanguage(language).isIdentifier(newName.trim(), project);
}
示例5: getDefinition
import com.intellij.lang.Language; //導入方法依賴的package包/類
private ParserDefinition getDefinition(Language lang) {
ParserDefinition parserDefinition;
if (lang.isKindOf(getBaseLanguage())) {
parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang.is(getBaseLanguage()) ? lang : getBaseLanguage());
} else {
parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
}
return parserDefinition;
}
示例6: findLanguage
import com.intellij.lang.Language; //導入方法依賴的package包/類
private static Language findLanguage(Language baseLanguage, FileViewProvider viewProvider) {
final Set<Language> languages = viewProvider.getLanguages();
for (final Language actualLanguage : languages) {
if (actualLanguage.isKindOf(baseLanguage)) {
return actualLanguage;
}
}
throw new AssertionError(
"Language " + baseLanguage + " doesn't participate in view provider " + viewProvider + ": " + new ArrayList<Language>(languages));
}
示例7: isAvailable
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
Pair<PsiElement, TextRange> pair = getRangePair(file, editor);
if (pair != null && pair.first != null) {
Language language = pair.first.getLanguage();
return language.isKindOf(RegExpLanguage.INSTANCE);
}
return false;
}
示例8: isApplicableFile
import com.intellij.lang.Language; //導入方法依賴的package包/類
static boolean isApplicableFile(PsiFile file) {
if (file == null) return false;
for (Language language : file.getViewProvider().getLanguages()) {
if (language.isKindOf(XMLLanguage.INSTANCE) || "JavaScript".equals(language.getID())) return true;
}
return false;
}
示例9: isAvailable
import com.intellij.lang.Language; //導入方法依賴的package包/類
private static boolean isAvailable(@NotNull PsiFile psiFile) {
for (PsiFile file : psiFile.getViewProvider().getAllFiles()) {
Language language = file.getLanguage();
if (language.isKindOf(HTMLLanguage.INSTANCE) || language.isKindOf(XHTMLLanguage.INSTANCE)) {
return true;
}
}
return false;
}
示例10: getInfoProvider
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Nullable
private static BreadcrumbsInfoProvider getInfoProvider(@NotNull final Language language) {
for (final BreadcrumbsInfoProvider provider : Extensions.getExtensions(BreadcrumbsInfoProvider.EP_NAME)) {
for (final Language language1 : provider.getLanguages()) {
if (language.isKindOf(language1)) {
return provider;
}
}
}
return null;
}
示例11: isApplicable
import com.intellij.lang.Language; //導入方法依賴的package包/類
public boolean isApplicable(@NotNull Language language) {
String langId = getLanguage();
return langId == null || language.getID().equals(langId) || applyToDialects() && language.isKindOf(langId);
}
示例12: narrowLanguage
import com.intellij.lang.Language; //導入方法依賴的package包/類
protected static Language narrowLanguage(final Language language, final Language candidate) {
if (candidate.isKindOf(language)) return candidate;
return language;
}
示例13: isMyLanguage
import com.intellij.lang.Language; //導入方法依賴的package包/類
@Override
public boolean isMyLanguage(@NotNull Language language) {
return language.isKindOf(getFileType().getLanguage());
}
示例14: findReparseableRoots
import com.intellij.lang.Language; //導入方法依賴的package包/類
/**
* This method searches ast node that could be reparsed incrementally and returns pair of target reparseable node and new replacement node.
* Returns null if there is no any chance to make incremental parsing.
*/
@Nullable
public Couple<ASTNode> findReparseableRoots(@NotNull PsiFileImpl file,
@NotNull TextRange changedPsiRange,
@NotNull CharSequence newFileText) {
Project project = file.getProject();
final FileElement fileElement = file.getTreeElement();
final CharTable charTable = fileElement.getCharTable();
int lengthShift = newFileText.length() - fileElement.getTextLength();
if (fileElement.getElementType() instanceof ITemplateDataElementType || isTooDeep(file)) {
// unable to perform incremental reparse for template data in JSP, or in exceptionally deep trees
return null;
}
final ASTNode leafAtStart = fileElement.findLeafElementAt(Math.max(0, changedPsiRange.getStartOffset() - 1));
final ASTNode leafAtEnd = fileElement.findLeafElementAt(Math.min(changedPsiRange.getEndOffset(), fileElement.getTextLength() - 1));
ASTNode node = leafAtStart != null && leafAtEnd != null ? TreeUtil.findCommonParent(leafAtStart, leafAtEnd) : fileElement;
Language baseLanguage = file.getViewProvider().getBaseLanguage();
while (node != null && !(node instanceof FileElement)) {
IElementType elementType = node.getElementType();
if (elementType instanceof IReparseableElementType) {
final TextRange textRange = node.getTextRange();
final IReparseableElementType reparseable = (IReparseableElementType)elementType;
if (baseLanguage.isKindOf(reparseable.getLanguage()) && textRange.getLength() + lengthShift > 0) {
final int start = textRange.getStartOffset();
final int end = start + textRange.getLength() + lengthShift;
if (end > newFileText.length()) {
reportInconsistentLength(file, newFileText, node, start, end);
break;
}
CharSequence newTextStr = newFileText.subSequence(start, end);
if (reparseable.isParsable(node.getTreeParent(), newTextStr, baseLanguage, project)) {
ASTNode chameleon = reparseable.createNode(newTextStr);
if (chameleon != null) {
DummyHolder holder = DummyHolderFactory.createHolder(file.getManager(), null, node.getPsi(), charTable);
holder.getTreeElement().rawAddChildren((TreeElement)chameleon);
if (holder.getTextLength() != newTextStr.length()) {
String details = ApplicationManager.getApplication().isInternal()
? "text=" + newTextStr + "; treeText=" + holder.getText() + ";"
: "";
LOG.error("Inconsistent reparse: " + details + " type=" + elementType);
}
return Couple.of(node, chameleon);
}
}
}
}
node = node.getTreeParent();
}
return null;
}
示例15: isAvailableForLanguage
import com.intellij.lang.Language; //導入方法依賴的package包/類
protected boolean isAvailableForLanguage(Language language) {
return language.isKindOf(StdFileTypes.JAVA.getLanguage());
}