Search in sources :

Example 46 with Nullable

use of javax.annotation.Nullable in project buck by facebook.

the class SignatureFactory method getSignature.

/**
   * Returns the type signature of the given element. If none is required by the VM spec, returns
   * null.
   */
@Nullable
public String getSignature(Element element) {
    SignatureWriter writer = new SignatureWriter();
    element.accept(elementVisitorAdapter, writer);
    String result = writer.toString();
    return result.isEmpty() ? null : result;
}
Also used : SignatureWriter(org.objectweb.asm.signature.SignatureWriter) Nullable(javax.annotation.Nullable)

Example 47 with Nullable

use of javax.annotation.Nullable in project buck by facebook.

the class ProcessHelper method getProcessResourceConsumption.

/**
   * Gets resource consumption of the process with the given pid.
   */
@Nullable
public ProcessResourceConsumption getProcessResourceConsumption(long pid) {
    try {
        OperatingSystem os = OSHI.getOperatingSystem();
        OSProcess process = os.getProcess((int) pid);
        return getProcessResourceConsumptionInternal(process);
    } catch (Exception ex) {
        // do nothing
        return null;
    }
}
Also used : OperatingSystem(oshi.software.os.OperatingSystem) OSProcess(oshi.software.os.OSProcess) Nullable(javax.annotation.Nullable)

Example 48 with Nullable

use of javax.annotation.Nullable in project buck by facebook.

the class ProcessHelper method unixLikeProcessId.

@Nullable
private Long unixLikeProcessId(Object process) {
    Class<?> clazz = process.getClass();
    try {
        if (clazz.getName().equals("java.lang.UNIXProcess")) {
            Field field = clazz.getDeclaredField("pid");
            field.setAccessible(true);
            return (long) field.getInt(process);
        }
    } catch (Exception e) {
        LOG.warn(e, "Cannot get process id!");
    }
    return null;
}
Also used : Field(java.lang.reflect.Field) Nullable(javax.annotation.Nullable)

Example 49 with Nullable

use of javax.annotation.Nullable in project buck by facebook.

the class Types method getContainerClass.

/**
   * @return The raw type of the {@link Collection} a field represents, even if contained in an
   *    {@link Optional}, but without the ParameterizedType information.
   */
@SuppressWarnings("unchecked")
@Nullable
public static Class<? extends Collection<?>> getContainerClass(Field field) {
    Type type = getFirstNonOptionalType(field);
    if (!(type instanceof ParameterizedType)) {
        return null;
    }
    Type rawType = ((ParameterizedType) type).getRawType();
    if (!(rawType instanceof Class)) {
        return null;
    }
    Class<?> clazz = (Class<?>) rawType;
    if (!(Collection.class.isAssignableFrom(clazz))) {
        return null;
    }
    return (Class<? extends Collection<?>>) clazz;
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) WildcardType(java.lang.reflect.WildcardType) Collection(java.util.Collection) Nullable(javax.annotation.Nullable)

Example 50 with Nullable

use of javax.annotation.Nullable in project buck by facebook.

the class FakeInputBasedRuleKeyFactory method newInstance.

private RuleKeyBuilder<RuleKey> newInstance(final BuildRule buildRule) {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
    SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
    return new RuleKeyBuilder<RuleKey>(ruleFinder, resolver, fileHashCache) {

        @Override
        protected RuleKeyBuilder<RuleKey> setBuildRule(BuildRule rule) {
            return this;
        }

        @Override
        protected RuleKeyBuilder<RuleKey> setReflectively(@Nullable Object val) {
            return this;
        }

        @Override
        public RuleKeyBuilder<RuleKey> setAppendableRuleKey(RuleKeyAppendable appendable) {
            return this;
        }

        @Override
        protected RuleKeyBuilder<RuleKey> setSourcePath(SourcePath sourcePath) {
            return this;
        }

        @Override
        protected RuleKeyBuilder<RuleKey> setNonHashingSourcePath(SourcePath sourcePath) {
            return setNonHashingSourcePathDirectly(sourcePath);
        }

        @Override
        public RuleKey build() {
            if (oversized.contains(buildRule.getBuildTarget())) {
                throw new SizeLimiter.SizeLimitException();
            }
            return ruleKeys.get(buildRule.getBuildTarget());
        }
    };
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) RuleKey(com.facebook.buck.rules.RuleKey) BuildRule(com.facebook.buck.rules.BuildRule) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Nullable(javax.annotation.Nullable) RuleKeyAppendable(com.facebook.buck.rules.RuleKeyAppendable)

Aggregations

Nullable (javax.annotation.Nullable)735 IOException (java.io.IOException)85 Test (org.junit.Test)59 Map (java.util.Map)58 Function (com.google.common.base.Function)57 List (java.util.List)55 ArrayList (java.util.ArrayList)43 File (java.io.File)42 HashMap (java.util.HashMap)37 ItemStack (net.minecraft.item.ItemStack)36 ImmutableList (com.google.common.collect.ImmutableList)32 SkyKey (com.google.devtools.build.skyframe.SkyKey)28 Nonnull (javax.annotation.Nonnull)28 ImmutableMap (com.google.common.collect.ImmutableMap)27 Predicate (com.google.common.base.Predicate)26 URL (java.net.URL)22 Label (com.google.devtools.build.lib.cmdline.Label)21 HashSet (java.util.HashSet)20 Collectors (java.util.stream.Collectors)15 TypeElement (javax.lang.model.element.TypeElement)15