Java源码示例:org.eclipse.core.runtime.Path

示例1
/**
 * The framework calls this to see if the file is correct. <!--
 * begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
protected boolean validatePage() {
	if (super.validatePage()) {
		String extension = new Path(getFileName()).getFileExtension();
		if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
			String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions"
					: "_WARN_FilenameExtension";
			setErrorMessage(IFMLMetamodelEditorPlugin.INSTANCE
					.getString(key,
							new Object[] { FORMATTED_FILE_EXTENSIONS }));
			return false;
		}
		return true;
	}
	return false;
}
 
示例2
private IPath computeDestinationContainerPath(Path resourcePath) {
    IPath destinationContainerPath = fDestinationContainerPath;

    // We need to figure out the new destination path relative to the
    // selected "base" source directory.
    // Here for example, the selected source directory is /home/user
    if ((fImportOptionFlags & ImportTraceWizardPage.OPTION_PRESERVE_FOLDER_STRUCTURE) != 0) {
        // /home/user/bar/foo/trace -> /home/user/bar/foo
        IPath sourceContainerPath = resourcePath.removeLastSegments(1);
        if (fBaseSourceContainerPath.equals(resourcePath)) {
            // Use resourcePath directory if fBaseSourceContainerPath
            // points to a directory trace
            sourceContainerPath = resourcePath;
        }
        // /home/user/bar/foo, /home/user -> bar/foo
        IPath relativeContainerPath = sourceContainerPath.makeRelativeTo(fBaseSourceContainerPath);
        // project/Traces + bar/foo -> project/Traces/bar/foo
        destinationContainerPath = fDestinationContainerPath.append(relativeContainerPath);
    }
    return destinationContainerPath;
}
 
示例3
protected IPath createTempDir() throws CoreException {
	// get a temporary folder location, do not use /tmp
	File workspaceRoot = OrionConfiguration.getRootLocation().toLocalFile(EFS.NONE, null);
	File tmpDir = new File(workspaceRoot, SimpleMetaStoreUtil.ARCHIVE);
	if (!tmpDir.exists()) {
		tmpDir.mkdirs();
	}
	if (!tmpDir.exists() || !tmpDir.isDirectory()) {
		fail("Cannot find the default temporary-file directory: " + tmpDir.toString());
	}

	// get a temporary folder name
	SecureRandom random = new SecureRandom();
	long n = random.nextLong();
	n = (n == Long.MIN_VALUE) ? 0 : Math.abs(n);
	String tmpDirStr = Long.toString(n);
	File tempDir = new File(tmpDir, tmpDirStr);
	if (!tempDir.mkdir()) {
		fail("Cannot create a temporary directory at " + tempDir.toString());
	}
	return Path.fromOSString(tempDir.toString());
}
 
示例4
/**
 * The framework calls this to see if the file is correct.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
protected boolean validatePage ()
{
    if ( super.validatePage () )
    {
        final String extension = new Path ( getFileName () ).getFileExtension ();
        if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) )
        {
            final String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$
            setErrorMessage ( RecipeEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) );
            return false;
        }
        return true;
    }
    return false;
}
 
示例5
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
	SubMonitor subMonitor = SubMonitor.convert(monitor, files.size());
	try {
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		for (Map.Entry<String, CharSequence> fileEntry : files.entrySet()) {
			IFile file = workspace.getRoot().getFile(new Path(fileEntry.getKey()));
			file.create(new StringInputStream(fileEntry.getValue().toString()), true, subMonitor);
			if (firstFile == null) {
				firstFile = file;
			}
			subMonitor.worked(1);
		}
	} finally {
		subMonitor.done();
	}
}
 
示例6
/**
 * Downloads a file from url, return the {@link File} on disk where it was saved.
 * 
 * @param url
 * @param monitor
 * @return
 * @throws CoreException
 */
private File download(URL url, String extension, IProgressMonitor monitor) throws CoreException
{
	DownloadManager manager = new DownloadManager();
	IPath path = Path.fromPortableString(url.getPath());
	String name = path.lastSegment();
	File f = new File(FileUtil.getTempDirectory().toFile(), name + extension);
	f.deleteOnExit();
	manager.addURL(url, f);
	IStatus status = manager.start(monitor);
	if (!status.isOK())
	{
		throw new CoreException(status);
	}
	List<IPath> locations = manager.getContentsLocations();
	return locations.get(0).toFile();
}
 
