当前位置: 首页>>代码示例>>Java>>正文


Java ElementManipulators.getValueTextRange方法代码示例

本文整理汇总了Java中com.intellij.psi.ElementManipulators.getValueTextRange方法的典型用法代码示例。如果您正苦于以下问题:Java ElementManipulators.getValueTextRange方法的具体用法?Java ElementManipulators.getValueTextRange怎么用?Java ElementManipulators.getValueTextRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.ElementManipulators的用法示例。


在下文中一共展示了ElementManipulators.getValueTextRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInjectedArea

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@NotNull
public List<TextRange> getInjectedArea(final PsiElement element) {
  final TextRange textRange = ElementManipulators.getValueTextRange(element);
  if (myCompiledValuePattern == null) {
    return Collections.singletonList(textRange);
  }
  else {
    final LiteralTextEscaper<? extends PsiLanguageInjectionHost> textEscaper =
            ((PsiLanguageInjectionHost)element).createLiteralTextEscaper();
    final StringBuilder sb = new StringBuilder();
    textEscaper.decode(textRange, sb);
    final List<TextRange> ranges = getMatchingRanges(myCompiledValuePattern.matcher(StringPattern.newBombedCharSequence(sb)), sb.length());
    return !ranges.isEmpty() ? ContainerUtil.map(ranges, new Function<TextRange, TextRange>() {
      public TextRange fun(TextRange s) {
        return new TextRange(textEscaper.getOffsetInHost(s.getStartOffset(), textRange), textEscaper.getOffsetInHost(s.getEndOffset(), textRange));
      }
    }) : Collections.<TextRange>emptyList();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:BaseInjection.java

示例2: createReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] createReferences(GenericDomValue value, final PsiElement element, final ConvertContext context) {
  String text = value.getStringValue();
  TextRange range = ElementManipulators.getValueTextRange(element);
  return new PsiReference[]{new MavenUrlPsiReference(element, text, range) {

    @NotNull
    @Override
    public Object[] getVariants() {
      Module module = context.getModule();

      if (module != null) {
        String name = MavenRepositoriesProvider.getInstance().getRepositoryUrl(getRepositoryId(context));
        if (!StringUtil.isEmptyOrSpaces(name)) return new Object[]{name};
      }
      return super.getVariants();
    }
  }};
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:MavenRepositoryConverter.java

示例3: createReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@Override
public boolean createReferences(@NotNull final PsiElement psiElement, final @NotNull List<PsiReference> references, final boolean soft) {

  final TextRange range = ElementManipulators.getValueTextRange(psiElement);
  int offset = range.getStartOffset();
  int endOffset = range.getEndOffset();
  final String elementText = psiElement.getText();
  for (DynamicContextProvider provider: Extensions.getExtensions(DynamicContextProvider.EP_NAME)) {
    final int dynamicOffset = provider.getOffset(psiElement, offset, elementText);
    if (dynamicOffset == -1) {
      return false;
    } else if (dynamicOffset != offset) {
      offset = dynamicOffset;
    }
  }

  final int pos = getLastPosOfURL(offset, elementText);
  if (pos != -1 && pos < endOffset) {
    endOffset = pos;
  }
  try {
    final String text = elementText.substring(offset, endOffset);
    return createReferences(psiElement, offset, text, references, soft);
  } catch (StringIndexOutOfBoundsException e) {
    LOG.error("Cannot process string: '" + psiElement.getParent().getParent().getText() + "'", e);
    return false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:PathReferenceProviderBase.java

示例4: createReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@Override
public boolean createReferences(@NotNull final PsiElement psiElement, @NotNull final List<PsiReference> references, final boolean soft) {

  final TextRange range = ElementManipulators.getValueTextRange(psiElement);
  final String elementText = psiElement.getText();
  final int anchorOffset = elementText.indexOf('#');
  if (anchorOffset == -1) {
    return false;
  }
  final boolean dynamic = isDynamic(psiElement, anchorOffset + 1, elementText);
  if (dynamic) {
    return false;
  }

  FileReference fileReference = null;
  if (range.getStartOffset() != anchorOffset) {
    fileReference = findFileReference(references);
    if (fileReference == null || fileReference.resolve() == null) {
      return false;
    }
  }
  final int pos = elementText.indexOf('?', anchorOffset);
  final String anchor;
  try {
    int endIndex = pos != -1 ? pos : range.getEndOffset();
    if (endIndex <= anchorOffset) {
      endIndex = anchorOffset + 1;
    }
    anchor = elementText.substring(anchorOffset + 1, endIndex);
  }
  catch (StringIndexOutOfBoundsException e) {      
    throw new RuntimeException(elementText, e);
  }
  final AnchorReferenceImpl anchorReference = new AnchorReferenceImpl(anchor, fileReference, psiElement, anchorOffset + 1, soft);
  references.add(anchorReference);
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:AnchorPathReferenceProvider.java

示例5: createReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@NotNull
public PsiReference[] createReferences(GenericDomValue<TargetResolver.Result> value, PsiElement element, ConvertContext context) {
  final XmlElement xmlElement = value.getXmlElement();
  if (!(xmlElement instanceof XmlAttribute)) {
    return PsiReference.EMPTY_ARRAY;
  }
  final XmlAttributeValue valueElement = ((XmlAttribute)xmlElement).getValueElement();
  if (valueElement == null) {
    return PsiReference.EMPTY_ARRAY;
  }
  final String refsString = value.getStringValue();
  if (refsString == null) {
    return PsiReference.EMPTY_ARRAY;
  }
  final List<PsiReference> refs = new ArrayList<PsiReference>();
  final AntDomTargetReference.ReferenceGroup group = new AntDomTargetReference.ReferenceGroup();
  final TextRange wholeStringRange = ElementManipulators.getValueTextRange(valueElement);
  final StringTokenizer tokenizer = new StringTokenizer(refsString, ",", false);
  while (tokenizer.hasMoreTokens()) {
    final String token = tokenizer.nextToken();
    int tokenStartOffset = tokenizer.getCurrentPosition() - token.length();
    final String ref = token.trim();
    if (ref.length() != token.length()) {
      for (int idx = 0; idx < token.length(); idx++) {
        if (Character.isWhitespace(token.charAt(idx))) {
          tokenStartOffset++;
        }
        else {
          break;
        }
      }
    }
    refs.add(new AntDomTargetReference(element, TextRange.from(wholeStringRange.getStartOffset() + tokenStartOffset, ref.length()), group));
  }
  return refs.toArray(new PsiReference[refs.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:AntDomTargetDependsListConverter.java

示例6: createReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
public boolean createReferences(@NotNull final PsiElement psiElement, final @NotNull List<PsiReference> references, final boolean soft) {

    final TextRange range = ElementManipulators.getValueTextRange(psiElement);
    final String elementText = psiElement.getText();
    final int anchorOffset = elementText.indexOf('#');
    if (anchorOffset == -1) {
      return false;
    }
    final boolean dynamic = isDynamic(psiElement, anchorOffset + 1, elementText);
    if (dynamic) {
      return false;
    }

    FileReference fileReference = null;
    if (range.getStartOffset() != anchorOffset) {
      fileReference = findFileReference(references);
      if (fileReference == null || fileReference.resolve() == null) {
        return false;
      }
    }
    final int pos = elementText.indexOf('?', anchorOffset);
    final String anchor;
    try {
      int endIndex = pos != -1 ? pos : range.getEndOffset();
      if (endIndex <= anchorOffset) {
        endIndex = anchorOffset + 1;
      }
      anchor = elementText.substring(anchorOffset + 1, endIndex);
    }
    catch (StringIndexOutOfBoundsException e) {      
      throw new RuntimeException(elementText, e);
    }
    final AnchorReference anchorReference = new AnchorReference(anchor, fileReference, psiElement, anchorOffset + 1, soft);
    references.add(anchorReference);
    return false;
  }
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:AnchorPathReferenceProvider.java

示例7: createReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@Override
public boolean createReferences(@Nonnull final PsiElement psiElement, final @Nonnull List<PsiReference> references, final boolean soft) {

  final TextRange range = ElementManipulators.getValueTextRange(psiElement);
  int offset = range.getStartOffset();
  int endOffset = range.getEndOffset();
  final String elementText = psiElement.getText();
  for (DynamicContextProvider provider: Extensions.getExtensions(DynamicContextProvider.EP_NAME)) {
    final int dynamicOffset = provider.getOffset(psiElement, offset, elementText);
    if (dynamicOffset == -1) {
      return false;
    } else if (dynamicOffset != offset) {
      offset = dynamicOffset;
    }
  }

  final int pos = getLastPosOfURL(offset, elementText);
  if (pos != -1 && pos < endOffset) {
    endOffset = pos;
  }
  try {
    final String text = elementText.substring(offset, endOffset);
    return createReferences(psiElement, offset, text, references, soft);
  } catch (StringIndexOutOfBoundsException e) {
    LOG.error("Cannot process string: '" + psiElement.getParent().getParent().getText() + "'", e);
    return false;
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:29,代码来源:PathReferenceProviderBase.java

示例8: getValueReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@Override
public PsiReference[] getValueReferences(XmlTag xmlTag, @NotNull String text)
{
	XmlTagValue value = xmlTag.getValue();
	XmlText[] elements = value.getTextElements();
	if(elements.length == 0 || xmlTag.getSubTags().length > 0)
	{
		return PsiReference.EMPTY_ARRAY;
	}
	return new PsiReference[]{
			new XmlEnumeratedValueReference(xmlTag, this, ElementManipulators.getValueTextRange(xmlTag))
	};
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:14,代码来源:XmlElementDescriptorImpl.java

示例9: createReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
public boolean createReferences(@NotNull final PsiElement psiElement, final @NotNull List<PsiReference> references, final boolean soft) {

    final TextRange range = ElementManipulators.getValueTextRange(psiElement);
    final String elementText = psiElement.getText();
    final int anchorOffset = elementText.indexOf('#');
    if (anchorOffset == -1) {
      return false;
    }
    final boolean dynamic = isDynamic(psiElement, anchorOffset + 1, elementText);
    if (dynamic) {
      return false;
    }

    FileReference fileReference = null;
    if (range.getStartOffset() != anchorOffset) {
      fileReference = findFileReference(references);
      if (fileReference == null || fileReference.resolve() == null) {
        return false;
      }
    }
    final int pos = elementText.indexOf('?', anchorOffset);
    final String anchor;
    try {
      int endIndex = pos != -1 ? pos : range.getEndOffset();
      if (endIndex <= anchorOffset) {
        endIndex = anchorOffset + 1;
      }
      anchor = elementText.substring(anchorOffset + 1, endIndex);
    }
    catch (StringIndexOutOfBoundsException e) {      
      throw new RuntimeException(elementText, e);
    }
    final AnchorReferenceImpl anchorReferenceImpl = new AnchorReferenceImpl(anchor, fileReference, psiElement, anchorOffset + 1, soft);
    references.add(anchorReferenceImpl);
    return false;
  }
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:37,代码来源:AnchorPathReferenceProvider.java

示例10: getRangeInElement

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@Override
public TextRange getRangeInElement() {
  final JsonValue nameElement = myProperty.getNameElement();
  // Either value of string with quotes stripped or element's text as is
  return ElementManipulators.getValueTextRange(nameElement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:JsonPropertyNameReference.java

示例11: XmlValueReference

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
protected XmlValueReference(XmlTag tag) {
  myTag = tag;
  myRange = ElementManipulators.getValueTextRange(tag);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:XmlValueReference.java

示例12: BasicAttributeValueReference

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
public BasicAttributeValueReference(final PsiElement element) {
  this ( element, ElementManipulators.getValueTextRange(element));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:BasicAttributeValueReference.java

示例13: getReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
public static PsiReference[] getReferences(PsiElement element, boolean isSoft) {
  TextRange textRange = ElementManipulators.getValueTextRange(element);
  if (textRange.isEmpty()) return PsiReference.EMPTY_ARRAY;

  String text = element.getText();

  if (StringUtil.isEmptyOrSpaces(text)) return PsiReference.EMPTY_ARRAY;

  if (!isElementCanContainReference(element)) return PsiReference.EMPTY_ARRAY;

  MavenProject mavenProject = null;
  XmlTag propertiesTag = null;
  List<PsiReference> result = null;

  Matcher matcher = MavenPropertyResolver.PATTERN.matcher(textRange.substring(text));
  while (matcher.find()) {
    String propertyName = matcher.group(1);
    int from;
    if (propertyName == null) {
      propertyName = matcher.group(2);
      from = matcher.start(2);
    }
    else {
      from = matcher.start(1);
    }

    TextRange range = TextRange.from(textRange.getStartOffset() + from, propertyName.length());

    if (result == null) {
      result = new ArrayList<PsiReference>();

      mavenProject = findMavenProject(element);
      if (mavenProject == null) {
        propertiesTag = findPropertiesParentTag(element);
        if (propertiesTag == null) {
          return PsiReference.EMPTY_ARRAY;
        }
      }
    }

    PsiReference ref;
    if (mavenProject != null) {
      ref = new MavenPropertyPsiReference(mavenProject, element, propertyName, range, isSoft);
    }
    else {
      ref = new MavenContextlessPropertyReference(propertiesTag, element, range, true);
    }

    result.add(ref);
  }

  return result == null ? PsiReference.EMPTY_ARRAY : result.toArray(new PsiReference[result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:MavenPropertyPsiReferenceProvider.java

示例14: createReferences

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
@NotNull
public PsiReference[] createReferences(GenericDomValue value, PsiElement element, ConvertContext context) {
  String text = value.getStringValue();
  TextRange range = ElementManipulators.getValueTextRange(element);
  return new PsiReference[]{createReference(element, text, range)};
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:MavenReferenceConverter.java

示例15: getRangeInElement

import com.intellij.psi.ElementManipulators; //导入方法依赖的package包/类
public TextRange getRangeInElement() {
  return ElementManipulators.getValueTextRange(myValue);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:StringLiteralReference.java


注:本文中的com.intellij.psi.ElementManipulators.getValueTextRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。