• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IFragmentProvider类的典型用法和代码示例

java 3次浏览

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

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

示例1: getFragment

点赞 3

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Override
public String getFragment(EObject obj, IFragmentProvider.Fallback fallback) {
	if (obj instanceof JvmTypeParameter)
		return getFragment(obj.eContainer(), fallback) + "/" + ((JvmTypeParameter) obj).getName();
	if (obj instanceof JvmTypeReference || obj instanceof JvmFormalParameter)
		return fallback.getFragment(obj);
	if (obj instanceof JvmIdentifiableElement) {
		if (obj instanceof JvmArrayType) {
			if (obj.eContainer() instanceof JvmGenericArrayTypeReference)
				return fallback.getFragment(obj);
			if (obj.eContainer() instanceof JvmIdentifiableElement) {
				return getFragment(obj.eContainer(), fallback) + "[]";
			}
		}
		return ((JvmIdentifiableElement) obj).getIdentifier();
	}
	return fallback.getFragment(obj);
}
 

开发者ID:eclipse,
项目名称:xtext-extras,
代码行数:19,
代码来源:AbstractClassMirror.java

示例2: getEObject

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Override
public EObject getEObject(Resource resource, String fragment, IFragmentProvider.Fallback fallback) {
	if (fragment.endsWith("[]")) {
		return getArrayEObject(resource, fragment, fallback);
	}
	for (EObject obj: resource.getContents()) {
		String otherFragment = getFragment(obj, fallback);
		if (fragment.equals(otherFragment))
			return obj;
	}
	return fallback.getEObject(fragment);
}
 

开发者ID:eclipse,
项目名称:xtext-extras,
代码行数:13,
代码来源:PrimitiveMirror.java

示例3: getEObject

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Override
public EObject getEObject(Resource resource, String fragment, IFragmentProvider.Fallback fallback) {
	if (!fragment.startsWith(PREFIX))
		return fallback.getEObject(fragment);
	String fragmentWithoutPrefix = fragment.substring(PREFIX.length());
	List<String> splitted = Strings.split(fragmentWithoutPrefix, '/');
	if (splitted.isEmpty()) {
		return fallback.getEObject(fragment);
	}
	String firstPart = splitted.get(0);
	Grammar grammar = null;
	for(EObject content: resource.getContents()) {
		if (content instanceof Grammar) {
			Grammar g = (Grammar) content;
			if (firstPart.equals(g.getName())) {
				grammar = g;
				if (splitted.size() == 1)
					return grammar;
				break;
			}
		}
	}
	if (splitted.size() == 2) {
		return GrammarUtil.findRuleForName(grammar, splitted.get(1));
	} else {
		return fallback.getEObject(fragment);
	}
}
 

开发者ID:eclipse,
项目名称:xtext-core,
代码行数:29,
代码来源:XtextFragmentProvider.java

示例4: getFragment

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Override
public String getFragment(EObject obj, IFragmentProvider.Fallback fallback) {
	if (obj instanceof Grammar) {
		return caseGrammar((Grammar)obj);
	} else if (obj instanceof AbstractRule && obj.eContainer() != null) {
		return caseAbstractRule((AbstractRule)obj, fallback);
	}
	return fallback.getFragment(obj);
}
 

开发者ID:eclipse,
项目名称:xtext-core,
代码行数:10,
代码来源:XtextFragmentProvider.java

示例5: getGuiceBindingsRt

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
  final BindFactory bindFactory = new BindFactory();
  final String namingPrefix = GrammarUtil.getNamespace(grammar) + ".naming." + GrammarUtil.getName(grammar); //$NON-NLS-1$
  final String resourcePrefix = GrammarUtil.getNamespace(grammar) + ".resource." + GrammarUtil.getName(grammar); //$NON-NLS-1$

  ExportModel m = getModel(grammar);
  if (m != null) {
    bindFactory.addTypeToType(IQualifiedNameProvider.class.getName(), namingPrefix + "ExportedNamesProvider"); //$NON-NLS-1$
    if (!m.getInterfaces().isEmpty()) {
      bindFactory.addTypeToType(IFingerprintComputer.class.getName(), resourcePrefix + "FingerprintComputer"); //$NON-NLS-1$
    }
    if (!m.getExports().isEmpty()) {
      bindFactory.addTypeToType(IDefaultResourceDescriptionStrategy.class.getName(), resourcePrefix + "ResourceDescriptionStrategy"); //$NON-NLS-1$
    }
    if (Iterables.any(m.getExports(), new Predicate<Export>() {
      @Override
      public boolean apply(final Export input) {
        return input.isFingerprint() && input.getFragmentAttribute() != null;
      }
    })) {
      bindFactory.addTypeToType(IFragmentProvider.class.getName(), resourcePrefix + "FragmentProvider");
    }
  }
  bindFactory.addTypeToType(IResourceDescription.Manager.class.getName(), resourcePrefix + "ResourceDescriptionManager"); //$NON-NLS-1$
  return bindFactory.getBindings();
}
 