示例7
private static void createClasspath(IPath root, List<String> paths, IJavaProject javaProject,
    int javaLanguageLevel) throws CoreException {
  String name = root.lastSegment();
  IFolder base = javaProject.getProject().getFolder(name);
  if (!base.isLinked()) {
    base.createLink(root, IResource.NONE, null);
  }
  List<IClasspathEntry> list = new LinkedList<>();
  for (String path : paths) {
    IPath workspacePath = base.getFullPath().append(path);
    list.add(JavaCore.newSourceEntry(workspacePath));
  }
  list.add(JavaCore.newContainerEntry(new Path(BazelClasspathContainer.CONTAINER_NAME)));

  list.add(
      JavaCore.newContainerEntry(new Path(STANDARD_VM_CONTAINER_PREFIX + javaLanguageLevel)));
  IClasspathEntry[] newClasspath = list.toArray(new IClasspathEntry[0]);
  javaProject.setRawClasspath(newClasspath, null);
}
 
示例8
/**
 * Display comparison view of test file with expected and actual xpect expectation
 */
private void displayComparisonView(ComparisonFailure cf, Description desc) {
	IXpectURIProvider uriProfider = XpectRunner.INSTANCE.getUriProvider();
	IFile fileTest = null;
	if (uriProfider instanceof N4IDEXpectTestURIProvider) {
		N4IDEXpectTestURIProvider fileCollector = (N4IDEXpectTestURIProvider) uriProfider;
		fileTest = ResourcesPlugin.getWorkspace().getRoot()
				.getFileForLocation(new Path(fileCollector.findRawLocation(desc)));
	}

	if (fileTest != null && fileTest.isAccessible()) {
		N4IDEXpectCompareEditorInput inp = new N4IDEXpectCompareEditorInput(fileTest, cf);
		CompareUI.openCompareEditor(inp);
	} else {
		throw new RuntimeException("paths in descriptions changed!");
	}
}
 
示例9
protected URI createDiffLocation(String toRefId, String fromRefId, String path) throws URISyntaxException {
	IPath diffPath = new Path(GitServlet.GIT_URI).append(Diff.RESOURCE);

	// diff range format is [fromRef..]toRef
	String diffRange = ""; //$NON-NLS-1$
	if (fromRefId != null)
		diffRange = fromRefId + ".."; //$NON-NLS-1$
	diffRange += toRefId;
	diffPath = diffPath.append(diffRange);

	// clone location is of the form /gitapi/clone/file/{workspaceId}/{projectName}[/{path}]
	IPath clonePath = new Path(cloneLocation.getPath()).removeFirstSegments(2);
	if (path == null) {
		diffPath = diffPath.append(clonePath);
	} else if (isRoot) {
		diffPath = diffPath.append(clonePath).append(path);
	} else {
		// need to start from the project root
		// project path is of the form /file/{workspaceId}/{projectName}
		IPath projectRoot = clonePath.uptoSegment(3);
		diffPath = diffPath.append(projectRoot).append(path);
	}

	return new URI(cloneLocation.getScheme(), cloneLocation.getAuthority(), diffPath.toString(), null, null);
}
 
示例10
/**
 * Builds the tree nodes for a set of modules and host pages.
 * 
 * @param modulesHostPages the set of modules along with their respective
 *          host pages
 * @return tree root nodes
 */
static LegacyGWTHostPageSelectionTreeItem[] buildTree(
    Map<String, Set<String>> modulesHostPages) {
  List<LegacyGWTHostPageSelectionTreeItem> treeItems = new ArrayList<LegacyGWTHostPageSelectionTreeItem>();
  for (String moduleName : modulesHostPages.keySet()) {
    LegacyGWTHostPageSelectionTreeItem moduleItem = new LegacyGWTHostPageSelectionTreeItem(
        Path.fromPortableString(moduleName.replace('.', '/')));
    treeItems.add(moduleItem);
    for (String hostPage : modulesHostPages.get(moduleName)) {
      new LegacyGWTHostPageSelectionTreeItem(
          Path.fromPortableString(hostPage), moduleItem);
    }
  }

  return treeItems.toArray(new LegacyGWTHostPageSelectionTreeItem[0]);
}
 
