Java Code Examples for com.intellij.psi.impl.source.parsing.xml.DtdParsing

The following are top voted examples for showing how to use com.intellij.psi.impl.source.parsing.xml.DtdParsing. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: intellij-ce-playground   File: XmlEntityDeclImpl.java   Source Code and License 6 votes vote down vote up
@Override
public PsiElement parse(PsiFile baseFile, EntityContextType contextType, final XmlEntityRef originalElement) {
  PsiElement dep = XmlElement.DEPENDING_ELEMENT.get(getParent());
  PsiElement dependsOnElement = getValueElement(dep instanceof PsiFile ? (PsiFile)dep : baseFile);
  String value = null;
  if (dependsOnElement instanceof XmlAttributeValue) {
    XmlAttributeValue attributeValue = (XmlAttributeValue)dependsOnElement;
    value = attributeValue.getValue();
  }
  else if (dependsOnElement instanceof PsiFile) {
    PsiFile file = (PsiFile)dependsOnElement;
    value = file.getText();
  }

  if (value == null) return null;

  DtdParsing dtdParsing = new DtdParsing(value, XML_ELEMENT_DECL, contextType, baseFile);
  PsiElement generated = dtdParsing.parse().getPsi().getFirstChild();
  if (contextType == EntityContextType.ELEMENT_CONTENT_SPEC && generated instanceof XmlElementContentSpec) {
    generated = generated.getFirstChild();
  }
  setDependsOnElement(generated, dependsOnElement);
  return setOriginalElement(generated, originalElement);
}
 
Example 2
Project: tools-idea   File: XmlEntityDeclImpl.java   Source Code and License 6 votes vote down vote up
public PsiElement parse(PsiFile baseFile, EntityContextType contextType, final XmlEntityRef originalElement) {
  PsiElement dep = XmlElement.DEPENDING_ELEMENT.get(getParent());
  PsiElement dependsOnElement = getValueElement(dep instanceof PsiFile ? (PsiFile)dep : baseFile);
  String value = null;
  if (dependsOnElement instanceof XmlAttributeValue) {
    XmlAttributeValue attributeValue = (XmlAttributeValue)dependsOnElement;
    value = attributeValue.getValue();
  }
  else if (dependsOnElement instanceof PsiFile) {
    PsiFile file = (PsiFile)dependsOnElement;
    value = file.getText();
  }

  if (value == null) return null;

  DtdParsing dtdParsing = new DtdParsing(value, XML_ELEMENT_DECL, contextType, baseFile);
  PsiElement generated = dtdParsing.parse().getPsi().getFirstChild();
  if (contextType == EntityContextType.ELEMENT_CONTENT_SPEC && generated instanceof XmlElementContentSpec) {
    generated = generated.getFirstChild();
  }
  setDependsOnElement(generated, dependsOnElement);
  return setOriginalElement(generated, originalElement);
}
 
Example 3
Project: intellij-ce-playground   File: DTDParserDefinition.java   Source Code and License 5 votes vote down vote up
@NotNull
@Override
public PsiParser createParser(Project project) {
  return new PsiParser() {
    @NotNull
    @Override
    public ASTNode parse(IElementType root, PsiBuilder builder) {
      return new DtdParsing(root, XmlEntityDecl.EntityContextType.GENERIC_XML, builder).parse();
    }
  };
}
 
Example 4
Project: tools-idea   File: DTDParserDefinition.java   Source Code and License 5 votes vote down vote up
@NotNull
@Override
public PsiParser createParser(Project project) {
  return new PsiParser() {
    @NotNull
    @Override
    public ASTNode parse(IElementType root, PsiBuilder builder) {
      return new DtdParsing(root, XmlEntityDecl.EntityContextType.GENERIC_XML, builder).parse();
    }
  };
}
 
Example 5
Project: consulo-xml   File: XmlEntityDeclImpl.java   Source Code and License 5 votes vote down vote up
@Override
public PsiElement parse(PsiFile baseFile, EntityContextType contextType, final XmlEntityRef originalElement)
{
	PsiElement dep = XmlElement.DEPENDING_ELEMENT.get(getParent());
	PsiElement dependsOnElement = getValueElement(dep instanceof PsiFile ? (PsiFile) dep : baseFile);
	String value = null;
	if(dependsOnElement instanceof XmlAttributeValue)
	{
		XmlAttributeValue attributeValue = (XmlAttributeValue) dependsOnElement;
		value = attributeValue.getValue();
	}
	else if(dependsOnElement instanceof PsiFile)
	{
		PsiFile file = (PsiFile) dependsOnElement;
		value = file.getText();
	}

	if(value == null)
	{
		return null;
	}

	DtdParsing dtdParsing = new DtdParsing(value, XML_ELEMENT_DECL, contextType, baseFile);
	PsiElement generated = dtdParsing.parse().getPsi().getFirstChild();
	if(contextType == EntityContextType.ELEMENT_CONTENT_SPEC && generated instanceof XmlElementContentSpec)
	{
		generated = generated.getFirstChild();
	}
	setDependsOnElement(generated, dependsOnElement);
	return setOriginalElement(generated, originalElement);
}
 
Example 6
Project: intellij-ce-playground   File: XmlElementType.java   Source Code and License 4 votes vote down vote up
@Override
public ASTNode parse(CharSequence text, CharTable table) {
  return new DtdParsing(text, XML_MARKUP_DECL, DtdParsing.TYPE_FOR_MARKUP_DECL, null).parse();
}
 
Example 7
Project: intellij-ce-playground   File: XmlParsingTest.java   Source Code and License 4 votes vote down vote up
private CompositeElement parseManually(final String value, final IElementType xmlElementDecl, XmlEntityDecl.EntityContextType parseType) {
  return (CompositeElement)new DtdParsing(value, xmlElementDecl, parseType, null).parse();
}
 
Example 8
Project: tools-idea   File: XmlElementType.java   Source Code and License 4 votes vote down vote up
public ASTNode parse(CharSequence text, CharTable table) {
  return new DtdParsing(text, XML_MARKUP_DECL, DtdParsing.TYPE_FOR_MARKUP_DECL, null).parse();
}
 
Example 9
Project: tools-idea   File: XmlParsingTest.java   Source Code and License 4 votes vote down vote up
private CompositeElement parseManually(final String value, final IElementType xmlElementDecl, XmlEntityDecl.EntityContextType parseType) {
  return (CompositeElement)new DtdParsing(value, xmlElementDecl, parseType, null).parse();
}
 
Example 10
Project: consulo-xml   File: XmlElementType.java   Source Code and License 4 votes vote down vote up
public ASTNode parse(CharSequence text, CharTable table) {
  return new DtdParsing(text, XML_MARKUP_DECL, DtdParsing.TYPE_FOR_MARKUP_DECL, null).parse();
}