コード例 #1
0
  @Override
  protected void setUp() throws Exception {
    cproject =
        cpp
            ? CProjectHelper.createCCProject(
                getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
            : CProjectHelper.createCProject(
                getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
    testData = testSourceReader.getContentsForTest(getName());

    if (testData.length > 0) {
      for (int i = 0; i < testData.length - 1; i++) {
        String filename = String.format("header%d.h", i + 1);
        IFile file =
            TestSourceReader.createFile(
                cproject.getProject(), new Path(filename), testData[i].toString());
        CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
      }
    }

    IFile cppfile =
        TestSourceReader.createFile(
            cproject.getProject(), new Path("source.c" + (cpp ? "pp" : "")), getAstSource());
    waitForIndexer(cproject);

    if (DEBUG) {
      System.out.println("Project PDOM: " + getName());
      ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
    }

    index = CCorePlugin.getIndexManager().getIndex(cproject);

    index.acquireReadLock();
    ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
  }
コード例 #2
0
    @Override
    public void setUp() throws Exception {
      cproject =
          cpp
              ? CProjectHelper.createCCProject(
                  getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
              : CProjectHelper.createCProject(
                  getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
      Bundle b = CTestPlugin.getDefault().getBundle();
      testData =
          TestSourceReader.getContentsForTest(
              b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);

      if (testData.length < 2) return;
      IFile file =
          TestSourceReader.createFile(
              cproject.getProject(), new Path("header.h"), testData[0].toString());
      CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
      waitForIndexer(cproject);

      if (DEBUG) {
        System.out.println("Project PDOM: " + getName());
        ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
      }

      index = CCorePlugin.getIndexManager().getIndex(cproject);

      index.acquireReadLock();
      IFile cppfile =
          TestSourceReader.createFile(
              cproject.getProject(),
              new Path("references.c" + (cpp ? "pp" : "")),
              testData[1].toString());
      ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
    }
コード例 #3
0
ファイル: RefactoringTest.java プロジェクト: alblue/cdt
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
   CTestPlugin.getDefault().getLog().addLogListener(this);
   CCorePlugin.getIndexManager().reindex(cproject);
   boolean joined =
       CCorePlugin.getIndexManager().joinIndexer(IIndexManager.FOREVER, NULL_PROGRESS_MONITOR);
   assertTrue(joined);
   astCache = new RefactoringASTCache();
 }
コード例 #4
0
ファイル: LaunchUtils.java プロジェクト: NVIDIA/cdt-nsight
  /**
   * Gets the CDT environment from the CDT project's configuration referenced by the launch
   *
   * @since 3.0
   */
  public static String[] getLaunchEnvironment(ILaunchConfiguration config) throws CoreException {
    // Get the project
    String projectName =
        config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
    if (projectName == null) {
      return null;
    }
    projectName = projectName.trim();
    if (projectName.length() == 0) {
      return null;
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    if (project == null || !project.isAccessible()) return null;

    ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project, false);

    // Not a CDT project?
    if (projDesc == null) return null;

    String buildConfigID =
        config.getAttribute(
            ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); // $NON-NLS-1$
    ICConfigurationDescription cfg = null;
    if (buildConfigID.length() != 0) cfg = projDesc.getConfigurationById(buildConfigID);

    // if configuration is null fall-back to active
    if (cfg == null) cfg = projDesc.getActiveConfiguration();

    // Environment variables and inherited vars
    HashMap<String, String> envMap = new HashMap<String, String>();
    IEnvironmentVariable[] vars =
        CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cfg, true);
    for (IEnvironmentVariable var : vars) envMap.put(var.getName(), var.getValue());

    // Add variables from build info
    ICdtVariable[] build_vars = CCorePlugin.getDefault().getCdtVariableManager().getVariables(cfg);
    for (ICdtVariable var : build_vars) {
      try {
        envMap.put(var.getName(), var.getStringValue());
      } catch (CdtVariableException e) {
        // Some Eclipse dynamic variables can't be resolved dynamically... we don't care.
      }
    }

    // Turn it into an envp format
    List<String> strings = new ArrayList<String>(envMap.size());
    for (Entry<String, String> entry : envMap.entrySet()) {
      StringBuffer buffer = new StringBuffer(entry.getKey());
      buffer.append('=').append(entry.getValue());
      strings.add(buffer.toString());
    }

    return strings.toArray(new String[strings.size()]);
  }
コード例 #5
0
 /**
  * @return compares two bindings for signature information. Signature information covers function
  *     signatures, or template specialization/instance arguments.
  * @param a
  * @param b
  */
 public static int compareSignatures(IBinding a, IBinding b) {
   try {
     int siga = getSignature(a).hashCode();
     int sigb = getSignature(b).hashCode();
     return siga < sigb ? -1 : siga > sigb ? 1 : 0;
   } catch (CoreException e) {
     CCorePlugin.log(e);
   } catch (DOMException e) {
     CCorePlugin.log(e);
   }
   return 0;
 }
コード例 #6
0
  /**
   * Checks if compatibility with CCorePlugin methods from CDT 6.0 was not violated.
   *
   * @throws Exception...
   */
  public void testCompatibility() throws Exception {
    final CCorePlugin cCorePlugin = CCorePlugin.getDefault();

    // CCorePlugin.getAllErrorParsersIDs()
    String all = ErrorParserManager.toDelimitedString(cCorePlugin.getAllErrorParsersIDs());
    assertTrue(all.contains(NOTREGEX_ERRORPARSER_ID));

    // CCorePlugin.getErrorParser(id)
    IErrorParser[] gccErrorParserArray = cCorePlugin.getErrorParser(NOTREGEX_ERRORPARSER_ID);
    assertNotNull(gccErrorParserArray);
    assertEquals(1, gccErrorParserArray.length);
    assertTrue(gccErrorParserArray[0] instanceof GASErrorParser);
  }
コード例 #7
0
 private void computeTemplateParameters(ICPPFunctionTemplate originalMethodTemplate) {
   try {
     fTemplateParameters =
         PDOMTemplateParameterArray.createPDOMTemplateParameters(
             getLinkage(), this, originalMethodTemplate.getTemplateParameters());
   } catch (DOMException e) {
     CCorePlugin.log(e);
     fTemplateParameters = IPDOMCPPTemplateParameter.EMPTY_ARRAY;
   } catch (CoreException e) {
     CCorePlugin.log(e);
     fTemplateParameters = IPDOMCPPTemplateParameter.EMPTY_ARRAY;
   }
 }
コード例 #8
0
    @Override
    public void setUp() throws Exception {
      cproject =
          cpp
              ? CProjectHelper.createCCProject(
                  getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
              : CProjectHelper.createCProject(
                  getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
      Bundle b = CTestPlugin.getDefault().getBundle();
      testData =
          TestSourceReader.getContentsForTest(
              b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 0);

      List<IFile> astFiles = new ArrayList<IFile>();
      for (int i = 0; i < testData.length; i++) {
        StringBuilder contents = testData[i];
        int endOfLine = contents.indexOf("\n");
        if (endOfLine >= 0) endOfLine++;
        else endOfLine = contents.length();
        String filename = contents.substring(0, endOfLine).trim();
        contents.delete(0, endOfLine); // Remove first line from the file contents
        boolean astRequested = filename.endsWith("*");
        if (astRequested) {
          filename = filename.substring(0, filename.length() - 1).trim();
        }
        IFile file =
            TestSourceReader.createFile(
                cproject.getProject(), new Path(filename), contents.toString());
        if (astRequested || (i == testData.length - 1 && astFiles.isEmpty())) {
          astSources.add(contents);
          astFiles.add(file);
        }
      }
      CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
      waitForIndexer(cproject);

      if (DEBUG) {
        System.out.println("Project PDOM: " + getName());
        ((PDOM) CCoreInternals.getPDOMManager().getPDOM(cproject)).accept(new PDOMPrettyPrinter());
      }

      index = CCorePlugin.getIndexManager().getIndex(cproject);

      index.acquireReadLock();
      for (IFile file : astFiles) {
        asts.add(TestSourceReader.createIndexBasedAST(index, cproject, file));
      }
    }
コード例 #9
0
 @Override
 public void handleEvent(CProjectDescriptionEvent event) {
   // we are only interested in about to apply
   if (event.getEventType() != CProjectDescriptionEvent.ABOUT_TO_APPLY) return;
   ICProjectDescription projDesc = event.getNewCProjectDescription();
   IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
   IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
   if (projDesc.getActiveConfiguration() != null) {
     IEnvironmentVariable var =
         contribEnv.getVariable(
             ArduinoConst.ENV_KEY_JANTJE_PLATFORM_FILE, projDesc.getActiveConfiguration());
     if (var != null) {
       IPath platformPath = new Path(var.getValue());
       ArduinoHelpers.setProjectPathVariables(
           projDesc.getProject(), platformPath.removeLastSegments(1));
       ArduinoHelpers.setTheEnvironmentVariables(
           projDesc.getProject(), projDesc.getActiveConfiguration(), false);
       try {
         ArduinoHelpers.addArduinoCodeToProject(
             projDesc.getProject(), projDesc.getActiveConfiguration());
       } catch (CoreException e1) {
         Common.log(
             new Status(
                 IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Error adding the arduino code", e1));
       }
       ArduinoLibraries.reAttachLibrariesToProject(projDesc.getActiveConfiguration());
     }
   }
 }
コード例 #10
0
ファイル: CIndex.java プロジェクト: xgsa/cdt-tests-runner
 public IIndexBinding[] findBindings(
     char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor)
     throws CoreException {
   if (SPECIALCASE_SINGLES && fFragments.length == 1) {
     return fFragments[0].findBindings(name, filescope, filter, monitor);
   } else {
     List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
     ILinkage[] linkages = Linkage.getIndexerLinkages();
     for (ILinkage linkage : linkages) {
       if (filter.acceptLinkage(linkage)) {
         IIndexFragmentBinding[][] fragmentBindings =
             new IIndexFragmentBinding[fPrimaryFragmentCount][];
         for (int i = 0; i < fPrimaryFragmentCount; i++) {
           try {
             IBinding[] part =
                 fFragments[i].findBindings(
                     name, filescope, retargetFilter(linkage, filter), monitor);
             fragmentBindings[i] = new IIndexFragmentBinding[part.length];
             System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
           } catch (CoreException e) {
             CCorePlugin.log(e);
             fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
           }
         }
         ICompositesFactory factory = getCompositesFactory(linkage.getLinkageID());
         result.add(factory.getCompositeBindings(fragmentBindings));
       }
     }
     return flatten(result);
   }
 }
コード例 #11
0
  protected static void doProjectUpdate(IProgressMonitor monitor, IProject[] project)
      throws CoreException {
    monitor.beginTask(
        MakeUIPlugin.getResourceString("UpdateMakeProjectAction.monitor.update"),
        project.length * 4); // $NON-NLS-1$
    try {
      for (int i = 0; i < project.length; i++) {
        // remove old builder
        project[i].refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(monitor, 1));
        MakeProjectNature.removeFromBuildSpec(
            project[i], MakeCorePlugin.OLD_BUILDER_ID, new SubProgressMonitor(monitor, 1));

        // convert .cdtproject
        CCorePlugin.getDefault().mapCProjectOwner(project[i], MakeCorePlugin.MAKE_PROJECT_ID, true);
        // add new nature
        MakeProjectNature.addNature(project[i], new SubProgressMonitor(monitor, 1));

        // move existing build properties to new
        IMakeBuilderInfo newInfo =
            MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
        final int LOCATION = 0, FULL_ARGS = 1, INC_ARGS = 2, STOP_ERORR = 3, USE_DEFAULT = 4;
        QualifiedName[] qName = new QualifiedName[USE_DEFAULT + 1];
        qName[LOCATION] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildLocation"); // $NON-NLS-1$
        qName[FULL_ARGS] =
            new QualifiedName(CCorePlugin.PLUGIN_ID, "buildFullArguments"); // $NON-NLS-1$
        qName[INC_ARGS] =
            new QualifiedName(CCorePlugin.PLUGIN_ID, "buildIncrementalArguments"); // $NON-NLS-1$
        qName[STOP_ERORR] = new QualifiedName(CCorePlugin.PLUGIN_ID, "stopOnError"); // $NON-NLS-1$
        qName[USE_DEFAULT] =
            new QualifiedName(CCorePlugin.PLUGIN_ID, "useDefaultBuildCmd"); // $NON-NLS-1$

        String property = project[i].getPersistentProperty(qName[LOCATION]);
        if (property != null) {
          newInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, property);
        }
        property = project[i].getPersistentProperty(qName[FULL_ARGS]);
        if (property != null) {
          newInfo.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, property);
        }
        property = project[i].getPersistentProperty(qName[STOP_ERORR]);
        if (property != null) {
          newInfo.setStopOnError(Boolean.valueOf(property).booleanValue());
        }
        property = project[i].getPersistentProperty(qName[USE_DEFAULT]);
        if (property != null) {
          newInfo.setUseDefaultBuildCmd(Boolean.valueOf(property).booleanValue());
        }
        for (int j = 0; j < qName.length; j++) {
          project[i].setPersistentProperty(qName[j], null);
        }

        IProgressMonitor subMon =
            new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
        project[i].accept(new TargetConvertVisitor(subMon), 0);
        monitor.worked(1);
      }
    } finally {
      monitor.done();
    }
  }
コード例 #12
0
 /**
  * Adds Error Parser extension to the global repository. Note that this function will "pollute"
  * the working environment and the error parser will be seen by other test cases as well.
  *
  * @param shortId - last portion of ID with which error parser will be added.
  * @param cl - Error Parser class
  * @return - full ID of the error parser (generated by the method).
  */
 private static String addErrorParserExtension(String shortId, Class cl) {
   String ext =
       "<plugin><extension id=\""
           + shortId
           + "\" name=\""
           + shortId
           + "\" point=\"org.eclipse.cdt.core.ErrorParser\">"
           + "<errorparser class=\""
           + cl.getName()
           + "\"/>"
           + "</extension></plugin>";
   IContributor contributor =
       ContributorFactoryOSGi.createContributor(CTestPlugin.getDefault().getBundle());
   boolean added =
       Platform.getExtensionRegistry()
           .addContribution(
               new ByteArrayInputStream(ext.getBytes()),
               contributor,
               false,
               shortId,
               null,
               ((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken());
   assertTrue("failed to add extension", added);
   String fullId = "org.eclipse.cdt.core.tests." + shortId;
   IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId);
   assertTrue(errorParser.length > 0);
   return fullId;
 }
コード例 #13
0
 @Override
 public IField[] getFields() {
   CCorePlugin.log(
       new Exception(
           "Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
   return getFields(null);
 }
コード例 #14
0
 @Override
 public ICPPClassType[] getNestedClasses() {
   CCorePlugin.log(
       new Exception(
           "Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
   return getNestedClasses(null);
 }
コード例 #15
0
  @Override
  public ICPPBase[] getBases(IASTNode point) {
    IScope scope = getCompositeScope();
    if (scope instanceof ICPPClassSpecializationScope) {
      return ((ICPPClassSpecializationScope) scope).getBases(point);
    }

    // This is an explicit specialization
    Long key = record + PDOMCPPLinkage.CACHE_BASES;
    ICPPBase[] bases = (ICPPBase[]) getPDOM().getCachedResult(key);
    if (bases != null) return bases;

    try {
      List<PDOMCPPBase> list = new ArrayList<PDOMCPPBase>();
      for (PDOMCPPBase base = getFirstBase(); base != null; base = base.getNextBase()) {
        list.add(base);
      }
      Collections.reverse(list);
      bases = list.toArray(new ICPPBase[list.size()]);
      getPDOM().putCachedResult(key, bases);
      return bases;
    } catch (CoreException e) {
      CCorePlugin.log(e);
    }
    return ICPPBase.EMPTY_BASE_ARRAY;
  }
コード例 #16
0
ファイル: ArchiveContainer.java プロジェクト: zhaog/cdt
 public ArchiveContainer(CProject cProject) {
   super(
       cProject,
       null,
       CCorePlugin.getResourceString("CoreModel.ArchiveContainer.Archives"),
       ICElement.C_VCONTAINER); // $NON-NLS-1$
 }
コード例 #17
0
        @Override
        public void handleEvent(Event e) {
          IEnvironmentVariableManager envManager =
              CCorePlugin.getDefault().getBuildEnvironmentManager();
          IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
          ICConfigurationDescription confdesc = getConfdesc();

          int selectedBoardFile = BoardSelectionPage.this.mControlBoardsTxtFile.getSelectionIndex();
          String boardFile = BoardSelectionPage.this.mControlBoardsTxtFile.getText().trim();
          if (confdesc != null) {
            IEnvironmentVariable var =
                new EnvironmentVariable(Const.ENV_KEY_JANTJE_BOARDS_FILE, boardFile);
            contribEnv.addVariable(var, confdesc);
            IPath platformPath =
                new Path(new File(boardFile).getParent()).append(Const.PLATFORM_FILE_NAME);
            var =
                new EnvironmentVariable(
                    Const.ENV_KEY_JANTJE_PLATFORM_FILE, platformPath.toString());
            contribEnv.addVariable(var, confdesc);
          }

          /*
           * Change the list of available boards
           */
          String CurrentBoard = BoardSelectionPage.this.mcontrolBoardName.getText();
          BoardSelectionPage.this.mcontrolBoardName.removeAll();
          BoardSelectionPage.this.mcontrolBoardName.setItems(
              BoardSelectionPage.this.mAllBoardsFiles[selectedBoardFile].GetArduinoBoards());
          BoardSelectionPage.this.mcontrolBoardName.setText(CurrentBoard);

          BoardSelectionPage.this.BoardModifyListener.handleEvent(null);
        }
コード例 #18
0
  IStatus performNavigation(IProgressMonitor monitor) throws CoreException {
    fAction.clearStatusLine();

    assert fIndex == null;
    if (fIndex != null) return Status.CANCEL_STATUS;

    fMonitor = monitor;
    fIndex =
        CCorePlugin.getIndexManager()
            .getIndex(
                fTranslationUnit.getCProject(),
                IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);

    try {
      fIndex.acquireReadLock();
    } catch (InterruptedException e) {
      return Status.CANCEL_STATUS;
    }

    try {
      return ASTProvider.getASTProvider()
          .runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor, this);
    } finally {
      fIndex.releaseReadLock();
    }
  }
コード例 #19
0
  /**
   * Based on the selected board and parameters save all info needed to the build environments
   *
   * @param confdesc
   */
  public void saveAllSelections(ICConfigurationDescription confdesc) {
    String boardFile = this.mControlBoardsTxtFile.getText().trim();
    String boardName = this.mcontrolBoardName.getText().trim();
    String uploadPort = this.mControlUploadPort.getValue();
    IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
    IContributedEnvironment contribEnv = envManager.getContributedEnvironment();

    // Set the path variables
    IPath platformPath =
        new Path(new File(this.mControlBoardsTxtFile.getText().trim()).getParent())
            .append(Const.PLATFORM_FILE_NAME);
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_BOARDS_FILE, boardFile);
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_PLATFORM_FILE, platformPath.toString());
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_BOARD_NAME, boardName);
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_COM_PORT, uploadPort);

    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_PACKAGE_ID, getPackage());
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_ARCITECTURE_ID, getArchitecture());
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_BOARD_ID, getBoardID());

    for (LabelCombo curLabelCombo : this.mBoardOptionCombos) {
      curLabelCombo.StoreValue(confdesc);
    }
    saveAllLastUseds();
  }
コード例 #20
0
    private ICProject createReferencedContent() throws Exception {
      ICProject referenced =
          cpp
              ? CProjectHelper.createCCProject(
                  "ReferencedContent" + System.currentTimeMillis(),
                  "bin",
                  IPDOMManager.ID_NO_INDEXER)
              : CProjectHelper.createCProject(
                  "ReferencedContent" + System.currentTimeMillis(),
                  "bin",
                  IPDOMManager.ID_NO_INDEXER);
      String content = testData[0].toString();
      IFile file =
          TestSourceReader.createFile(referenced.getProject(), new Path("header.h"), content);

      IndexerPreferences.set(
          referenced.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
      CCorePlugin.getIndexManager().reindex(referenced);

      waitForIndexer(referenced);

      if (DEBUG) {
        System.out.println("Referenced: " + getName());
        ((PDOM) CCoreInternals.getPDOMManager().getPDOM(referenced))
            .accept(new PDOMPrettyPrinter());
      }

      return referenced;
    }
コード例 #21
0
ファイル: PDOMFile.java プロジェクト: PARAG00991/cdt
 private IIndexFragmentName createPDOMName(PDOMLinkage linkage, IASTName name, PDOMName caller)
     throws CoreException {
   final IBinding binding = name.getBinding();
   if (binding instanceof IParameter) {
     return null;
   }
   try {
     if (binding instanceof IMacroBinding
         || (binding == null
             && name.getPropertyInParent() == IASTPreprocessorStatement.MACRO_NAME)) {
       return createPDOMMacroReferenceName(linkage, name);
     }
     PDOMBinding pdomBinding = linkage.addBinding(name);
     if (pdomBinding != null) {
       final PDOMName result = new PDOMName(fLinkage, name, this, pdomBinding, caller);
       linkage.onCreateName(this, name, result);
       return result;
     }
   } catch (CoreException e) {
     final IStatus status = e.getStatus();
     if (status != null && status.getCode() == CCorePlugin.STATUS_PDOM_TOO_LARGE) {
       if (CCorePlugin.PLUGIN_ID.equals(status.getPlugin())) throw e;
     }
     CCorePlugin.log(e);
   }
   return null;
 }
コード例 #22
0
ファイル: EvalFunctionSet.java プロジェクト: zhaog/cdt
  /**
   * Attempts to resolve the function using the parameters of a function call.
   *
   * @param args the arguments of a function call
   * @param point the name lookup context
   * @return the resolved or the original evaluation depending on whether function resolution
   *     succeeded or not
   */
  public ICPPEvaluation resolveFunction(ICPPEvaluation[] args, IASTNode point) {
    // Set up the LookupData.
    LookupData data;
    ICPPFunction[] functions = null;
    if (fFunctionSet == null) {
      data = new LookupData(fName, null, point);
    } else {
      functions = fFunctionSet.getBindings();
      data =
          new LookupData(
              functions[0].getNameCharArray(), fFunctionSet.getTemplateArguments(), point);
      data.foundItems = functions;
    }
    data.setFunctionArguments(false, args);
    if (fImpliedObjectType != null) data.setImpliedObjectType(fImpliedObjectType);

    try {
      // Perform ADL if appropriate.
      if (!fQualified
          && fImpliedObjectType == null
          && !data.hasTypeOrMemberFunctionOrVariableResult()) {
        CPPSemantics.doKoenigLookup(data);

        Object[] foundItems = (Object[]) data.foundItems;
        if (foundItems != null && (functions == null || foundItems.length > functions.length)) {
          // ADL found additional functions.
          int start = functions == null ? 0 : functions.length;
          for (int i = start; i < foundItems.length; i++) {
            Object obj = foundItems[i];
            if (obj instanceof ICPPFunction) {
              functions = ArrayUtil.append(ICPPFunction.class, functions, (ICPPFunction) obj);
            } else if (obj instanceof ICPPClassType) {
              functions =
                  ArrayUtil.addAll(
                      ICPPFunction.class,
                      functions,
                      ClassTypeHelper.getConstructors((ICPPClassType) obj, point));
            }
          }

          // doKoenigLookup() may introduce duplicates into the result. These must be
          // eliminated to avoid resolveFunction() reporting an ambiguity. (Normally, when
          // lookup() and doKoenigLookup() are called on the same LookupData object, the
          // two functions coordinate using data stored in that object to eliminate
          // duplicates, but in this case lookup() was called before with a different
          // LookupData object and now we are only calling doKoenigLookup()).
          functions = ArrayUtil.removeDuplicates(functions);
        }
      }

      // Perform template instantiation and overload resolution.
      IBinding binding = CPPSemantics.resolveFunction(data, functions, true);
      if (binding instanceof ICPPFunction && !(binding instanceof ICPPUnknownBinding))
        return new EvalBinding(binding, null, getTemplateDefinition());
    } catch (DOMException e) {
      CCorePlugin.log(e);
    }
    return this;
  }
コード例 #23
0
 private IBinding getBinding() {
   try {
     return getLinkage().loadBinding(record + TARGET_BINDING);
   } catch (CoreException e) {
     CCorePlugin.log(e);
   }
   return null;
 }
コード例 #24
0
 private IType loadFixedType() {
   try {
     return getLinkage().loadType(record + OFFSET_FIXED_TYPE);
   } catch (CoreException e) {
     CCorePlugin.log(e);
     return null;
   }
 }
コード例 #25
0
 public int getNodeOffset() {
   try {
     return linkage.getDB().getInt(record + NODE_OFFSET_OFFSET);
   } catch (CoreException e) {
     CCorePlugin.log(e);
     return 0;
   }
 }
コード例 #26
0
 public int getNodeLength() {
   try {
     return (linkage.getDB().getShort(record + NODE_LENGTH_OFFSET)) & 0xffff;
   } catch (CoreException e) {
     CCorePlugin.log(e);
     return 0;
   }
 }
コード例 #27
0
 public char[] getSimpleID() {
   try {
     return getContainer().getNameCharArray();
   } catch (CoreException e) {
     CCorePlugin.log(e);
     return CharArrayUtils.EMPTY;
   }
 }
コード例 #28
0
 public CProjectConfigurator() {
   this(
       new BuildWrapperJsonFactory(),
       CCorePlugin.getDefault(),
       CoreModel::isTranslationUnit,
       SonarLintCorePlugin.getDefault(),
       new FilePathResolver());
 }
コード例 #29
0
ファイル: CProjectDescription.java プロジェクト: zhaog/cdt
 private String load() {
   try {
     return getProject().getPersistentProperty(fPersistanceName);
   } catch (CoreException e) {
     CCorePlugin.log(e);
   }
   return null;
 }
コード例 #30
0
 private void syncronizeProjectSettings(IProject project, IProgressMonitor monitor) {
   try {
     IFolder settings = project.getFolder(SETTINGS_FOLDER_NAME);
     settings.refreshLocal(IResource.DEPTH_INFINITE, monitor);
   } catch (CoreException e) {
     CCorePlugin.log(e);
   }
   monitor.done();
 }