Java Code Examples for com.intellij.psi.PsiFile#copy()

The following examples show how to use com.intellij.psi.PsiFile#copy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BPMNFileSchemaProvider.java    From intellij-bpmn-editor with GNU General Public License v3.0 5 votes vote down vote up
private static XmlFile getReference(@NotNull @NonNls String url, @NotNull Module module) {
    if (url.equalsIgnoreCase("http://bpmn.sourceforge.net")) {
        return null;
    }
    final URL resource = BPMNFileSchemaProvider.class.getResource(BPMNModelConstants.BPMN_SCHEMA_BASEURI + BPMNModelConstants.BPMN_SYSTEM_ID);
    final VirtualFile fileByURL = VfsUtil.findFileByURL(resource);
    if (fileByURL == null) {
        return null;
    }

    PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(fileByURL);
    return (XmlFile) psiFile.copy();
}
 
Example 2
Source File: NMMLSchemaProvider.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public XmlFile getSchema(@NotNull @NonNls String url, @Nullable Module module, @NotNull PsiFile baseFile) {
  final URL resource = NMMLSchemaProvider.class.getResource("/nmml.xsd");
  final VirtualFile fileByURL = VfsUtil.findFileByURL(resource);
  PsiFile result = baseFile.getManager().findFile(fileByURL);
  if (result instanceof XmlFile) {
    return (XmlFile)result.copy();
  }
  return null;
}