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


Java TypedPosition类代码示例

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


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


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