• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TypedPosition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: adjustFormattedCssWhitespace

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
@Override
protected String adjustFormattedCssWhitespace(String formattedCssBlock,
    IDocument document, TypedPosition partition, CssExtractor extractor) {
  try {
    String cssLineSeparator = extractor.getStructuredDocument().getLineDelimiter();
    String xmlLineSeparator = ((IStructuredDocument) document).getLineDelimiter();
    // The formattedCssBlock starts at column 0, we need to indent it to fit
    // with the <ui:style>'s indentation
    formattedCssBlock = indentCssForXml(formattedCssBlock, document,
        partition, cssLineSeparator, xmlLineSeparator);
    return formattedCssBlock;
  } catch (BadLocationException e) {
    GWTPluginLog.logWarning(e, "Could not format CSS block.");
  }

  return null;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:18,代码来源:InlinedCssFormattingStrategy.java


示例2: formatterStarts

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
@Override
public void formatterStarts(final IFormattingContext context)
{
	super.formatterStarts(context);
	final IDocument document = (IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
	final TypedPosition partition = (TypedPosition) context
			.getProperty(FormattingContextProperties.CONTEXT_PARTITION);
	final IProject project = (IProject) context.getProperty(ScriptFormattingContextProperties.CONTEXT_PROJECT);
	final String formatterId = (String) context.getProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_ID);
	final Boolean isSlave = (Boolean) context
			.getProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_IS_SLAVE);
	final Boolean canConsumeIndentation = isSlave != null
			&& isSlave
			&& (Boolean) context
					.getProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_CAN_CONSUME_INDENTATION);
	final Boolean isSelection = !(Boolean) context.getProperty(FormattingContextProperties.CONTEXT_DOCUMENT);
	IRegion selectionRegion = null;
	if (isSelection != null && isSelection)
	{
		selectionRegion = (IRegion) context.getProperty(FormattingContextProperties.CONTEXT_REGION);
	}
	fJobs.addLast(new FormatJob(context, document, partition, project, formatterId, isSlave, canConsumeIndentation,
			isSelection, selectionRegion));
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:25,代码来源:ScriptFormattingStrategy.java


示例3: createPresentation

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
 */