示例11
private void readParticipantsIndexNamesFile() {
	SimpleLookupTable containers = new SimpleLookupTable(3);
	try {
		char[] participantIndexNames = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(this.participantIndexNamesFile, null);
		if (participantIndexNames.length > 0) {
			char[][] names = CharOperation.splitOn('\n', participantIndexNames);
			if (names.length >= 3) {
				// First line is DiskIndex signature  (see writeParticipantsIndexNamesFile())
				if (DiskIndex.SIGNATURE.equals(new String(names[0]))) {					
					for (int i = 1, l = names.length-1 ; i < l ; i+=2) {
						IndexLocation indexLocation = new FileIndexLocation(new File(new String(names[i])), true);
						containers.put(indexLocation, new Path(new String(names[i+1])));
					}
				}				
			}
		}	
	} catch (IOException ignored) {
		if (VERBOSE)
			Util.verbose("Failed to read participant index file names"); //$NON-NLS-1$
	}
	this.participantsContainers = containers;
	return;
}
 
示例12
private void configurePlainProject(ProjectDescriptor descriptor, ProjectFactory factory) {
	factory.setProjectName(descriptor.getName());
	factory.setLocation(new Path(descriptor.getLocation()));
	factory.setProjectDefaultCharset(projectInfo.getEncoding().toString());
	factory.addWorkingSets(Lists.newArrayList(projectInfo.getWorkingSets()));
	factory.addContributor(new DescriptorBasedContributor(descriptor));
	if (needsM2eIntegration(descriptor)) {
		factory.addProjectNatures("org.eclipse.m2e.core.maven2Nature");
		factory.addBuilderIds("org.eclipse.m2e.core.maven2Builder");
	}
	if (needsBuildshipIntegration(descriptor)) {
		factory.addProjectNatures("org.eclipse.buildship.core.gradleprojectnature");
		factory.addBuilderIds("org.eclipse.buildship.core.gradleprojectbuilder");
		factory.addEarlyContributor(new GradleContributor(descriptor));
	}
}
 
示例13
private void validateInput() {
  if (getFolderName().length() == 0) {
    updateStatus("Folder must be specified");
    return;
  }
  IResource resource = root.findMember(new Path(getFolderName()));
  if (resource != null && resource.exists() && !(resource instanceof IFolder)) {
    updateStatus("Invalid folder");
    return;
  }
  String serviceName = getServiceName();
  if (serviceName.isEmpty()) {
    updateStatus("Service name must be specified");
    return;
  }
  updateStatus(null);
}
 
示例14
public void setUpConfigWorkspaceFiles() throws Exception {
    projectStub = new org.python.pydev.shared_core.resource_stubs.ProjectStub(
            new File(TestDependent.TEST_COM_REFACTORING_PYSRC_LOC),
            natureRefactoring);
    TextEditCreation.createWorkspaceFile = new ICallback<IFile, File>() {

        @Override
        public IFile call(File file) {
            return new FileStub(projectStub, file) {
                @Override
                public IPath getFullPath() {
                    return Path.fromOSString(this.file.getAbsolutePath());
                }

            };
        }
    };
}
 
示例15
private static String getFileName(Item item) {
	String label = item.getProperty().getLabel();
	String selectedVersion = item.getProperty().getVersion();

	if ("Latest".equals(selectedVersion)) {
		return label;
	}

	IPath path = new Path(label);
	String fileExtension = path.getFileExtension();
	String fileName = path.removeFileExtension().toPortableString();
	fileName = fileName + "_" + selectedVersion;
	if (fileExtension != null && !fileExtension.isEmpty()) {
		fileName = fileName + "." + fileExtension;
	}
	return fileName;
}
 
