Package org.eclipse.xtext.util

Examples of org.eclipse.xtext.util.StringInputStream


    this.injector = injector;
  }

  public IParseResult parseText(String text) {
    boolean ignoreSyntaxErrors = shouldIgnoreSyntaxErrorsIn(text);
    XtextResource resource = createResourceFrom(new StringInputStream(text));
    IParseResult parseResult = resource.getParseResult();
    if (ignoreSyntaxErrors || !parseResult.hasSyntaxErrors()) {
      return parseResult;
    }
    StringBuilder builder = new StringBuilder();
View Full Code Here


    reader = new ContentReader();
  }

  @Test public void should_read_InputStream() throws IOException {
    String contents = "Hello \r\n World";
    InputStream input = new StringInputStream(contents);
    assertThat(reader.contentsOf(input), equalTo(contents));
  }
View Full Code Here

   */
  public XtextResource createResource(URI uri, String contents) throws IOException {
    // TODO get project from URI.
    ResourceSet resourceSet = resourceSetProvider.get(projects.activeProject());
    XtextResource resource = (XtextResource) resourceSet.createResource(uri, UNSPECIFIED_CONTENT_TYPE);
    resource.load(new StringInputStream(contents), singletonMap(OPTION_ENCODING, UTF_8));
    resolveLazyCrossReferences(resource, NullImpl);
    return resource;
  }
View Full Code Here

  }

  protected void enhanceProject(final IProject project, final IProgressMonitor monitor) throws CoreException {
    project.setDefaultCharset(Charsets.UTF_8.name(), monitor);
    IFile file = project.getFile(FILE_NAME);
    file.create(new StringInputStream(TurtleNewFileWizard.initialFileContent), true, monitor);
    file.setCharset(Charsets.UTF_8.name(), monitor);
    project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
  }
View Full Code Here

  @Test
  public void run() throws Exception {
    String[] vmArgs = {};
    String fileName = "Hello.g4";
    InputStream toolStream = new StringInputStream(
        "warning: warning message\nerror: undefined rule: 'x'");
    InputStream dependStream = new StringInputStream("");

    QualifiedName generatedFiles = new QualifiedName("antlr4ide", "generatedFiles");

    IPath fileFullPath = Path.fromOSString("home").append("demo").append("project")
        .append(fileName);
View Full Code Here

      String encoding = getEncoding(file);
      CharSequence postProcessedContent = postProcess(fileName, outputName, contents, encoding);
      String contentsAsString = postProcessedContent.toString();
      if (file.exists()) {
        if (outputConfig.isOverrideExistingResources()) {
          StringInputStream newContent = getInputStream(contentsAsString, encoding);
          if (hasContentsChanged(file, newContent)) {
            // reset to offset zero allows to reuse internal byte[]
            // no need to convert the string twice
            newContent.reset();
            file.setContents(newContent, true, true, monitor);
          } else {
            file.touch(getMonitor());
          }
          if (file.isDerived() != outputConfig.isSetDerivedProperty()) {
View Full Code Here

    }
  }

  protected StringInputStream getInputStream(String contentsAsString, String encoding) {
    try {
      return new StringInputStream(contentsAsString, encoding);
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeIOException(e);
    }
  }
View Full Code Here

    resourceSet.getResources().clear();
    Resource resource = resourceSet.createResource(createURI("MyQuery.__query"));
    try {
      Map<String,String> options = newHashMap();
      options.put(XtextResource.OPTION_ENCODING, UTF_8);
      resource.load(new StringInputStream(input, UTF_8), options);
      EcoreUtil.resolveAll(resource);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    return filter(resource.getContents(), Query.class).iterator().next();
View Full Code Here

 
 
  protected Resource resource(String input, String extension)  {
    Resource resource = resourceSet.createResource(createURI(format("TaskTest" + resourceSet.getResources().size() + "." + extension)));
    try {
      resource.load(new StringInputStream(input), null);
      EcoreUtil.resolveAll(resource);
    } catch (IOException e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }
View Full Code Here

          reader.close();
        } catch (IOException e) {
        }
      }
    }
    return new StringInputStream(replaceVariables(contents.toString(), variables));
  }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.util.StringInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.