本文整理汇总了Java中com.intellij.psi.InjectedLanguagePlaces.addPlace方法的典型用法代码示例。如果您正苦于以下问题:Java InjectedLanguagePlaces.addPlace方法的具体用法?Java InjectedLanguagePlaces.addPlace怎么用?Java InjectedLanguagePlaces.addPlace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.InjectedLanguagePlaces
的用法示例。
在下文中一共展示了InjectedLanguagePlaces.addPlace方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host, @NotNull final InjectedLanguagePlaces injectionPlacesRegistrar) {
if (!(host instanceof XmlText)) return;
final XmlText xmlText = (XmlText)host;
if (!MavenPluginParamInfo.isSimpleText(xmlText)) return;
MavenPluginParamInfo.ParamInfoList infoList = MavenPluginParamInfo.getParamInfoList(xmlText);
for (MavenPluginParamInfo.ParamInfo info : infoList) {
Language language = info.getLanguage();
if (language == null) {
MavenParamLanguageProvider provider = info.getLanguageProvider();
if (provider != null) {
language = provider.getLanguage(xmlText, infoList.getDomCfg());
}
}
if (language != null) {
injectionPlacesRegistrar.addPlace(language, TextRange.from(0, host.getTextLength()), info.getLanguageInjectionPrefix(), info.getLanguageInjectionSuffix());
return;
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MavenPluginConfigurationLanguageInjector.java
示例2: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectedLanguagePlaces) {
if (host.getLanguage().isKindOf(JavaScriptLanguage) &&
host.getClass().getSimpleName().equals(TEMPLATE_STRING)) {
String hostText = host.getText();
if (!hostText.contains("${") &&
hostText.startsWith(prefix) && hostText.endsWith(suffix)) {
injectedLanguagePlaces.addPlace(
GraphQLLanguage.INSTANCE,
new TextRange(
prefix.length(),
hostText.length() - suffix.length()
),
null, null);
}
}
}
示例3: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(
@NotNull PsiLanguageInjectionHost host,
@NotNull InjectedLanguagePlaces injectionPlacesRegistrar)
{
// we accept only PHP literal expressions, such as docBlocks and string for PointcutBuilder->method('<expr>')
if (!(host instanceof StringLiteralExpression)) {
return;
}
StringLiteralExpression literalExpression = (StringLiteralExpression) host;
boolean enableInjection = CodePattern.isInsideAnnotation(literalExpression, GO_AOP_ANNOTATION);
enableInjection |= CodePattern.isInsidePointcutBuilderMethod(literalExpression);
if (enableInjection) {
TextRange rangeInsideHost = new TextRange(1, Math.max(literalExpression.getTextLength()-1, 1));
injectionPlacesRegistrar.addPlace(PointcutQueryLanguage.INSTANCE, rangeInsideHost, null, null);
}
}
示例4: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host,
@NotNull final InjectedLanguagePlaces places) {
final boolean isSelectQuery = host.getText().trim().toUpperCase().startsWith("SELECT");
final boolean isDataSetFile = host.getContainingFile().getText().startsWith("<dataset>");
if (isDataSetFile && isSelectQuery) {
final Language language = Language.findLanguageByID("SQL");
if (language != null) {
try {
places.addPlace(language, TextRange.from(0, host.getTextLength()), null, null);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}
示例5: injectLanguage
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
private void injectLanguage(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectedLanguagePlaces, String scriptingName) {
final Language requiredLanguage = Language.findLanguageByID(scriptingName);
if (requiredLanguage != null) {
final TextRange range = TextRange.from(0, host.getTextRange().getLength());
injectedLanguagePlaces.addPlace(requiredLanguage, range, null, null);
}
}
示例6: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
if (!(host instanceof CupJavaImpl) || !(settings.ENABLE_JAVA_INJECTION)) {
return;
}
final CupJavaImpl cupJavaCode = (CupJavaImpl) host;
final String text = cupJavaCode.getText();
if (!(text.startsWith(PREFIX) && text.endsWith(SUFFIX))) {
return;
}
injectionPlacesRegistrar.addPlace(JavaLanguage.INSTANCE, new TextRange(SUFFIX.length(), text.length() - SUFFIX.length()), "public class Dummy { public void dummyMethod(){", "}}");
}
示例7: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
Iterator it = myInjectionConfiguration.getInjections("fusion").iterator();
while(it.hasNext()) {
BaseInjection injection = (BaseInjection) it.next();
if (injection.acceptsPsiElement(host)) {
Language language = InjectedLanguage.findLanguageById(injection.getInjectedLanguageId());
if (language != null) {
injectionPlacesRegistrar.addPlace(language, new TextRange(0, host.getTextLength()), "", "");
}
}
}
}
示例8: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
if (!(host instanceof XmlAttributeValue)) {
return;
}
String valueText = ((XmlAttributeValue)host).getValue();
if (valueText.length() <= PREFIX_BINDING_EXPR.length() || !valueText.startsWith(PREFIX_BINDING_EXPR)) {
return;
}
PsiElement parent = host.getParent();
if (!(parent instanceof XmlAttribute)) return;
GenericAttributeValue element = DomManager.getDomManager(host.getProject()).getDomElement((XmlAttribute)parent);
if (element == null || !(element.getParent() instanceof AndroidDomElement)) return;
// Parser only parses the expression, not the prefix '@{' or the suffix '}'. Extract the start/end index of the expression.
String unescapedValue = host.getText();
int startIndex = unescapedValue.indexOf(PREFIX_BINDING_EXPR.charAt(0)) + PREFIX_BINDING_EXPR.length();
int endIndex;
if (valueText.endsWith("}")) {
endIndex = unescapedValue.lastIndexOf('}');
} else {
if (host.getNode().getLastChildNode().getElementType() == XmlTokenType.XML_ATTRIBUTE_VALUE_END_DELIMITER) {
endIndex = host.getLastChild().getStartOffsetInParent();
} else {
endIndex = unescapedValue.length();
}
}
injectionPlacesRegistrar.addPlace(DbLanguage.INSTANCE, TextRange.from(startIndex, endIndex-startIndex), null, null);
}
示例9: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
if(ApplicationManager.getApplication().isUnitTestMode()) {
// intellij unit test env doesn't properly support language injection in combination with formatter tests, so skip injection in that case
return;
}
if (host instanceof PsiComment && host.getLanguage() == JSGraphQLEndpointLanguage.INSTANCE) {
injectionPlacesRegistrar.addPlace(JSGraphQLEndpointDocLanguage.INSTANCE, TextRange.create(0, host.getTextLength()), "", "");
}
}
示例10: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
if (host instanceof HaxeRegularExpression) {
final String text = host.getText();
final TextRange textRange = new TextRange(text.indexOf('/') + 1, text.lastIndexOf('/'));
injectionPlacesRegistrar.addPlace(RegExpLanguage.INSTANCE, textRange, null, null);
}
}
示例11: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host, @NotNull final InjectedLanguagePlaces injectionPlacesRegistrar) {
if (host instanceof RestLine) {
int start = 0;
int end = host.getTextLength() - 1;
final String text = host.getText();
final List<String> strings = StringUtil.split(text, "\n", false);
boolean gotExample = false;
int currentPosition = 0;
boolean endsWithSlash = false;
for (String string : strings) {
final String trimmedString = string.trim();
if (!trimmedString.startsWith(">>>") && !trimmedString.startsWith("...") && gotExample && start < end) {
gotExample = false;
if (!endsWithSlash)
injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end), null, null);
}
if (endsWithSlash) {
endsWithSlash = false;
injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(),
TextRange.create(start, getEndOffset(currentPosition, string)), null, null);
}
if (trimmedString.startsWith(">>>")) {
if (trimmedString.endsWith("\\"))
endsWithSlash = true;
if (!gotExample)
start = currentPosition;
gotExample = true;
end = getEndOffset(currentPosition, string);
}
else if (trimmedString.startsWith("...") && gotExample) {
if (trimmedString.endsWith("\\"))
endsWithSlash = true;
end = getEndOffset(currentPosition, string);
}
currentPosition += string.length();
}
if (gotExample && start < end)
injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end), null, null);
}
}
示例12: getLanguagesToInject
import com.intellij.psi.InjectedLanguagePlaces; //导入方法依赖的package包/类
@Override
public void getLanguagesToInject(@NotNull final PsiLanguageInjectionHost host, @NotNull final InjectedLanguagePlaces injectionPlacesRegistrar) {
if (!(host instanceof PyStringLiteralExpression)) {
return;
}
final Module module = ModuleUtilCore.findModuleForPsiElement(host);
if (module == null || !PyDocumentationSettings.getInstance(module).isAnalyzeDoctest()) return;
final PyDocStringOwner
docStringOwner = PsiTreeUtil.getParentOfType(host, PyDocStringOwner.class);
if (docStringOwner != null && host.equals(docStringOwner.getDocStringExpression())) {
int start = 0;
int end = host.getTextLength() - 1;
final String text = host.getText();
final Pair<String,String> quotes = PythonStringUtil.getQuotes(text);
final List<String> strings = StringUtil.split(text, "\n", false);
boolean gotExample = false;
int currentPosition = 0;
int maxPosition = text.length();
boolean endsWithSlash = false;
for (String string : strings) {
final String trimmedString = string.trim();
if (!trimmedString.startsWith(">>>") && !trimmedString.startsWith("...") && gotExample && start < end) {
gotExample = false;
if (!endsWithSlash)
injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end), null, null);
}
final String closingQuote = quotes == null ? text.substring(0, 1) : quotes.second;
if (endsWithSlash && !trimmedString.endsWith("\\")) {
endsWithSlash = false;
injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(),
TextRange.create(start, getEndOffset(currentPosition, string, maxPosition, closingQuote)), null, null);
}
if (trimmedString.startsWith(">>>")) {
if (trimmedString.endsWith("\\"))
endsWithSlash = true;
if (!gotExample)
start = currentPosition;
gotExample = true;
end = getEndOffset(currentPosition, string, maxPosition, closingQuote);
}
else if (trimmedString.startsWith("...") && gotExample) {
if (trimmedString.endsWith("\\"))
endsWithSlash = true;
end = getEndOffset(currentPosition, string, maxPosition, closingQuote);
}
currentPosition += string.length();
}
if (gotExample && start < end)
injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end), null, null);
}
}