com.google.gwt.core.ext.TreeLogger.Type Java Examples

The following examples show how to use com.google.gwt.core.ext.TreeLogger.Type. 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: ObjectMapperCreator.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
/**
 * Build the new deserializer method.
 *
 * @param mappedTypeClass the type to map
 *
 * @return the method
 */
private MethodSpec buildNewDeserializerMethod( JClassType mappedTypeClass ) throws UnableToCompleteException {
    JDeserializerType type;
    try {
        type = getJsonDeserializerFromType( mappedTypeClass );
    } catch ( UnsupportedTypeException e ) {
        logger.log( Type.ERROR, "Cannot generate mapper due to previous errors : " + e.getMessage() );
        throw new UnableToCompleteException();
    }

    return MethodSpec.methodBuilder( "newDeserializer" )
            .addModifiers( Modifier.PROTECTED )
            .addAnnotation( Override.class )
            .returns( parameterizedName( JsonDeserializer.class, mappedTypeClass ) )
            .addStatement( "return $L", type.getInstance() )
            .build();
}
 
Example #2
Source File: EventBinderWriterTest.java    From gwteventbinder with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailOnPrimitiveParameter() throws Exception {
  JClassType paramType = mock(JClassType.class);
  when(paramType.isClassOrInterface()).thenReturn(null);

  JMethod method = newMethod("myMethod", paramType);
  when(target.getInheritableMethods()).thenReturn(new JMethod[] {method});

  try {
    writer.writeDoBindEventHandlers(target, output, typeOracle);
    fail("Exception not thrown");
  } catch (UnableToCompleteException expected) {}

  verify(logger).log(
      eq(Type.ERROR), contains("myMethod"), isNull(Throwable.class), isNull(HelpInfo.class));
}
 
Example #3
Source File: EventBinderWriterTest.java    From gwteventbinder with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailOnInvalidParameter() throws Exception {
  JClassType paramType = mock(JClassType.class);
  when(paramType.isAssignableTo(genericEventType)).thenReturn(false);
  when(paramType.isClassOrInterface()).thenReturn(paramType);

  JMethod method = newMethod("myMethod", paramType);
  when(target.getInheritableMethods()).thenReturn(new JMethod[] {method});

  try {
    writer.writeDoBindEventHandlers(target, output, typeOracle);
    fail("Exception not thrown");
  } catch (UnableToCompleteException expected) {}

  verify(logger).log(
      eq(Type.ERROR), contains("myMethod"), isNull(Throwable.class), isNull(HelpInfo.class));
}
 
Example #4
Source File: EventBinderWriterTest.java    From gwteventbinder with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailOnAbstractParameter() throws Exception {
  JClassType paramType = getEventType(AbstractEvent.class);
  when(paramType.isAbstract()).thenReturn(true);
  
  JMethod method = newMethod("myMethod", paramType);
  when(target.getInheritableMethods()).thenReturn(new JMethod[] {method});
  
  try {
    writer.writeDoBindEventHandlers(target, output, typeOracle);
    fail("Exception not thrown");
  } catch (UnableToCompleteException expected) {}
  
  verify(logger).log(
      eq(Type.ERROR), contains("myMethod"), isNull(Throwable.class), isNull(HelpInfo.class));
}
 
Example #5
Source File: AppcacheLinker.java    From gwt-appcache with Apache License 2.0 6 votes vote down vote up
@Nonnull
final Map<String, String> parseFallbackResources( @Nonnull final TreeLogger logger,
                                                  @Nonnull final Set<String> values )
  throws UnableToCompleteException
{
  final HashMap<String, String> fallbackFiles = new HashMap<>();
  for ( final String line : values )
  {
    final String[] elements = line.trim().split( " +" );
    if ( 2 != elements.length )
    {
      final String message = FALLBACK_FILES_CONFIGURATION_PROPERTY_NAME + " property value '" +
                             line + "' should have two url paths separated by whitespace";
      logger.log( Type.ERROR, message );
      throw new UnableToCompleteException();
    }
    fallbackFiles.put( elements[ 0 ], elements[ 1 ] );
  }

  return fallbackFiles;
}
 
