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


Java Region类代码示例

本文整理汇总了Java中org.eclipse.jface.text.Region的典型用法代码示例。如果您正苦于以下问题:Java Region类的具体用法?Java Region怎么用?Java Region使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

Region类属于org.eclipse.jface.text包,在下文中一共展示了Region类的38个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDamageRegion

import org.eclipse.jface.text.Region; //导入依赖的package包/类
@Override
public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged) {
	if (!documentPartitioningChanged) {
		try {

			IRegion info = fDocument.getLineInformationOfOffset(event.getOffset());
			int start = Math.max(partition.getOffset(), info.getOffset());

			int end = event.getOffset() + (event.getText() == null ? event.getLength() : event.getText().length());

			if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
				// optimize the case of the same line
				end = info.getOffset() + info.getLength();
			} else{
				end = endOfLineOf(end);
			}

			end = Math.min(partition.getOffset() + partition.getLength(), end);
			return new Region(start, end - start);

		} catch (BadLocationException x) {
		}
	}

	return partition;
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:27,代码来源:PresentationSupport.java


示例2: getMatchingLocation

import org.eclipse.jface.text.Region; //导入依赖的package包/类
private Region getMatchingLocation(String text, String filter, Pattern regExPattern) {
    if (filter != null && !filter.isEmpty() && text != null) {
        String textLc = text.toLowerCase();
        int offset = -1;
        int length = 0;
        if (regExPattern != null) {
            Matcher matcher = regExPattern.matcher(textLc);
            if (matcher.find()) {
                offset = matcher.start();
                length = matcher.end() - offset;
            }
        } else {
            offset = textLc.indexOf(filter);
            length = filter.length();
        }
        if (offset >= 0) {
            return new Region(offset, length);
        }
    }
    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:22,代码来源:DiffTableViewer.java


示例3: detectHyperlinks

import org.eclipse.jface.text.Region; //导入依赖的package包/类
@Override
public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region,
        boolean canShowMultipleHyperlinks) {
    SQLEditor editor = getAdapter(SQLEditor.class);
    PgDbParser parser = editor.getParser();

    int offset = region.getOffset();
    List<PgObjLocation> refs = parser.getObjsForEditor(editor.getEditorInput());
    for (PgObjLocation obj : refs) {
        if (offset > obj.getOffset()
                && offset < (obj.getOffset() + obj.getObjLength())) {
            IHyperlink[] links =  parser.getDefinitionsForObj(obj)
                    .map(def -> new SQLEditorHyperLink(
                            new Region(def.getOffset(), def.getObjLength()),
                            new Region(obj.getOffset(), obj.getObjLength()),
                            obj.getObjName(), def.getFilePath(), def.getLineNumber()))
                    .toArray(IHyperlink[]::new);
            if (links.length != 0) {
                return links;
            }
        }
    }
    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:25,代码来源:SQLEditorHyperLinkDetector.java


示例4: getHoverRegion

import org.eclipse.jface.text.Region; //导入依赖的package包/类
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
    PgDbParser parser = editor.getParser();
    List<PgObjLocation> refs = parser.getObjsForEditor(editor.getEditorInput());
    for (PgObjLocation obj : refs) {
        if (offset > obj.getOffset()
                && offset < (obj.getOffset() + obj.getObjLength())) {
            Optional<PgObjLocation> loc = parser.getDefinitionsForObj(obj).findAny();
            if (loc.isPresent()) {
                SQLEditorMyRegion region = new SQLEditorMyRegion(obj.getOffset(), obj.getObjLength());
                region.setComment(loc.get().getComment());
                return region;
            }
        }
    }
    return new Region(offset, 0);
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:18,代码来源:SQLEditorTextHover.java


示例5: getHoverRegion

import org.eclipse.jface.text.Region; //导入依赖的package包/类
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {

	IDocument document = textViewer.getDocument();

	/* Vérifie qu'on est dans une String de KSP */
	boolean isSqlString = DocumentUtils.isContentType(document, offset, KspRegionType.STRING);
	if (!isSqlString) {
		return null;
	}

	/* Extrait le mot courant. */
	ITextSelection selection = new TextSelection(document, offset, 0);
	ITextSelection currentWordSelection = DocumentUtils.findCurrentWord(document, selection, WordSelectionType.SNAKE_CASE);
	if (currentWordSelection == null) {
		return null;
	}
	String currentWord = currentWordSelection.getText();
	if (currentWord == null) {
		return null;
	}

	/* Renvoie la région du mot. */
	return new Region(currentWordSelection.getOffset(), currentWordSelection.getLength());
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:26,代码来源:KspTextHover.java


示例6: handleFileLink

import org.eclipse.jface.text.Region; //导入依赖的package包/类
private IHyperlink[] handleFileLink(IRegion lineInfo, GradleHyperLinkResult result) {
	try {
		File folder = editorFile.getParentFile();
		String fileName = result.linkContent;
		
		File target = new File(folder, fileName); 
		if (!target.exists()) {
			target = new File(fileName);
		}
		if (!target.exists()) {
			return null;
		}

		IFileStore fileStore = EFS.getLocalFileSystem().getStore(target.toURI());
		if (fileStore==null){
			return null;
		}
		IRegion urlRegion = new Region(lineInfo.getOffset() + result.linkOffsetInLine, result.linkLength);
		GradleFileHyperlink	gradleFileHyperlink = new GradleFileHyperlink(urlRegion, fileStore);
		return new IHyperlink[] { gradleFileHyperlink };
	} catch (RuntimeException e) {
		return null;
	}
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:25,代码来源:GradleHyperlinkDetector.java


示例7: getCommandArgument

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Returns the first mandatory argument of the command
 * 
 * @param input
 * @param index The index at or after the beginning of the command and before the
 *            argument
 * @return The argument without braces, null if there is no valid argument
 * @throws BadLocationException if index is out of bounds
 */
public static IRegion getCommandArgument(String input, int index){
    int pos = index;
    final int length = input.length();
    if (input.charAt(index) == '\\')
        pos++;
    while (pos < length && Character.isLetter(input.charAt(pos)))
        pos++;
    while (pos < length && Character.isWhitespace(input.charAt(pos)))
        pos++;
    if (pos == length) return null;
    if (input.charAt(pos) == '{') {
        int end = findPeerChar(input, pos + 1, LEFT, '{', '}');
        if (end == -1)
            return null;
        return new Region (pos + 1, end - pos - 1);
    }
    return null;
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:28,代码来源:LatexParserUtils.java


示例8: findEnvironment

import org.eclipse.jface.text.Region; //导入依赖的package包/类
private static IRegion findEnvironment(String input, String envName, String command, int fromIndex) {
    int pos = input.indexOf("{" + envName + "}", fromIndex + command.length());
    while (pos != -1) {
        int end = pos + envName.length() + 2;
        // Search for the command
        int beginStart = findLastCommand(input, command, pos);
        if (beginStart != -1 && beginStart >= fromIndex) {
            // Check for whitespaces between \begin and {...}
                while (pos != beginStart + command.length() && Character.isWhitespace(input.charAt(--pos)))
                    ;
            if (pos == beginStart + command.length()) {
                return new Region(beginStart, end - beginStart);
            }
        }
        pos = input.indexOf("{" + envName + "}", pos + envName.length() + 2);
    }
    return null;
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:19,代码来源:LatexParserUtils.java


示例9: findLastEnvironment

import org.eclipse.jface.text.Region; //导入依赖的package包/类
private static IRegion findLastEnvironment(String input, String envName, String command, int fromIndex) {
    int pos = input.lastIndexOf("{" + envName + "}", fromIndex);
    while (pos != -1) {
        int end = pos + envName.length() + 2;
        // Search for the command
        int beginStart = findLastCommand(input, command, pos);
        if (beginStart != -1 && beginStart <= fromIndex) {
            // Check for whitespaces between \command and {...}
                while (pos != beginStart + command.length() && Character.isWhitespace(input.charAt(--pos)))
                    ;
            if (pos == beginStart + command.length()) {
                return new Region(beginStart, end - beginStart);
            }
        }
        pos = input.lastIndexOf("{" + envName + "}", pos-1);
    }
    return null;
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:19,代码来源:LatexParserUtils.java


示例10: createMatchReferenceJob

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Creates and returns a background job which searches and highlights all \label and \*ref. 
 * @param document
 * @param model
 * @param refName   The name of the reference
 * @return The job
 */
private Job createMatchReferenceJob(final IDocument document, final IAnnotationModel model, final String refName) {
    return
        new Job("Update Annotations") {
            public IStatus run(IProgressMonitor monitor) {
                String text = document.get();
                String refNameRegExp = refName.replaceAll("\\*", "\\\\*");
                final String simpleRefRegExp = "\\\\([a-zA-Z]*ref|label)\\s*\\{" + refNameRegExp + "\\}";
                Matcher m = (Pattern.compile(simpleRefRegExp)).matcher(text);
                while (m.find()) {
                    if (monitor.isCanceled()) return Status.CANCEL_STATUS;
                    IRegion match = LatexParserUtils.getCommand(text, m.start());
                    //Test if it is a real LaTeX command
                    if (match != null) {
                        IRegion fi = new Region(m.start(), m.end()-m.start());
                        createNewAnnotation(fi, "References", model);
                    }
                }
                return Status.OK_STATUS;
            }
    };
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:29,代码来源:TexlipseAnnotationUpdater.java


示例11: createHyperlinksByOffset

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void createHyperlinksByOffset(final XtextResource resource, final int offset, final IHyperlinkAcceptor acceptor) {
  final IParseResult parseResult = resource.getParseResult();
  if (parseResult == null || parseResult.getRootNode() == null) {
    return; // Return, no need to call in super.createAdditionalHyperlinks
  }

  // Check if the current parse tree node represents an override keyword, in which case we want to link
  // to the overridden rule
  INode node = NodeModelUtils.findLeafNodeAtOffset(parseResult.getRootNode(), offset);
  if (node != null && isOverrideKeyword(node.getGrammarElement())) {
    Rule rule = (Rule) eObjectAtOffsetHelper.resolveElementAt(resource, offset);
    Region region = new Region(node.getOffset(), node.getLength());
    List<Rule> extendedRules = getExtendedRules(rule);
    for (Rule extendedRule : extendedRules) {
      createHyperlinksTo(resource, region, extendedRule, acceptor);
    }
  }
  super.createHyperlinksByOffset(resource, offset, acceptor);
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:22,代码来源:FormatHyperlinkHelper.java


示例12: jumptToPCal

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public static pcal.Region jumptToPCal(TLAtoPCalMapping mapping, Location location, IDocument document) throws BadLocationException {
      /*
       * Get the best guess of the line number in the
       * current contents of the editor that corresponds to what was line
       * mapping.tlaStartLine when the algorithm was translated. 
       * It is computed by assuming that neither the algorithm nor the translation
       * have changed, but they both may have been moved down by the same 
       * number delta of lines (possibly negative).  A more sophisticated approach 
       * using fingerprints of lines could be used, requiring that the necessary 
       * fingerprint information be put in TLAtoPCalMapping.
       */
      int beginAlgorithmLine = AdapterFactory.GetLineOfPCalAlgorithm(document);
      if (beginAlgorithmLine == -1) {
      	throw new BadLocationException("The algorithm is no longer in the module.");
      }

// Translate editor location to pcal.Region
      final pcal.Region tlaRegion = location.toRegion();

      // Do actual mapping
      return mapping.mapTLAtoPCalRegion(tlaRegion,
		beginAlgorithmLine);
  }
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:24,代码来源:AdapterFactory.java


示例13: selectAndReveal

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public void selectAndReveal(final pcal.Region aRegion) throws BadLocationException {
	final IDocument document = getDocumentProvider().getDocument(
			getEditorInput());

	// Translate pcal.Region coordinates into Java IDocument coordinates
	final PCalLocation begin = aRegion.getBegin();
	final int startLineOffset = document.getLineOffset(begin.getLine());
	final int startOffset = startLineOffset + begin.getColumn();
	
	final PCalLocation end = aRegion.getEnd();
	final int endLineOffset = document.getLineOffset(end.getLine());
	final int endOffset = endLineOffset + end.getColumn();

	final int length = endOffset - startOffset;
	
	selectAndReveal(startOffset, length);
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:18,代码来源:TLAEditor.java


示例14: gotoMarker

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public void gotoMarker(final IMarker marker) {
	// if the given marker happens to be of instance TLAtoPCalMarker, it
	// indicates that the user wants to go to the PCal equivalent of the
	// current TLA+ marker
	if (marker instanceof TLAtoPCalMarker) {
		final TLAtoPCalMarker tlaToPCalMarker = (TLAtoPCalMarker) marker;
		try {
			final pcal.Region region = tlaToPCalMarker.getRegion();
			if (region != null) {
				selectAndReveal(region);
				return;
			} else {
				UIHelper.setStatusLineMessage("No valid TLA to PCal mapping found for current selection");
			}
		} catch (BadLocationException e) {
			// not expected to happen
			e.printStackTrace();
		}
	}
	
	// fall back to original marker if the TLAtoPCalMarker didn't work or no
	// TLAtoPCalMarker
	super.gotoMarker(marker);
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:25,代码来源:TLAEditor.java


示例15: getTextBlockFromSelection

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Creates a region describing the text block (something that starts at
 * the beginning of a line) completely containing the current selection.
 *
 * @param selection The selection to use
 * @param document The document
 * @return the region describing the text block comprising the given selection
 */
private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document)
{

    try
    {
        IRegion line = document.getLineInformationOfOffset(selection.getOffset());
        int length = selection.getLength() == 0 ? line.getLength() : selection.getLength()
                + (selection.getOffset() - line.getOffset());
        return new Region(line.getOffset(), length);

    } catch (BadLocationException x)
    {
        // should not happen
        // TODO
    }

    return null;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:27,代码来源:ToggleCommentAction.java


示例16: getRegionWithPreviousLine

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Returns a new region that ends at the end of the input region and begins
 * at the first character of the line before the line containing the offset
 * of the input region. If the input region's offset is on the first
 * line of the document, this method does nothing.
 * 
 * @param document
 * @param region
 * @return
 * @throws BadLocationException
 */
public static IRegion getRegionWithPreviousLine(IDocument document, IRegion region) throws BadLocationException
{
    // the first line of the region
    int currentFirstLine = document.getLineOfOffset(region.getOffset());
    if (currentFirstLine > 0)
    {
        int newOffset = document.getLineOffset(currentFirstLine - 1);
        return new Region(newOffset, region.getLength() + (region.getOffset() - newOffset));
    } else
    {
        // no previous line so do nothing
        return region;
    }

}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:27,代码来源:DocumentHelper.java


示例17: findIds

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Find the IDs in the given text and return the array of 
 * regions pointing to those or an empty array, if no IDs were found.
 * An ID is scheme_timestamp, created by {@link ModelWriter#getValidIdentifier(String)} e.G. next_125195338522638000
 * @param text text containing IDs (error text)
 * @return array of regions or empty array
 */
public static IRegion[] findIds(String text)
{
    if (text == null || text.length() == 0)
    {
        return new IRegion[0];
    }

    Matcher matcher = ModelWriter.ID_MATCHER.matcher(text);
    Vector<Region> regions = new Vector<Region>();
    while (matcher.find())
    {
        regions.add(new Region(matcher.start(), matcher.end() - matcher.start()));
    }
    return regions.toArray(new IRegion[regions.size()]);
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:23,代码来源:ModelWriter.java


示例18: findLocations

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Finds the locations in the given text and return the array of 
 * regions pointing to those or an empty array, if no location were found.
 * A location is a pointer in the TLA file, e.G. "line 11, col 8 to line 14, col 26 of module Foo"
 * @param text text containing locations (error text)
 * @return array of regions or empty array
 */
public static IRegion[] findLocations(String text)
{
    if (text == null || text.length() == 0)
    {
        return new IRegion[0];
    }

    Matcher matcher = Location.LOCATION_MATCHER.matcher(text);
    Vector<IRegion> regions = new Vector<IRegion>();
    while (matcher.find())
    {
        regions.add(new Region(matcher.start(), matcher.end() - matcher.start()));
    }
    // look for this pattern also
    // this pattern appears when there
    // is an error evaluating a nested expression
    matcher = Location.LOCATION_MATCHER4.matcher(text);
    while (matcher.find())
    {
        regions.add(new Region(matcher.start(), matcher.end() - matcher.start()));
    }
    return regions.toArray(new IRegion[regions.size()]);
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:31,代码来源:ModelHelper.java


示例19: searchBackwardsInSamePartition

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * searches backwards for the given string within the same partition type
 * @return the region of the match or <code>null</code> if no match were found
 * @since 2.4
 */
public IRegion searchBackwardsInSamePartition(String toFind, String documentText, IDocument document, int endOffset) throws BadLocationException {
	if (endOffset < 0) {
		return null;
	}
	int length = toFind.length();
	String text = preProcessSearchString(documentText);
	ITypedRegion partition = document.getPartition(endOffset);
	int indexOf = text.lastIndexOf(toFind, endOffset - length);
	while (indexOf >= 0) {
		ITypedRegion partition2 = document.getPartition(indexOf);
		if (partition2.getType().equals(partition.getType())) {
			return new Region(indexOf, length);
		}
		indexOf = text.lastIndexOf(toFind, partition2.getOffset() - length);
	}
	String trimmed = toFind.trim();
	if (trimmed.length() > 0 && trimmed.length() != length) {
		return searchBackwardsInSamePartition(trimmed, documentText, document, endOffset);
	}
	return null;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:27,代码来源:DocumentUtil.java


示例20: searchInSamePartition

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * searches for the given string within the same partition type
 * 
 * @return the region of the match or <code>null</code> if no match were found
 * @since 2.4
 */
public IRegion searchInSamePartition(String toFind, String documentText, IDocument document, int startOffset)
		throws BadLocationException {
	if (startOffset >= document.getLength()) {
		return null;
	}
	String text = preProcessSearchString(documentText);
	ITypedRegion partition = document.getPartition(startOffset);
	
	int indexOf = text.indexOf(toFind, getOffset(toFind, startOffset));
	while (indexOf >= 0 && indexOf < document.getLength()) {
		ITypedRegion partition2 = document.getPartition(indexOf);
		if (partition2.getType().equals(partition.getType())) {
			return new Region(indexOf, toFind.length());
		}
		indexOf = text.indexOf(toFind, partition2.getOffset() + partition2.getLength());
	}
	String trimmed = toFind.trim();
	if (trimmed.length() > 0 && trimmed.length() != toFind.length()) {
		return searchInSamePartition(trimmed, documentText, document, startOffset);
	}
	return null;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:29,代码来源:DocumentUtil.java


示例21: getDamageRegion

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged) {
    if (!documentPartitioningChanged) {
        try {

            IRegion info= document.getLineInformationOfOffset(event.getOffset());
            int start= Math.max(partition.getOffset(), info.getOffset());

            int end= event.getOffset() + (event.getText() == null ? event.getLength() : event.getText().length());

            if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
                // optimize the case of the same line
                end= info.getOffset() + info.getLength();
            } else
                end= endOfLineOf(end);

            end= Math.min(partition.getOffset() + partition.getLength(), end);
            return new Region(start, end - start);

        } catch (BadLocationException x) {
            logger.logInfo("unable to find location in document to repair a given region",x); //$NON-NLS-1$
        }
    }
    return partition;
}
 
开发者ID:anb0s,项目名称:LogViewer,代码行数:25,代码来源:DamageRepairer.java


示例22: getHoverRegion

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public IRegion getHoverRegion(ITextViewer textViewer, int offset)
{
	IParseNode activeNode = getActiveNode(textViewer, offset);
	if (activeNode instanceof CSSSimpleSelectorNode)
	{
		CSSSimpleSelectorNode node = (CSSSimpleSelectorNode) activeNode;
		// Verify that this is an HTML element selector
		String typeSelector = node.getTypeSelector();
		if (!StringUtil.isEmpty(typeSelector))
		{
			ElementElement element = new HTMLIndexQueryHelper().getElement(typeSelector.toLowerCase());
			if (element != null)
			{
				return new Region(node.getStartingOffset(), node.getLength());
			}
		}
	}

	return null;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:21,代码来源:CSSElementSelectorHover.java


示例23: collect

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public static void collect(
    ASTNode node,
    IJavaProject project,
    Region rangeLimit,
    boolean skipMethodBodies,
    Collection<SimpleName> resultingTypeImports,
    Collection<SimpleName> resultingStaticImports) {
  ASTNode root = node.getRoot();
  CompilationUnit astRoot = root instanceof CompilationUnit ? (CompilationUnit) root : null;
  node.accept(
      new ImportReferencesCollector(
          project,
          astRoot,
          rangeLimit,
          skipMethodBodies,
          resultingTypeImports,
          resultingStaticImports));
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:ImportReferencesCollector.java


示例24: ImportReferencesCollector

import org.eclipse.jface.text.Region; //导入依赖的package包/类
private ImportReferencesCollector(
    IJavaProject project,
    CompilationUnit astRoot,
    Region rangeLimit,
    boolean skipMethodBodies,
    Collection<SimpleName> resultingTypeImports,
    Collection<SimpleName> resultingStaticImports) {
  super(processJavadocComments(astRoot));
  fTypeImports = resultingTypeImports;
  fStaticImports = resultingStaticImports;
  fSubRange = rangeLimit;
  if (project == null || !JavaModelUtil.is50OrHigher(project)) {
    fStaticImports = null; // do not collect
  }
  fASTRoot = astRoot; // can be null
  fSkipMethodBodies = skipMethodBodies;
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ImportReferencesCollector.java


示例25: remove

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Exclude specified regions
 */
public void remove(IRegion... region) {
	for (IRegion r : region) {
		Assert.isLegal(r.getLength() >= 0, "Negative region length"); //$NON-NLS-1$
		IRegion from = new Region(r.getOffset(), Integer.MAX_VALUE);
		IRegion floor = NavigableSetFloor(regions, from);
		List<IRegion> list = new ArrayList<IRegion>(NavigableSetTailSet(regions, floor != null ? floor : from, true));
		for (IRegion current : list) {
			if (overlap(current, r)) {
				regions.remove(current);
				IRegion[] parts = substruct(current, r);
				if (parts.length > 0) {
					regions.addAll(Arrays.asList(parts));
				} else {
					break;
				}
			}

		}
	}
	validate();
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:25,代码来源:Regions.java


示例26: visit

import org.eclipse.jface.text.Region; //导入依赖的package包/类
@Override
public boolean visit(SimpleName node) {
  VariableDeclaration decl = getVariableDeclaration(node);
  if (decl == null) return super.visit(node);

  IVariableBinding binding = decl.resolveBinding();
  if (binding == null) return super.visit(node);

  boolean keysEqual = fKey.equals(binding.getKey());
  boolean rangeInSet =
      fRanges.contains(new Region(node.getStartPosition(), node.getLength()));

  if (keysEqual && !rangeInSet) fProblemNodes.add(node);

  if (!keysEqual && rangeInSet) fProblemNodes.add(node);

  /*
   * if (!keyEquals && !rangeInSet)
   * 		ok, different local variable.
   *
   * if (keyEquals && rangeInSet)
   * 		ok, renamed local variable & has been renamed.
   */

  return super.visit(node);
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:RenameAnalyzeUtil.java


示例27: getAttributeValueRegion

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Gets a region for the attribute's value (without the quotes).
 */
public static IRegion getAttributeValueRegion(IDOMAttr attribute) {
  String attrValue = attribute.getValueRegionText();
  if (attrValue == null) {
    return null;
  }
  
  int offset = attribute.getValueRegionStartOffset();
  int length = attrValue.length();

  // Strip off the quotes
  if (isXmlQuote(attrValue.charAt(0))) {
    offset++;
    length--;
  }
  if (isXmlQuote(attrValue.charAt(attrValue.length() - 1))) {
    length--;
  }

  return new Region(offset, length);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:XmlUtilities.java


示例28: tryParseCssElExpression

import org.eclipse.jface.text.Region; //导入依赖的package包/类
private void tryParseCssElExpression(IDOMElement styleElement,
    String remainingFragments, int remainingFragmentsOffsetInDoc,
    IRegion fieldRefRegion) {
  CssExtractor extractor = UiBinderXmlModelUtilities.createCssExtractorForStyleElement(
      styleElement, javaProject);
  if (extractor != null) {
    for (String selector : CssSelectorNameCollector.getValidSelectorNames(extractor.getCssDocument())) {
      if (selector.equals(remainingFragments)) {
        return;
      }
    }
  }

  if (remainingFragments.length() > 0) {
    problemMarkerManager.setCssSelectorFragmentUndefinedError(new Region(
        remainingFragmentsOffsetInDoc, remainingFragments.length()),
        remainingFragments);
  } else {
    problemMarkerManager.setCssSelectorFragmentUnspecifiedError(fieldRefRegion);
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:22,代码来源:UiBinderXmlParser.java


示例29: run

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public void run()
{
    VelocityEditor editor = (VelocityEditor) getTextEditor();
    if (editor.fMouseListener.fActiveRegion != null)
    {
        // If the user is using the ctrl-alt mouse click feature, then
        // goto the definition under the mouse, and not under the current cursor location
        editor.gotoDefinition(editor.fMouseListener.fActiveRegion);
        return;
    }
    
    ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
    if (!selection.isEmpty())
    {
        
        editor.gotoDefinition(new Region(selection.getOffset(), selection.getLength()));
    }
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:19,代码来源:GotoDefinitionAction.java


示例30: getTextBlockFromSelection

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Creates a region describing the text block (something that starts at the
 * beginning of a line) completely containing the current selection.
 * 
 * @param selection
 *            The selection to use
 * @param document
 *            The document
 * @return the region describing the text block comprising the given
 *         selection
 */
private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document)
{
    try
    {
        IRegion line = document.getLineInformationOfOffset(selection.getOffset());
        int length = selection.getLength() == 0 ? line.getLength() : selection.getLength() + (selection.getOffset() - line.getOffset());
        return new Region(line.getOffset(), length);
    }
    catch (BadLocationException x)
    {
        // should not happen
        // JavaPlugin.log(x);
    }
    return null;
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:27,代码来源:ToggleCommentAction.java


示例31: documentChanged

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public void documentChanged(DocumentEvent event)
{
    if ((fRememberedPosition != null) && !fRememberedPosition.isDeleted())
    {
        event.getDocument().removePosition(fRememberedPosition);
        fActiveRegion = new Region(fRememberedPosition.getOffset(), fRememberedPosition.getLength());
    }
    fRememberedPosition = null;
    ISourceViewer viewer = getSourceViewer();
    if (viewer != null)
    {
        StyledText widget = viewer.getTextWidget();
        if ((widget != null) && !widget.isDisposed())
        {
            widget.getDisplay().asyncExec(new Runnable() {

                public void run()
                {
                    deactivate();
                }
            });
        }
    }
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:25,代码来源:VelocityEditor.java


示例32: processFix

import org.eclipse.jface.text.Region; //导入依赖的package包/类
@Override
public IRegion processFix(IDocument document, IMarker marker) throws CoreException {
    int line = (int) marker.getAttribute(IMarker.LINE_NUMBER);
    try {
        String indent = getIndent(document, line);
        // getLineOffset() is zero-based, and imarkerLine is one-based.
        int endOfCurrLine = document.getLineInformation(line - 1).getOffset()
                + document.getLineInformation(line - 1).getLength();
        // should be fine for first and last lines in the doc as well
        String replacementText = indent + "type: object";
        String delim = TextUtilities.getDefaultLineDelimiter(document);
        document.replace(endOfCurrLine, 0, delim + replacementText);
        return new Region(endOfCurrLine + delim.length(), replacementText.length());
    } catch (BadLocationException e) {
        throw new CoreException(createStatus(e, "Cannot process the IMarker"));
    }
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:18,代码来源:QuickFixer.java


示例33: getHoverRegion

import org.eclipse.jface.text.Region; //导入依赖的package包/类
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
	IRegion region = new Region(offset, 0);
	try {
		IDocument doc = textViewer.getDocument();
		
		if (doc instanceof IDocumentExtension3) {
			IDocumentExtension3 ext3 = (IDocumentExtension3) doc;
			region = ext3.getPartition(EditorConstants.BF_PARTITIONING, offset, true);
		}
		else {
			region = doc.getPartition(offset);
		}
	}
	catch (BadPartitioningException | BadLocationException ex) {
		BfActivator.getDefault().logError("Partitioning Problem", ex);
	}
	return region;
}
 
开发者ID:RichardBirenheide,项目名称:brainfuck,代码行数:20,代码来源:BfSourceViewerConfiguration.java


示例34: applyTemplateAtTheEnd

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * @see msi.gama.lang.gaml.ui.editor.IGamlEditor#applyTemplate(org.eclipse.jface.text.templates.Template)
 */

public void applyTemplateAtTheEnd(final Template t) {

	try {
		final IDocument doc = getDocument();
		int offset = doc.getLineOffset(doc.getNumberOfLines() - 1);
		doc.replace(offset, 0, "\n\n");
		offset += 2;
		final int length = 0;
		final Position pos = new Position(offset, length);
		final XtextTemplateContextType ct = new XtextTemplateContextType();
		final DocumentTemplateContext dtc = new DocumentTemplateContext(ct, doc, pos);
		final IRegion r = new Region(offset, length);
		final TemplateProposal tp = new TemplateProposal(t, dtc, r, null);
		tp.apply(getInternalSourceViewer(), (char) 0, 0, offset);
	} catch (final BadLocationException e) {
		e.printStackTrace();
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:23,代码来源:GamlEditor.java


示例35: getRegionType

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Get the partition type for the specified offset. The offset must be within 
 * this line.
 * @param offset The offset relative to the beginning of the document.
 * @return The partition that the offset is in, or null if it is outside the 
 * range of this line.
 */
public Partition getRegionType( int offset )
{
   if( offset >= start && offset <= commentStart ) {
      for( Region region : stringAreas ) {
         if( offset > region.getOffset() && 
            offset <= region.getOffset() + region.getLength() ) 
         {
            return Partition.STRING;
         }
      }
      return Partition.CODE;
   }
   if( offset > commentStart ) {
      return Partition.COMMENT;
   }
   
   ZDebug.dumpStackTrace( "Offset out of range? ", offset );
   return null;
}
 
开发者ID:brocade,项目名称:vTM-eclipse,代码行数:27,代码来源:CodeLine.java


示例36: run

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * Open the declaration if possible.
 */
@Override
public void run()
{
	ITextEditor textEditor = getTextEditor();

	if (textEditor instanceof JSSourceEditor)
	{
		ITextSelection selection = (ITextSelection) textEditor.getSelectionProvider().getSelection();
		IRegion region = new Region(selection.getOffset(), 1);
		JSHyperlinkDetector detector = new JSHyperlinkDetector();
		IHyperlink[] hyperlinks = detector.detectHyperlinks((AbstractThemeableEditor) textEditor, region, true);

		if (!ArrayUtil.isEmpty(hyperlinks))
		{
			// give first link highest precedence
			hyperlinks[0].open();
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:23,代码来源:OpenDeclarationAction.java


示例37: selectValidRanges

import org.eclipse.jface.text.Region; //导入依赖的package包/类
public IRegion[] selectValidRanges(int start, int end)
{
	final List<Region> result = new ArrayList<Region>();
	for (final IRegion region : excludes)
	{
		final int regionEnd = region.getOffset() + region.getLength();
		if (start <= regionEnd && region.getOffset() <= end)
		{
			if (start < region.getOffset())
			{
				int validEnd = Math.min(end, region.getOffset());
				result.add(new Region(start, validEnd - start));
			}
			start = regionEnd;
			if (start > end)
			{
				break;
			}
		}
	}
	if (start < end)
	{
		result.add(new Region(start, end - start));
	}
	return result.toArray(new IRegion[result.size()]);
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:27,代码来源:ExcludeRegionList.java


示例38: getFunctionRegionInfo

import org.eclipse.jface.text.Region; //导入依赖的package包/类
/**
 * getFunctionRegionInfo
 * 
 * @param node
 * @return
 */
private RegionInfo getFunctionRegionInfo(CSSFunctionNode node)
{
	RegionInfo result = null;
	Matcher m = RGB_CHANNELS.matcher(node.toString());

	if (m.matches())
	{
		int red = Integer.parseInt(m.group(1));
		int green = Integer.parseInt(m.group(2));
		int blue = Integer.parseInt(m.group(3));

		// @formatter:off
		result = new RegionInfo(new Region(node.getStartingOffset(), node.getLength()), new RGB(red, green, blue));
		// @formatter:on
	}

	return result;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:25,代码来源:CSSTextHover.java



注:本文中的org.eclipse.jface.text.Region类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。