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


Java IPackageFragmentRoot.K_SOURCE属性代码示例

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


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

示例1: getIFileFromQualifiedName

/**
 * @param project
 * @param qualifiedName
 * @return
 * @throws CoreException
 */
public static IFile getIFileFromQualifiedName(String projectname, String qualifiedName) throws CoreException {
	IProject project = getProject(projectname);
	IJavaProject jproject = JavaCore.create(project);
	IPackageFragment[] pkgs = jproject.getPackageFragments();
	String spath = qualifiedName.replace(".", "/");
	for (int i = 0; i < pkgs.length; i++) {
		if (pkgs[i].getKind() != IPackageFragmentRoot.K_SOURCE)
			continue;
		IPath path = pkgs[i].getPath().append(spath);
		IFile iFile = (IFile) ResourceManager.getResource(path.toString() + ".java");
		if (iFile != null && iFile.exists())
			return iFile;
	}
	return null;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:21,代码来源:ResourceManager.java

示例2: build

/**
 * @see IBuilder#build
 */
@Override
public void build(Measure measure, ItemMeasured item) {
	IPackageFragment[] packages;
	ItemMeasured packageMeasured; 
	String packageName = "";
	try {
		packages = project.getPackageFragments();
		for (IPackageFragment myPackage : packages) {
			if ((myPackage.getKind() == IPackageFragmentRoot.K_SOURCE) && myPackage.hasChildren()) {
				
				packageName = myPackage.isDefaultPackage() ? "(default)" : myPackage.getElementName();
				packageMeasured = new ItemMeasured(packageName, item);
				addClassBuilder(measure, myPackage, packageMeasured);
				item.addChild(packageMeasured);
				item.setMax(packageMeasured.getMax());
				item.setClassWithMax(packageMeasured.getClassWithMax());
				item.addValue(packageMeasured.getValue());
				item.addMean(packageMeasured.getMean());
			}
		}
	} catch (JavaModelException exception) {
		logger.error(exception);
	}
}
 
开发者ID:mariazevedo88,项目名称:o3smeasures-tool,代码行数:27,代码来源:PackageBuilder.java

示例3: getTopLevelPackages

public static Collection<IPackageFragment> getTopLevelPackages(IJavaProject javaProject) {
	Set<IPackageFragment> packages = new LinkedHashSet<>();
	try {
		if (javaProject == null || !javaProject.getProject().isAccessible()) {
			return packages;
		}
		for (IPackageFragment f : javaProject.getPackageFragments()){
			if (f.getKind() != IPackageFragmentRoot.K_SOURCE || f.isDefaultPackage() ) {
			  continue;
			}
			if (f.containsJavaResources() || f.getChildren().length > 1) {
				packages.add(f);
			}
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return packages;
}
 
开发者ID:fbricon,项目名称:wildfly-hive,代码行数:19,代码来源:HotClassReloaderUtil.java

示例4: test

@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
	IProject project = null;
	boolean authorized = false; 
	if (receiver instanceof IJavaProject) {
		project =  ((IJavaProject)receiver).getProject();
		authorized = true;
	} else {
		if (receiver instanceof IPackageFragmentRoot) {
			IPackageFragmentRoot pfr = ((IPackageFragmentRoot)receiver);
			project = pfr.getJavaProject().getProject();
			try {
				authorized =  (pfr.getKind() == IPackageFragmentRoot.K_SOURCE);
			} catch (JavaModelException ignore) {
			}
		} else {
			if (receiver instanceof IPackageFragment) {
				IPackageFragment  pf = (IPackageFragment)receiver;
				project = pf.getJavaProject().getProject();
				authorized = true;
			}
		}
	}
	if (authorized && project!= null) {
		if (GW4ENature.hasGW4ENature(project)) 
			return true;
	}

	return false; 
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:30,代码来源:SynchronizeBuildPoliciesEnabled.java

示例5: loadComboJarListFromBuildPath

@SuppressWarnings("restriction")
private void loadComboJarListFromBuildPath(Combo comboJarList, String newJarName) {
	comboJarList.removeAll();
	IProject iProject = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject();
	IJavaProject iJavaProject=null;
	try {
		iJavaProject = JavaCore.create(iProject);
		PackageFragmentRoot srcfragmentRoot= BuildExpressionEditorDataSturcture.INSTANCE.getSrcPackageFragment(iJavaProject);
		comboJarList.add(hydrograph.ui.common.util.Constants.ProjectSupport_SRC);
		comboJarList.setData(String.valueOf(comboJarList.getItemCount() - 1), srcfragmentRoot);
		
		for (IPackageFragmentRoot iPackageFragmentRoot : iJavaProject.getAllPackageFragmentRoots()) {
			if (isJarPresentInLibFolder(iPackageFragmentRoot.getPath())
					&& iPackageFragmentRoot.getKind() != IPackageFragmentRoot.K_SOURCE) {
				comboJarList.add(iPackageFragmentRoot.getElementName());
				comboJarList.setData(String.valueOf(comboJarList.getItemCount() - 1), iPackageFragmentRoot);
			}
		}
		selectAndLoadJarData(newJarName);
	} catch (JavaModelException javaModelException) {
		LOGGER.error("Error occurred while loading engines-transform jar", javaModelException);
	}
	finally{
		if(iJavaProject!=null){
			try {
				iJavaProject.close();
			} catch (JavaModelException e) {
				LOGGER.warn("JavaModelException occurred while closing java-project"+e);
			}
		}
	}

}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:33,代码来源:CategoriesDialogSourceComposite.java

示例6: getSourceFolders

/**
 * Returns all folders configured as source folders for the given project.
 *
 * @param javaProject
 *            the java project to examine
 * @return a List of all source folders as IJavaElements
 * @throws JavaModelException
 * @see {@link #getJavaProjects(IJavaModel)}
 */
private List<IJavaElement> getSourceFolders(IJavaElement javaProject) throws JavaModelException {
	List<IJavaElement> folders = new ArrayList<>();
	IJavaElement[] children = ((IParent) javaProject).getChildren();
	for (IJavaElement child : children) {
		if (child instanceof IPackageFragmentRoot) {
			IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) child;
			if (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) {
				folders.add(packageFragmentRoot);
			}
		}
	}
	return folders;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:22,代码来源:BreakpointLocator.java

示例7: sourceFoldersOnly

private void sourceFoldersOnly(Collection<IPackageFragmentRoot> filtered)
    throws JavaModelException {
  for (final Iterator<IPackageFragmentRoot> i = filtered.iterator(); i
      .hasNext();) {
    if (i.next().getKind() != IPackageFragmentRoot.K_SOURCE) {
      i.remove();
    }
  }
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:9,代码来源:DefaultScopeFilter.java

示例8: createSourceFileLocator

private ISourceFileLocator createSourceFileLocator(IPackageFragmentRoot root)
    throws JavaModelException {
  if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
    return new SourceFolderSourceFileLocator(root);
  } else {
    return new LibrarySourceFileLocator(root);
  }
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:8,代码来源:SessionExporter.java

示例9: 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

示例10: getProjectCompilationUnits

public Set<ICompilationUnit> getProjectCompilationUnits(IJavaProject project) throws JavaModelException {
	Set<ICompilationUnit> compilationUnits = new HashSet<ICompilationUnit>();
	for (IPackageFragment packageFragment : project.getPackageFragments()) {
		if (packageFragment.getKind() == IPackageFragmentRoot.K_SOURCE)
			Collections.addAll(compilationUnits, packageFragment.getCompilationUnits());
	}
	return compilationUnits;
}
 
开发者ID:secure-software-engineering,项目名称:cheetah,代码行数:8,代码来源:PrepareAnalysis.java

示例11: organizeImportsInDirectory

/**
 * Organize imports underlying a directory
 *
 * @param folderUri
 *            Selected folder URI
 * @param proj
 *            the folder associated project
 * @return
 * @throws CoreException
 */
public WorkspaceEdit organizeImportsInDirectory(String folderUri, IProject proj) throws CoreException {
	WorkspaceEdit rootEdit = new WorkspaceEdit();
	IPackageFragment fragment = null;
	if (JDTUtils.toURI(folderUri) != null) {
		fragment = JDTUtils.resolvePackage(folderUri);
	}
	// Select an individual package
	if (fragment != null) {
		organizeImportsInPackageFragment(fragment, rootEdit);
	} else if (proj != null) {
		// Search the packages under the selected folder:
		IJavaProject javaProject = JavaCore.create(proj);
		IPath rootPath = ResourceUtils.filePathFromURI(folderUri);
		IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
		HashSet<IJavaElement> result = new HashSet<>();
		for (IPackageFragmentRoot root : roots) {
			if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
				String packageRoot = root.getResource().getLocation().toString();
				if (packageRoot.toLowerCase().indexOf(rootPath.toString().toLowerCase()) >= 0) {
					collectCompilationUnits(javaProject, result, null);
				}
			}
		}
		for (IJavaElement elem : result) {
			if (elem.getElementType() == IJavaElement.COMPILATION_UNIT) {
				organizeImportsInCompilationUnit((ICompilationUnit) elem, rootEdit);
			}
		}
	}
	return rootEdit;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:41,代码来源:OrganizeImportsCommand.java

示例12: collectCompilationUnits

private void collectCompilationUnits(IPackageFragmentRoot root, Collection<IJavaElement> result, String prefix) throws JavaModelException {
	if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
		IJavaElement[] children = root.getChildren();
		for (int i = 0; i < children.length; i++) {
			IPackageFragment pack = (IPackageFragment) children[i];
			if (StringUtils.isBlank(prefix) || pack.getElementName().indexOf(prefix) >= 0) {
				collectCompilationUnits(pack, result);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:OrganizeImportsCommand.java

示例13: isJavaFilePresent

/**
 * Checks that the Java file for the given class name exists in the project.
 *
 * @param project
 *          the project, must not be {@code null}
 * @param className
 *          the class name, must not be {@code null}
 * @return whether the corresponding java file exists in the project
 */
public boolean isJavaFilePresent(final IProject project, final String className) {
  int packageSplitIndex = className.lastIndexOf('.');
  if (packageSplitIndex == -1) {
    throw new IllegalArgumentException(String.format("%s is a simple class name or not a class name at all.", className));
  }
  int fileNameEndIndex = className.indexOf('$');
  if (fileNameEndIndex == -1) {
    fileNameEndIndex = className.length();
  }
  String packageName = className.substring(0, packageSplitIndex);
  String fileName = className.substring(packageSplitIndex + 1, fileNameEndIndex) + ".java";
  try {
    if (project.hasNature(JavaCore.NATURE_ID)) {
      for (IPackageFragmentRoot root : JavaCore.create(project).getAllPackageFragmentRoots()) {
        if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
          for (IJavaElement element : root.getChildren()) {
            if (element instanceof IPackageFragment && packageName.equals(element.getElementName())
                && ((IPackageFragment) element).getCompilationUnit(fileName).exists()) {
              return true;
            }
          }
        }
      }
    }
  } catch (CoreException e) {
    LOGGER.error(String.format("Failed to read project %s.", project.getName()), e);
  }
  return false;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:38,代码来源:CheckProjectHelper.java

示例14: SourceViewer

public SourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
		boolean showAnnotationsOverview, int styles, IAnnotationAccess annotationAccess, ISharedTextColors sharedColors,
		IDocument document) 
{
	super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, SWT.BOLD);
	int id = currentId++;
	filename = VIEWER_CLASS_NAME + id++ + ".java";
	this.sharedColors=sharedColors;
	this.annotationAccess=annotationAccess;
	this.fOverviewRuler=overviewRuler;
	oldAnnotations= new HashMap<ProjectionAnnotation, Position>();

	IJavaProject javaProject = JavaCore.create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject());
	try 
	{
		IPackageFragmentRoot[] ipackageFragmentRootList=javaProject.getPackageFragmentRoots();
		IPackageFragmentRoot ipackageFragmentRoot=null;
		for(IPackageFragmentRoot tempIpackageFragmentRoot:ipackageFragmentRootList)
		{
			if(tempIpackageFragmentRoot.getKind()==IPackageFragmentRoot.K_SOURCE 
					&& StringUtils.equals(PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER,tempIpackageFragmentRoot.getPath().removeFirstSegments(1).toString()))
			{
				ipackageFragmentRoot=tempIpackageFragmentRoot;
				break;
			}   
		} 

		IPackageFragment compilationUnitPackage=   ipackageFragmentRoot.createPackageFragment(HYDROGRAPH_COMPILATIONUNIT_PACKAGE, true, new NullProgressMonitor());
		compilatioUnit=   compilationUnitPackage.createCompilationUnit(filename,document.get(),true, new NullProgressMonitor());
	} 
	catch (Exception exception) {
		LOGGER.warn("Exception occurred while initializing source viewer", exception);
	} finally {
		if (javaProject != null) {
			try {
				javaProject.close();
			} catch (JavaModelException javaModelException) {
				LOGGER.warn("Exception occurred while closing java-project", javaModelException);
			}
		}
	}
	initializeViewer(document);
	updateContents();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:44,代码来源:SourceViewer.java


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