org.eclipse.wst.jsdt.core.JavaScriptModelException Java Examples

The following examples show how to use org.eclipse.wst.jsdt.core.JavaScriptModelException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HybridProjectCreator.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
private void setUpJavaScriptProject(IProject project,
        IProgressMonitor monitor) throws JavaScriptModelException {
    IJavaScriptProject javascriptProject = JavaScriptCore.create(project);
    IIncludePathEntry[] entries = javascriptProject.getRawIncludepath();
    List<IIncludePathEntry> entryList = new ArrayList<IIncludePathEntry>();
    
    //remove all source entries && existing cordova libs
    for (IIncludePathEntry aEntry : entries) {
        if(!(IIncludePathEntry.CPE_SOURCE == aEntry.getEntryKind()) &&
        		!aEntry.getPath().segment(0).equals(CordovaLibraryJsContainerInitializer.CONTAINER_ID)){
        	entryList.add(aEntry);
        }
    }
    
    //add cordova.js lib
    IIncludePathEntry cordovaLibEntry = JavaScriptCore.newContainerEntry(new Path(CordovaLibraryJsContainerInitializer.CONTAINER_ID));
    entryList.add(cordovaLibEntry);
    
    // add www
    IIncludePathEntry wwwSrcEntry = JavaScriptCore.newSourceEntry(project.getFolder("www").getFullPath());
    entryList.add(wwwSrcEntry);
    
    javascriptProject.setRawIncludepath(entryList.toArray(new IIncludePathEntry[entryList.size()]), monitor);
}
 
Example #2
Source File: JSDocAutoIndentStrategy.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * Returns <code>true</code> if the comment being inserted at
 * <code>command.offset</code> is the first comment (the first javadoc
 * comment if <code>ignoreJavadoc</code> is <code>true</code>) of the given
 * member.
 * <p>
 * see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=55325 (don't add
 * parameters if the member already has a comment)
 * </p>
 */
private boolean isFirstComment(IDocument document, DocumentCommand command, IMember member,
		boolean ignoreNonJavadoc) throws BadLocationException, JavaScriptModelException {
	IRegion partition = TextUtilities.getPartition(document, fPartitioning, command.offset, false);
	ISourceRange sourceRange = member.getSourceRange();
	if (sourceRange == null || sourceRange.getOffset() != partition.getOffset())
		return false;
	int srcOffset = sourceRange.getOffset();
	int srcLength = sourceRange.getLength();
	int nameRelativeOffset = member.getNameRange().getOffset() - srcOffset;
	int partitionRelativeOffset = partition.getOffset() - srcOffset;
	String token = ignoreNonJavadoc ? "/**" : "/*"; //$NON-NLS-1$ //$NON-NLS-2$
	return document.get(srcOffset, srcLength).lastIndexOf(token, nameRelativeOffset) == partitionRelativeOffset;
}
 
Example #3
Source File: JSDocAutoIndentStrategy.java    From typescript.java with MIT License 3 votes vote down vote up
/**
 * Returns the method inherited from, <code>null</code> if method is newly
 * defined.
 * 
 * @param method
 *            the method being written
 * @return the ancestor method, or <code>null</code> if none
 * @throws JavaScriptModelException
 *             if accessing the java model fails
 */
private static IFunction getInheritedMethod(IFunction method) throws JavaScriptModelException {
	IType declaringType = method.getDeclaringType();
	if (declaringType == null)
		return null;
	MethodOverrideTester tester = SuperTypeHierarchyCache.getMethodOverrideTester(declaringType);
	return tester.findOverriddenMethod(method, true);
}