Example #6
Source File: AppcacheLinker.java    From gwt-appcache with Apache License 2.0 6 votes vote down vote up
@Nonnull
final ArtifactSet perPermutationLink( @Nonnull final TreeLogger logger,
                                      @Nonnull final LinkerContext context,
                                      @Nonnull final ArtifactSet artifacts )
  throws UnableToCompleteException
{
  final Permutation permutation = calculatePermutation( logger, context, artifacts );
  if ( null == permutation )
  {
    logger.log( Type.ERROR, "Unable to calculate permutation " );
    throw new UnableToCompleteException();
  }

  final ArtifactSet results = new ArtifactSet( artifacts );
  results.add( new PermutationArtifact( AppcacheLinker.class, permutation ) );
  return results;
}
 
Example #7
Source File: EventBinderGenerator.java    From gwteventbinder with Apache License 2.0 6 votes vote down vote up
@Override
public String generate(TreeLogger logger, GeneratorContext context,
    String typeName) throws UnableToCompleteException {
  try {
    JClassType eventBinderType = context.getTypeOracle().getType(typeName);
    JClassType targetType = getTargetType(eventBinderType, context.getTypeOracle());
    SourceWriter writer = createSourceWriter(logger, context, eventBinderType, targetType);
    if (writer != null) { // Otherwise the class was already created
      new EventBinderWriter(
          logger,
          context.getTypeOracle().getType(GenericEvent.class.getCanonicalName()))
              .writeDoBindEventHandlers(targetType, writer, context.getTypeOracle());
      writer.commit(logger);
    }
    return getFullyQualifiedGeneratedClassName(eventBinderType);
  } catch (NotFoundException e) {
    logger.log(Type.ERROR, "Error generating " + typeName, e);
    throw new UnableToCompleteException();
  }
}
 
Example #8
Source File: AppcacheLinker.java    From gwt-appcache with Apache License 2.0 6 votes vote down vote up
@Nonnull
final EmittedArtifact createPermutationMap( @Nonnull final TreeLogger logger,
                                            @Nonnull final Collection<PermutationArtifact> artifacts )
  throws UnableToCompleteException
{
  try
  {
    final String string = PermutationsIO.serialize( collectPermutationSelectors( logger, artifacts ) );
    return emitString( logger, string, PermutationsIO.PERMUTATIONS_DESCRIPTOR_FILE_NAME );
  }
  catch ( final Exception e )
  {
    logger.log( Type.ERROR, "can not build manifest map", e );
    throw new UnableToCompleteException();
  }
}
 
Example #9
Source File: BeanJsonDeserializerCreator.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
private Optional<MethodSpec> buildInitAnySetterDeserializerMethod( PropertyInfo anySetterPropertyInfo )
        throws UnableToCompleteException {

    FieldAccessor fieldAccessor = anySetterPropertyInfo.getSetterAccessor().get();
    JType type = fieldAccessor.getMethod().get().getParameterTypes()[1];

    JDeserializerType deserializerType;
    try {
        deserializerType = getJsonDeserializerFromType( type );
    } catch ( UnsupportedTypeException e ) {
        logger.log( Type.WARN, "Method '" + fieldAccessor.getMethod().get()
                .getName() + "' annotated with @JsonAnySetter has an unsupported type" );
        return Optional.absent();
    }

    return Optional.of( MethodSpec.methodBuilder( "initAnySetterDeserializer" )
            .addModifiers( Modifier.PROTECTED )
            .addAnnotation( Override.class )
            .returns( ParameterizedTypeName.get(
                    ClassName.get( AnySetterDeserializer.class ), typeName( beanInfo.getType() ), DEFAULT_WILDCARD ) )
            .addStatement( "return $L", buildDeserializer( anySetterPropertyInfo, type, deserializerType ) )
            .build() );
}
 