示例16
public NativeLibrariesConfigurationBlock(IStatusChangeListener listener, Shell parent, String nativeLibPath, IClasspathEntry parentEntry) {
	fListener= listener;
	fEntry= parentEntry;

	NativeLibrariesAdapter adapter= new NativeLibrariesAdapter();

	fPathField= new StringDialogField();
	fPathField.setLabelText(NewWizardMessages.NativeLibrariesDialog_location_label);
	fPathField.setDialogFieldListener(adapter);

	fBrowseWorkspace= new SelectionButtonDialogField(SWT.PUSH);
	fBrowseWorkspace.setLabelText(NewWizardMessages.NativeLibrariesDialog_workspace_browse);
	fBrowseWorkspace.setDialogFieldListener(adapter);

	fBrowseExternal= new SelectionButtonDialogField(SWT.PUSH);
	fBrowseExternal.setLabelText(NewWizardMessages.NativeLibrariesDialog_external_browse);
	fBrowseExternal.setDialogFieldListener(adapter);

	if (nativeLibPath != null) {
		fPathField.setText(Path.fromPortableString(nativeLibPath).toString());
		fOrginalValue= nativeLibPath;
	} else {
		fOrginalValue= ""; //$NON-NLS-1$
	}
}
 
示例17
private void updateProjectPath() {
	frameworkViewer.getList().removeAll();
	IPath projectFilePath = ProjectFileAccessor.getProjectFile(projectContainer);
	if (projectFilePath == null) {
		frameworkViewer.add(Messages.DotnetRunTab_noFrameworks);
		frameworkViewer.getList().setEnabled(false);
		return;
	}

	frameworkViewer.getList().deselectAll();
	frameworkViewer.add(Messages.DotnetRunTab_loadingFrameworks);
	frameworkViewer.getList().setEnabled(false);
	targetFrameworks = ProjectFileAccessor.getTargetFrameworks(
			new Path(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getAbsolutePath().toString()
					+ projectFilePath.toString()));
	frameworkViewer.getList().removeAll();
	if (targetFrameworks.length > 0) {
		frameworkViewer.add(targetFrameworks);
		frameworkViewer.getList().select(0);
		frameworkViewer.getList().setEnabled(true);
	} else {
		frameworkViewer.add(Messages.DotnetRunTab_noFrameworks);
		frameworkViewer.getList().setEnabled(false);
	}
}
 
示例18
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	traceRequest(req);
	String pathString = req.getPathInfo();
	IPath path = new Path(pathString == null ? "" : pathString); //$NON-NLS-1$
	if (path.segmentCount() > 0) {
		try {
			WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(path.segment(0));
			if (workspaceResourceHandler.handleRequest(req, resp, workspace))
				return;
		} catch (CoreException e) {
			handleException(resp, "Error reading workspace metadata", e);
			return;
		}
	}
	super.doDelete(req, resp);
}
 
示例19
/**
 * <p>
 * The constructor
 * </p>
 * 
 * @param parent
 *            <p>
 *            The ViewPart to whom the object of this class belongs.
 *            </p>
 */
public PreviousAction(PlayableViewPart parent) {

	// Set the calling class to the local ViewPart field
	viewer = parent;

	// Set the "hover" text
	this.setText("Previous");

	// Set the button image
	Bundle bundle = FrameworkUtil.getBundle(getClass());
	Path imagePath = new Path("icons" + System.getProperty("file.separator")
			+ "previous.gif");
	URL imageURL = FileLocator.find(bundle, imagePath, null);
	ImageDescriptor imageDescriptor = ImageDescriptor
			.createFromURL(imageURL);
	this.setImageDescriptor(imageDescriptor);

	return;
}
 
示例20
public MultiModuleMoveRefactoringRequest(List<ModuleRenameRefactoringRequest> requests, IContainer target)
        throws MisconfigurationException, TargetNotInPythonpathException {
    super(requests.toArray(new RefactoringRequest[requests.size()]));
    PythonNature nature = PythonNature.getPythonNature(target);
    File file = target.getLocation().toFile();
    this.target = target;
    this.initialName = nature.resolveModule(file);
    IPath fullPath = target.getFullPath();
    if (this.initialName == null) {
        //Check if it's a source folder...
        try {
            Set<String> projectSourcePathSet = nature.getPythonPathNature().getProjectSourcePathSet(true);
            for (String string : projectSourcePathSet) {
                if (new Path(string).equals(fullPath)) {
                    this.initialName = "";
                    break;
                }
            }
        } catch (CoreException e) {
            Log.log(e);
        }
    }
    if (this.initialName == null) {
        throw new TargetNotInPythonpathException("Unable to resolve file as a python module: " + fullPath);
    }
}
 
