Package org.eclipse.emf.common.util

Examples of org.eclipse.emf.common.util.Diagnostic


        .getInstance()
        .getInjector(
            TargetPlatformActivator.FR_OBEO_RELENG_TARGETPLATFORM_TARGETPLATFORM);
    Converter converter = new Converter();
    injector.injectMembers(converter);
    Diagnostic diagnostic = null;
    final String path = selectedElement.getLocation().toFile().getAbsolutePath();
    URI targetplatformFileURI = URI.createFileURI(path);

    try {
      diagnostic = converter.generateTargetDefinitionFile(targetplatformFileURI, subMonitor.newChild(95));
View Full Code Here


    Converter converter = new Converter();
    injector.injectMembers(converter);

    URI uri = normalize(org.eclipse.emf.common.util.URI.createURI(path));
   
    Diagnostic diagnostic = converter.generateTargetDefinitionFile(uri, createPrintingMonitor());
   
    if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
      for (Diagnostic child : diagnostic.getChildren()) {
        printDiagnostic(child, "");
      }
    }
   
    if (diagnostic.getSeverity() == Diagnostic.ERROR) {
      System.out.println("Problems occurred during generation of target platform definition file.");
      return -1;
    } else if (diagnostic.getSeverity() == Diagnostic.CANCEL) {
      System.out.println("Operation cancelled.");
      return -2;
    } else {
      System.out.println("The target platform definition file has been successfully generated.");
      return 0;
View Full Code Here

    for (ResolvedLocation location : getLocations()) {
      if(subMonitor.isCanceled()) {
        ret.merge(BasicDiagnostic.CANCEL_INSTANCE);
        break;
      }
      Diagnostic diagnostic = location.resolve(metadataRepositoryManager, subMonitor);
      if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
        ret.merge(diagnostic);
      }
      subMonitor.worked(1);
    }
    return ret;
View Full Code Here

  public Diagnostic generateTargetDefinitionFile(URI uri, IProgressMonitor monitor) {
    BasicDiagnostic ret = new BasicDiagnostic(TargetPlatformBundleActivator.PLUGIN_ID, 0, "Diagnostic of the generation of the target platform.", null);
    if (!"targetplatform".equals(uri.fileExtension()) && !"tpd".equals(uri.fileExtension())) {
      ret.merge(new BasicDiagnostic(Diagnostic.ERROR, TargetPlatformBundleActivator.PLUGIN_ID, -1, "The target platform file '" + uri + "' must ends with '.tpd' or '.targetplatform' extensions.", null));
    } else {
      Diagnostic diagnostic = doGenerateTargetDefinitionFile(uri, monitor);
      if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
        ret.merge(diagnostic);
      }
    }
    return ret;
  }
View Full Code Here

   
    try {
      Resource resource = loadTargetPlatform(uri);
      subMonitor.worked(2);
     
      Diagnostic resourceDiagnostic = EcoreUtil.computeDiagnostic(resource, true);
      if (resourceDiagnostic.getSeverity() >= Diagnostic.WARNING) {
        ret.merge(resourceDiagnostic);
      }

      if (resourceDiagnostic.getSeverity() < Diagnostic.ERROR) {
        TargetPlatform targetPlatform = null;
        if (resource != null && !resource.getContents().isEmpty()) {
          targetPlatform = (TargetPlatform) resource.getContents().get(0);
        }
        if (targetPlatform == null) {
          ret.merge(new BasicDiagnostic(Diagnostic.ERROR, TargetPlatformBundleActivator.PLUGIN_ID, -1, "Error occured while loading the file " + uri + ".", null));
        } else if (subMonitor.isCanceled()) {
          ret.merge(Diagnostic.CANCEL_INSTANCE);
        } else {
          SubMonitor diagnosticianMonitor = subMonitor.newChild(90).setWorkRemaining(targetPlatform.getLocations().size());
          Diagnostic validation = new CustomDiagnostician(diagnosticianMonitor).validate(targetPlatform);
          if (validation.getSeverity() >= Diagnostic.WARNING) {
            ret.merge(validation);
          } else if (subMonitor.isCanceled()) {
            ret.merge(Diagnostic.CANCEL_INSTANCE);
          }
         
          if (validation.getSeverity() < Diagnostic.ERROR) {
            Diagnostic diagnostic = doGenerateTargetDefinitionFile(uri, targetPlatform, subMonitor.newChild(8));
            if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
              ret.merge(diagnostic);
            }
          }
          subMonitor.setWorkRemaining(0);
        }
View Full Code Here

      subMonitor.worked(5);
     
      if (subMonitor.isCanceled()) {
        ret.merge(Diagnostic.CANCEL_INSTANCE);
      } else {
        Diagnostic diagnostic = resolvedTargetPlatform.resolve(repositoryManager, subMonitor.newChild(90));
        if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
          ret.merge(diagnostic);
        }
        if (subMonitor.isCanceled()) {
          ret.merge(Diagnostic.CANCEL_INSTANCE);
        } else if (ret.getSeverity() < Diagnostic.ERROR) {
          diagnostic = doGenerateTargetDefinitionFile(uri, resolvedTargetPlatform);
          if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
            ret.merge(diagnostic);
          }
          subMonitor.worked(5);
        }
      }