Example #10
Source File: GssGenerationVisitor.java    From gss.gwt with Apache License 2.0 6 votes vote down vote up
@Override
public boolean visit(CssExternalSelectors x, Context ctx) {
  if (inMedia) {
    if (lenient) {
      treeLogger.log(Type.WARN, "An external at-rule is not allowed inside a @media at-rule. " +
          "The following external at-rule [" + x + "] will be moved in the upper scope");
      wrongExternalNodes.add(x);
    } else {
      treeLogger.log(Type.ERROR, "An external at-rule is not allowed inside a @media at-rule. ");
    }
  } else {
    printExternal(x);
  }

  return false;
}
 
Example #11
Source File: ObjectMapperCreator.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
/**
 * Build the new serializer method.
 *
 * @param mappedTypeClass the type to map
 *
 * @return the method
 */
private MethodSpec buildNewSerializerMethod( JClassType mappedTypeClass ) throws UnableToCompleteException {
    JSerializerType type;
    try {
        type = getJsonSerializerFromType( mappedTypeClass );
    } catch ( UnsupportedTypeException e ) {
        logger.log( Type.ERROR, "Cannot generate mapper due to previous errors : " + e.getMessage() );
        throw new UnableToCompleteException();
    }

    return MethodSpec.methodBuilder( "newSerializer" )
            .addModifiers( Modifier.PROTECTED )
            .addAnnotation( Override.class )
            .returns( ParameterizedTypeName.get( ClassName.get( JsonSerializer.class ), DEFAULT_WILDCARD ) )
            .addStatement( "return $L", type.getInstance() )
            .build();
}
 
Example #12
Source File: DefCollectorVisitor.java    From gss.gwt with Apache License 2.0 6 votes vote down vote up
private boolean handleDefNode(CssDef def) {
  constantNodes.add(def);

  if (!defMapping.containsKey(def.getKey())) {

    String upperCaseName = toUpperCase(def.getKey());

    if (defMapping.containsValue(upperCaseName)) {
      if (lenient) {
        treeLogger.log(Type.WARN, "Two constants have the same name [" + upperCaseName + "] " +
            "after conversion. The second constant will be renamed automatically.");
        upperCaseName = renameConstant(upperCaseName);
      } else {
        throw new Css2GssConversionException(
            "Two constants have the same name [" + upperCaseName +
                "] after conversion.");
      }

    }

    defMapping.forcePut(def.getKey(), upperCaseName);
  }
  return false;
}
 
Example #13
Source File: ObjectMapperCreator.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
/**
 * Extract the type to map from the interface.
 *
 * @param interfaceClass the interface
 *
 * @return the extracted type to map
 * @throws UnableToCompleteException if we don't find the type
 */
private JClassType extractMappedType( JClassType interfaceClass ) throws UnableToCompleteException {
    JClassType intf = interfaceClass.isInterface();
    if ( intf == null ) {
        logger.log( TreeLogger.Type.ERROR, "Expected " + interfaceClass + " to be an interface." );
        throw new UnableToCompleteException();
    }

    JClassType[] intfs = intf.getImplementedInterfaces();
    for ( JClassType t : intfs ) {
        if ( t.getQualifiedSourceName().equals( OBJECT_MAPPER_CLASS ) ) {
            return extractParameterizedType( OBJECT_MAPPER_CLASS, t.isParameterized() );
        } else if ( t.getQualifiedSourceName().equals( OBJECT_READER_CLASS ) ) {
            return extractParameterizedType( OBJECT_READER_CLASS, t.isParameterized() );
        } else if ( t.getQualifiedSourceName().equals( OBJECT_WRITER_CLASS ) ) {
            return extractParameterizedType( OBJECT_WRITER_CLASS, t.isParameterized() );
        }
    }
    logger.log( TreeLogger.Type.ERROR, "Expected  " + interfaceClass + " to extend one of the following interface : " +
            OBJECT_MAPPER_CLASS + ", " + OBJECT_READER_CLASS + " or " + OBJECT_WRITER_CLASS );
    throw new UnableToCompleteException();
}
 