public void createPresentation(TextPresentation presentation, ITypedRegion region)
{
	wipeExistingScopes(region);
	synchronized (getLockObject(fDocument))
	{
		try
		{
			fDocument.addPositionCategory(ICommonConstants.SCOPE_CATEGORY);
			fDocument.addPosition(
					ICommonConstants.SCOPE_CATEGORY,
					new TypedPosition(region.getOffset(), region.getLength(), (String) fDefaultTextAttribute
							.getData()));
		}
		catch (Exception e)
		{
			IdeLog.logError(CommonEditorPlugin.getDefault(), e);
		}
	}

	addRange(presentation, region.getOffset(), region.getLength(), getTextAttribute(region));
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:25,代码来源:NonRuleBasedDamagerRepairer.java


示例4: updateContex

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * Update the fomatting context to reflect to the script formatter that should be used with the given content-type.
 * 
 * @param context
 * @param region
 * @param lastContentType
 */
private void updateContex(IFormattingContext context, String contentType, int offset, int length)
{
	IScriptFormatterFactory factory = ScriptFormatterManager.getSelected(contentType);
	if (factory != null)
	{
		factory.setMainContentType(contentType);
		if (context != null)
		{
			context.setProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_ID, factory.getId());
			context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, new TypedPosition(offset, length,
					contentType));
			context.setProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_CAN_CONSUME_INDENTATION,
					factory.canConsumePreviousIndent());
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:24,代码来源:CommonMultiPassContentFormatter.java


示例5: getExclusions

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * Get all positions of the given position category
 * In sexp's these positions are typically skipped
 * 
 * @param doc
 * @param pos_names
 * @return the positions to exclude
 */
public static List<Position> getExclusions(IDocument doc, String[] pos_names) {
	List<Position> excludePositions = new LinkedList<Position>();
	String cat = getTypeCategory(doc);
	if (cat != null) {
		try {
			Position[] xpos = doc.getPositions(cat);
			for (int j = 0; j < xpos.length; j++) {
				if (xpos[j] instanceof TypedPosition) {

					for (int jj = 0; jj < pos_names.length; jj++) {
						if (((TypedPosition) xpos[j]).getType().contains(pos_names[jj])) {
							excludePositions.add(xpos[j]);
						}
					}
				}
			}
		} catch (BadPositionCategoryException e) {}
	}
	return excludePositions;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:29,代码来源:EmacsPlusUtils.java


示例6: getPartsWithPartition

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
private String getPartsWithPartition(IDocument document, String contentType) {
    Position[] positions = PartitionCodeReader.getDocumentTypedPositions(document, contentType);
    int total = 0;
    for (int i = 0; i < positions.length; i++) {
        Position position = positions[i];
        total += position.length;
    }

    List<TypedPosition> sortAndMergePositions = PartitionMerger.sortAndMergePositions(positions,
            document.getLength());
    FastStringBuffer buf = new FastStringBuffer(total + 5);

    for (TypedPosition typedPosition : sortAndMergePositions) {
        try {
            String string = document.get(typedPosition.getOffset(), typedPosition.getLength());
            buf.append(string);
        } catch (BadLocationException e) {
            Log.log(e);
        }
    }
    return buf.toString();
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:23,代码来源:AutoEditStrategyHelper.java


示例7: createPositions

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
private Position[] createPositions(IDocument document) throws BadPositionCategoryException {
    Position[] positions = getDocumentTypedPositions(document, contentType);
    List<TypedPosition> typedPositions = PartitionMerger.sortAndMergePositions(positions, document.getLength());
    int size = typedPositions.size();
    List<Position> list = new ArrayList<Position>(size);
    for (int i = 0; i < size; i++) {
        Position position = typedPositions.get(i);
        if (isPositionValid(position, contentType)) {
            list.add(position);
        }
    }

    if (!fForward) {
        Collections.reverse(list);
    }
    Position[] ret = list.toArray(new Position[list.size()]);
    return ret;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:19,代码来源:PartitionCodeReader.java


示例8: getDocumentTypedPositions

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * Note: this just gets the positions in the document. To cover for holes, use
 * StringUtils.sortAndMergePositions with the result of this call.
 */
public static Position[] getDocumentTypedPositions(IDocument document, String defaultContentType) {
    if (ALL_CONTENT_TYPES_AVAILABLE.equals(defaultContentType)) {
        //Consider the whole document
        return new Position[] { new TypedPosition(0, document.getLength(), defaultContentType) };
    }
    Position[] positions;
    try {
        IDocumentPartitionerExtension2 partitioner = (IDocumentPartitionerExtension2) document
                .getDocumentPartitioner();
        String[] managingPositionCategories = partitioner.getManagingPositionCategories();
        Assert.isTrue(managingPositionCategories.length == 1);
        positions = document.getPositions(managingPositionCategories[0]);
        if (positions == null) {
            positions = new Position[] { new TypedPosition(0, document.getLength(), defaultContentType) };
        }
    } catch (Exception e) {
        Log.log("Unable to get positions for: " + defaultContentType, e); //Shouldn't happen, but if it does, consider the whole doc.
        positions = new Position[] { new TypedPosition(0, document.getLength(), defaultContentType) };
    }
    return positions;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:26,代码来源:PartitionCodeReader.java


示例9: testPartitionCodeReaderKeepingPositions

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
public void testPartitionCodeReaderKeepingPositions() throws Exception {
    PartitionCodeReader reader = new PartitionCodeReader(IDocument.DEFAULT_CONTENT_TYPE);
    Document document = new Document("abcde");
    String category = setupDocument(document);

    document.addPosition(category, new TypedPosition(1, 1, "cat1")); //skip b
    document.addPosition(category, new TypedPosition(3, 1, "cat1")); //skip d

    reader.configureForwardReader(document, 3, document.getLength(), true);
    FastStringBuffer buf = new FastStringBuffer(document.getLength());
    readAll(reader, buf);
    assertEquals("e", buf.toString());

    reader.configureForwardReaderKeepingPositions(2, document.getLength());
    buf.clear();
    readAll(reader, buf);
    assertEquals("ce", buf.toString());

    reader.configureForwardReaderKeepingPositions(0, document.getLength());
    buf.clear();
    readAll(reader, buf);
    assertEquals("ace", buf.toString());
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:24,代码来源:PartitionCodeReaderTest.java


示例10: testName

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
@Test
public void testName() throws Exception {
	HashMap<String, String> javaFormattingPrefs = TestUtils.getJavaProperties();

	int i = INPUT.indexOf("/*-");
	int i2 = INPUT.indexOf("-*/");
	TypedPosition partition = new TypedPosition(i, i2 - i + 3, "");
	HashMap<String, String> jsMap = TestUtils.getJSProperties();

	IDocument document = new Document(INPUT);
	JsniFormattingUtil jsniFormattingUtil = new JsniFormattingUtil();
	TextEdit format1 = jsniFormattingUtil.format(document, partition, javaFormattingPrefs, jsMap, null);
	// TextEdit format1 = JsniFormattingUtil.format(document,javaFormattingPrefs, jsMap, null);
	format1.apply(document);
	Assert.assertEquals(FORMATTED, document.get());
	System.err.println(FORMATTED);
}
 
开发者ID:krasa,项目名称:EclipseCodeFormatter,代码行数:18,代码来源:GWTTest.java


示例11: getContentType

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * May be replaced or extended by subclasses.
 * </p>
 */
public String getContentType(int offset) {
    checkInitialization();

    TypedPosition p= findClosestPosition(offset);
    if (p != null && p.includes(offset))
        return p.getType();

    return IDocument.DEFAULT_CONTENT_TYPE;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:16,代码来源:TLAFastPartitioner.java


示例12: debugPrint

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * For printing out debugging information
 *   (TypedPosition)
 * @param msg
 */
public void debugPrint(String msg) {
    System.out.println("Debug print " + msg);
    System.out.println("Start comment offset: " + pcalStartCommentOffset
            + ";  Start: (" + pcalStartOffset + ", " + pcalStartLength + 
            ");  End comment: (" + pcalEndCommentOffset + ", "
            + pcalEndCommentLength + ")") ;
    Position[] positions = null;
    try {
        positions = fDocument.getPositions(fPositionCategory);
    } catch (BadPositionCategoryException e1) {
        System.out.println("Can't get positions") ;
        e1.printStackTrace();
        return ;
    }
    for (int i = 0; i < positions.length; i++) {
       try {
          TypedPosition position = (TypedPosition) positions[i] ;
          System.out.println("Position " + i + ": (" + position.getOffset()
                  + ", " + position.getLength() + ")  type: "
                  + position.getType() + (position.isDeleted?" DELETED":""));
          System.out.println("  `" + 
                  fDocument.get(position.getOffset(), position.getLength()) + "'") ;
    
       } catch (Exception e) {
            System.out.println("Item " + i + " Exception: " + e.getMessage()) ;
         }
    }
    IRegion result = createRegion();
    if (result == null) {
        System.out.println("Returned null");
    } else {
        System.out.println("Returned (" + result.getOffset() + ", " 
            + result.getLength() + ")") ;
    }
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:41,代码来源:TLAFastPartitioner.java


示例13: getContentType

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * May be replaced or extended by subclasses.
 * </p>
 * 
 * @since 2.2
 */
public String getContentType(int offset) {
	checkInitialization();

	TypedPosition p = findClosestPosition(offset);
	if (p != null && p.includes(offset))
		return p.getType();

	return IDocument.DEFAULT_CONTENT_TYPE;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:DocumentPartitioner.java


示例14: isOpenSingleLineCommentPartition

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
private boolean isOpenSingleLineCommentPartition(TypedPosition position, int offset) throws BadLocationException {
	if (position.isDeleted()) {
		return false;
	}
	int endOffset = position.getOffset() + position.getLength();
	if (offset != endOffset) {
		return false;
	}
	if (!TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION.equals(position.getType())) {
		return false;
	}
	int line = fDocument.getLineOfOffset(offset - 1);
	return fDocument.getLineDelimiter(line) == null;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:DocumentPartitioner.java


示例15: getContentType

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * <p>May be replaced or extended by subclasses.
 */
public String getContentType(int offset) {
  checkInitialization();

  TypedPosition p = findClosestPosition(offset);
  if (p != null && p.includes(offset)) return p.getType();

  return IDocument.DEFAULT_CONTENT_TYPE;
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:FastPartitioner.java


示例16: format

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
@Override
public void format() {
  super.format();

  IDocument document = documents.removeFirst();
  TypedPosition partition = partitions.removeFirst();

  if (document == null || partition == null) {
    return;
  }

  format(document, partition);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:14,代码来源:AbstractFormattingStrategy.java


示例17: formatterStarts

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
@Override
public void formatterStarts(IFormattingContext context) {
  super.formatterStarts(context);

  IDocument document = (IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
  TypedPosition position = (TypedPosition) context.getProperty(FormattingContextProperties.CONTEXT_PARTITION);

  partitions.addLast(position);
  documents.addLast(document);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:11,代码来源:AbstractFormattingStrategy.java


示例18: indentCssForXml

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
private String indentCssForXml(String formattedCssBlock, IDocument document,
    TypedPosition partition, String cssLineSeparator, String xmlLineSeparator)
    throws BadLocationException {

  String oneXmlIndent = computeOneXmlIndentString();

  int lineNumberInDocument = document.getLineOfOffset(partition.getOffset());
  int offsetOfLineInDocument = document.getLineOffset(lineNumberInDocument);
  String lineContents = document.get(offsetOfLineInDocument,
      document.getLineLength(lineNumberInDocument));
  int offsetOfNonwhitespaceInLine = StringUtilities.findNonwhitespaceCharacter(
      lineContents, 0);

  // The indent string that will be used for the closing tag </ui:style>
  String styleElementIndentString;
  // The indent string that will be used for to precede each line of the CSS
  // block
  String cssBlockIndentString;

  if (offsetOfLineInDocument + offsetOfNonwhitespaceInLine == partition.getOffset()) {
    // The CSS block is alone on this line, use whatever indentation it has
    cssBlockIndentString = lineContents.substring(0,
        offsetOfNonwhitespaceInLine);
    styleElementIndentString = cssBlockIndentString.replace(oneXmlIndent, "");

  } else {
    // Something else is before the CSS block on this line (likely the style
    // tag)
    styleElementIndentString = lineContents.substring(0,
        offsetOfNonwhitespaceInLine);
    cssBlockIndentString = styleElementIndentString + oneXmlIndent;
  }

  return processCssBlock(formattedCssBlock, cssLineSeparator,
      xmlLineSeparator, cssBlockIndentString, styleElementIndentString);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:37,代码来源:InlinedCssFormattingStrategy.java


示例19: format

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * Returns a text edit that formats the given document according to the given
 * settings.
 * 
 * @param document The document to format.
 * @param javaFormattingPrefs The formatting preferences for Java, used to
 *          determine the method level indentation.
 * @param javaScriptFormattingPrefs The formatting preferences for JavaScript.
 *          See org.eclipse.wst.jsdt.internal.formatter
 *          .DefaultCodeFormatterOptions and
 *          org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants
 * @param originalJsniMethods The original jsni methods to use if the
 *          formatter fails to format the method. The original jsni Strings
 *          must be in the same order that the jsni methods occur in the
 *          document. This is to work around the Java formatter blasting the
 *          jsni tabbing for the format-on-save action. May be null.
 * @return A text edit that when applied to the document, will format the jsni
 *         methods.
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public static TextEdit format(IDocument document, Map javaFormattingPrefs,
    Map javaScriptFormattingPrefs, String[] originalJsniMethods) {
  TextEdit combinedEdit = new MultiTextEdit();
  try {
    ITypedRegion[] regions = TextUtilities.computePartitioning(document,
        GWTPartitions.GWT_PARTITIONING, 0, document.getLength(), false);

    // Format all JSNI blocks in the document
    int i = 0;
    for (ITypedRegion region : regions) {
      if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
        String originalJsniMethod = null;
        if (originalJsniMethods != null && i < originalJsniMethods.length) {
          originalJsniMethod = originalJsniMethods[i];
        }
        TextEdit edit = format(document, new TypedPosition(region),
            javaFormattingPrefs, javaScriptFormattingPrefs,
            originalJsniMethod);
        if (edit != null) {
          combinedEdit.addChild(edit);
        }
        i++;
      }
    }
    return combinedEdit;

  } catch (BadLocationException e) {
    GWTPluginLog.logError(e);
    return null;
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:52,代码来源:JsniFormattingUtil.java


示例20: FormatJob

import org.eclipse.jface.text.TypedPosition; //导入依赖的package包/类
/**
 * @param context
 * @param document
 * @param partition
 * @param project
 * @param formatterId
 * @param isSlave
 * @param canConsumeIndentation
 * @param isSelection
 * @param selectedRegion
 *            - Should be valid when isSelection is true.
 */
public FormatJob(IFormattingContext context, IDocument document, TypedPosition partition, IProject project,
		String formatterId, Boolean isSlave, Boolean canConsumeIndentation, Boolean isSelection,
		IRegion selectedRegion)
{
	this.context = context;
	this.document = document;
	this.partition = partition;
	this.project = project;
	this.formatterId = formatterId;
	this.canConsumeIndentation = canConsumeIndentation;
	this.isSlave = (isSlave != null) ? isSlave : false;
	this.isSelection = (isSelection != null) ? isSelection : false;
	this.selectedRegion = selectedRegion;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:27,代码来源:ScriptFormattingStrategy.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DragControl类代码示例发布时间:2022-05-22
下一篇:
Java VCFConstants类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap