当前位置: 首页>>代码示例>>Java>>正文


Java IPackageFragmentRoot.K_BINARY属性代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IPackageFragmentRoot.K_BINARY属性的典型用法代码示例。如果您正苦于以下问题:Java IPackageFragmentRoot.K_BINARY属性的具体用法?Java IPackageFragmentRoot.K_BINARY怎么用?Java IPackageFragmentRoot.K_BINARY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.jdt.core.IPackageFragmentRoot的用法示例。


在下文中一共展示了IPackageFragmentRoot.K_BINARY属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attachSource

public static void attachSource(final IPackageFragmentRoot fragment, final IPath newSourcePath,
    IProgressMonitor monitor) {
  try {
    if (fragment == null || fragment.getKind() != IPackageFragmentRoot.K_BINARY) {
      return;
    }
    if (!Objects.equals(fragment.getSourceAttachmentPath(), newSourcePath)) {
      // would be so cool if it refreshed the UI automatically
      fragment.attachSource(newSourcePath, null, monitor);
      // close the root so that source attachment cache is flushed. Else UI
      // won't update
      fragment.close();
      // we have to manually fire a delta to notify the UI about the source
      // attachment.
      JavaModelManager manager = JavaModelManager.getJavaModelManager();
      JavaElementDelta attachedSourceDelta = new JavaElementDelta(fragment.getJavaModel());
      attachedSourceDelta.sourceAttached(fragment);
      manager.getDeltaProcessor().fire(attachedSourceDelta, ElementChangedEvent.POST_CHANGE);
    }
  } catch (CoreException e) {
    // ignore
  }
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:23,代码来源:ClasspathUtils.java

示例2: getSimpleTextForJavaElement

private String getSimpleTextForJavaElement(Object element) {
  if (element instanceof IPackageFragmentRoot) {
    final IPackageFragmentRoot root = (IPackageFragmentRoot) element;
    // tweak label if the package fragment root is the project itself:
    if (root.getElementName().length() == 0) {
      element = root.getJavaProject();
    }
    // shorten JAR references
    try {
      if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
        return root.getPath().lastSegment();
      }
    } catch (JavaModelException e) {
      EclEmmaUIPlugin.log(e);
    }
  }
  return workbenchLabelProvider.getText(element);
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:18,代码来源:CellTextConverter.java

示例3: internalGetContentReader

/**
 * Gets a reader for an package fragment's Javadoc comment content from the source attachment.
 * The content does contain only the text from the comment without the Javadoc leading star characters.
 * Returns <code>null</code> if the package fragment does not contain a Javadoc comment or if no source is available.
 * @param fragment The package fragment to get the Javadoc of.
 * @return Returns a reader for the Javadoc comment content or <code>null</code> if the member
 * does not contain a Javadoc comment or if no source is available
 * @throws JavaModelException is thrown when the package fragment's javadoc can not be accessed
 * @since 3.4
 */
private static Reader internalGetContentReader(IPackageFragment fragment) throws JavaModelException {
	IPackageFragmentRoot root= (IPackageFragmentRoot) fragment.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);

	//1==> Handle the case when the documentation is present in package-info.java or package-info.class file
	boolean isBinary= root.getKind() == IPackageFragmentRoot.K_BINARY;
	ITypeRoot packageInfo;
	if (isBinary) {
		packageInfo= fragment.getClassFile(PACKAGE_INFO_CLASS);
	} else {
		packageInfo= fragment.getCompilationUnit(PACKAGE_INFO_JAVA);
	}
	if (packageInfo != null && packageInfo.exists()) {
		String source = packageInfo.getSource();
		//the source can be null for some of the class files
		if (source != null) {
			Javadoc javadocNode = getPackageJavadocNode(fragment, source);
			if (javadocNode != null) {
				int start = javadocNode.getStartPosition();
				int length = javadocNode.getLength();
				return new JavaDocCommentReader(source, start, start + length - 1);
			}
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:JavadocContentAccess.java

示例4: isBinaryFragment

public static boolean isBinaryFragment(IPackageFragmentRoot pfr) {
  try {
    return pfr != null && pfr.getKind() == IPackageFragmentRoot.K_BINARY;
  } catch (JavaModelException e) {
    return false;
  }
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:7,代码来源:ClasspathUtils.java

示例5: isBinaryProject

private boolean isBinaryProject(IPackageFragmentRoot fragment) {
  try {
    return fragment.getKind() == IPackageFragmentRoot.K_BINARY;
  } catch (JavaModelException e) {
    return false;
  }
}
 
开发者ID:fbricon,项目名称:pde.source.lookup,代码行数:7,代码来源:DownloadSourcesActionDelegate.java

示例6: getPathLabel

/**
 * Calculates a label for the class path of the given package fragment root.
 * For external entries this is the full path, otherwise it is the project
 * relative path.
 *
 * @param root
 *          package fragment root
 * @return label for the class path entry
 */
private static String getPathLabel(IPackageFragmentRoot root) {
  final IPath path = root.getPath();
  try {
    if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
      return path.lastSegment();
    }
  } catch (JavaModelException e) {
    EclEmmaUIPlugin.log(e);
  }
  return path.removeFirstSegments(1).toString();
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:20,代码来源:ScopeViewer.java

示例7: processPackageFragment

private void processPackageFragment(ITypeVisitor visitor,
    IPackageFragment fragment, IProgressMonitor monitor)
    throws JavaModelException {
  switch (fragment.getKind()) {
  case IPackageFragmentRoot.K_SOURCE:
    final ICompilationUnit[] units = fragment.getCompilationUnits();
    monitor.beginTask("", units.length); //$NON-NLS-1$
    for (final ICompilationUnit unit : units) {
      if (monitor.isCanceled()) {
        break;
      }
      processCompilationUnit(visitor, unit, monitor);
      monitor.worked(1);
    }
    break;
  case IPackageFragmentRoot.K_BINARY:
    final IClassFile[] classfiles = fragment.getClassFiles();
    monitor.beginTask("", classfiles.length); //$NON-NLS-1$
    for (final IClassFile classfile : classfiles) {
      if (monitor.isCanceled()) {
        break;
      }
      processClassFile(visitor, classfile, monitor);
      monitor.worked(1);
    }
    break;
  }
  monitor.done();
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:29,代码来源:TypeTraverser.java

示例8: getClassfilesLocation

private IResource getClassfilesLocation(IPackageFragmentRoot root)
    throws CoreException {

  // For binary roots the underlying resource directly points to class files:
  if (root.getKind() == IPackageFragmentRoot.K_BINARY) {
    return root.getResource();
  }

  // For source roots we need to find the corresponding output folder:
  IPath path = root.getRawClasspathEntry().getOutputLocation();
  if (path == null) {
    path = root.getJavaProject().getOutputLocation();
  }
  return root.getResource().getWorkspace().getRoot().findMember(path);
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:15,代码来源:PackageFragementRootAnalyzer.java


注:本文中的org.eclipse.jdt.core.IPackageFragmentRoot.K_BINARY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。