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

Java IDOMAttr类代码示例

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

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



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

示例1: completion

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
private List<CompletionItem> completion(String html, int offset) throws CoreException {
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
	if (!project.exists()) {
		project.create(new NullProgressMonitor());
		project.open(new NullProgressMonitor());
	}
	IFile file = project.getFile("test.html");
	if (file.exists()) {
		file.setContents(IOUtils.toInputStream(html), 1, new NullProgressMonitor());
	} else {
		file.create(IOUtils.toInputStream(html), 1, new NullProgressMonitor());
	}

	IDOMModel model = DOMUtils.getModel(project, file);
	IDOMElement element = (IDOMElement) DOMUtils.getNodeByOffset(model, offset);
	IDOMAttr attr = DOMUtils.getAttrByOffset(element, offset);
	String attrName = attr.getName();

	CompletionCollector collector = new CompletionCollector(element, attr);
	AngularCorePlugin.getBindingManager().collect(element, attrName, file, collector);
	return collector.getList();
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:23,代码来源:HTMLAngularCompletionTest.java


示例2: getAttribute

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
/**
 * Returns the attribute from a content assist request from an attribute
 * completion.
 * 
 * @param request the content assist request, in the context of an attribute
 *          completion
 * @return the XML DOM attribute, or null
 */
public static IDOMAttr getAttribute(ContentAssistRequest request) {
  int valueRegionStartOffset = request.getStartOffset();

  NamedNodeMap attributes = request.getNode().getAttributes();
  
  if (attributes == null) {
    return null;
  }
  
  for (int i = 0; i < attributes.getLength(); i++) {
    IDOMAttr attribute = (IDOMAttr) attributes.item(i);
    if (attribute.getValueRegionStartOffset() == valueRegionStartOffset) {
      return attribute;
    }
  }

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


示例3: getAttributeValueRegion

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
/**
 * Gets a region for the attribute's value (without the quotes).
 */
public static IRegion getAttributeValueRegion(IDOMAttr attribute) {
  String attrValue = attribute.getValueRegionText();
  if (attrValue == null) {
    return null;
  }
  
  int offset = attribute.getValueRegionStartOffset();
  int length = attrValue.length();

  // Strip off the quotes
  if (isXmlQuote(attrValue.charAt(0))) {
    offset++;
    length--;
  }
  if (isXmlQuote(attrValue.charAt(attrValue.length() - 1))) {
    length--;
  }

  return new Region(offset, length);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:XmlUtilities.java


示例4: newUrnImportProposalComputer

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
/**
 * Creates a proposal computer for autocompleting the UiBinder root element
 * URN import scheme. For example, <ui:UiBinder
 * xmlns:g="urn:import:com.google.gwt._" />
 */
public static IProposalComputer newUrnImportProposalComputer(
    ContentAssistRequest contentAssistRequest, IJavaProject javaProject) {
  IDOMAttr attribute = XmlContentAssistUtilities.getAttribute(contentAssistRequest);
  if (attribute == null) {
    return null;
  }

  String attrValue = XmlContentAssistUtilities.getAttributeValueUsingMatchString(contentAssistRequest);
  if (!UiBinderXmlModelUtilities.isUrnImportAttribute(attribute)) {
    return null;
  }

  int urnImportLength = UiBinderConstants.URN_IMPORT_NAMESPACE_BEGINNING.length();
  if (attrValue.length() < urnImportLength) {
    return null;
  }

  String replaceText = attrValue.substring(urnImportLength);
  int replaceOffset = XmlContentAssistUtilities.getAttributeValueOffset(contentAssistRequest)
      + urnImportLength;

  return new CodeCompleteProposalComputer(
      new int[]{CompletionProposal.PACKAGE_REF}, javaProject, replaceText,
      replaceOffset, replaceText.length(), null, false);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:31,代码来源:ProposalComputerFactory.java


示例5: markDuplicateFieldErrors

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
private void markDuplicateFieldErrors() {
  for (ElExpressionFirstFragment fragment : firstFragmentComputer.getDuplicateFirstFragments()) {
    IRegion region;
    IDOMAttr fieldAttribute = (IDOMAttr) UiBinderXmlModelUtilities.getFieldAttribute(fragment.getNode());
    if (fieldAttribute != null) {
      region = XmlUtilities.getAttributeValueRegion(fieldAttribute);
    } else {
      List<IRegion> tagRegions = XmlUtilities.getElementTagRegions(
          (IDOMElement) fragment.getNode(), true);
      region = tagRegions.size() > 0 ? tagRegions.get(0) : null;
    }

    if (region != null) {
      problemMarkerManager.setDuplicateFieldError(region, fragment.getValue());
    }
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:18,代码来源:UiBinderXmlParser.java


示例6: parseTypeAliasElements

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
private void parseTypeAliasElements(IDOMDocument domDoc, final TypeAliasMap aliasMap)
	throws XPathExpressionException
{
	NodeList nodes = XpathUtil.xpathNodes(domDoc, "//typeAliases/typeAlias");
	for (int i = 0; i < nodes.getLength(); i++)
	{
		String type = null;
		String alias = null;
		NamedNodeMap attrs = nodes.item(i).getAttributes();
		for (int j = 0; j < attrs.getLength(); j++)
		{
			IDOMAttr attr = (IDOMAttr)attrs.item(j);
			String attrName = attr.getName();
			if ("type".equals(attrName))
				type = attr.getValue();
			else if ("alias".equals(attrName))
				alias = attr.getValue();
		}
		aliasMap.put(alias, type);
	}
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:22,代码来源:TypeAliasCache.java


示例7: validateResultMapId

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
private void validateResultMapId(IJavaProject project, IFile file, IDOMDocument doc,
	ValidationResult result, IDOMAttr attr, String attrValue, IReporter reporter)
	throws JavaModelException, XPathExpressionException
{
	if (attrValue.indexOf(',') == -1)
	{
		validateReference(project, file, doc, result, attr, attrValue, "resultMap", reporter);
	}
	else
	{
		String[] resultMapArr = attrValue.split(",");
		for (String resultMapRef : resultMapArr)
		{
			String ref = resultMapRef.trim();
			if (ref.length() > 0)
			{
				validateReference(project, file, doc, result, attr, ref, "resultMap", reporter);
			}
		}
	}
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:22,代码来源:XmlValidator.java


示例8: validateStatementId

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
private void validateStatementId(IDOMElement element, IFile file, IDOMDocument doc,
	ValidationResult result, IJavaProject project, IDOMAttr attr, String attrValue)
	throws JavaModelException, XPathExpressionException
{
	if (attrValue == null)
	{
		return;
	}

	String qualifiedName = MybatipseXmlUtil.getNamespace(doc);
	IType mapperType = project.findType(qualifiedName);
	if (mapperType != null
		&& !JavaMapperCache.getInstance().methodExists(project, qualifiedName, attrValue))
	{
		addMarker(result, file, doc.getStructuredDocument(), attr, MISSING_STATEMENT_METHOD,
			IMarker.SEVERITY_WARNING, IMarker.PRIORITY_HIGH,
			"Method '" + attrValue + "' not found or there is an overload method"
				+ " (same name with different parameters) in mapper interface " + qualifiedName);
	}
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:21,代码来源:XmlValidator.java


示例9: addMarker

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
private void addMarker(ValidationResult result, IFile file, IStructuredDocument doc,
	IDOMAttr attr, String problemType, int severity, int priority, String message)
{
	int start = attr.getValueRegionStartOffset();
	int length = attr.getValueRegionText().length();
	int lineNo = doc.getLineOfOffset(start);
	ValidatorMessage marker = ValidatorMessage.create(message, file);
	marker.setType(MARKER_ID);
	marker.setAttribute(IMarker.SEVERITY, severity);
	marker.setAttribute(IMarker.PRIORITY, priority);
	marker.setAttribute(IMarker.MESSAGE, message);
	marker.setAttribute(IMarker.LINE_NUMBER, lineNo);
	if (start != 0)
	{
		marker.setAttribute(IMarker.CHAR_START, start);
		marker.setAttribute(IMarker.CHAR_END, start + length);
	}
	// Adds custom attributes.
	marker.setAttribute("problemType", problemType);
	marker.setAttribute("errorValue", attr.getValue());
	result.add(marker);
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:23,代码来源:XmlValidator.java


示例10: renameResultMapId

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
protected void renameResultMapId(IDocument document, final IDOMAttr attr, int offset)
{
	String id = attr.getValue();
	if (id.indexOf(',') > -1)
	{
		// multiple result maps. get the one that has the cursor.
		String valueRegionText = attr.getValueRegionText();
		int selectionOffset = offset - attr.getValueRegionStartOffset();
		int valueOffset = valueRegionText.indexOf(id);
		int start = valueRegionText.lastIndexOf(',', selectionOffset - 1);
		start = start == -1 ? valueOffset : start + 1;
		int end = valueRegionText.indexOf(',', selectionOffset);
		end = end == -1 ? valueOffset + id.length() : end;
		id = valueRegionText.substring(start, end).trim();
	}
	ElementRenameInfo refactoringInfo = createRefactoringInfo(document, attr, id);
	ElementRenameRefactoring refactoring = new ElementRenameRefactoring(
		new ResultMapRenameEditCollector(refactoringInfo));
	runRefactoringWizard(refactoringInfo, refactoring);
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:21,代码来源:XmlElementRenameHandler.java


示例11: renameStatementId

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
protected void renameStatementId(IDocument document, final IDOMAttr attr)
{
	String id = attr.getValue();
	ElementRenameInfo refactoringInfo = createRefactoringInfo(document, attr, id);
	IMethod method = findMapperMethod(refactoringInfo);
	if (method == null)
	{
		ElementRenameRefactoring refactoring = new ElementRenameRefactoring(
			new StatementRenameEditCollector(refactoringInfo, false));
		runRefactoringWizard(refactoringInfo, refactoring);
	}
	else
	{
		invokeJdtRename(method);
	}
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:17,代码来源:XmlElementRenameHandler.java


示例12: createRefactoringInfo

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
protected ElementRenameInfo createRefactoringInfo(IDocument document, final IDOMAttr attr,
	String id)
{
	String namespace;
	String oldId;
	int namespaceEnd = id.lastIndexOf('.');
	if (namespaceEnd > -1)
	{
		oldId = id.substring(namespaceEnd + 1);
		namespace = id.substring(0, namespaceEnd);
	}
	else
	{
		oldId = id;
		namespace = MybatipseXmlUtil.getNamespace(attr.getOwnerDocument());
	}
	ElementRenameInfo refactoringInfo = new ElementRenameInfo();
	refactoringInfo.setOldId(oldId);
	refactoringInfo.setNamespace(namespace);
	refactoringInfo.setProject(MybatipseXmlUtil.getJavaProject(document));
	return refactoringInfo;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:23,代码来源:XmlElementRenameHandler.java


示例13: validateImage

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
/**
 * Validate img/@src
 * 
 * @param documentRegion
 * @param reporter
 * @param model
 * @param file
 * @param factory
 * @param attrValueRegion
 * @param resourceType
 */
private void validateImage(IStructuredDocumentRegion documentRegion,
		IReporter reporter, IStructuredModel model, IFile file,
		MessageFactory factory, WebResourcesTextRegion attrValueRegion,
		WebResourcesFinderType resourceType) {
	IDOMAttr attr = DOMHelper.getAttrByOffset(model,
			documentRegion.getStartOffset()
					+ attrValueRegion.getRegion().getStart());
	if (attr != null) {
		String attrValue = DOMHelper.getAttrValue(documentRegion
				.getText(attrValueRegion.getRegion()));
		if (URIHelper.isDataURIScheme(attrValue)) {
			// see https://en.wikipedia.org/wiki/Data_URI_scheme
			// ex : <img
			// src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
			// alt="Red dot" />
			// TODO : validate format of data uri scheme.
		} else {
			// ex : <img src="path/to/image.png" />
			validateFile(documentRegion, reporter, model, file, factory,
					attrValueRegion, resourceType);
		}
	}
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-webresources,代码行数:35,代码来源:WebResourcesValidator.java


示例14: validateAttributeValue

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
private ValidationMessage validateAttributeValue(IDOMElement target, String attrName) {
	AngularType type = directive.getDirectiveType();
	switch (type) {
	case module:
	case controller:
		try {
			IFile file = getFile();
			IDocument document = getDocument();
			IIDETernProject ternProject = AngularProject.getTernProject(file.getProject());
			IDOMAttr attr = (IDOMAttr) target.getAttributeNode(attrName);
			boolean exists = isAngularElementExists(attr, file, document, ternProject, type);
			if (!exists) {
				Segment segment = CustomValidatorUtil.getAttributeSegment(
						(IDOMNode) target.getAttributeNode(attrName), CustomValidatorUtil.ATTR_REGION_VALUE);
				return new ValidationMessage(
						NLS.bind(AngularCoreMessages.Validation_AngularElementNotFound, type.name(),
								attr.getValue()),
						segment.getOffset(), segment.getLength(), ValidationMessage.ERROR);
			}
		} catch (Exception e) {
			Trace.trace(Trace.SEVERE, "Error while Angular validator.", e);
		}
		break;
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:27,代码来源:HTMLAngularAttributeValidator.java


示例15: isAngularElementExists

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
private static boolean isAngularElementExists(IDOMAttr attr, IFile file, IDocument document,
		IIDETernProject ternProject, final AngularType angularType) throws CoreException, IOException, Exception {

	TernAngularQuery query = new TernAngularTypeQuery(angularType);
	query.setExpression(AngularScopeHelper.getAngularValue(attr, angularType));

	ITernScriptPath scriptPath = AngularScopeHelper.populateScope(attr.getOwnerElement(), file, angularType, query);

	ValidationTernTypeCollector collector = new ValidationTernTypeCollector();

	if (scriptPath != null) {
		ternProject.request(query, null, scriptPath, null, null, collector);
	} else {
		ITernFile tf = new TernDocumentFile(file, document);
		ternProject.request(query, null, null, attr, tf, collector);
	}
	return collector.isExists();
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:19,代码来源:HTMLAngularAttributeValidator.java


示例16: getAttr

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
/**
 * Returns the SSE DOM attribute by name from the ownner element.
 * 
 * @param element
 * @param attrName
 * @return
 */
public static IDOMAttr getAttr(IDOMElement element, String attrName) {
	if (StringUtils.isEmpty(attrName)) {
		return null;
	}
	String prefix = element.getPrefix();
	if (!StringUtils.isEmpty(prefix)) {
		String namespaceURI = element.getNamespaceURI();
		IDOMAttr attr = (IDOMAttr) element.getAttributeNodeNS(namespaceURI,
				attrName);
		if (attr != null) {
			return attr;
		}
	}
	return (IDOMAttr) element.getAttributeNode(attrName);
}
 
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:23,代码来源:DOMUtils.java


示例17: getAttrByRegion

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
/**
 * Returns the SSE DOM Attribute {@link IDOMAttr} by region from the SSE DOM
 * element {@link IDOMElement}.
 * 
 * @param element
 *            the SSE DOM element {@link IDOMElement}.
 * @param region
 *            the region.
 * @return
 */
public static IDOMAttr getAttrByRegion(IDOMNode element, ITextRegion region) {
	if (!isAttrRegion(region)) {
		return null;
	}

	IStructuredDocumentRegion structuredDocumentRegionElement = element.getFirstStructuredDocumentRegion();

	// 1) Get attribute name region
	ITextRegionList elementRegions = structuredDocumentRegionElement.getRegions();
	int index = elementRegions.indexOf(region);
	if (index < 0) {
		return null;
	}

	ITextRegion attrNameRegion = null;
	while (index >= 0) {
		attrNameRegion = elementRegions.get(index--);
		if (attrNameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
			break;
		}
	}
	if (attrNameRegion == null) {
		return null;
	}
	String attrName = structuredDocumentRegionElement.getText(attrNameRegion);
	return (IDOMAttr) element.getAttributes().getNamedItem(attrName);
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:38,代码来源:DOMUtils.java


示例18: getAttrByOffset

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
/**
 * Returns the SSE DOM Attribute {@link IDOMAttr} by offset from the SSE DOM
 * node {@link IDOMNode}.
 * 
 * @param E
 *            the SSE DOM element {@link IDOMElement}.
 * @param region
 *            the region.
 * @return
 */
public static final IDOMAttr getAttrByOffset(Node node, int offset) {
	if ((node instanceof IndexedRegion) && ((IndexedRegion) node).contains(offset) && node.hasAttributes()) {
		NamedNodeMap attrs = node.getAttributes();
		for (int i = 0; i < attrs.getLength(); i++) {
			IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
			if (attRegion.contains(offset))
				return (IDOMAttr) attrs.item(i);
		}

	}
	return null;
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:23,代码来源:DOMUtils.java


示例19: getAttr

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
/**
 * Returns the SSE DOM attribute by name from the ownner element.
 * 
 * @param element
 * @param attrName
 * @return
 */
public static IDOMAttr getAttr(IDOMElement element, String attrName) {
	if (StringUtils.isEmpty(attrName)) {
		return null;
	}
	String prefix = element.getPrefix();
	if (!StringUtils.isEmpty(prefix)) {
		String namespaceURI = element.getNamespaceURI();
		IDOMAttr attr = (IDOMAttr) element.getAttributeNodeNS(namespaceURI, attrName);
		if (attr != null) {
			return attr;
		}
	}
	return (IDOMAttr) element.getAttributeNode(attrName);
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:22,代码来源:DOMUtils.java


示例20: HTMLAngularCompletionCollector

import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; //导入依赖的package包/类
public HTMLAngularCompletionCollector(IDOMElement element, IDOMAttr attr,
		ContentAssistRequest contentAssistRequest, HTMLAngularTagsCompletionProposalComputer computer) {
	super(element, attr, false);
	this.computer = computer;
	this.contentAssistRequest = contentAssistRequest;
	this.hasValue = attr != null && attr.getValueRegionText() != null;
}
 
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:8,代码来源:HTMLAngularCompletionCollector.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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