Java Code Examples for org.eclipse.xtext.util.internal.Stopwatches#StoppedTask

The following examples show how to use org.eclipse.xtext.util.internal.Stopwatches#StoppedTask . 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: StorageAwareResource.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public void loadFromStorage(ResourceStorageLoadable storageInputStream) throws IOException {
	// check the argument for null before the internal state is modified
	Preconditions.checkNotNull(storageInputStream, "storageInputStream");
	Stopwatches.StoppedTask task = Stopwatches.forTask("Loading from storage");
	task.start();
	isLoading = true;
	isLoadedFromStorage = true;
	try {
		storageInputStream.loadIntoResource(this);
		isLoaded = true;
	} finally {
		isLoading = false;
		task.stop();
	}
}
 
Example 2
Source File: AnnotationProcessor.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * gets called from Xtend compiler, during "model inference", i.e. translation of Xtend AST to Java AST
 */
public Object indexingPhase(final ActiveAnnotationContext ctx, final IJvmDeclaredTypeAcceptor acceptor, final CancelIndicator monitor) {
  Object _xblockexpression = null;
  {
    final Stopwatches.StoppedTask task = Stopwatches.forTask("[macros] indexingPhase (AnnotationProcessor.indexingPhase)");
    task.start();
    Object _xtrycatchfinallyexpression = null;
    try {
      Object _switchResult = null;
      Object _processorInstance = ctx.getProcessorInstance();
      final Object processor = _processorInstance;
      boolean _matched = false;
      if (processor instanceof RegisterGlobalsParticipant) {
        _matched=true;
        Object _xblockexpression_1 = null;
        {
          final RegisterGlobalsContextImpl registerGlobalsCtx = this.registerGlobalsContextProvider.get();
          registerGlobalsCtx.setAcceptor(acceptor);
          registerGlobalsCtx.setCompilationUnit(ctx.getCompilationUnit());
          final Runnable _function = () -> {
            final Function1<XtendAnnotationTarget, Declaration> _function_1 = (XtendAnnotationTarget it) -> {
              Declaration _switchResult_1 = null;
              boolean _matched_1 = false;
              if (it instanceof XtendMember) {
                _matched_1=true;
                _switchResult_1 = ctx.getCompilationUnit().toXtendMemberDeclaration(((XtendMember)it));
              }
              if (!_matched_1) {
                if (it instanceof XtendParameter) {
                  _matched_1=true;
                  _switchResult_1 = ctx.getCompilationUnit().toXtendParameterDeclaration(((XtendParameter)it));
                }
              }
              final Declaration xtendMember = _switchResult_1;
              return xtendMember;
            };
            ((RegisterGlobalsParticipant<NamedElement>)processor).doRegisterGlobals(
              ListExtensions.<XtendAnnotationTarget, Declaration>map(ctx.getAnnotatedSourceElements(), _function_1), registerGlobalsCtx);
          };
          _xblockexpression_1 = this.runWithCancelIndiciator(ctx, monitor, _function);
        }
        _switchResult = _xblockexpression_1;
      }
      _xtrycatchfinallyexpression = _switchResult;
    } finally {
      task.stop();
    }
    _xblockexpression = _xtrycatchfinallyexpression;
  }
  return _xblockexpression;
}
 
