本文整理汇总了Java中com.intellij.openapi.util.Segment类的典型用法代码示例。如果您正苦于以下问题:Java Segment类的具体用法?Java Segment怎么用?Java Segment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Segment类属于com.intellij.openapi.util包,在下文中一共展示了Segment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compareTo
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
public int compareTo(@NotNull UsageGroup usageGroup) {
if (!(usageGroup instanceof MethodUsageGroup)) {
LOG.error("MethodUsageGroup expected but " + usageGroup.getClass() + " found");
}
MethodUsageGroup other = (MethodUsageGroup)usageGroup;
if (SmartPointerManager.getInstance(myProject).pointToTheSameElement(myMethodPointer, other.myMethodPointer)) {
return 0;
}
if (!UsageViewSettings.getInstance().IS_SORT_MEMBERS_ALPHABETICALLY) {
Segment segment1 = myMethodPointer.getRange();
Segment segment2 = other.myMethodPointer.getRange();
if (segment1 != null && segment2 != null) {
return segment1.getStartOffset() - segment2.getStartOffset();
}
}
return myName.compareToIgnoreCase(other.myName);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MethodGroupingRule.java
示例2: testEqualPointerRangesWhenCreatedFromStubAndAST
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
public void testEqualPointerRangesWhenCreatedFromStubAndAST() {
final PsiFile file = configureByText(JavaFileType.INSTANCE,
"class S {\n" +
"}");
PsiClass aClass = ((PsiJavaFile)file).getClasses()[0];
assertNotNull(((PsiFileImpl)file).getStubTree());
final SmartPointerManager manager = getPointerManager();
final SmartPsiElementPointer<PsiClass> pointer1 = createPointer(aClass);
Segment range1 = pointer1.getRange();
manager.removePointer(pointer1);
final FileASTNode node = file.getNode();
final SmartPsiElementPointer<PsiClass> pointer2 = createPointer(aClass);
assertEquals(range1, pointer2.getRange());
assertNotNull(node);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SmartPsiElementPointersTest.java
示例3: flashUsageScriptaculously
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
private static void flashUsageScriptaculously(@NotNull final Usage usage) {
if (!(usage instanceof UsageInfo2UsageAdapter)) {
return;
}
UsageInfo2UsageAdapter usageInfo = (UsageInfo2UsageAdapter)usage;
Editor editor = usageInfo.openTextEditor(true);
if (editor == null) return;
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES);
RangeBlinker rangeBlinker = new RangeBlinker(editor, attributes, 6);
List<Segment> segments = new ArrayList<Segment>();
CommonProcessors.CollectProcessor<Segment> processor = new CommonProcessors.CollectProcessor<Segment>(segments);
usageInfo.processRangeMarkers(processor);
rangeBlinker.resetMarkers(segments);
rangeBlinker.startBlinking();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SearchForUsagesRunnable.java
示例4: getRangeInElement
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
/**
* @return range in element
*/
@Nullable("null means range is invalid")
public ProperTextRange getRangeInElement() {
PsiElement element = getElement();
if (element == null) return null;
TextRange elementRange = element.getTextRange();
ProperTextRange result;
if (myPsiFileRange == null) {
int startOffset = element.getTextOffset();
result = ProperTextRange.create(startOffset, elementRange.getEndOffset());
}
else {
Segment rangeInFile = myPsiFileRange.getRange();
if (rangeInFile == null) return null;
result = ProperTextRange.create(rangeInFile);
}
int delta = elementRange.getStartOffset();
return result.getStartOffset() < delta ? null : result.shiftRight(-delta);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:UsageInfo.java
示例5: ReplacementPreviewDialog
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
public ReplacementPreviewDialog(final Project project, UsageInfo info, String replacementString) {
super(project,true);
setTitle(SSRBundle.message("structural.replace.preview.dialog.title"));
setOKButtonText(SSRBundle.message("replace.preview.oktext"));
this.project = project;
final PsiElement element = info.getElement();
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
myFileType = virtualFile != null ? virtualFile.getFileType() : FileTypes.PLAIN_TEXT;
init();
Segment range = info.getSegment();
hilight(virtualFile, range.getStartOffset(), range.getEndOffset());
UIUtil.setContent(replacement, replacementString,0,-1,project);
final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(element);
if (profile != null) {
UIUtil.updateHighlighter(replacement, profile);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ReplacementPreviewDialog.java
示例6: applyChange
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Nullable
static Pair<ProperTextRange, LinesCols> applyChange(DocumentEvent event, Segment range, int intervalStart, int intervalEnd, boolean greedyLeft, boolean greedyRight, LinesCols linesCols) {
final boolean shouldTranslateViaDiff = PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, range);
Pair<ProperTextRange, LinesCols> translated = null;
if (shouldTranslateViaDiff) {
translated = translateViaDiff((DocumentEventImpl)event, linesCols);
}
if (translated == null) {
ProperTextRange fallback = applyChange(event, intervalStart, intervalEnd, greedyLeft, greedyRight);
if (fallback == null) return null;
LinesCols lc = storeLinesAndCols(fallback, event.getDocument());
if (lc == null) return null;
translated = Pair.create(fallback, lc);
}
if (translated.first.getEndOffset() > event.getDocument().getTextLength() ||
translated.second.myEndLine < translated.second.myStartLine ||
translated.second.myStartLine == translated.second.myEndLine && translated.second.myEndColumn < translated.second.myStartColumn ||
event.getDocument().getLineCount() < translated.second.myEndLine) {
return null;
}
return translated;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PersistentRangeMarker.java
示例7: restoreElement
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
public PsiElement restoreElement() {
PsiFile hostFile = myHostContext.getContainingFile();
if (hostFile == null || !hostFile.isValid()) return null;
PsiElement hostContext = myHostContext.getElement();
if (hostContext == null) return null;
Segment segment = myInjectedFileRangeInHostFile.getPsiRange();
if (segment == null) return null;
PsiFile injectedPsi = getInjectedFileIn(hostContext, hostFile, TextRange.create(segment));
ProperTextRange rangeInInjected = hostToInjected(true, segment, injectedPsi, myAffixOffsets);
if (rangeInInjected == null) return null;
return SelfElementInfo.findElementInside(injectedPsi, rangeInInjected.getStartOffset(), rangeInInjected.getEndOffset(), anchorClass, anchorLanguage);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:InjectedSelfElementInfo.java
示例8: getNonEditableFragments
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@NotNull
@Override
public List<TextRange> getNonEditableFragments(@NotNull DocumentWindow window) {
List<TextRange> result = ContainerUtil.newArrayList();
int offset = 0;
for (PsiLanguageInjectionHost.Shred shred : ((DocumentWindowImpl)window).getShreds()) {
Segment hostRange = shred.getHostRangeMarker();
if (hostRange == null) continue;
offset = appendRange(result, offset, shred.getPrefix().length());
offset += hostRange.getEndOffset() - hostRange.getStartOffset();
offset = appendRange(result, offset, shred.getSuffix().length());
}
return result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InjectedLanguageManagerImpl.java
示例9: getRangeInsideHost
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
@NotNull
public TextRange getRangeInsideHost() {
PsiLanguageInjectionHost host = getHost();
Segment psiRange = relevantRangeInHost.getPsiRange();
TextRange textRange = psiRange == null ? null : TextRange.create(psiRange);
if (host == null) {
if (textRange != null) return textRange;
Segment fromSP = hostElementPointer.getPsiRange();
if (fromSP != null) return TextRange.create(fromSP);
return new TextRange(0,0);
}
TextRange hostTextRange = host.getTextRange();
textRange = textRange == null ? null : textRange.intersection(hostTextRange);
if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength());
return textRange.shiftRight(-hostTextRange.getStartOffset());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ShredImpl.java
示例10: equals
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PsiLanguageInjectionHost.Shred shred = (PsiLanguageInjectionHost.Shred)o;
PsiLanguageInjectionHost host = getHost();
Segment hostRangeMarker = getHostRangeMarker();
Segment hostRangeMarker2 = shred.getHostRangeMarker();
return host != null &&
host.equals(shred.getHost()) &&
prefix.equals(shred.getPrefix()) &&
suffix.equals(shred.getSuffix()) &&
range.equals(shred.getRange()) &&
hostRangeMarker != null &&
hostRangeMarker2 != null &&
TextRange.create(hostRangeMarker).equals(TextRange.create(hostRangeMarker2));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ShredImpl.java
示例11: compareTo
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
public int compareTo(UsageGroup usageGroup) {
if (!(usageGroup instanceof MethodUsageGroup)) {
LOG.error("MethodUsageGroup expected but " + usageGroup.getClass() + " found");
}
MethodUsageGroup other = (MethodUsageGroup)usageGroup;
if (SmartPointerManager.getInstance(myProject).pointToTheSameElement(myMethodPointer, other.myMethodPointer)) {
return 0;
}
if (!UsageViewSettings.getInstance().IS_SORT_MEMBERS_ALPHABETICALLY) {
Segment segment1 = myMethodPointer.getRange();
Segment segment2 = other.myMethodPointer.getRange();
if (segment1 != null && segment2 != null) {
return segment1.getStartOffset() - segment2.getStartOffset();
}
}
return myName.compareToIgnoreCase(other.myName);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:MethodGroupingRule.java
示例12: compareTo
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
public int compareTo(final UsageInfo2UsageAdapter o) {
VirtualFile containingFile = getFile();
int shift1 = 0;
if (containingFile instanceof VirtualFileWindow) {
shift1 = ((VirtualFileWindow)containingFile).getDocumentWindow().injectedToHost(0);
containingFile = ((VirtualFileWindow)containingFile).getDelegate();
}
VirtualFile oContainingFile = o.getFile();
int shift2 = 0;
if (oContainingFile instanceof VirtualFileWindow) {
shift2 = ((VirtualFileWindow)oContainingFile).getDocumentWindow().injectedToHost(0);
oContainingFile = ((VirtualFileWindow)oContainingFile).getDelegate();
}
if (containingFile == null && oContainingFile == null || !Comparing.equal(containingFile, oContainingFile)) {
return 0;
}
Segment s1 = getFirstSegment();
Segment s2 = o.getFirstSegment();
if (s1 == null || s2 == null) return 0;
return s1.getStartOffset() + shift1 - s2.getStartOffset() - shift2;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:UsageInfo2UsageAdapter.java
示例13: getRangeInsideHost
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
@NotNull
public TextRange getRangeInsideHost() {
PsiLanguageInjectionHost host = getHost();
ProperTextRange textRange =
relevantRangeInHost.isValid() ? new ProperTextRange(relevantRangeInHost.getStartOffset(), relevantRangeInHost.getEndOffset()) : null;
if (host == null) {
if (textRange != null) return textRange;
Segment fromSP = hostElementPointer.getRange();
if (fromSP != null) return TextRange.create(fromSP);
return new TextRange(0,0);
}
TextRange hostTextRange = host.getTextRange();
textRange = textRange == null ? null : textRange.intersection(hostTextRange);
if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength());
return textRange.shiftRight(-hostTextRange.getStartOffset());
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:ShredImpl.java
示例14: equals
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PsiLanguageInjectionHost.Shred shred = (PsiLanguageInjectionHost.Shred)o;
PsiLanguageInjectionHost host = getHost();
Segment hostRangeMarker = shred.getHostRangeMarker();
return host != null &&
host.equals(shred.getHost()) &&
prefix.equals(shred.getPrefix()) &&
suffix.equals(shred.getSuffix()) &&
range.equals(shred.getRange()) &&
hostRangeMarker != null &&
TextRange.create(relevantRangeInHost).equals(TextRange.create(hostRangeMarker));
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:ShredImpl.java
示例15: flashUsageScriptaculously
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
private static void flashUsageScriptaculously(@Nonnull final Usage usage) {
if (!(usage instanceof UsageInfo2UsageAdapter)) {
return;
}
UsageInfo2UsageAdapter usageInfo = (UsageInfo2UsageAdapter)usage;
Editor editor = usageInfo.openTextEditor(true);
if (editor == null) return;
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES);
RangeBlinker rangeBlinker = new RangeBlinker(editor, attributes, 6);
List<Segment> segments = new ArrayList<>();
Processor<Segment> processor = Processors.cancelableCollectProcessor(segments);
usageInfo.processRangeMarkers(processor);
rangeBlinker.resetMarkers(segments);
rangeBlinker.startBlinking();
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:SearchForUsagesRunnable.java
示例16: applyChange
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Nullable
private static Pair<TextRange, LinesCols> applyChange(DocumentEvent event, Segment range, int intervalStart, int intervalEnd,
boolean greedyLeft, boolean greedyRight, boolean stickingToRight,
LinesCols linesCols) {
final boolean shouldTranslateViaDiff = PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, range.getStartOffset(), range.getEndOffset());
Pair<TextRange, LinesCols> translated = null;
if (shouldTranslateViaDiff) {
translated = translateViaDiff((DocumentEventImpl)event, linesCols);
}
if (translated == null) {
TextRange fallback = applyChange(event, intervalStart, intervalEnd, greedyLeft, greedyRight, stickingToRight);
if (fallback == null) return null;
LinesCols lc = storeLinesAndCols(event.getDocument(), fallback.getStartOffset(), fallback.getEndOffset());
if (lc == null) return null;
translated = Pair.create(fallback, lc);
}
return translated;
}
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:PersistentRangeMarker.java
示例17: updatePointerTarget
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
private static <E extends PsiElement> void updatePointerTarget(@Nonnull SmartPsiElementPointerImpl<E> pointer, @Nullable Segment pointerRange) {
E cachedElement = pointer.getCachedElement();
if (cachedElement == null) {
return;
}
if (cachedElement.isValid()) {
if (pointerRange == null) {
// document change could be damaging, but if PSI survived after reparse, let's point to it
((SelfElementInfo)pointer.getElementInfo()).switchToAnchor(cachedElement);
return;
}
// after reparse and its complex tree diff, the element might have "moved" to other range
// but if an element of the same type can still be found at the old range, let's point there
if (pointerRange.equals(cachedElement.getTextRange())) {
return;
}
}
pointer.cacheElement(pointer.doRestoreElement());
}
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:SmartPointerTracker.java
示例18: restoreElement
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Override
PsiElement restoreElement() {
PsiFile hostFile = myHostContext.getContainingFile();
if (hostFile == null || !hostFile.isValid()) return null;
PsiElement hostContext = myHostContext.getElement();
if (hostContext == null) return null;
Segment segment = myInjectedFileRangeInHostFile.getPsiRange();
if (segment == null) return null;
PsiFile injectedPsi = getInjectedFileIn(hostContext, hostFile, TextRange.create(segment));
ProperTextRange rangeInInjected = hostToInjected(true, segment, injectedPsi, myAffixOffsets);
if (rangeInInjected == null) return null;
return myType.findPsiElement(injectedPsi, rangeInInjected.getStartOffset(), rangeInInjected.getEndOffset());
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:InjectedSelfElementInfo.java
示例19: getNonEditableFragments
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Nonnull
@Override
public List<TextRange> getNonEditableFragments(@Nonnull DocumentWindow window) {
List<TextRange> result = ContainerUtil.newArrayList();
int offset = 0;
for (PsiLanguageInjectionHost.Shred shred : ((DocumentWindowImpl)window).getShreds()) {
Segment hostRange = shred.getHostRangeMarker();
if (hostRange == null) continue;
offset = appendRange(result, offset, shred.getPrefix().length());
offset += hostRange.getEndOffset() - hostRange.getStartOffset();
offset = appendRange(result, offset, shred.getSuffix().length());
}
return result;
}
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:InjectedLanguageManagerImpl.java
示例20: calcRangeInsideHostElement
import com.intellij.openapi.util.Segment; //导入依赖的package包/类
@Nonnull
private TextRange calcRangeInsideHostElement(boolean usePsiRange) {
PsiLanguageInjectionHost host = getHost();
Segment psiRange = usePsiRange ? relevantRangeInHost.getPsiRange() : relevantRangeInHost.getRange();
TextRange textRange = psiRange == null ? null : TextRange.create(psiRange);
if (host == null) {
if (textRange != null) return textRange;
Segment fromSP = usePsiRange ? hostElementPointer.getPsiRange() : hostElementPointer.getRange();
if (fromSP != null) return TextRange.create(fromSP);
return new TextRange(0, 0);
}
TextRange hostTextRange = host.getTextRange();
textRange = textRange == null ? null : textRange.intersection(hostTextRange);
if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength());
return textRange.shiftLeft(hostTextRange.getStartOffset());
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:ShredImpl.java
注:本文中的com.intellij.openapi.util.Segment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论