Example #14
Source File: DefCollectorVisitor.java    From gss.gwt with Apache License 2.0 6 votes vote down vote up
private String toUpperCase(String camelCase) {
  if (Strings.isNullOrEmpty(camelCase) || isUpperCase(camelCase)) {
    return camelCase;
  }

  StringBuilder output = new StringBuilder().append(Character.toUpperCase(camelCase.charAt(0)));

  for (int i = 1; i < camelCase.length(); i++) {
    char c = camelCase.charAt(i);
    if (Character.isUpperCase(c)) {
      output.append('_').append(c);
    }  else {
      output.append(Character.toUpperCase(c));
    }
  }

  String validName = INVALID_CHAR.matcher(output).replaceAll("_");

  if (validName.length() > output.length()) {
    treeLogger.log(Type.WARN, "Invalid characters detected in [" + camelCase + "]. They have " +
        "been replaced [" + validName + "]");
  }

  return validName;
}
 
Example #15
Source File: ModelLabelProvider.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private Image getBrowserTabImage(BrowserTab browserTab) {
  String imageId = DevModeImages.WEB_BROWSER;
  if (browserTab.isTerminated()) {
    imageId = DevModeImages.WEB_BROWSER_TERMINATED;
  } else {
    String attentionLevel = browserTab.getNeedsAttentionLevel();
    if (attentionLevel != null) {
      Type logLevel = LogEntry.toTreeLoggerType(attentionLevel);
      if (logLevel == Type.ERROR) {
        imageId = DevModeImages.WEB_BROWSER_ERROR;
      } else if (logLevel == Type.WARN) {
        imageId = DevModeImages.WEB_BROWSER_WARNING;
      }
    }
  }

  return Activator.getDefault().getImage(imageId);
}
 
Example #16
Source File: ModelLabelProvider.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private Image getLaunchConfigurationImage(LaunchConfiguration launchConfiguration) {
  String launchConfigType = launchConfiguration.getLaunchTypeId();
  String imageId = DevModeImages.GDT_ICON;

  if (launchConfiguration.isTerminated()) {
    imageId = DevModeImages.GDT_ICON_TERMINATED;
  } else {
    String attentionLevel = launchConfiguration.getNeedsAttentionLevel();
    if (attentionLevel != null) {
      Type logLevel = LogEntry.toTreeLoggerType(attentionLevel);
      if (logLevel == Type.ERROR) {
        imageId = DevModeImages.GDT_ICON_ERROR;
      } else if (logLevel == Type.WARN) {
        imageId = DevModeImages.GDT_ICON_WARNING;
      }
    }
  }

  return Activator.getDefault().getImage(imageId);
}
 
Example #17
Source File: PropertyProcessor.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
private static JType findType( TreeLogger logger, PropertyAccessors fieldAccessors, JacksonTypeOracle typeOracle,
		boolean getterAutoDetected, boolean setterAutoDetected, boolean fieldAutoDetected ) throws UnableToCompleteException {
    JType type;
    if ( getterAutoDetected && fieldAccessors.getGetter().isPresent() ) {
        type = fieldAccessors.getGetter().get().getReturnType();
    } else if ( setterAutoDetected && fieldAccessors.getSetter().isPresent() ) {
        type = fieldAccessors.getSetter().get().getParameters()[0].getType();
    } else if ( fieldAutoDetected && fieldAccessors.getField().isPresent() ) {
        type = fieldAccessors.getField().get().getType();
    } else if ( fieldAccessors.getParameter().isPresent() ) {
        type = fieldAccessors.getParameter().get().getType();
    } else {
        logger.log( Type.ERROR, "Cannot find the type of the property " + fieldAccessors.getPropertyName() );
        throw new UnableToCompleteException();
    }

    Optional<Annotation> jd = fieldAccessors.getAnnotation( "com.fasterxml.jackson.databind.annotation.JsonDeserialize" );
    if ( jd.isPresent() ) {
        return typeOracle.replaceType( logger, type, jd.get() );
    }

    return type;
}
 
