private CustomType getCustomType(IJstNode jstNode) { if (jstNode == null) { return null; } MetaProvider metaProvider = (MetaProvider) getMetaProvider(); IJstType ownerType = jstNode.getOwnerType(); CustomType cType = metaProvider.getCustomType(ownerType.getName()); if (cType == null) { cType = new CustomType(ownerType.getName()); metaProvider.addCustomType(ownerType.getName(), cType); } return cType; }
/* * (non-Javadoc) * * @see org.eclipse.vjet.eclipse.internal.codeassist.select.translator.DefaultNodeTranslator#resolveBinding(org.eclipse.vjet.dsf.jst.IJstNode) */ @Override public IJstNode lookupBinding(IJstNode jstNode) { JstIdentifier identifier = (JstIdentifier) jstNode; // TODO should this part of binding? each client currently has to do this lookup. // see similiar logic in VjoCcObjLiteralAdvisor if (identifier.getParentNode() instanceof NV) { NV realParent = (NV) identifier.getParentNode(); String fieldName = realParent.getName(); ObjLiteral enclosingObjLiteral = (ObjLiteral) ((NV) realParent).getParentNode(); final IJstType olExprType = enclosingObjLiteral.getResultType(); if (olExprType != null && olExprType instanceof SynthOlType) { final SynthOlType enclosingObjLiteralType = (SynthOlType) olExprType; List<IJstType> olResolvedTypes = enclosingObjLiteralType.getResolvedOTypes(); if (olResolvedTypes == null) { return null; } for (IJstType iJstType : olResolvedTypes) { IJstProperty prop = iJstType.getProperty(fieldName); if (prop != null) { return prop; } } } } if (identifier.getJstBinding() == null) { return null; } if (isKeyWord(identifier)) { return null; } IJstNode binding = identifier.getJstBinding(); // check the identifer in local variable declarion site. if ((binding == null || binding instanceof IJstType) && CodeassistUtils.isLocalVarDeclaration(identifier)) { binding = identifier.getParentNode().getParentNode(); // JstVars } if (binding == null || binding == identifier) { return null; } return JstNodeDLTKElementResolver.lookupBinding(binding); }
public void testOnNativeSource() throws ModelException { String js = "search/NativeTypeA.js"; FixtureManager m_fixtureManager = FixtureUtils.setUpFixture(this, js); try { IJSSourceModule module = (IJSSourceModule) getSourceModule(getProjectName(), "src", new Path(js)); IType[] types = module.getTypes(); assertEquals("Wrong number of types", 1, types.length); IJstType nativeJstType = getNativeJstType("Array"); IJstMethod element = nativeJstType.getMethod("reverse"); assertNotSame("native type source is null", null, element.getSource()); if (element.getSource() != null) { int offset = element.getSource().getStartOffSet(); assertNotSame("Invalid offset, the actrual value is -1", -1, offset); } } finally { FixtureUtils.tearDownFixture(m_fixtureManager); } }
public boolean isSerializableForVjo(IJstType type, boolean isRoot) { boolean ret = false; if (type == null) return false; if (isRoot) { if (getJavaTypeForSerialable(type) != null) { return true; } } if (isJavaPrimitiveOrWrapper(type.getName()) || type.isEnum()) { return false; } String forName = ISerializableForVjo.class.getName(); if (type.isInterface()) { // Check extends of Interface if (type.getName().equals(forName)) { return true; } } else { if (type.getName().equals(forName)) { return true; } // Check interfaces of the class for (IJstType iType : type.getSatisfies()) { if (iType.getName().equals(forName)) { return true; } ret = isSerializableForVjo(iType, false); if (ret) return ret; } } for (IJstType eType : type.getExtends()) { ret = isSerializableForVjo(eType, false); if (ret) return ret; } return false; }
public Class<?> getJavaTypeForSerialable(IJstType type) { return s_javaSerializable.get(type.getName()); }
public boolean isSkipImportJsr(IJstType jstType) { String name = jstType.getName(); return s_excludeList.contains(name); }
public boolean isSkipExtends(IJstType jstType) { return (s_extends.contains(jstType.getName())); }
public boolean isSkipSatisfies(IJstType jstType) { return (s_satisfies.contains(jstType.getName())); }
public boolean isSkipImport(IJstType jstType) { String name = normalize(jstType.getName()); return isJavaPrimitiveOrWrapper(name) || isJavaLang(name); }