Example 3
Source File: AnnotationProcessor.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Object inferencePhase(final ActiveAnnotationContext ctx, final CancelIndicator monitor) {
  Object _xblockexpression = null;
  {
    final Stopwatches.StoppedTask task = Stopwatches.forTask("[macros] inferencePhase (AnnotationProcessor.inferencePhase)");
    task.start();
    Object _xtrycatchfinallyexpression = null;
    try {
      Object _switchResult = null;
      Object _processorInstance = ctx.getProcessorInstance();
      final Object processor = _processorInstance;
      boolean _matched = false;
      if (processor instanceof TransformationParticipant) {
        _matched=true;
        Object _xblockexpression_1 = null;
        {
          final TransformationContextImpl modifyCtx = this.modifyContextProvider.get();
          modifyCtx.setUnit(ctx.getCompilationUnit());
          final Runnable _function = () -> {
            final Function1<XtendAnnotationTarget, MutableNamedElement> _function_1 = (XtendAnnotationTarget it) -> {
              Declaration _switchResult_1 = null;
              boolean _matched_1 = false;
              if (it instanceof XtendMember) {
                _matched_1=true;
                _switchResult_1 = ctx.getCompilationUnit().toXtendMemberDeclaration(((XtendMember)it));
              }
              if (!_matched_1) {
                if (it instanceof XtendParameter) {
                  _matched_1=true;
                  _switchResult_1 = ctx.getCompilationUnit().toXtendParameterDeclaration(((XtendParameter)it));
                }
              }
              final Declaration xtendMember = _switchResult_1;
              Element _primaryGeneratedJavaElement = modifyCtx.getPrimaryGeneratedJavaElement(xtendMember);
              return ((MutableNamedElement) _primaryGeneratedJavaElement);
            };
            final List<MutableNamedElement> map = ListExtensions.<XtendAnnotationTarget, MutableNamedElement>map(ctx.getAnnotatedSourceElements(), _function_1);
            ((TransformationParticipant<MutableNamedElement>)processor).doTransform(map, modifyCtx);
          };
          _xblockexpression_1 = this.runWithCancelIndiciator(ctx, monitor, _function);
        }
        _switchResult = _xblockexpression_1;
      }
      _xtrycatchfinallyexpression = _switchResult;
    } finally {
      task.stop();
    }
    _xblockexpression = _xtrycatchfinallyexpression;
  }
  return _xblockexpression;
}
 
Example 4
Source File: AnnotationProcessor.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Object validationPhase(final ActiveAnnotationContext ctx, final CancelIndicator monitor) {
  Object _xblockexpression = null;
  {
    final Stopwatches.StoppedTask task = Stopwatches.forTask("[macros] validationPhase (AnnotationProcessor.validationPhase)");
    task.start();
    Object _xtrycatchfinallyexpression = null;
    try {
      Object _switchResult = null;
      Object _processorInstance = ctx.getProcessorInstance();
      final Object processor = _processorInstance;
      boolean _matched = false;
      if (processor instanceof ValidationParticipant) {
        _matched=true;
        Object _xblockexpression_1 = null;
        {
          final ValidationContextImpl validationContext = this.validationContextProvider.get();
          validationContext.setUnit(ctx.getCompilationUnit());
          final Runnable _function = () -> {
            final Function1<XtendAnnotationTarget, NamedElement> _function_1 = (XtendAnnotationTarget it) -> {
              Declaration _switchResult_1 = null;
              boolean _matched_1 = false;
              if (it instanceof XtendMember) {
                _matched_1=true;
                _switchResult_1 = ctx.getCompilationUnit().toXtendMemberDeclaration(((XtendMember)it));
              }
              if (!_matched_1) {
                if (it instanceof XtendParameter) {
                  _matched_1=true;
                  _switchResult_1 = ctx.getCompilationUnit().toXtendParameterDeclaration(((XtendParameter)it));
                }
              }
              final Declaration xtendMember = _switchResult_1;
              Element _primaryGeneratedJavaElement = validationContext.getPrimaryGeneratedJavaElement(xtendMember);
              return ((NamedElement) _primaryGeneratedJavaElement);
            };
            final List<NamedElement> map = ListExtensions.<XtendAnnotationTarget, NamedElement>map(ctx.getAnnotatedSourceElements(), _function_1);
            ((ValidationParticipant<NamedElement>)processor).doValidate(map, validationContext);
          };
          _xblockexpression_1 = this.runWithCancelIndiciator(ctx, monitor, _function);
        }
        _switchResult = _xblockexpression_1;
      }
      _xtrycatchfinallyexpression = _switchResult;
    } finally {
      task.stop();
    }
    _xblockexpression = _xtrycatchfinallyexpression;
  }
  return _xblockexpression;
}