Example #18
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 6 votes vote down vote up
private boolean ensureEitherCssOrGss(List<URL> resources, TreeLogger logger)
    throws UnableToCompleteException {
  boolean css = resources.get(0).toString().endsWith(".css");
  for (URL stylesheet : resources) {
    if (css && !stylesheet.toString().endsWith(".css")) {
      logger.log(Type.ERROR,
          "Only either css files or gss files are supported on one interface");
      throw new UnableToCompleteException();
    } else if (!css && !stylesheet.toString().endsWith(".gss")) {
      logger.log(Type.ERROR,
          "Only either css files or gss files are supported on one interface");
      throw new UnableToCompleteException();
    }
  }
  return css;
}
 
Example #19
Source File: PropertyParser.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
private static void parseFields( TreeLogger logger, JClassType type, Map<String, PropertyAccessorsBuilder> propertiesMap,
                                 boolean mixin ) {
    if ( type.getQualifiedSourceName().equals( "java.lang.Object" ) ) {
        return;
    }

    for ( JField field : type.getFields() ) {
        if ( field.isStatic() ) {
            continue;
        }

        String fieldName = field.getName();
        PropertyAccessorsBuilder property = propertiesMap.get( fieldName );
        if ( null == property ) {
            property = new PropertyAccessorsBuilder( fieldName );
            propertiesMap.put( fieldName, property );
        }
        if ( property.getField().isPresent() && !mixin ) {
            // we found an other field with the same name on a superclass. we ignore it
            logger.log( Type.INFO, "A field with the same name as '" + field
                    .getName() + "' has already been found on child class" );
        } else {
            property.addField( field, mixin );
        }
    }
}
 
Example #20
Source File: BeanJsonSerializerCreator.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
private JSerializerType getJsonSerializerFromProperty( PropertyInfo propertyInfo ) throws UnableToCompleteException {
    if ( null != propertyInfo && propertyInfo.getGetterAccessor().isPresent() && !propertyInfo.isIgnored() ) {
        if ( propertyInfo.isRawValue() ) {
            return new JSerializerType.Builder().type( propertyInfo.getType() ).instance( CodeBlock.builder()
                    .add( "$T.<$T>getInstance()", RawValueJsonSerializer.class, typeName( propertyInfo.getType() ) ).build() )
                    .build();
        } else {
            try {
                return getJsonSerializerFromType( propertyInfo.getType() );
            } catch ( UnsupportedTypeException e ) {
                logger.log( Type.WARN, "Property '" + propertyInfo.getPropertyName() + "' is ignored." );
            }
        }
    }
    return null;
}
 
Example #21
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 6 votes vote down vote up
private void validateExternalClasses(Set<String> externalClasses,
    Set<String> externalClassCandidates, JMethod method,
    TreeLogger logger) throws UnableToCompleteException {
  if (!isStrictResource(method)) {
    return;
  }

  boolean hasError = false;

  for (String candidate : externalClassCandidates) {
    if (!externalClasses.contains(candidate)) {
      logger.log(Type.ERROR, "The following non-obfuscated class is present in a strict " +
          "CssResource: " + candidate);
      hasError = true;
    }
  }

  if (hasError) {
    throw new UnableToCompleteException();
  }
}
 
Example #22
Source File: AbstractBeanJsonCreator.java    From gwt-jackson with Apache License 2.0 6 votes vote down vote up
/**
 * Add the common property parameters to the code builder.
 *
 * @param paramBuilder the code builder
 * @param property the information about the property
 */