示例21
/**
 * The framework calls this to see if the file is correct.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected boolean validatePage ()
{
    if ( super.validatePage () )
    {
        String extension = new Path ( getFileName () ).getFileExtension ();
        if ( extension == null || !FILE_EXTENSIONS.contains ( extension ) )
        {
            String key = FILE_EXTENSIONS.size () > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; //$NON-NLS-1$ //$NON-NLS-2$
            setErrorMessage ( DetailViewEditorPlugin.INSTANCE.getString ( key, new Object[] { FORMATTED_FILE_EXTENSIONS } ) );
            return false;
        }
        return true;
    }
    return false;
}
 
示例22
protected EclipseProcessLauncher getValidLaunchInfo(
		ILaunchConfiguration configuration, CompositeBuildTargetSettings buildTargetSettings)
		throws CommonException, CoreException {
	
	IProject project = buildTargetSettings.getBuildTargetSupplier().getValidProject();
	
	String workingDirectoryString = evaluateStringVars(
		configuration.getAttribute(LaunchConstants.ATTR_WORKING_DIRECTORY, (String) null));

	IPath workingDirectory = workingDirectoryString == null ? 
			project.getLocation() : 
			new Path(workingDirectoryString);
	
	Location programLoc = buildTarget.getValidExecutableLocation(); // not null
	
	String programArguments = configuration.getAttribute(LaunchConstants.ATTR_PROGRAM_ARGUMENTS, "");
	String commandLine = programLoc.toString() + " " + programArguments;
	
	Map<String, String> configEnv = configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, 
		new HashMap<>(0));
	boolean appendEnv = configuration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true);
	
	CommandInvocation programInvocation = new CommandInvocation(commandLine, new HashMap2<>(configEnv), appendEnv);
	
	return new EclipseProcessLauncher(
		project, 
		programLoc,
		workingDirectory, 
		programInvocation,
		LaunchConstants.PROCESS_TYPE_ID
	);
}
 
示例23
/**
 * Creates an editor input for the passed file.
 *
 * If forceExternalFile is True, it won't even try to create a FileEditorInput, otherwise,
 * it will try to create it with the most suitable type it can
 * (i.e.: FileEditorInput, FileStoreEditorInput, PydevFileEditorInput, ...)
 */
public static IEditorInput create(File file, boolean forceExternalFile) {
    IPath path = Path.fromOSString(FileUtils.getFileAbsolutePath(file));

    if (!forceExternalFile) {
        //May call again to this method (but with forceExternalFile = true)
        IEditorInput input = new PySourceLocatorBase().createEditorInput(path, false, null, null);
        if (input != null) {
            return input;
        }
    }

    IPath zipPath = new Path("");
    while (path.segmentCount() > 0) {
        if (path.toFile().exists()) {
            break;
        }
        zipPath = new Path(path.lastSegment()).append(zipPath);
        path = path.uptoSegment(path.segmentCount() - 1);
    }

    if (zipPath.segmentCount() > 0 && path.segmentCount() > 0) {
        return new PydevZipFileEditorInput(new PydevZipFileStorage(path.toFile(), zipPath.toPortableString()));
    }

    try {
        URI uri = file.toURI();
        return new FileStoreEditorInput(EFS.getStore(uri));
    } catch (Throwable e) {
        //not always available! (only added in eclipse 3.3)
        return new PydevFileEditorInput(file);
    }
}
 
示例24
private IClasspathEntry[] getClassPathEntries( IProject project )
{
	IClasspathEntry[] internalClassPathEntries = getInternalClassPathEntries( project );
	IClasspathEntry[] entries = new IClasspathEntry[internalClassPathEntries.length + 1];
	System.arraycopy( internalClassPathEntries,
			0,
			entries,
			0,
			internalClassPathEntries.length );
	entries[entries.length - 1] = JavaCore.newContainerEntry( new Path( "org.eclipse.jdt.launching.JRE_CONTAINER" ) ); //$NON-NLS-1$
	return entries;
}
 
示例25
@Override
public String getName()
{
	String name = super.getName();
	if (name != null)
	{
		return name;
	}
	return Path.fromPortableString(getURI().getPath()).lastSegment();
}
 
