Package com.googlecode.goclipse.go

Examples of com.googlecode.goclipse.go.CodeContext


    if (path != null) {
      String filename = path.toOSString();
      IDocument document = viewer.getDocument();

      CodeContext codeContext = codeContexts.get(filename);
      int linenumber = 0;

      try {
        // the following starts on line 0?, so we add 1 to the result
        linenumber = document.getLineOfOffset(offset) + 1;
      } catch (BadLocationException e1) {
        Activator.logError(e1);
      }

      if (codeContext == null) {

        try {
          codeContext = CodeContext.getCodeContext(filename, document.get());
        } catch (IOException | CommonException e) {
          Activator.logError(e);
        }
      }

      String prefix = lastWord(document, offset);
      String indent = lastIndent(document, offset);
      String line = document.get().split("\\r?\\n")[linenumber];

      if (codeContext != null) {

        List<Node> units = codeContext.getCompletionsForString(line, prefix, linenumber);

        for (Node unit : units) {
          IContextInformation info = new ContextInformation(unit.getDocumentation(),
              unit.getDocumentation());
View Full Code Here


     
      if (fileEditorInput == null) {
        return null;
      }
     
      CodeContext cc1 = CodeContext.getCodeContext(project, fileEditorInput.getFile().getLocation().toOSString(),
          document.get());

      if (cc1 == null) {
        return null;
      }

      GoHyperLink h    = new GoHyperLink();
      int         line = document.getLineOfOffset(offset);
     
      // imported function call or method call
      if (word.contains(".")) {
       
        String[] parts = word.split("\\.");
        Import   i     = cc1.getImportForName(parts[0]);
       
        if (i != null) {
       
          Node node = cc1.getLocationForPkgAndName(i.path, parts[1]);
          if (node == null) {
            return null;
          }

          h.node   = node;
          h.region = wordRegion;
          h.text   = word;
          h.type   = "go function";
          link[0= h;

          return link;
        }
       
        Var v = cc1.getVarForName(parts[0], line);
        if (v != null) {
          h.node = v;
          h.region = wordRegion;
          h.text = word;
          h.type = "go methods";
          link[0] = h;
          return link;
        }

        // variable or local function call
      } else {
       
        // Is there a variable?
        Var v = cc1.getVarForName(word, line+1);
        if (v != null) {
          h.node = v;
          h.region = wordRegion;
          h.text = word;
          h.type = "go variable";
          link[0] = h;
          return link;
        }
       
        // Is there a variable?
        Function f = cc1.getFunctionForName(word+"()");
        if (f != null) {
          h.node = f;
          h.region = wordRegion;
          h.text = word;
          h.type = "go variable";
View Full Code Here

    try {
      if (!getTreeViewer().getControl().isDisposed()) {
        IDocument document = documentProvider.getDocument(editor.getEditorInput());
       
        if (document != null) {
          CodeContext codeContext = null;
         
          IEditorInput input = editor.getEditorInput();
         
          if (input instanceof IFileEditorInput) {
            IFile file = ((IFileEditorInput)input).getFile();
View Full Code Here

     
      ExternalProcessResult processResult = client.execute(filePath, document.get(), offset);
      String stdout = processResult.getStdOutBytes().toString(StringUtil.UTF8);
      List<String> completions = new ArrayList2<>(GocodeClient.LINE_SPLITTER.split(stdout));
     
      CodeContext codeContext = codeContexts.get(filePath);
      if (codeContext == null) {
        try {
          codeContext = CodeContext.getCodeContext(project, filePath, document.get());
        } catch (IOException e) {
          throw LangCore.createCoreException("Error during code Context:", e);
View Full Code Here

                + " tests were successful at "
                + new Date(), IMarker.SEVERITY_INFO);
          } else {
            // parse test file and mark correctly failed tests
            File        f       = parent.getLocation().toFile();
            CodeContext context = CodeContext.getTestCodeContext(activeTest.project, f);
           
            for (String name:failedTests){
              Function func = context.getFunctionForName(name+"()");
              if(func != null) {
                IResource res = parent.findMember(func.getFile().getName());
                MarkerUtilities.addMarker(res, func.getLine(), name+" failed.", IMarker.SEVERITY_ERROR);
              }
            }
View Full Code Here

TOP

Related Classes of com.googlecode.goclipse.go.CodeContext

Copyright © 2018 www.massapicom. 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.