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


Java MarkerUtilities.getCharEnd方法代码示例

本文整理汇总了Java中org.eclipse.ui.texteditor.MarkerUtilities.getCharEnd方法的典型用法代码示例。如果您正苦于以下问题:Java MarkerUtilities.getCharEnd方法的具体用法?Java MarkerUtilities.getCharEnd怎么用?Java MarkerUtilities.getCharEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.texteditor.MarkerUtilities的用法示例。


在下文中一共展示了MarkerUtilities.getCharEnd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExistingMarkerFor

import org.eclipse.ui.texteditor.MarkerUtilities; //导入方法依赖的package包/类
private IMarker getExistingMarkerFor(IResource resource, String message, int start, int end,
		Set<IMarker> remainingMarkers) {
	ITextFileBuffer textFileBuffer = FileBuffers.getTextFileBufferManager()
			.getTextFileBuffer(resource.getFullPath(), LocationKind.IFILE);
	if (textFileBuffer == null) {
		return null;
	}
	try {
		for (IMarker marker : remainingMarkers) {
			int startOffset = MarkerUtilities.getCharStart(marker);
			int endOffset = MarkerUtilities.getCharEnd(marker);
			if (MarkerUtils.getOptionType(marker) == null && message.equals(MarkerUtilities.getMessage(marker))) {
				if (start <= startOffset && end >= endOffset) {
					return marker;
				}
			}
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:23,代码来源:ValidateEditorConfigStrategy.java

示例2: getMarkerPosition

import org.eclipse.ui.texteditor.MarkerUtilities; //导入方法依赖的package包/类
/**
 * @return the position for a marker.
 */
public static Position getMarkerPosition(IDocument document, IMarker marker, IAnnotationModel model) {
    if (model instanceof AbstractMarkerAnnotationModel) {
        Position ret = ((AbstractMarkerAnnotationModel) model).getMarkerPosition(marker);
        if (ret != null) {
            return ret;
        }
    }
    int start = MarkerUtilities.getCharStart(marker);
    int end = MarkerUtilities.getCharEnd(marker);

    if (start > end) {
        end = start + end;
        start = end - start;
        end = end - start;
    }

    if (start == -1 && end == -1) {
        // marker line number is 1-based
        int line = MarkerUtilities.getLineNumber(marker);
        if (line > 0 && document != null) {
            try {
                start = document.getLineOffset(line - 1);
                end = start;
            } catch (BadLocationException x) {
            }
        }
    }

    if (start > -1 && end > -1) {
        return new Position(start, end - start);
    }

    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:38,代码来源:PyMarkerUtils.java

示例3: run

import org.eclipse.ui.texteditor.MarkerUtilities; //导入方法依赖的package包/类
@Override
public void run(IMarker[] markers, IProgressMonitor monitor) {
	if (isBasedOnN4Modification()) {
		// applying an N4Modification to one or more markers

		try {
			// collect all changes
			final List<IChange> changes = new ArrayList<>();
			for (IMarker currMarker : markers) {

				if (!isMarkerStillValid(currMarker))
					continue;

				final Issue currIssue = issueUtil.createIssue(currMarker);
				final IModificationContext currContext = modificationContextFactory
						.createModificationContext(currIssue);
				final int offset = MarkerUtilities.getCharStart(currMarker);
				final int length = MarkerUtilities.getCharEnd(currMarker) - offset;
				final EObject element = getElementForMarker(currContext, currMarker);

				Collection<? extends IChange> changeSet = null;
				if (markers.length == 1) {
					changeSet = getN4Modification().computeChanges(
							currContext, currMarker, offset, length, element);
				} else {
					changeSet = getN4Modification().computeOneOfMultipleChanges(
							currContext, currMarker, offset, length, element);
				}

				changes.addAll(changeSet);
			}

			getN4Modification().computeFinalChanges();

			// perform changes
			changeManager.applyAll(changes);

		} catch (Exception e) {
			throw new WrappedException(
					"exception while applying resolution for quick fix '" + resolution.getLabel() + "'", e);
		}
	} else {
		// support for applying modifications other than N4Modification

		// applying a single quick fix to multiple markers only supported for N4Modifications (see
		// #findOtherMarkers(IMarker[]) below), so we assert markers.length==1 here
		if (markers.length != 1)
			throw new IllegalStateException();

		// default Xtext implementation
		resolution.apply();
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:54,代码来源:N4JSMarkerResolutionGenerator.java

示例4: selectReveal

import org.eclipse.ui.texteditor.MarkerUtilities; //导入方法依赖的package包/类
public boolean selectReveal( Object marker )
{
	int start = MarkerUtilities.getCharStart( (IMarker) marker );
	int end = MarkerUtilities.getCharEnd( (IMarker) marker );

	boolean selectLine = start < 0 || end < 0;

	// look up the current range of the marker when the document has been
	// edited
	IAnnotationModel model = reportXMLEditor.getDocumentProvider( )
			.getAnnotationModel( reportXMLEditor.getEditorInput( ) );
	if ( model instanceof AbstractMarkerAnnotationModel )
	{
		AbstractMarkerAnnotationModel markerModel = (AbstractMarkerAnnotationModel) model;
		Position pos = markerModel.getMarkerPosition( (IMarker) marker );
		if ( pos != null )
		{
			if ( !pos.isDeleted( ) )
			{
				// use position instead of marker values
				start = pos.getOffset( );
				end = pos.getOffset( ) + pos.getLength( );
			}
			else
			{
				return false;
			}
		}
	}

	IDocument document = reportXMLEditor.getDocumentProvider( )
			.getDocument( reportXMLEditor.getEditorInput( ) );
	if ( selectLine )
	{
		int line;
		try
		{
			if ( start >= 0 )
				line = document.getLineOfOffset( start );
			else
			{
				line = MarkerUtilities.getLineNumber( (IMarker) marker );
				// Marker line numbers are 1-based
				if ( line >= 1 )
				{
					line--;
				}
				start = document.getLineOffset( line );
			}
			end = start + document.getLineLength( line ) - 1;
		}
		catch ( BadLocationException e )
		{
			return false;
		}
	}

	int length = document.getLength( );
	if ( end - 1 < length && start < length )
		reportXMLEditor.selectAndReveal( start, end - start );
	return true;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:63,代码来源:ReportXMLSourceEditorFormPage.java


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