protected final void buildCommonPropertyParameters( CodeBlock.Builder paramBuilder, PropertyInfo property ) {
    if ( property.getFormat().isPresent() ) {
        JsonFormat format = property.getFormat().get();

        if ( !Strings.isNullOrEmpty( format.pattern() ) ) {
            paramBuilder.add( "\n.setPattern($S)", format.pattern() );
        }

        paramBuilder.add( "\n.setShape($T.$L)", Shape.class, format.shape().name() );

        if ( !Strings.isNullOrEmpty( format.locale() ) && !JsonFormat.DEFAULT_LOCALE.equals( format.locale() ) ) {
            logger.log( Type.WARN, "JsonFormat.locale is not supported by default" );
            paramBuilder.add( "\n.setLocale($S)", format.locale() );
        }
    }

    if ( property.getIgnoredProperties().isPresent() ) {
        for ( String ignoredProperty : property.getIgnoredProperties().get() ) {
            paramBuilder.add( "\n.addIgnoredProperty($S)", ignoredProperty );
        }
    }
}
 
Example #23
Source File: GssGenerationVisitor.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
private boolean validateExternalClass(String selector) {
  if (selector.contains(":")) {
    if (lenient) {
      treeLogger.log(Type.WARN, "This invalid external selector will be skipped: " + selector);
      return false;
    } else {
      throw new Css2GssConversionException(
          "One of your external statements contains a pseudo class: " + selector);
    }
  }
  return true;
}
 
Example #24
Source File: AppcacheLinker.java    From gwt-appcache with Apache License 2.0 5 votes vote down vote up
@Nonnull
final List<SelectionDescriptor> collectPermutationSelectors( @Nonnull final TreeLogger logger,
                                                             @Nonnull final Collection<PermutationArtifact> artifacts )
{
  final List<SelectionDescriptor> descriptors = new ArrayList<>();
  for ( final PermutationArtifact artifact : artifacts )
  {
    final Permutation permutation = artifact.getPermutation();
    final List<BindingProperty> calculatedBindings = new ArrayList<>();
    final HashSet<String> completed = new HashSet<>();

    final List<SelectionDescriptor> selectors = permutation.getSelectors();
    final SelectionDescriptor firstSelector = selectors.iterator().next();
    for ( final BindingProperty p : firstSelector.getBindingProperties() )
    {
      final String key = p.getName();
      if ( !completed.contains( key ) )
      {
        final HashSet<String> values = collectValuesForKey( selectors, key );
        if ( 1 == selectors.size() || values.size() > 1 )
        {
          calculatedBindings.add( new BindingProperty( key, joinValues( values ) ) );
        }
        completed.add( key );
      }
    }
    calculatedBindings.sort( ( o1, o2 ) -> o2.getComponents().length - o1.getComponents().length );
    descriptors.add( new SelectionDescriptor( permutation.getPermutationName(), calculatedBindings ) );
  }
  logger.log( Type.DEBUG, "Permutation map created with " + descriptors.size() + " descriptors." );
  return descriptors;
}
 
Example #25
Source File: GssGenerationVisitor.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
@Override
public boolean visit(CssProperty x, Context ctx) {
  maybePrintOpenBrace();

  StringBuilder propertyBuilder = new StringBuilder();

  if (noFlip) {
    propertyBuilder.append(NO_FLIP);
    propertyBuilder.append(' ');
  }

  propertyBuilder.append(x.getName());
  propertyBuilder.append(": ");

  propertyBuilder.append(printValuesList(x.getValues().getValues()));

  if (x.isImportant()) {
    propertyBuilder.append(IMPORTANT);
  }

  String cssProperty = propertyBuilder.toString();

  if (lenient) {
    // lenient mode: Try to parse the css rule and if an error occurs,
    // print a warning message and don't print the rule.
    try {
      new GssParser(new SourceCode(null, "body{" + cssProperty + "}")).parse();
    } catch (GssParserException e) {
      treeLogger.log(Type.WARN, "The following property is not valid and will be skipped: " +
          cssProperty);
      return false;
    }
  }

  out.print(cssProperty);

  semiColon();

  return true;
}
 
