Java源码示例:org.eclipse.xtext.xbase.lib.ListExtensions

示例1
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/");
    final String fileName = (_join + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
示例2
protected List<Class<?>> getExtensionClasses() {
	return Lists.<Class<?>> newArrayList(
		ArrayExtensions.class,
		BigDecimalExtensions.class,
		BigIntegerExtensions.class,
		BooleanExtensions.class,
		ByteExtensions.class,
		CharacterExtensions.class,
		CollectionExtensions.class,
		ComparableExtensions.class,
		DoubleExtensions.class,
		FloatExtensions.class,
		FunctionExtensions.class,
		IntegerExtensions.class,
		IterableExtensions.class,
		IteratorExtensions.class,
		ListExtensions.class,
		LongExtensions.class,
		MapExtensions.class,
		ObjectExtensions.class,
		ProcedureExtensions.class,
		ShortExtensions.class,
		StringExtensions.class);
}
 
示例3
public Set<String> getFQFeatureNamesToExclude(final Grammar g) {
  Set<String> _xifexpression = null;
  Grammar _nonTerminalsSuperGrammar = GrammarUtil2.getNonTerminalsSuperGrammar(g);
  boolean _tripleNotEquals = (_nonTerminalsSuperGrammar != null);
  if (_tripleNotEquals) {
    Sets.SetView<String> _xblockexpression = null;
    {
      final Set<String> thisGrammarFqFeatureNames = IterableExtensions.<String>toSet(this.computeFQFeatureNames(g));
      final Function1<Grammar, Iterable<String>> _function = (Grammar it) -> {
        return this.computeFQFeatureNames(it);
      };
      final Set<String> superGrammarsFqFeatureNames = IterableExtensions.<String>toSet(Iterables.<String>concat(ListExtensions.<Grammar, Iterable<String>>map(GrammarUtil.allUsedGrammars(g), _function)));
      _xblockexpression = Sets.<String>intersection(thisGrammarFqFeatureNames, superGrammarsFqFeatureNames);
    }
    _xifexpression = _xblockexpression;
  } else {
    _xifexpression = CollectionLiterals.<String>emptySet();
  }
  return _xifexpression;
}
 
示例4
@Test
public void testListToArrayHasTwoOrThreeCandidates() {
  final IResolvedOperation operation = this.toOperation("(null as java.util.List<String>).toArray(null)");
  final List<JvmOperation> candidates = operation.getOverriddenAndImplementedMethodCandidates();
  final Function1<JvmOperation, String> _function = (JvmOperation it) -> {
    return it.getIdentifier();
  };
  final String message = IterableExtensions.join(ListExtensions.<JvmOperation, String>map(candidates, _function), ", ");
  try {
    Assert.assertEquals(message, 2, candidates.size());
  } catch (final Throwable _t) {
    if (_t instanceof AssertionError) {
      Assert.assertEquals(message, 3, candidates.size());
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
}
 
示例5
public List<String> getPossibleGetterNames(final FieldDeclaration it) {
  final ArrayList<String> names = CollectionLiterals.<String>newArrayList();
  if ((((this.isBooleanType(this.orObject(it.getType())) && it.getSimpleName().startsWith("is")) && (it.getSimpleName().length() > 2)) && Character.isUpperCase(it.getSimpleName().charAt(2)))) {
    String _simpleName = it.getSimpleName();
    names.add(_simpleName);
  }
  List<String> _xifexpression = null;
  boolean _isBooleanType = this.isBooleanType(this.orObject(it.getType()));
  if (_isBooleanType) {
    _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("is", "get"));
  } else {
    _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("get"));
  }
  final Function1<String, String> _function = (String prefix) -> {
    String _firstUpper = StringExtensions.toFirstUpper(it.getSimpleName());
    return (prefix + _firstUpper);
  };
  names.addAll(ListExtensions.<String, String>map(_xifexpression, _function));
  return names;
}
 
示例6
@Test
public void testMultiQuickAssist() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("c {\tbadname { foo {} } }");
  _builder.newLine();
  _builder.append("a {\tbadname { bar {} } }");
  _builder.newLine();
  final IFile resource = this.dslFile(_builder);
  final XtextEditor editor = this.openEditor(resource);
  final ICompletionProposal[] proposals = this.computeQuickAssistProposals(editor, 1);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("Fix Bad Names");
  final Function1<ICompletionProposal, String> _function = (ICompletionProposal it) -> {
    return it.getDisplayString();
  };
  Assert.assertEquals(_builder_1.toString(), IterableExtensions.join(ListExtensions.<ICompletionProposal, String>map(((List<ICompletionProposal>)Conversions.doWrapArray(proposals)), _function), "\n"));
  IterableExtensions.<ICompletionProposal>head(((Iterable<ICompletionProposal>)Conversions.doWrapArray(proposals))).apply(editor.getDocument());
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("newElement { } c {\tgoodname { foo {} } }");
  _builder_2.newLine();
  _builder_2.append("a {\tbadname { bar {} } }");
  _builder_2.newLine();
  Assert.assertEquals(_builder_2.toString(), editor.getDocument().get());
}
 
