Examples of SourceFile


Examples of com.stuffwithstuff.magpie.SourceFile

   
    Module module = mModules.get(name);
   
    // Only load it once.
    if (module == null) {
      SourceFile info = mHost.loadModule(name);
      module = new Module(name, info, this);
      mModules.put(name, module);
     
      evaluateModule(module);
    }
View Full Code Here

Examples of com.stuffwithstuff.magpie.SourceFile

        System.out.print(right);
        return null;
      }
    });
   
    String result = magpie.run(new SourceFile(path, script));
    if (result != null) {
      System.out.println(result);
    }
  }
View Full Code Here

Examples of com.stuffwithstuff.magpie.SourceFile

      String modulePath = name.replace('.', '/');

      // $CWD/foo/bar.mag
      File file = new File(modulePath + ".mag");
      if (file.exists()) {
        return new SourceFile(file.getPath(), readFile(file.getPath()));
      }
     
      // $CWD/foo/bar/_init.mag
      file = new File(modulePath + "/_init.mag");
      if (file.exists()) {
        return new SourceFile(file.getPath(), readFile(file.getPath()));
      }
     
      // $APPDIR/lib/foo/bar.mag
      File appDir = new File(getAppDirectory(), "lib");
      file = new File(appDir, modulePath + ".mag");
      if (file.exists()) {
        return new SourceFile(file.getPath(), readFile(file.getPath()));
      }
     
      // $APPDIR/lib/foo/bar/_init.mag
      file = new File(appDir, modulePath + "/_init.mag");
      if (file.exists()) {
        return new SourceFile(file.getPath(), readFile(file.getPath()));
      }

      throw new IOException("Couldn't find module " + name);
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.SourceFile

        if (LOOK_IN_SOURCE_FOR_FALLTHRU_COMMENT) {
            BufferedReader r = null;
            try {
                SourceLineAnnotation srcLine = SourceLineAnnotation.fromVisitedInstructionRange(this, lastPC, getPC());
                SourceFinder sourceFinder = AnalysisContext.currentAnalysisContext().getSourceFinder();
                SourceFile sourceFile = sourceFinder.findSourceFile(srcLine.getPackageName(), srcLine.getSourceFile());

                int startLine = srcLine.getStartLine();
                int numLines = srcLine.getEndLine() - startLine - 1;
                if (numLines <= 0) {
                    return false;
                }
                r = UTF8.bufferedReader(sourceFile.getInputStream());
                for (int i = 0; i < startLine; i++) {
                    String line = r.readLine();
                    if (line == null) {
                        return false;
                    }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.SourceFile

                continue;
            }
            if (!sourceFinder.hasSourceFile(s)) {
                continue;
            }
            SourceFile sourceFile = sourceFinder.findSourceFile(s);
            long when = sourceFile.getLastModified();
            if (when > 0) {
                Date firstSeen = new Date(when);
                b.getXmlProps().setFirstSeen(firstSeen);
                System.out.println("Set first seen to " + firstSeen);
            }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.SourceFile

            return;
        }

        String fullName = SourceFinder.getPlatformName(sourceAnnotation);

        SourceFile sourceFile;
        try {
            sourceFile = sourceFinder.findSourceFile(sourceAnnotation);
        } catch (IOException e) {

            if (couldNotFind.add(fullName)) {
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.SourceFile

            return false;
        }

        SourceFinder sourceFinder = AnalysisContext.currentAnalysisContext().getSourceFinder();
        try {
            SourceFile sourceFile = sourceFinder.findSourceFile(srcLine.getPackageName(), srcLine.getSourceFile());
            int startLine = srcLine.getStartLine();

            int scanStartLine = startLine - NUM_CONTEXT_LINES;
            if (scanStartLine < 1) {
                scanStartLine = 1;
            }

            int offset = sourceFile.getLineOffset(scanStartLine - 1);
            if (offset < 0)
            {
                return false; // Source file has changed?
            }
            Tokenizer tokenizer = new Tokenizer(UTF8.reader(sourceFile.getInputStreamFromOffset(offset)));

            // Read the tokens into an ArrayList,
            // keeping track of where the catch block is reported
            // to start
            ArrayList<Token> tokenList = new ArrayList<Token>(40);
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.SourceFile

    }

    @Nonnull
    private JavaSourceDocument getDocument(SourceLineAnnotation source) {
        try {
            SourceFile sourceFile = frame.getProject().getSourceFinder().findSourceFile(source);
            String fullFileName = sourceFile.getFullFileName();
            SoftReference<JavaSourceDocument> resultReference = map.get(fullFileName);
            JavaSourceDocument result = null;
            if (resultReference != null) {
                result = resultReference.get();
            }
            if (result != null) {
                return result;
            }
            try {
                InputStream in = sourceFile.getInputStream();
                result = new JavaSourceDocument(source.getClassName(), SourceCharset.bufferedReader(in), sourceFile);
            } catch (Exception e) {
                result = JavaSourceDocument.UNKNOWNSOURCE;
                Debug.println(e); // e.printStackTrace();
            }
View Full Code Here

Examples of flash.tools.debugger.SourceFile

       {
         cli.err(getLocalizationManager().getLocalizedTextString("key28")); //$NON-NLS-1$
       }
       else
       {
         SourceFile file = fileInfo.getFile(module1);
         numLines = file.getLineCount();
         // pressing return is ok, otherwise throw the exception
         if (line1 > numLines && arg1 != null)
           throw new IndexOutOfBoundsException();
         /* if no arg2 then user list a single line */
         if (arg2 == null)
           line2 = line1;
         /* adjust our range of lines to ensure we conform */
         if (line1 < 1)
         {
           /* shrink line 1, grow line2 */
           line2 += -(line1 - 1);
           line1 = 1;
         }
         if (line2 > numLines)
           line2 = numLines;
        //          System.out.println("1="+module1+":"+line1+",2="+module2+":"+line2+",num="+numLines+",half="+half);
         /* nothing to display */
         if (line1 > line2)
           throw new IndexOutOfBoundsException();
         /* now dump the mixed source / assembly */
         // now lets find which swf this in
         DSwfInfo swf = (DSwfInfo)fileInfo.swfForFile(file);
         ActionLocation lStart = null;
         ActionLocation lEnd = null;
         if (swf == null)
        {
          Map<String, String> args = new HashMap<String, String>();
          args.put("arg3", file.getName()); //$NON-NLS-1$
           cli.err(getLocalizationManager().getLocalizedTextString("key29", args)); //$NON-NLS-1$
        }
         else if (functionNamed)
         {
           // if we name a function just dump the whole thing without source.
           int offset = file.getOffsetForLine(line1);
           lStart = swf.locate(offset);
           if (lStart.function == null)
             cli.err(getLocalizationManager().getLocalizedTextString("key30")); //$NON-NLS-1$
           else
           {
             // create a psudeo action list from which to disasemble the function
             ActionList al = new ActionList(true);
             al.setActionOffset(0, lStart.function);
             lStart.actions = al;
             lStart.at = 0;
             lEnd = new ActionLocation();
             lEnd.actions = al;
             lEnd.at = 0;
             outputAssembly(cli, swf, lStart, lEnd);
           }
         }
         else
         {
           ActionLocation lastEnd = null;
           for(int i=line1; i<=line2; i++)
           {
             int offset = file.getOffsetForLine(i);
             // locate the action list associated with this of the swf
             if (offset != 0)
             {
               // get the starting point and try to locate a nice ending
               lStart = swf.locate(offset);
               lEnd = swf.locateSourceLineEnd(lStart);
               // now see if we skipped some assembly between source lines
               if (lastEnd != null)
               {
                 lastEnd.at++;  // point our pseudo start to the next action
                 // new actions list so attempt to find the end of source in the old actions list
                 if (lastEnd.actions != lStart.actions && lastEnd.actions.size() != lastEnd.at)
                 {
                   String atString = Integer.toHexString(lastEnd.actions.getOffset(lastEnd.at));
                  Map<String, String> args = new HashMap<String, String>();
                  args.put("arg4", atString); //$NON-NLS-1$
                   cli.out(getLocalizationManager().getLocalizedTextString("key31", args)); //$NON-NLS-1$
                    // we are missing some of the dissassembly, so back up a bit and dump it out
                   ActionLocation gapEnd = swf.locateSourceLineEnd(lastEnd);
                   outputAssembly(cli, swf, lastEnd, gapEnd);
                 }
                 else if (lastEnd.at < lStart.at)
                 {
                   // same action list but we skipped some instructions
                   ActionLocation gapEnd = new ActionLocation(lStart);
                   gapEnd.at--;
                   outputAssembly(cli, swf, lastEnd, gapEnd);
                 }
               }
               lastEnd = lEnd;
             }
             // dump source
             cli.outputSource(module1, i, file.getLine(i));
            
             // obtain the offset, locate it in the swf
             if (offset != 0)
               outputAssembly(cli, swf, lStart, lEnd);
           }
View Full Code Here

Examples of flash.tools.debugger.SourceFile

   * @param module the FIRST module to search; but we also search all the others if 'onlyThisModule' is false
   * @return two ints: first is the module, and second is the line
   */
    private int[] parseFunctionName(int module, String partialFunctionName, boolean onlyThisModule) throws NoMatchException, AmbiguousException
    {
        SourceFile m = m_fileInfo.getFile(module);
    ArrayList<ModuleFunctionPair> functionNames = new ArrayList<ModuleFunctionPair>(); // each member is a ModuleFunctionPair

        appendFunctionNamesMatching(functionNames, m, partialFunctionName);

        if (functionNames.size() == 0)
        {
      if (!onlyThisModule)
      {
        // not found in the specified module; search all the other modules
        Iterator fileIter = m_fileInfo.getAllFiles();
        while (fileIter.hasNext())
        {
          SourceFile nextFile = (SourceFile) ((Map.Entry)fileIter.next()).getValue();
          if (nextFile != m) // skip the one file we searched at the beginning
          {
            appendFunctionNamesMatching(functionNames, nextFile, partialFunctionName);
          }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.