View Full Code Here

    BasicDiagnostic ret = new BasicDiagnostic();
    TargetDefinitionGenerator generator = new TargetDefinitionGenerator();
    String xml = generator.generate(resolvedTargetPlatform, (int)TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
    final URI targetDefinitionLocation = uri.trimFileExtension().appendFileExtension("target");
   
    Diagnostic diagnostic = serialize(targetDefinitionLocation, xml);
    if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
      ret.merge(diagnostic);
    }
   
    return ret;
  }
View Full Code Here

      _builder.append("}");
      _builder.newLine();
      final TargetPlatform targetPlatform = this.parser.parse(_builder);
      final ResolvedTargetPlatform resolvedTargetPlatform = ResolvedTargetPlatform.create(targetPlatform, this.indexBuilder);
      NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
      final Diagnostic d = resolvedTargetPlatform.resolve(new MockMetadataRepositoryManager(null) {
        public IMetadataRepository loadRepository(final URI location, final IProgressMonitor monitor) throws ProvisionException, OperationCanceledException {
          IMetadataRepository _xifexpression = null;
          String _string = location.toString();
          boolean _equals = "unknownHost".equals(_string);
          if (_equals) {
            throw new ProvisionException("Unknown Host");
          } else {
            _xifexpression = super.loadRepository(location, monitor);
          }
          return _xifexpression;
        }
      }, _nullProgressMonitor);
      int _severity = d.getSeverity();
      Assert.assertEquals(Diagnostic.ERROR, _severity);
      List<Diagnostic> _children = d.getChildren();
      Diagnostic _head = IterableExtensions.<Diagnostic>head(_children);
      String _message = _head.getMessage();
      String _plus = ("Message is " + _message);
      List<Diagnostic> _children_1 = d.getChildren();
      Diagnostic _head_1 = IterableExtensions.<Diagnostic>head(_children_1);
      String _message_1 = _head_1.getMessage();
      boolean _startsWith = _message_1.startsWith("Unknown Host");
      Assert.assertTrue(_plus, _startsWith);
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
View Full Code Here

          }
          return _xifexpression;
        }
      });
      NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
      final Diagnostic d = resolvedTargetPlatform.resolve(_mockMetadataRepositoryManager, _nullProgressMonitor);
      int _severity = d.getSeverity();
      Assert.assertEquals(Diagnostic.ERROR, _severity);
      List<Diagnostic> _children = d.getChildren();
      String _join = IterableExtensions.join(_children, ", ");
      List<Diagnostic> _children_1 = d.getChildren();
      final Function1<Diagnostic, Boolean> _function = new Function1<Diagnostic, Boolean>() {
        public Boolean apply(final Diagnostic it) {
          int _severity = it.getSeverity();
          return Boolean.valueOf((_severity >= Diagnostic.WARNING));
        }
View Full Code Here

                    constraintSet.add(TagIdentifierFactory.createJSPTagWrapper(
                            tagId.getUri(), tagId.getName()));
                }
                final MemberConstraint memberConstraint = new MemberConstraint(
                        constraintSet);
                final Diagnostic diag = memberConstraint.isSatisfied(set);

                if (diag.getSeverity() != Diagnostic.OK)
                {
                    _containmentValidationCount++; // found a violation

                    final List data = diag.getData();

                    for (final Iterator it = data.iterator(); it.hasNext();)
                    {
                        final TagIdentifier missingParent = (TagIdentifier) it
                                .next();
View Full Code Here

TOP

Related Classes of org.eclipse.emf.common.util.Diagnostic

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.