Example #26
Source File: AppcacheLinker.java    From gwt-appcache with Apache License 2.0 5 votes vote down vote up
/**
 * Write a manifest file for the given set of artifacts and return it as a
 * string
 *
 * @param staticResources   - the static resources of the app, such as
 *                          index.html file
 * @param fallbackResources the fall back files to add to the manifest.
 * @param cacheResources    the gwt output artifacts like cache.html files
 * @return the manifest as a string
 */
@Nonnull
final String writeManifest( @Nonnull final TreeLogger logger,
                            @Nonnull final Set<String> staticResources,
                            @Nonnull final Map<String, String> fallbackResources,
                            @Nonnull final Set<String> cacheResources )
  throws UnableToCompleteException
{
  final ManifestDescriptor descriptor = new ManifestDescriptor();
  final List<String> cachedResources =
    Stream
      .concat( staticResources.stream(), cacheResources.stream() )
      .sorted()
      .distinct()
      .collect( Collectors.toList() );
  descriptor.getCachedResources().addAll( cachedResources );
  descriptor.getFallbackResources().putAll( fallbackResources );
  descriptor.getNetworkResources().add( "*" );
  try
  {
    return descriptor.toString();
  }
  catch ( final Exception e )
  {
    logger.log( Type.ERROR, "Error generating manifest: " + e, e );
    throw new UnableToCompleteException();
  }
}
 
Example #27
Source File: GssGenerationVisitor.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
private boolean validateDefNode(CssDef def, String atRule) {
  if (inMedia) {
    if (lenient) {
      treeLogger.log(Type.WARN, "A " + atRule + " is not allowed inside a @media at-rule." +
          "The following " + atRule + " [" + def + "] will be moved in the upper scope");
      wrongDefNodes.add(def);
      return false;
    } else {
      treeLogger.log(Type.ERROR, "A " + atRule + " is not allowed inside a @media at-rule.");
    }
  }
  return true;
}
 
Example #28
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
private boolean writeClassMethod(TreeLogger logger, JMethod userMethod,
    Map<String, String> substitutionMap, SourceWriter sw) throws
    UnableToCompleteException {

  if (!isReturnTypeString(userMethod.getReturnType().isClass())) {
    logger.log(Type.ERROR, "The return type of the method [" + userMethod.getName() + "] must " +
        "be java.lang.String.");
    throw new UnableToCompleteException();
  }

  if (userMethod.getParameters().length > 0) {
    logger.log(Type.ERROR, "The method [" + userMethod.getName() + "] shouldn't contain any " +
        "parameters");
    throw new UnableToCompleteException();
  }

  String name = getClassName(userMethod);

  String value = substitutionMap.get(name);

  if (value == null) {
    logger.log(Type.ERROR, "The following style class [" + name + "] is missing from the source" +
        " CSS file");
    return false;
  } else {
    writeSimpleGetter(userMethod, "\"" + value + "\"", sw);
  }

  return true;
}
 
Example #29
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
@Override
public void report(GssError error) {
  String fileName = "";
  String location = "";
  SourceCodeLocation codeLocation = error.getLocation();

  if (codeLocation != null) {
    fileName = codeLocation.getSourceCode().getFileName();
    location = "[line:" + codeLocation.getBeginLineNumber() + " column:" + codeLocation
        .getBeginIndexInLine() + "]";
  }

  logger.log(Type.ERROR, "Error in " + fileName + location + ": " + error.getMessage());
  hasErrors = true;
}
 
Example #30
Source File: LabelProviderUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static ColumnLabelInfo getColumnLabelInfoFor(String treeLoggerLevelName) {
  Type logLevel = LogEntry.toTreeLoggerType(treeLoggerLevelName);
  if (logLevel != null) {
    return typeToColumnLabelInfos.get(logLevel);
  }
  return null;
}