示例26
/**
 * Actually creates the process (and create the encoding config file)
 */
@SuppressWarnings("deprecation")
private static Process createProcess(ILaunch launch, String[] envp, String[] cmdLine, File workingDirectory)
        throws CoreException {
    Map<String, String> arrayAsMapEnv = ProcessUtils.getArrayAsMapEnv(envp);
    arrayAsMapEnv.put("PYTHONUNBUFFERED", "1");
    arrayAsMapEnv.put("PYDEV_COMPLETER_PYTHONPATH", CorePlugin.getBundleInfo().getRelativePath(new Path("pysrc"))
            .toString());

    //Not using DebugPlugin.ATTR_CONSOLE_ENCODING to provide backward compatibility for eclipse 3.2
    String encoding = launch.getAttribute(IDebugUIConstants.ATTR_CONSOLE_ENCODING);
    if (encoding != null && encoding.trim().length() > 0) {
        arrayAsMapEnv.put("PYDEV_CONSOLE_ENCODING", encoding);

        //In Python 3.0, we can use the PYTHONIOENCODING.
        //Note that we always replace it, because this is really the encoding of the allocated console view,
        //so, if we had something different put, the encoding from the Python side would differ from the encoding
        //on the java side (which would make things garbled anyways).
        arrayAsMapEnv.put("PYTHONIOENCODING", encoding);
    }
    envp = ProcessUtils.getMapEnvAsArray(arrayAsMapEnv);
    Process p = DebugPlugin.exec(cmdLine, workingDirectory, envp);
    if (p == null) {
        throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Could not execute python process.",
                null));
    }
    PythonRunnerCallbacks.afterCreatedProcess.call(p);
    return p;
}
 
示例27
/**
 * Gets the workspace member.
 *
 * @param name
 *          the name
 * @return the workspace member
 */
private IResource getWorkspaceMember(final String name) {
  IWorkspaceRoot workspaceRoot = EcorePlugin.getWorkspaceRoot();
  if (workspaceRoot == null) {
    return null;
  }
  return workspaceRoot.findMember(new Path(name));
}
 
示例28
public static String getPackageName(IJavaProject javaProject, URI uri) {
	try {
		File file = ResourceUtils.toFile(uri);
		//FIXME need to determine actual charset from file
		String content = Files.toString(file, Charsets.UTF_8);
		if (content.isEmpty() && javaProject != null && ProjectsManager.DEFAULT_PROJECT_NAME.equals(javaProject.getProject().getName())) {
			java.nio.file.Path path = Paths.get(uri);
			java.nio.file.Path parent = path;
			while (parent.getParent() != null && parent.getParent().getNameCount() > 0) {
				parent = parent.getParent();
				String name = parent.getName(parent.getNameCount() - 1).toString();
				if (SRC.equals(name)) {
					String pathStr = path.getParent().toString();
					if (pathStr.length() > parent.toString().length()) {
						pathStr = pathStr.substring(parent.toString().length() + 1);
						pathStr = pathStr.replace(PATH_SEPARATOR, PERIOD);
						return pathStr;
					}
				}
			}
		} else {
			return getPackageName(javaProject, content);
		}
	} catch (IOException e) {
		JavaLanguageServerPlugin.logException("Failed to read package name from "+uri, e);
	}
	return "";
}
 
示例29
private static void assertRemoteUri(String remoteUri) {
	URI uri = URI.create(toRelativeURI(remoteUri));
	IPath path = new Path(uri.getPath());
	// /git/remote/file/{path}
	assertTrue(path.segmentCount() > 3);
	assertEquals(GitServlet.GIT_URI.substring(1), path.segment(0));
	assertEquals(Remote.RESOURCE, path.segment(1));
	assertEquals("file", path.segment(2));
}
 
示例30
private static String findOutsideWorkspace(final String fp, final URI modelBase, final boolean mustExist) {
	if (!mustExist) { return fp; }
	final IFileStore file = FILE_SYSTEM.getStore(new Path(fp));
	final IFileInfo info = file.fetchInfo();
	if (info.exists()) {
		final IFile linkedFile = createLinkToExternalFile(fp, modelBase);
		if (linkedFile == null) { return fp; }
		return linkedFile.getLocation().toFile().getAbsolutePath();
	}
	return null;
}