Java Code Examples for com.intellij.openapi.util.TextRange#EMPTY_RANGE

The following examples show how to use com.intellij.openapi.util.TextRange#EMPTY_RANGE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ORParameterInfoHandlerWithTabActionSupport.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Override
public void updateUI(@Nullable ORSignature signature, @NotNull ParameterInfoUIContext context) {
    if (signature == null) {
        context.setUIComponentEnabled(false);
        return;
    }

    int currentParameterIndex = context.getCurrentParameterIndex();
    ORSignature.SignatureType[] types = signature.getTypes();

    boolean grayedOut = types.length <= currentParameterIndex;
    context.setUIComponentEnabled(!grayedOut);

    TextRange paramRange = TextRange.EMPTY_RANGE;

    context.setupUIComponentPresentation(signature.asParameterInfo(OclLanguage.INSTANCE), paramRange.getStartOffset(), paramRange.getEndOffset(),
                                         !context.isUIComponentEnabled(), false, true, context.getDefaultParameterColor());
}
 
Example 2
Source File: FileReferenceNode.java    From protobuf-jetbrains-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
public PsiReference[] getReferences() {
    String filename = getFilename();
    if (filename == null) {
        return new PsiReference[0];
    }
    int filenameStart = getText().lastIndexOf('/');
    TextRange textRange;
    if (filenameStart >= 0) {
        textRange = TextRange.create(filenameStart + 1, getTextLength() - 1);
    } else {
        textRange = TextRange.EMPTY_RANGE;
    }
    ProtoPsiFileRoot target = getTarget();
    ImportProtoReference reference = new ImportProtoReference(this, textRange, target);
    return new PsiReference[]{reference};
}
 
Example 3
Source File: StringLiteral.java    From intellij with Apache License 2.0 6 votes vote down vote up
/** The range of text characters, excluding leading and trailing quotes. */
public static TextRange textRangeInElement(String string) {
  // TODO: Handle escaped characters, etc. here?
  // (extract logic from BuildLexerBase.addStringLiteral)
  if (string.startsWith("\"\"\"")) {
    return string.length() <= 3
        ? TextRange.EMPTY_RANGE
        : TextRange.create(3, endTrimIndex(string, '"', 3));
  }
  if (string.startsWith("'''")) {
    return string.length() <= 3
        ? TextRange.EMPTY_RANGE
        : TextRange.create(3, endTrimIndex(string, '\'', 3));
  }
  if (string.startsWith("\"")) {
    return TextRange.create(1, endTrimIndex(string, '"', 1));
  }
  if (string.startsWith("'")) {
    return TextRange.create(1, endTrimIndex(string, '\'', 1));
  }
  return TextRange.allOf(string);
}
 
Example 4
Source File: ORUtil.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@NotNull
private static TextRange rangeInParent(@NotNull TextRange parent, @NotNull TextRange child) {
    int start = child.getStartOffset() - parent.getStartOffset();
    if (start < 0) {
        return TextRange.EMPTY_RANGE;
    }

    return TextRange.create(start, start + child.getLength());
}
 
Example 5
Source File: CompilerTask.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static TextRange getTextRange(final CompilerMessage message) {
  Navigatable navigatable = message.getNavigatable();
  if (navigatable instanceof OpenFileDescriptor) {
    int offset = ((OpenFileDescriptor)navigatable).getOffset();
    return new TextRange(offset, offset);
  }
  return TextRange.EMPTY_RANGE;
}
 
Example 6
Source File: ExternalWorkspaceReferenceFragment.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public TextRange getRangeInElement() {
  String rawText = myElement.getText();
  boolean valid = LabelUtils.getExternalWorkspaceComponent(myElement.getStringContents()) != null;
  if (!valid) {
    return TextRange.EMPTY_RANGE;
  }
  int endIndex = rawText.indexOf("//");
  if (endIndex == -1) {
    endIndex = rawText.length() - 1;
  }
  return new TextRange(1, endIndex);
}
 
Example 7
Source File: CSharpReferenceExpressionImplUtil.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
public static TextRange getRangeInElement(@Nonnull CSharpReferenceExpression referenceExpression)
{
	PsiElement referenceElement = referenceExpression.getReferenceElement();
	if(referenceElement == null)
	{
		return TextRange.EMPTY_RANGE;
	}

	int startOffset = referenceElement.getStartOffsetInParent();
	return new TextRange(startOffset, referenceElement.getTextLength() + startOffset);
}
 
Example 8
Source File: RenameableFakePsiElement.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nullable
public TextRange getTextRange() {
  return TextRange.EMPTY_RANGE;
}
 
Example 9
Source File: LombokLightModifierList.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}
 
Example 10
Source File: LombokLightClassBuilder.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}
 
Example 11
Source File: SelectionEvent.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static TextRange getRange(TextRange[] ranges) {
  if (ranges.length == 0) {
    return TextRange.EMPTY_RANGE;
  }
  return new TextRange(ranges[0].getStartOffset(), ranges[ranges.length - 1].getEndOffset());
}
 
Example 12
Source File: HaxeRangeUtil.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
@NotNull
public static TextRange getCombinedRange(@Nullable PsiElement... elements) {
  if (null == elements)
    return TextRange.EMPTY_RANGE;
  return getCombinedRange(Arrays.asList(elements));
}
 
Example 13
Source File: LombokLightFieldBuilder.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}
 
Example 14
Source File: LombokLightMethodBuilder.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}
 
Example 15
Source File: SqliteMagicLightParameter.java    From sqlitemagic with Apache License 2.0 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}
 
Example 16
Source File: SqliteMagicLightModifierList.java    From sqlitemagic with Apache License 2.0 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}
 
Example 17
Source File: SqliteMagicLightIdentifier.java    From sqlitemagic with Apache License 2.0 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}
 
Example 18
Source File: SqliteMagicLightFieldBuilder.java    From sqlitemagic with Apache License 2.0 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}
 
Example 19
Source File: WolfHighlightingPass.java    From consulo with Apache License 2.0 4 votes vote down vote up
WolfHighlightingPass(@Nonnull Project project, @Nonnull Document document, @Nonnull PsiFile file) {
  super(project, document, DaemonBundle.message("pass.wolf"), file, null, TextRange.EMPTY_RANGE, false, HighlightInfoProcessor.getEmpty());
}
 
Example 20
Source File: LombokLightParameter.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public TextRange getTextRange() {
  TextRange r = super.getTextRange();
  return r == null ? TextRange.EMPTY_RANGE : r;
}