示例7
@Test
public void testNoCrossRef() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("fixable_a {\tref fixable_b }");
  _builder.newLine();
  _builder.append("fixable_b {\tref fixable_a }");
  _builder.newLine();
  final IFile resource = this.dslFile(_builder);
  final XtextEditor editor = this.openEditor(resource);
  final ICompletionProposal[] proposals = this.computeQuickAssistProposals(editor, 1);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("rename fixable");
  final Function1<ICompletionProposal, String> _function = (ICompletionProposal it) -> {
    return it.getDisplayString();
  };
  Assert.assertEquals(_builder_1.toString(), IterableExtensions.join(ListExtensions.<ICompletionProposal, String>map(((List<ICompletionProposal>)Conversions.doWrapArray(proposals)), _function), "\n"));
  IterableExtensions.<ICompletionProposal>head(((Iterable<ICompletionProposal>)Conversions.doWrapArray(proposals))).apply(editor.getDocument());
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("fixedName {\tref fixable_b }");
  _builder_2.newLine();
  _builder_2.append("fixable_b {\tref fixable_a }");
  _builder_2.newLine();
  Assert.assertEquals(_builder_2.toString(), editor.getDocument().get());
}
 
示例8
protected void performMove(final IContainer theDestination, final IResource... theResources) {
  try {
    MoveResourcesDescriptor _moveResourcesDescriptor = new MoveResourcesDescriptor();
    final Procedure1<MoveResourcesDescriptor> _function = (MoveResourcesDescriptor it) -> {
      final Function1<IResource, IPath> _function_1 = (IResource it_1) -> {
        return it_1.getFullPath();
      };
      it.setResourcePathsToMove(((IPath[])Conversions.unwrapArray(ListExtensions.<IResource, IPath>map(((List<IResource>)Conversions.doWrapArray(theResources)), _function_1), IPath.class)));
      it.setDestinationPath(theDestination.getFullPath());
    };
    MoveResourcesDescriptor _doubleArrow = ObjectExtensions.<MoveResourcesDescriptor>operator_doubleArrow(_moveResourcesDescriptor, _function);
    this.performRefactoring(_doubleArrow);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
示例9
public List<EqualAmbiguousTransitions> getAllAmbiguousTransitionsBySyntax() {
  if ((this.ambiguousTransitions != null)) {
    return this.ambiguousTransitions;
  }
  final Map<GrammarAlias.AbstractElementAlias, EqualAmbiguousTransitions> result = CollectionLiterals.<GrammarAlias.AbstractElementAlias, EqualAmbiguousTransitions>newHashMap();
  Set<ISyntacticSequencerPDAProvider.ISynTransition> _allAmbiguousTransitions = this.getAllAmbiguousTransitions();
  for (final ISyntacticSequencerPDAProvider.ISynTransition transition : _allAmbiguousTransitions) {
    List<GrammarAlias.AbstractElementAlias> _ambiguousSyntaxes = transition.getAmbiguousSyntaxes();
    for (final GrammarAlias.AbstractElementAlias syntax : _ambiguousSyntaxes) {
      {
        EqualAmbiguousTransitions list = result.get(syntax);
        if ((list == null)) {
          String _elementAliasToIdentifier = this.elementAliasToIdentifier(syntax);
          EqualAmbiguousTransitions _equalAmbiguousTransitions = new EqualAmbiguousTransitions(_elementAliasToIdentifier, syntax);
          list = _equalAmbiguousTransitions;
          result.put(syntax, list);
        }
        list.getTransitions().add(transition);
      }
    }
  }
  this.ambiguousTransitions = CollectionLiterals.<EqualAmbiguousTransitions>newArrayList(((EqualAmbiguousTransitions[])Conversions.unwrapArray(result.values(), EqualAmbiguousTransitions.class)));
  ListExtensions.<EqualAmbiguousTransitions>sortInplace(this.ambiguousTransitions);
  return this.ambiguousTransitions;
}
 
示例10
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/");
    final String fileName = (_join + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
示例11
@Test
public void testDuplicateNames_04() {
  try {
    final IJavaProject javaProject = JavaCore.create(this.second);
    final IClasspathEntry[] cp = javaProject.getRawClasspath();
    final List<IClasspathEntry> reversed = ListExtensions.<IClasspathEntry>reverse(((List<IClasspathEntry>)Conversions.doWrapArray(cp)));
    javaProject.setRawClasspath(((IClasspathEntry[])Conversions.unwrapArray(reversed, IClasspathEntry.class)), null);
    IResourcesSetupUtil.reallyWaitForAutoBuild();
    this.testHelper.createFileImpl("first/src/com/acme/A.xtend", "package com.acme class A { new(String s) {} }");
    this.testHelper.createFileImpl("second/src/com/acme/A.xtend", "package com.acme class A { new(int i) {} }");
    this.testHelper.createFileImpl("second/src/com/acme/B.xtend", "package com.acme class B extends A { new() { super(1) } }");
    this.testHelper.createFileImpl("third/src/com/acme/A.xtend", "package com.acme class A {}");
    IResourcesSetupUtil.waitForBuild();
    IResourcesSetupUtil.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
示例12
public void assertHasErrors(final IFile file, final String msgPart) {
  try {
    final IMarker[] findMarkers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    for (final IMarker iMarker : findMarkers) {
      {
        final String message = MarkerUtilities.getMessage(iMarker);
        if (((MarkerUtilities.getSeverity(iMarker) == IMarker.SEVERITY_ERROR) && message.contains(msgPart))) {
          return;
        }
      }
    }
    IPath _fullPath = file.getFullPath();
    String _plus = ((("Expected an error marker containing \'" + msgPart) + "\' on ") + _fullPath);
    String _plus_1 = (_plus + " but found ");
    final Function1<IMarker, String> _function = (IMarker it) -> {
      return MarkerUtilities.getMessage(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<IMarker, String>map(((List<IMarker>)Conversions.doWrapArray(findMarkers)), _function), ",");
    String _plus_2 = (_plus_1 + _join);
    Assert.fail(_plus_2);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
示例13
@Override
public List<Movie> apply() {
  try {
    final Function1<String, Movie> _function = (String line) -> {
      final Iterator<String> segments = ((List<String>)Conversions.doWrapArray(line.split("  "))).iterator();
      String _next = segments.next();
      int _parseInt = Integer.parseInt(segments.next());
      double _parseDouble = Double.parseDouble(segments.next());
      long _parseLong = Long.parseLong(segments.next());
      Set<String> _set = IteratorExtensions.<String>toSet(segments);
      return new Movie(_next, _parseInt, _parseDouble, _parseLong, _set);
    };
    List<Movie> _map = ListExtensions.<String, Movie>map(CharStreams.readLines(new FileReader("data.csv")), _function);
    return _map;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
示例14
public void appendConstructorFromSuper(final XtendClass overrider, final IResolvedConstructor superConstructor, final ISourceAppender appendable) {
  final JvmGenericType inferredType = this.associations.getInferredType(overrider);
  final AbstractConstructorBuilder constructorBuilder = this.codeBuilderFactory.createConstructorBuilder(inferredType);
  this.initializeExecutableBuilder(constructorBuilder, inferredType, superConstructor);
  final Procedure1<ISourceAppender> _function = (ISourceAppender it) -> {
    boolean _isEmpty = superConstructor.getResolvedParameterTypes().isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("super(");
      final Function1<JvmFormalParameter, String> _function_1 = (JvmFormalParameter it_1) -> {
        return it_1.getSimpleName();
      };
      String _join = IterableExtensions.join(ListExtensions.<JvmFormalParameter, String>map(superConstructor.getDeclaration().getParameters(), _function_1), ", ");
      _builder.append(_join);
      _builder.append(")");
      it.append(_builder);
    }
  };
  constructorBuilder.setBodyGenerator(_function);
  boolean _isValid = constructorBuilder.isValid();
  if (_isValid) {
    constructorBuilder.build(appendable);
  }
}
 
示例15
@Override
public Iterable<? extends Path> getChildren(final URI uri, final Path path) {
  final IResource resource = this.findMember(uri);
  if ((resource instanceof IContainer)) {
    try {
      final Function1<IResource, Path> _function = (IResource it) -> {
        String _string = it.getFullPath().toString();
        return new Path(_string);
      };
      return ListExtensions.<IResource, Path>map(((List<IResource>)Conversions.doWrapArray(((IContainer)resource).members())), _function);
    } catch (final Throwable _t) {
      if (_t instanceof CoreException) {
        final CoreException exc = (CoreException)_t;
        String _message = exc.getMessage();
        throw new IllegalArgumentException(_message, exc);
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
  return CollectionLiterals.<Path>emptyList();
}
 
示例16
protected java.net.URI toURI(final URI uri, final List<String> trailingSegments) {
  java.net.URI _xblockexpression = null;
  {
    final IResource resource = this.findMember(uri);
    if ((resource == null)) {
      String _lastSegment = uri.lastSegment();
      trailingSegments.add(_lastSegment);
      return this.toURI(uri.trimSegments(1), trailingSegments);
    }
    final Function2<IPath, String, IPath> _function = (IPath $0, String $1) -> {
      return $0.append($1);
    };
    _xblockexpression = URIUtil.toURI(IterableExtensions.<String, IPath>fold(ListExtensions.<String>reverse(trailingSegments), resource.getLocation(), _function));
  }
  return _xblockexpression;
}
 
示例17
@Test
public void testAddError() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("@org.eclipse.xtend.core.tests.macro.Bug456264 class C {}");
  _builder.newLine();
  final IAcceptor<XtendCompilerTester.CompilationResult> _function = (XtendCompilerTester.CompilationResult it) -> {
    final List<? extends Problem> problems = it.getAllProblems();
    final Function1<Problem, String> _function_1 = (Problem it_1) -> {
      return it_1.getMessage();
    };
    Assert.assertEquals(ListExtensions.map(problems, _function_1).toString(), 1, problems.size());
    Assert.assertEquals("My error message", IterableExtensions.head(problems).getMessage());
    final List<? extends Problem> specificProblems = it.getProblems(IterableExtensions.head(it.getCompilationUnit().getSourceTypeDeclarations()));
    Assert.assertEquals(specificProblems.toString(), 1, problems.size());
    Assert.assertEquals("My error message", IterableExtensions.head(specificProblems).getMessage());
  };
  this._xtendCompilerTester.compile(_builder, _function);
}
 
示例18
@Test
public void testBug487559_01() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("import org.eclipse.xtend.core.tests.macro.AnnotationWithNestedEnum");
  _builder.newLine();
  _builder.newLine();
  _builder.append("@org.eclipse.xtend.core.tests.macro.AnnotationWithNestedEnum");
  _builder.newLine();
  _builder.append("class Client {");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final IAcceptor<XtendCompilerTester.CompilationResult> _function = (XtendCompilerTester.CompilationResult it) -> {
    final Function1<Problem, String> _function_1 = (Problem it_1) -> {
      return it_1.getMessage();
    };
    Assert.assertTrue(IterableExtensions.join(ListExtensions.map(it.getAllProblems(), _function_1), ", "), it.getAllProblems().isEmpty());
  };
  this._xtendCompilerTester.compile(_builder, _function);
}
 
示例19
protected void testFormatting(final Procedure1<? super DocumentFormattingParams> paramsConfigurator, final Procedure1<? super FormattingConfiguration> configurator) {
  try {
    @Extension
    final FormattingConfiguration configuration = new FormattingConfiguration();
    configuration.setFilePath(("MyModel." + this.fileExtension));
    configurator.apply(configuration);
    final FileInfo fileInfo = this.initializeContext(configuration);
    DocumentFormattingParams _documentFormattingParams = new DocumentFormattingParams();
    final Procedure1<DocumentFormattingParams> _function = (DocumentFormattingParams it) -> {
      String _uri = fileInfo.getUri();
      TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(_uri);
      it.setTextDocument(_textDocumentIdentifier);
      if ((paramsConfigurator != null)) {
        paramsConfigurator.apply(it);
      }
    };
    DocumentFormattingParams _doubleArrow = ObjectExtensions.<DocumentFormattingParams>operator_doubleArrow(_documentFormattingParams, _function);
    final CompletableFuture<List<? extends TextEdit>> changes = this.languageServer.formatting(_doubleArrow);
    String _contents = fileInfo.getContents();
    final Document result = new Document(Integer.valueOf(1), _contents).applyChanges(ListExtensions.<TextEdit>reverse(CollectionLiterals.<TextEdit>newArrayList(((TextEdit[])Conversions.unwrapArray(changes.get(), TextEdit.class)))));
    this.assertEqualsStricter(configuration.getExpectedText(), result.getContents());
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
示例20
@Override
public void appendImmediate(Object object, String indentation) {
	List<IGeneratorNode> removed = Lists.<IGeneratorNode>newArrayList();
	for (int i = currentParent.getChildren().size() - 1; i >= 0; i--) {
		IGeneratorNode node = currentParent.getChildren().get(i);
		if (node instanceof TextNode && !TemplateNode.hasContent(((TextNode) node).getText())) {
			removed.add(currentParent.getChildren().remove(i));
		} else {
			if (node instanceof NewLineNode) {
				removed.add(currentParent.getChildren().remove(i));
			} else {
				append(object, indentation);
				ListExtensions.reverse(removed).forEach(it -> append(it, indentation));
				return;
			}
		}
	}
	append(object, indentation);
}
 
示例21
@Override
protected void performTest(Project project, String moduleName, TestCompletionConfiguration tcc)
		throws InterruptedException, ExecutionException {

	CompletionParams completionParams = new CompletionParams();
	Position pos = new Position(tcc.getLine(), tcc.getColumn());
	completionParams.setPosition(pos);

	FileURI uri = getFileURIFromModuleName(tcc.getFilePath());
	TextDocumentIdentifier textDocument = new TextDocumentIdentifier();
	textDocument.setUri(uri.toString());
	completionParams.setTextDocument(textDocument);

	CompletableFuture<Either<List<CompletionItem>, CompletionList>> future = languageServer
			.completion(completionParams);

	Either<List<CompletionItem>, CompletionList> result = future.get();
	List<CompletionItem> items = result.isLeft() ? result.getLeft() : result.getRight().getItems();

	// assert already sorted
	List<CompletionItem> sortedItems = ListExtensions.sortInplaceBy(items, CompletionItem::getSortText);
	Assert.assertEquals(items, sortedItems);

	if (tcc.getAssertCompletionList() != null) {
		tcc.getAssertCompletionList().apply(result.getRight());
	} else {
		String resultStr = Strings.join("\n", getStringLSP4J()::toString, items);
		assertEquals(tcc.getExpectedCompletionItems().trim(), resultStr.trim());
	}
}
 
示例22
/**
 * Execute the given operation in a clustered fashion.
 */
public <T> List<T> executeClustered(Iterable<URI> uris, Function1<? super Resource, ? extends T> operation) {
	int loadedURIsCount = 0;
	Set<URI> sourceLevelURIs = new HashSet<>();
	List<Resource> resources = new ArrayList<>();
	List<T> result = new ArrayList<>();
	Iterator<URI> iter = uris.iterator();
	while (iter.hasNext()) {
		URI uri = iter.next();
		XtextResourceSet resourceSet = context.getResourceSet();
		if (!context.getClusteringPolicy().continueProcessing(resourceSet, uri, loadedURIsCount)) {
			result.addAll(ListExtensions.map(resources, operation::apply));
			this.clearResourceSet();
			resources.clear();
			loadedURIsCount = 0;
		}
		loadedURIsCount++;
		if (this.isSource(uri)) {
			sourceLevelURIs.add(uri);
			Resource existingResource = resourceSet.getResource(uri, false);
			if (existingResource instanceof StorageAwareResource) {
				if (((StorageAwareResource) existingResource).isLoadedFromStorage()) {
					existingResource.unload();
				}
			}
			SourceLevelURIsAdapter.setSourceLevelUrisWithoutCopy(resourceSet, sourceLevelURIs);
		}
		resources.add(resourceSet.getResource(uri, true));
	}
	result.addAll(ListExtensions.map(resources, operation::apply));
	return result;
}
 
示例23
@Override
public NameEnvironmentAnswer findType(final char[] typeName, final char[][] packageName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(packageName)), _function), "/");
    String _plus = (_join + "/");
    String _valueOf = String.valueOf(typeName);
    String _plus_1 = (_plus + _valueOf);
    final String fileName = (_plus_1 + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
示例24
protected String _toJava(final TypeReference type) {
  String _name = type.getTypeRef().getName();
  final Function1<String, String> _function = (String it) -> {
    return "[]";
  };
  String _join = IterableExtensions.join(ListExtensions.<String, String>map(type.getArrayDiemensions(), _function), "");
  return (_name + _join);
}
 
示例25
public ResponseError toResponseError() {
	Severity maxSeverity = getMaximumSeverity();
	ResponseError responseError = new ResponseError();
	responseError.setMessage(getMessageBySeverity(maxSeverity));
	responseError.setCode(getCodeBySeverity(maxSeverity));
	List<Issue> bySeverity = IterableExtensions.sortBy(issues, (i) -> i.severity);
	List<String> messages = ListExtensions.map(ListExtensions.reverse(bySeverity), (i) -> i.message);
	responseError.setData(IterableExtensions.join(messages, "\n"));
	return responseError;
}
 
示例26
public void recordExpectation(final XExpression expression, final ITypeComputationState state) {
  List<? extends ITypeExpectation> _expectations = state.getExpectations();
  Iterables.<ITypeExpectation>addAll(this.finalExpectations, _expectations);
  final Function1<ITypeExpectation, String> _function = (ITypeExpectation it) -> {
    LightweightTypeReference _expectedType = it.getExpectedType();
    String _simpleName = null;
    if (_expectedType!=null) {
      _simpleName=_expectedType.getSimpleName();
    }
    return _simpleName;
  };
  List<String> _map = ListExtensions.map(state.getExpectations(), _function);
  Iterables.<String>addAll(this.expectations, _map);
  this.expressions.add(expression);
}
 
示例27
protected String _toExpectation(final CodeAction it) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("title : ");
  String _title = it.getTitle();
  _builder.append(_title);
  _builder.newLineIfNotEmpty();
  _builder.append("kind : ");
  String _kind = it.getKind();
  _builder.append(_kind);
  _builder.newLineIfNotEmpty();
  _builder.append("command : ");
  Command _command = it.getCommand();
  _builder.append(_command);
  _builder.newLineIfNotEmpty();
  {
    boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(it.getDiagnostics());
    boolean _not = (!_isNullOrEmpty);
    if (_not) {
      _builder.append("codes : ");
      final Function1<Diagnostic, Object> _function = (Diagnostic it_1) -> {
        return it_1.getCode().get();
      };
      String _join = IterableExtensions.join(ListExtensions.<Diagnostic, Object>map(it.getDiagnostics(), _function), ",");
      _builder.append(_join);
    }
  }
  _builder.newLineIfNotEmpty();
  _builder.append("edit : ");
  String _expectation = this.toExpectation(it.getEdit());
  _builder.append(_expectation);
  _builder.newLineIfNotEmpty();
  return _builder.toString();
}
 
示例28
public TypeReference replace(final TypeReference target, final TypeReference oldType, final TypeReference newType) {
  boolean _equals = Objects.equal(target, oldType);
  if (_equals) {
    return newType;
  }
  boolean _isEmpty = target.getActualTypeArguments().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    final Function1<TypeReference, TypeReference> _function = (TypeReference it) -> {
      return this.replace(it, oldType, newType);
    };
    return this.context.newTypeReference(target.getType(), ((TypeReference[])Conversions.unwrapArray(ListExtensions.<TypeReference, TypeReference>map(target.getActualTypeArguments(), _function), TypeReference.class)));
  }
  boolean _isWildCard = target.isWildCard();
  if (_isWildCard) {
    TypeReference _upperBound = target.getUpperBound();
    TypeReference _object = this.context.getObject();
    boolean _notEquals = (!Objects.equal(_upperBound, _object));
    if (_notEquals) {
      return this.context.newWildcardTypeReference(this.replace(target.getUpperBound(), oldType, newType));
    } else {
      boolean _isAnyType = target.getLowerBound().isAnyType();
      boolean _not_1 = (!_isAnyType);
      if (_not_1) {
        return this.context.newWildcardTypeReferenceWithLowerBound(this.replace(target.getLowerBound(), oldType, newType));
      }
    }
  }
  boolean _isArray = target.isArray();
  if (_isArray) {
    return this.context.newArrayTypeReference(this.replace(target.getArrayComponentType(), oldType, newType));
  }
  return target;
}
 
示例29
@Test
public void testQuickAssist() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("\"no doc\"");
  _builder.newLine();
  _builder.append("Foo { ref Bor }");
  _builder.newLine();
  _builder.append("\"no doc\" Bor { }");
  _builder.newLine();
  final IFile dslFile = this.dslFile(_builder);
  final XtextEditor editor = this.openEditor(dslFile);
  final ICompletionProposal[] proposals = this.computeQuickAssistProposals(editor, 1);
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("Multi fix");
  final Function1<ICompletionProposal, String> _function = (ICompletionProposal it) -> {
    return it.getDisplayString();
  };
  Assert.assertEquals(_builder_1.toString(), IterableExtensions.join(ListExtensions.<ICompletionProposal, String>map(((List<ICompletionProposal>)Conversions.doWrapArray(proposals)), _function), "\n"));
  IterableExtensions.<ICompletionProposal>head(((Iterable<ICompletionProposal>)Conversions.doWrapArray(proposals))).apply(editor.getDocument());
  StringConcatenation _builder_2 = new StringConcatenation();
  _builder_2.append("\"Better documentation\"");
  _builder_2.newLine();
  _builder_2.append("Foo { ref Bor }");
  _builder_2.newLine();
  _builder_2.append("\"no doc\" Bor { }");
  _builder_2.newLine();
  Assert.assertEquals(_builder_2.toString(), editor.getDocument().get());
}
 
示例30
private String additionalSpaces(final Event it) {
  String _xblockexpression = null;
  {
    EObject _eContainer = it.eContainer();
    final Statemachine statemachine = ((Statemachine) _eContainer);
    final Function1<Event, String> _function = (Event it_1) -> {
      return it_1.getName();
    };
    _xblockexpression = this.additionalSpaces(ListExtensions.<Event, String>map(statemachine.getEvents(), _function), it.getName());
  }
  return _xblockexpression;
}