/*
(non-Javadoc)

@see
edu.umd.cs.findbugs.classfile.IAnalysisEngine#analyze(edu.umd.cs.findbugs
.classfile.IAnalysisCache, java.lang.Object)
435338
@Override
    public JavaClass analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
        try {
            ClassData classData = analysisCache.getClassAnalysis(ClassData.class, descriptor);
            JavaClass javaClass = new ClassParser(classData.getInputStream(), descriptor.toResourceName()).parse();

            // Make sure that the JavaClass object knows the repository
            // it was loaded from.
            javaClass.setRepository(Repository.getRepository());

            if (DEBUG_MISSING_CLASSES && !(javaClass.getRepository() instanceof AnalysisCacheToRepositoryAdapter)) {
                throw new IllegalStateException("this should not happen");
            }

            return javaClass;
        } catch (RuntimeException e) {
            throw new RuntimeException("Unable to parse classfile for " + descriptor, e);
        } catch (IOException e) {
            throw new ResourceNotFoundException(descriptor.toResourceName(), e);
        }
    }
576011
function analyze(filename, analyzeCallback) {

    var stack = [];
    var input = fs.createReadStream(filename);
    var fileext = path.extname(filename);
    var lineN = 0;
    var objects = [];
    var lines = []

    // CHECK EXTLANG [

    function _configGetExtLang(filext) {
      var fileext1 = filext.indexOf('.') == 0 ? fileext.substring(1, filext.length) : fileext;
      if (!config.extlangs.hasOwnProperty(fileext1))
        return null;

      return config.extlangs[fileext1];
    };

    var extlang = _configGetExtLang(fileext);
    if (!extlang) {
      analyzeCallback()
      return;
    }

    // CHECK EXTLANG ]
    // READ LINES/LINE [

    readLines(input, function readLine(line, complete) {
  //    console.log(line);
      lines.push(line);
      lineN += 1;

      // checkCommentLine [

      function checkCommentLine(stack, fileext, line, lineN, cbs) {

        // custom comment format use config.extractCommentTagFromLine [

        function extractCommentTagFromLine(fileext, line) {
          line = line.trim();
          // CHECK FORMAT [
          var b;
          function chkfmt(b) {
            if (line.indexOf(b) == 0 && line.indexOf('[') == line.length-1) // begin
              return [line.substr(b.length, line.length-b.length-1).trim(), 0];
            if (line.indexOf(b) == 0 && line.indexOf(']') == line.length-1 && line.indexOf('[') == -1) // end
              return [line.substr(b.length, line.length-b.length-1).trim(), 1];
            return null;
          };
          // CHECK FORMAT ]

          // SUPPORT FORMATS [
          switch (fileext) {
            case '.js':
            case '.java':
            case '.c':
            case '.h':
            case '.cpp':
            case '.hpp':
            case '.less':
            case '.m':
            case '.mm':
              return chkfmt('//') || false;
            case '.css':
              return chkfmt('/*') || false;
            case '.acpul':
            case '.sh':
            case '.py':
            case '.pro':
              return chkfmt('#') || false;
            case '.ejs':
            case '.jade':
            case '.sass':
            case '.styl':
            case '.coffee':
              break;
            default:
              return null;
          }
          // SUPPORT FORMATS ]
          return false;
        }

        var tag = (config.extractCommentTagFromLine && config.extractCommentTagFromLine(fileext, line)) || extractCommentTagFromLine(fileext, line);
        if (tag === null)
          return false;

        // custom comment format use config.extractCommentTagFromLine ]

        if (tag) {
          // PROCESSING TAG [
          if (tag[1] == 0) {
            // ON BEGIN [
            var c = {name:tag[0], lines:[lineN, -1], parents:[]};
            stack.push(c);
            cbs.begin(stack, c);
            // ON BEGIN ]
          } else if (tag[1] == 1) {
            // ON END [
            if (stack.length > 0) {
              var ok = false;
              // dirty hack! [
              if (stack.slice(-1)[0].name == tag[0])
                ok = true;
              else if (stack.length > 1 && stack.slice(-2)[0].name == tag[0]) {
                var a = stack.slice(-2);
                var c = stack.pop();
                ok = true;
              } else
                cbs.error('Found close tag without match start tag'+tag[0]);
              // dirty hack! ]
              if (ok) {
                var c = stack.pop();
                c.lines[1] = lineN;
                //_.each(stack, function(p) {c.parents.push(p.name);});
                c.parents  = stack.slice(0);
                cbs.end(stack, c);
              }
            } else {
              cbs.error('Found close tag without any start tag '+tag[0]);
            }
            // ON END ]
          }
  //        console.log(filename);
  //        console.log(tag);
          // PROCESSING TAG ]
        }

        return true;
      };

      // checkCommentLine ]
      // complete [

      if (complete)
      {
        mergeChanges(filename, extlang, lines, objects);
        analyzeCallback()
        return true;
      }

      // complete ]
      // check line [

      var res = checkCommentLine(stack, fileext, line, lineN, {
        begin: function(stack, c) {
        },
        end: function(stack, c) {
  //        udb.add(c);
          if (isLogging('object.parsed'))
            console.log(c);
          objects.push(c);
        },
        error: function(msg) {
          console.log('ERROR:', msg);
        }
      });

      // check line ]

      return res;
    });
    // READ LINES/LINE ]

  }
870685
@Override
    public void prepareFileTypeAnalyzer(Engine engine) throws InitializationException {
        LOGGER.debug("Initializing Nexus Analyzer");
        LOGGER.debug("Nexus Analyzer enabled: {}", isEnabled());
        if (isEnabled()) {
            final boolean useProxy = useProxy();
            LOGGER.debug("Using proxy: {}", useProxy);
            try {
                searcher = new NexusSearch(getSettings(), useProxy);
                if (!searcher.preflightRequest()) {
                    setEnabled(false);
                    throw new InitializationException("There was an issue getting Nexus status. Disabling analyzer.");
                }
            } catch (MalformedURLException mue) {
                setEnabled(false);
                throw new InitializationException("Malformed URL to Nexus", mue);
            }
        }
    }
499309
protected void analyzeElVars(final T descriptor, final DescriptorContext context) {
        descriptor.el = ElAnalyzer.analyzeQuery(context.generics, descriptor.command);
    }
1350156
public Analysis     analyze() throws Exception
    {
        AtomicReference<String>     error = new AtomicReference<String>(null);
        Map<String, PathComplete>   loadedPaths = loadedPaths(paths, error);
        if ( error.get() != null )
        {
            return new Analysis(error.get(), Lists.<PathComplete>newArrayList(), Lists.<Set<String>>newArrayList());
        }

        List<Node>        resourceAllocationGraph = buildResourceAllocationGraph(loadedPaths);
        List<Set<String>> possibleCycles = checkForCycles(resourceAllocationGraph, loadedPaths);

        return new Analysis(null, loadedPaths.values(), possibleCycles);
    }
376760
@Override
    protected void prepareFileTypeAnalyzer(Engine engine) throws InitializationException {
        try {
            final File baseDir = getSettings().getTempDirectory();
            tempFileLocation = File.createTempFile("check", "tmp", baseDir);
            if (!tempFileLocation.delete()) {
                setEnabled(false);
                final String msg = String.format(
                        "Unable to delete temporary file '%s'.",
                        tempFileLocation.getAbsolutePath());
                throw new InitializationException(msg);
            }
            if (!tempFileLocation.mkdirs()) {
                setEnabled(false);
                final String msg = String.format(
                        "Unable to create directory '%s'.",
                        tempFileLocation.getAbsolutePath());
                throw new InitializationException(msg);
            }
        } catch (IOException ex) {
            setEnabled(false);
            throw new InitializationException("Unable to create a temporary file", ex);
        }
    }
169485
@Override
    public void registerAnalysisEngines(IAnalysisCache analysisCache) {
        for (IClassAnalysisEngine<?> engine : classAnalysisEngineList) {
            engine.registerWith(analysisCache);
        }
        for (IMethodAnalysisEngine<?> engine : methodAnalysisEngineList) {
            engine.registerWith(analysisCache);
        }
    }
1055717
public void analyze() {
    for (String key : importSource.getKeys()) {
      Change change = createChange(key);
      setConflictAttributes(change);

      if (change.getType() != Change.TYPE_NO_CHANGE) {
        if (change.isConflicting()) {
          conflictingChanges.add(change);
        } else {
          nonConflictingChanges.add(change);
        }
      }
    }
  }
660916
@Override
    public ClassInfo analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {

        if (descriptor instanceof ClassInfo) {
            return (ClassInfo) descriptor;
        }
        ClassData classData;
        try {
            classData = analysisCache.getClassAnalysis(ClassData.class, descriptor);
        } catch (edu.umd.cs.findbugs.classfile.MissingClassException e) {
            if (!"package-info".equals(descriptor.getSimpleName())) {
                throw e;
            }

            ClassInfo.Builder builder = new ClassInfo.Builder();
            builder.setClassDescriptor(descriptor);
            builder.setAccessFlags(1536);
            return builder.build();
        }

        // Read the class info

        FBClassReader reader = analysisCache.getClassAnalysis(FBClassReader.class, descriptor);
        ClassParserInterface parser = new ClassParserUsingASM(reader, descriptor, classData.getCodeBaseEntry());

        ClassInfo.Builder classInfoBuilder = new ClassInfo.Builder();
        parser.parse(classInfoBuilder);
        ClassInfo classInfo = classInfoBuilder.build();

        if (!classInfo.getClassDescriptor().equals(descriptor)) {
            throw new ClassNameMismatchException(descriptor, classInfo.getClassDescriptor(), classData.getCodeBaseEntry());
        }
        return classInfo;
    }
768807
void analyze() throws ToolException {
        // compute the specified element, by expanding module dependencies
        computeSpecifiedModules();

        // compute all specified packages and subpackages
        computeSpecifiedPackages();

        // compute the specified types
        computeSpecifiedTypes();

        // compute the packages belonging to all the specified modules
        Set<PackageElement> expandedModulePackages = computeModulePackages();
        initializeIncludedSets(expandedModulePackages);
    }
273778
public <L extends JqlBaseListener> void analyze(final JQLContext jqlContext, final JQL jql, L listener) {
		analyzeInternal(jqlContext, jql.value, listener);
	}
282982
def analyze(self, handle, filename):
        
        # ensure the handle is at offset 0.
        handle.seek(0)

        try:
            return self.jbx.submit_sample(handle)['webids'][0]
        except (jbxapi.JoeException, KeyError, IndexError) as e:
            raise sandboxapi.SandboxError("error in analyze: {e}".format(e=e))
1219455
@Override
    protected final void prepareAnalyzer(Engine engine) throws InitializationException {
        if (filesMatched) {
            prepareFileTypeAnalyzer(engine);
        } else {
            this.setEnabled(false);
        }
    }
1364879
private void analyze(Analyzer analyzer,
                       boolean allowFlow,
                       IntArray pendingTargets,
                       IntArray completedTargets)
    throws Exception
  {
    pending:
    while (pendingTargets.size() > 0) {
      int pc = pendingTargets.pop();

      if (allowFlow) {
        if (completedTargets.contains(pc))
          continue pending;

        completedTargets.add(pc);
      }

      setOffset(pc);

      flow:
      do {
        pc = getOffset();

        if (pc < 0)
          throw new IllegalStateException();
    
        if (! allowFlow) {
          if (completedTargets.contains(pc))
            break flow;

          completedTargets.add(pc);
        }

        if (isBranch()) {
          int targetPC = getBranchTarget();

          if (! pendingTargets.contains(targetPC))
            pendingTargets.add(targetPC);
        }
        else if (isSwitch()) {
          int []switchTargets = getSwitchTargets();

          for (int i = 0; i < switchTargets.length; i++) {
            if (! pendingTargets.contains(switchTargets[i]))
              pendingTargets.add(switchTargets[i]);
          }
        }

        analyzer.analyze(this);
      } while (next());
    }
  }
94376
private Map<String, SpringResource> analyzeController(Class<?> controllerClazz, Map<String, SpringResource> resourceMap, String description) {
	String[] controllerRequestMappingValues = SpringUtils.getControllerResquestMapping(controllerClazz);

        // Iterate over all value attributes of the class-level RequestMapping annotation
        for (String controllerRequestMappingValue : controllerRequestMappingValues) {
            for (Method method : controllerClazz.getMethods()) {
                // Skip methods introduced by compiler
                if (method.isSynthetic()) {
                    continue;
                }
                RequestMapping methodRequestMapping = findMergedAnnotation(method, RequestMapping.class);

                // Look for method-level @RequestMapping annotation
                if (methodRequestMapping != null) {
                    RequestMethod[] requestMappingRequestMethods = methodRequestMapping.method();

                    // For each method-level @RequestMapping annotation, iterate over HTTP Verb
                    for (RequestMethod requestMappingRequestMethod : requestMappingRequestMethods) {
                        String[] methodRequestMappingValues = methodRequestMapping.value();

                        // Check for cases where method-level @RequestMapping#value is not set, and use the controllers @RequestMapping
                        if (methodRequestMappingValues.length == 0) {
                            // The map key is a concat of the following:
                            //   1. The controller package
                            //   2. The controller class name
                            //   3. The controller-level @RequestMapping#value
                            String resourceKey = controllerClazz.getCanonicalName() + controllerRequestMappingValue + requestMappingRequestMethod;
                            if (!resourceMap.containsKey(resourceKey)) {
                                resourceMap.put(
                                        resourceKey,
                                        new SpringResource(controllerClazz, controllerRequestMappingValue, resourceKey, description));
                            }
                            resourceMap.get(resourceKey).addMethod(method);
                        } else {
                            // Here we know that method-level @RequestMapping#value is populated, so
                            // iterate over all the @RequestMapping#value attributes, and add them to the resource map.
                            for (String methodRequestMappingValue : methodRequestMappingValues) {
                                String resourceKey = controllerClazz.getCanonicalName() + controllerRequestMappingValue
                                        + methodRequestMappingValue + requestMappingRequestMethod;
                                if (!methodRequestMappingValue.isEmpty()) {
                                    if (!resourceMap.containsKey(resourceKey)) {
                                        resourceMap.put(resourceKey, new SpringResource(controllerClazz, methodRequestMappingValue, resourceKey, description));
                                    }
                                    resourceMap.get(resourceKey).addMethod(method);
                                }
                            }
                        }
                    }
                }
            }
        }
        controllerClazz.getFields();
        controllerClazz.getDeclaredFields(); //<--In case developer declares a field without an associated getter/setter.
        //this will allow NoClassDefFoundError to be caught before it triggers bamboo failure.

        return resourceMap;
    }
1258950
protected <L extends JqlBaseListener> void analyzeInternal(JQLContext jqlContext, final String jql, L listener) {
		walker.walk(listener, prepareParser(jqlContext, jql).value0);
	}
1214484
@Override
    public DepthFirstSearch analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        CFG cfg = getCFG(analysisCache, descriptor);
        DepthFirstSearch dfs = new DepthFirstSearch(cfg);
        dfs.search();
        return dfs;
    }