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


Java EObjectAtOffsetHelper类代码示例

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


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

示例1: getSelectionURI

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
private URI getSelectionURI(ISelection currentSelection) {
	if (currentSelection instanceof IStructuredSelection) {
		IStructuredSelection iss = (IStructuredSelection) currentSelection;
		if (iss.size() == 1) {
			EObjectNode node = (EObjectNode) iss.getFirstElement();
			return node.getEObjectURI();
		}
	} else if (currentSelection instanceof TextSelection) {
		// Selection may be stale, get latest from editor
		XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor();
		TextSelection ts = (TextSelection) xtextEditor.getSelectionProvider().getSelection();
		return xtextEditor.getDocument().readOnly(resource -> {
			EObject e = new EObjectAtOffsetHelper().resolveContainedElementAt(resource, ts.getOffset());
			return EcoreUtil2.getURI(e);
		});
	}
	return null;
}
 
开发者ID:smaccm,项目名称:smaccm,代码行数:19,代码来源:AadlHandler.java

示例2: getSelectedElement

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
private static EObject getSelectedElement(final XtextEditor editor, final ITextSelection textSelection) {
	return editor.getDocument().modify(
			resource -> {
				final IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider();
				final EObjectAtOffsetHelper offsetHelper = serviceProvider.get(EObjectAtOffsetHelper.class);
				return offsetHelper.resolveElementAt(resource, textSelection.getOffset());
			});
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:TestDiscoveryUIUtils.java

示例3: getSelectedLanguage

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
protected Language getSelectedLanguage(XtextResource resource, int offset){
	final EObjectAtOffsetHelper eObjectAtOffsetHelper =
		resource.getResourceServiceProvider().get(EObjectAtOffsetHelper.class);
	EObject selectedElement = eObjectAtOffsetHelper.resolveContainedElementAt(resource, offset);
	if (selectedElement != null) {
		EObject currentElem = selectedElement;
		while(currentElem != null){
			if(currentElem instanceof Language){
				return (Language)currentElem;
			}
			currentElem = currentElem.eContainer();
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:16,代码来源:AbstractGemocLanguageProjectHandler.java

示例4: getActualNode

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
/**
 * Given the current position in the editing area, tries
 * to recover the corresponding actual node.
 * 
 * @return the actual node, <code>null</code> if not possible
 */
public ICompositeNode getActualNode(){
	if(xtextAdapter.getXtextParseResult()!=null){
		int caretOffset = textArea.getCaretOffset();
		EObjectAtOffsetHelper eobjHelper=new EObjectAtOffsetHelper();
		EObject resolvedEObj = eobjHelper.resolveElementAt(xtextAdapter.getFakeResourceContext().getFakeResource(), caretOffset);
		return NodeModelUtils.findActualNodeFor(resolvedEObj);
	}
	return null;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:16,代码来源:EditingAreaHelper.java

示例5: findEObjectAtPosition

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
public static Optional<EObject> findEObjectAtPosition(XtextEditor editor, ITextSelection selection) {
    Optional<EObjectAtOffsetHelper> helper = determineEPackage(editor)
            .flatMap(InjectingFactoryRegistry.getInstance()::getFactory)
            .map(f -> f.inject(EObjectAtOffsetHelper.class)).map(EObjectAtOffsetHelper.class::cast);
    if (!helper.isPresent()) {
        return Optional.empty();
    }
    return Optional.ofNullable(editor.getDocument().priorityReadOnly(new IUnitOfWork<EObject, XtextResource>() {
        @Override
        public EObject exec(XtextResource resource) throws Exception {
            return helper.get().resolveElementAt(resource, selection.getOffset());
        }
    }));
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:15,代码来源:EditorHandlingUtils.java

示例6: execute

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        final XtextEditor editor = EditorUtils.getActiveXtextEditor(event);
        Optional<EPackage> ePackage = EditorHandlingUtils.determineEPackage(editor);
        Optional<EObjectAtOffsetHelper> eObjectAtOffsetHelper = ePackage
                .flatMap(InjectingFactoryRegistry.INSTANCE::getFactory)
                .map(f -> f.inject(EObjectAtOffsetHelper.class)).map(EObjectAtOffsetHelper.class::cast);
        if (!eObjectAtOffsetHelper.isPresent()) {
            throw new IllegalStateException("Unable to create required helper classes.");
        }

        if (editor != null) {
            final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
            EObject selectedEObject = editor.getDocument()
                    .priorityReadOnly(new IUnitOfWork<EObject, XtextResource>() {
                        @Override
                        public EObject exec(XtextResource resource) throws Exception {
                            return eObjectAtOffsetHelper.get().resolveElementAt(resource, selection.getOffset());
                        }
                    });
            startRename(selectedEObject, editor, editor.getShell());
        }
    } catch (OperationCanceledException e) {
        LOGGER.debug("Refactoring operation has been canceled.", e);
    } catch (Exception exc) {
        LOGGER.error("Error initializing refactoring", exc);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error initializing refactoring",
                exc.getMessage() + "\nSee log for details");
    }
    return null;
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:33,代码来源:RenameUMLElementRefactoringHandler.java

示例7: process

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
@Override
public void process(XtextResource state) throws Exception {
    EObjectAtOffsetHelper helper = new EObjectAtOffsetHelper();
    if (offset != -1) {
        focusedElement = helper.resolveContainedElementAt(state, offset);
    }
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:8,代码来源:FocusIUnitOfWork.java

示例8: bindEObjectAtOffsetHelper

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
public Class<? extends EObjectAtOffsetHelper> bindEObjectAtOffsetHelper() {
	return BrokenConstructorCallAwareEObjectAtOffsetHelper.class;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:DefaultXbaseRuntimeModule.java

示例9: getOffsetHelper

import org.eclipse.xtext.resource.EObjectAtOffsetHelper; //导入依赖的package包/类
protected EObjectAtOffsetHelper getOffsetHelper() {
	if(offsetHelper == null){
		offsetHelper = injector.getInstance(EObjectAtOffsetHelper.class);
	}
	return offsetHelper;
}
 
开发者ID:smaccm,项目名称:smaccm,代码行数:7,代码来源:AgreeAnnexContentAssist.java


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