开发者ID:dsldevkit,
项目名称:dsl-devkit,
代码行数:29,
代码来源:ExportFragment.java

示例6: setUp

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
  super.setUp();
  with(Modules2.mixin(new XtextRuntimeModule(), new AbstractModule() {
    @Override
    protected void configure() {
      bind(IFragmentProvider.class).to(TestSelectorFragmentProvider.class);
    }
  }));
}
 

开发者ID:dsldevkit,
项目名称:dsl-devkit,
代码行数:12,
代码来源:AbstractSelectorFragmentProviderTest.java

示例7: getEObject

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Override
public EObject getEObject(Resource resource, String fragment, IFragmentProvider.Fallback fallback) {
	assertEquals(expectedURI, resource.getURI());
	assertEquals(expectedFragment, fragment);
	return expectedObject;
}
 

开发者ID:eclipse,
项目名称:xtext-extras,
代码行数:7,
代码来源:TypeResourceTest.java

示例8: getFragment

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Override
public String getFragment(EObject obj, IFragmentProvider.Fallback fallback) {
	assertEquals(expectedObject, obj);
	return expectedFragment;
}
 

开发者ID:eclipse,
项目名称:xtext-extras,
代码行数:6,
代码来源:TypeResourceTest.java

示例9: getEObject

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Override
public EObject getEObject(Resource resource, String fragment, IFragmentProvider.Fallback fallback) {
	if (fragment.endsWith("[]")) {
		return getArrayEObject(resource, fragment, fallback);
	}
	int slash = fragment.indexOf('/'); 
	if (slash != -1) {
		if (slash == 0)
			return fallback.getEObject(fragment);
		String containerFragment = fragment.substring(0, slash);
		EObject container = getEObject(resource, containerFragment, fallback);
		if (container != null) {
			String parameterName = fragment.substring(slash + 1);
			if (container instanceof JvmTypeParameterDeclarator) {
				JvmTypeParameterDeclarator executable = (JvmTypeParameterDeclarator) container;
				for(JvmTypeParameter parameter: executable.getTypeParameters()) {
					if (parameter.getName().equals(parameterName))
						return parameter;
				}
			} 
		}
	} else {
		if (resource.getContents().isEmpty()) {
			if (typeResourceServices!= null) 
				typeResourceServices.outdatedStateManager.checkCanceled(resource.getResourceSet());
			if (!isEmptynessLogged) {
				isEmptynessLogged = true;
				logger.error("resource is empty: " + resource.getURI(), new IllegalStateException());
				if (logger.isDebugEnabled()) {
					logger.debug(getClass().getName(), new Exception());
				}
			}
			return null;
		}
		final EObject type = resource.getContents().get(0);
		if (type instanceof JvmType) {
			String typeName = getTypeName((JvmType) type);
			if (typeName.equals(fragment)) {
				return type;
			}
			if(fragment.startsWith(typeName)) {
				EObject member = findMember(type, fragment);
				if(member != null)
					return member;
			}
		}
	}
	return fallback.getEObject(fragment);	
}
 

开发者ID:eclipse,
项目名称:xtext-extras,
代码行数:50,
代码来源:AbstractClassMirror.java

示例10: getArrayEObject

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
protected EObject getArrayEObject(Resource resource, String fragment, IFragmentProvider.Fallback fallback) {
	JvmComponentType component = (JvmComponentType) getEObject(resource, fragment.substring(0, fragment.length() - 2), fallback);
	if (component == null)
		return null;
	return component.getArrayType();
}
 

开发者ID:eclipse,
项目名称:xtext-extras,
代码行数:7,
代码来源:AbstractClassMirror.java

示例11: caseAbstractRule

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
public String caseAbstractRule(AbstractRule obj, IFragmentProvider.Fallback fallback) {
	return getFragment(obj.eContainer(), fallback) + "/" + obj.getName();
}
 

开发者ID:eclipse,
项目名称:xtext-core,
代码行数:4,
代码来源:XtextFragmentProvider.java

示例12: bindIFragmentProvider

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
public Class<? extends IFragmentProvider> bindIFragmentProvider() {
	return DefaultFragmentProvider.class;
}
 

开发者ID:eclipse,
项目名称:xtext-core,
代码行数:4,
代码来源:DefaultRuntimeModule.java

示例13: bindIFragmentProvider

点赞 2

import org.eclipse.xtext.resource.IFragmentProvider; //导入依赖的package包/类
@Override
public Class<? extends IFragmentProvider> bindIFragmentProvider() {
	return XtextFragmentProvider.class;
}
 

开发者ID:eclipse,
项目名称:xtext-core,
代码行数:5,
代码来源:XtextRuntimeModule.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)